[llvm] r280794 - [SimplifyCFG] Followup fix to r280790
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 7 02:01:23 PDT 2016
Author: jamesm
Date: Wed Sep 7 04:01:22 2016
New Revision: 280794
URL: http://llvm.org/viewvc/llvm-project?rev=280794&view=rev
Log:
[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.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=280794&r1=280793&r2=280794&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Sep 7 04:01:22 2016
@@ -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();
}))
More information about the llvm-commits
mailing list