From: Chris Lattner Date: Thu, 14 Feb 2008 19:18:13 +0000 (+0000) Subject: Fix PR2029 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8c5c22f610f21dbf10e83be360b8fbeb247a0fe1;p=oota-llvm.git Fix PR2029 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47129 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 39738a09ba7..920a0286ead 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -256,6 +256,17 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, SwitchInst *CatchSwitch) { ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo); + // If the unwind edge has phi nodes, split the edge. + if (isa(II->getUnwindDest()->begin())) { + SplitCriticalEdge(II, 1, this); + + // If there are any phi nodes left, they must have a single predecessor. + while (PHINode *PN = dyn_cast(II->getUnwindDest()->begin())) { + PN->replaceAllUsesWith(PN->getIncomingValue(0)); + PN->eraseFromParent(); + } + } + // Insert a store of the invoke num before the invoke and store zero into the // location afterward. new StoreInst(InvokeNoC, InvokeNum, true, II); // volatile diff --git a/test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll b/test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll new file mode 100644 index 00000000000..fa825398653 --- /dev/null +++ b/test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll @@ -0,0 +1,14 @@ +; RUN: llvm-as < %s | opt -lowerinvoke -enable-correct-eh-support -disable-output +; PR2029 +define i32 @main(i32 %argc, i8** %argv) { +bb470: + invoke i32 @main(i32 0, i8** null) to label %invcont474 unwind label +%lpad902 + +invcont474: ; preds = %bb470 + ret i32 0 + +lpad902: ; preds = %bb470 + %tmp471.lcssa = phi i8* [ null, %bb470 ] ; + ret i32 0 +}