[llvm-commits] [llvm] r47129 - in /llvm/trunk: lib/Transforms/Utils/LowerInvoke.cpp test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll
Chris Lattner
sabre at nondot.org
Thu Feb 14 11:18:14 PST 2008
Author: lattner
Date: Thu Feb 14 13:18:13 2008
New Revision: 47129
URL: http://llvm.org/viewvc/llvm-project?rev=47129&view=rev
Log:
Fix PR2029
Added:
llvm/trunk/test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll
Modified:
llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=47129&r1=47128&r2=47129&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Thu Feb 14 13:18:13 2008
@@ -256,6 +256,17 @@
SwitchInst *CatchSwitch) {
ConstantInt *InvokeNoC = ConstantInt::get(Type::Int32Ty, InvokeNo);
+ // If the unwind edge has phi nodes, split the edge.
+ if (isa<PHINode>(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<PHINode>(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
Added: llvm/trunk/test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll?rev=47129&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll (added)
+++ llvm/trunk/test/Transforms/LowerInvoke/2008-02-14-CritEdgePhiCrash.ll Thu Feb 14 13:18:13 2008
@@ -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 ] ; <i8*>
+ ret i32 0
+}
More information about the llvm-commits
mailing list