[LSR] Fix crash in Phi node with EHPad block
This fixes a crash I observed in issue #48708 where the LSR pass tries to insert an instruction in a basic block with only a catchswitch statement in there. This happens because the Phi node being evaluated assumes the same value for different basic blocks. If the basic block associated with the incoming value of the operand being evaluated has an EHPad terminator LSR skips optimizing it. But if that incoming value can come from multiple different blocks there can be some incoming basic blocks which are terminated in an EHPad. If these are then rewritten in RewriteForPhi the ones containing an EHPad terminator will hit the "Insertion point must be a normal instruction" assert in AdjustInsertPositionForExpand. This fix makes CollectLoopInvariantFixupsAndFormulae also ignore cases where the same value has another incoming basic block with an EHPad, same as it already does in case the primary value has one. Patch by Lorenz Brun <lorenz@brun.one> Differential Revision: https://reviews.llvm.org/D98378
Loading
Please sign in to comment