diff options
author | James Molloy <james.molloy@arm.com> | 2016-09-07 09:01:22 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2016-09-07 09:01:22 +0000 |
commit | 6c009c1c85e3de0e090ae31258d5d0bbd2a9f54d (patch) | |
tree | a1d9bf1ccd2e961676a5a6a94559a4f2b889df52 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 46031e6fecf334ebf0f867cc84430f1c927c7591 (diff) | |
download | llvm-6c009c1c85e3de0e090ae31258d5d0bbd2a9f54d.zip llvm-6c009c1c85e3de0e090ae31258d5d0bbd2a9f54d.tar.gz llvm-6c009c1c85e3de0e090ae31258d5d0bbd2a9f54d.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 909a72c2..e5da77e 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -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(); })) |