PR4662: Fix a crash introduced by the recent LLVMContext changes.
authorEli Friedman <eli.friedman@gmail.com>
Fri, 31 Jul 2009 19:36:47 +0000 (19:36 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 31 Jul 2009 19:36:47 +0000 (19:36 +0000)
llvm-svn: 77716

llvm/lib/Transforms/Scalar/TailDuplication.cpp
llvm/test/Transforms/TailDup/2009-07-31-phicrash.ll [new file with mode: 0644]

index dccc3e6..5e54a69 100644 (file)
@@ -360,7 +360,8 @@ void TailDup::eliminateUnconditionalBranch(BranchInst *Branch) {
       Instruction *Inst = BI++;
       if (isInstructionTriviallyDead(Inst))
         Inst->eraseFromParent();
-      else if (Constant *C = ConstantFoldInstruction(Inst, BI->getContext())) {
+      else if (Constant *C = ConstantFoldInstruction(Inst,
+                                                     Inst->getContext())) {
         Inst->replaceAllUsesWith(C);
         Inst->eraseFromParent();
       }
diff --git a/llvm/test/Transforms/TailDup/2009-07-31-phicrash.ll b/llvm/test/Transforms/TailDup/2009-07-31-phicrash.ll
new file mode 100644 (file)
index 0000000..6abd2a5
--- /dev/null
@@ -0,0 +1,14 @@
+; RUN: llvm-as < %s | opt -tailduplicate -disable-output
+; PR4662
+
+define void @a() {
+BB:
+       br label %BB6
+
+BB6:
+       %tmp9 = phi i64 [ 0, %BB ], [ 5, %BB34 ]
+       br label %BB34
+
+BB34:
+       br label %BB6
+}