[llvm-commits] [llvm] r171846 - in /llvm/trunk: lib/Transforms/Utils/DemoteRegToStack.cpp test/Transforms/Reg2Mem/ test/Transforms/Reg2Mem/crash.ll test/Transforms/Reg2Mem/lit.local.cfg
Bill Wendling
isanbard at gmail.com
Tue Jan 8 02:51:32 PST 2013
Author: void
Date: Tue Jan 8 04:51:32 2013
New Revision: 171846
URL: http://llvm.org/viewvc/llvm-project?rev=171846&view=rev
Log:
Make sure we don't emit instructions before a landingpad instruction.
PR14782
Added:
llvm/trunk/test/Transforms/Reg2Mem/
llvm/trunk/test/Transforms/Reg2Mem/crash.ll
llvm/trunk/test/Transforms/Reg2Mem/lit.local.cfg
Modified:
llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp
Modified: llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp?rev=171846&r1=171845&r2=171846&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/DemoteRegToStack.cpp Tue Jan 8 04:51:32 2013
@@ -124,7 +124,12 @@
}
// Insert a load in place of the PHI and replace all uses.
- Value *V = new LoadInst(Slot, P->getName()+".reload", P);
+ BasicBlock::iterator InsertPt = P;
+
+ for (; isa<PHINode>(InsertPt) || isa<LandingPadInst>(InsertPt); ++InsertPt)
+ /* empty */; // Don't insert before PHI nodes or landingpad instrs.
+
+ Value *V = new LoadInst(Slot, P->getName()+".reload", InsertPt);
P->replaceAllUsesWith(V);
// Delete PHI.
Added: llvm/trunk/test/Transforms/Reg2Mem/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reg2Mem/crash.ll?rev=171846&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Reg2Mem/crash.ll (added)
+++ llvm/trunk/test/Transforms/Reg2Mem/crash.ll Tue Jan 8 04:51:32 2013
@@ -0,0 +1,88 @@
+; RUN: opt -reg2mem -disable-output < %s
+; PR14782
+
+declare void @f1()
+
+declare i32 @__gxx_personality_sj0(...)
+
+declare void @f2()
+
+declare void @f3()
+
+declare void @f4_()
+
+declare void @_Z12xxxdtsP10xxxpq()
+
+define hidden void @_ZN12xxxyzIi9xxxwLi29ELi0EE4f3NewES0_i() ssp align 2 {
+bb:
+ invoke void @f4_()
+ to label %bb1 unwind label %.thread
+
+.thread: ; preds = %bb
+ %tmp = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
+ cleanup
+ br label %bb13
+
+bb1: ; preds = %bb
+ invoke void @f1()
+ to label %.noexc unwind label %bb10
+
+.noexc: ; preds = %bb1
+ invoke void @f4_()
+ to label %bb6 unwind label %bb2
+
+bb2: ; preds = %.noexc
+ %tmp3 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
+ cleanup
+ invoke void @f3()
+ to label %.body unwind label %bb4
+
+bb4: ; preds = %bb2
+ %tmp5 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
+ catch i8* null
+ unreachable
+
+bb6: ; preds = %.noexc
+ invoke void @_Z12xxxdtsP10xxxpq()
+ to label %_ZN6xxxdIN12xxxyzIi9xxxwLi29ELi0EE4fr1jS3_.exit unwind label %bb10
+
+_ZN6xxxdIN12xxxyzIi9xxxwLi29ELi0EE4fr1jS3_.exit: ; preds = %bb6
+ invoke void @f2()
+ to label %bb7 unwind label %bb8
+
+bb7: ; preds = %_ZN6xxxdIN12xxxyzIi9xxxwLi29ELi0EE4fr1jS3_.exit
+ ret void
+
+bb8: ; preds = %_ZN6xxxdIN12xxxyzIi9xxxwLi29ELi0EE4fr1jS3_.exit
+ %tmp9 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
+ cleanup
+ br label %_ZN10xxxpqdlev.exit
+
+bb10: ; preds = %bb6, %bb1
+ %.1 = phi i1 [ true, %bb1 ], [ false, %bb6 ]
+ %tmp11 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
+ cleanup
+ br label %.body
+
+.body: ; preds = %bb10, %bb2
+ %.1.lpad-body = phi i1 [ %.1, %bb10 ], [ true, %bb2 ]
+ invoke void @f2()
+ to label %bb12 unwind label %bb14
+
+bb12: ; preds = %.body
+ br i1 %.1.lpad-body, label %bb13, label %_ZN10xxxpqdlev.exit
+
+bb13: ; preds = %bb12, %.thread
+ invoke void @xxx_MemFree()
+ to label %_ZN10xxxpqdlev.exit unwind label %bb14
+
+_ZN10xxxpqdlev.exit: ; preds = %bb13, %bb12, %bb8
+ resume { i8*, i32 } undef
+
+bb14: ; preds = %bb13, %.body
+ %tmp15 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_sj0 to i8*)
+ catch i8* null
+ unreachable
+}
+
+declare void @xxx_MemFree()
Added: llvm/trunk/test/Transforms/Reg2Mem/lit.local.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reg2Mem/lit.local.cfg?rev=171846&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Reg2Mem/lit.local.cfg (added)
+++ llvm/trunk/test/Transforms/Reg2Mem/lit.local.cfg Tue Jan 8 04:51:32 2013
@@ -0,0 +1 @@
+config.suffixes = ['.ll', '.c', '.cpp']
More information about the llvm-commits
mailing list