forked from OSchip/llvm-project
[SimplifyCFG] Followup fix to r280790
In failure cases it's not guaranteed that the PHI we're inspecting is actually in the successor block! In this case we need to bail out early, and never query getIncomingValueForBlock() as that will cause an assert. llvm-svn: 280794
This commit is contained in:
parent
46031e6fec
commit
6c009c1c85
|
@ -1401,9 +1401,11 @@ static bool canSinkInstructions(
|
|||
// we're contemplating sinking, it must already be determined to be sinkable.
|
||||
if (!isa<StoreInst>(I0)) {
|
||||
auto *PNUse = dyn_cast<PHINode>(*I0->user_begin());
|
||||
if (!all_of(Insts, [&PNUse](const Instruction *I) -> bool {
|
||||
auto *Succ = I0->getParent()->getTerminator()->getSuccessor(0);
|
||||
if (!all_of(Insts, [&PNUse,&Succ](const Instruction *I) -> bool {
|
||||
auto *U = cast<Instruction>(*I->user_begin());
|
||||
return (PNUse &&
|
||||
PNUse->getParent() == Succ &&
|
||||
PNUse->getIncomingValueForBlock(I->getParent()) == I) ||
|
||||
U->getParent() == I->getParent();
|
||||
}))
|
||||
|
|
Loading…
Reference in New Issue