From: James Molloy Date: Wed, 7 Sep 2016 09:01:22 +0000 (+0000) Subject: [SimplifyCFG] Followup fix to r280790 X-Git-Tag: llvmorg-4.0.0-rc1~10477 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6c009c1c85e3de0e090ae31258d5d0bbd2a9f54d;p=platform%2Fupstream%2Fllvm.git [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 --- 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(I0)) { auto *PNUse = dyn_cast(*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(*I->user_begin()); return (PNUse && + PNUse->getParent() == Succ && PNUse->getIncomingValueForBlock(I->getParent()) == I) || U->getParent() == I->getParent(); }))