aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp3
-rw-r--r--test/Transforms/TailDup/2009-07-31-phicrash.ll14
2 files changed, 16 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp
index dccc3e6ffb..5e54a69bfa 100644
--- a/lib/Transforms/Scalar/TailDuplication.cpp
+++ b/lib/Transforms/Scalar/TailDuplication.cpp
@@ -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/test/Transforms/TailDup/2009-07-31-phicrash.ll b/test/Transforms/TailDup/2009-07-31-phicrash.ll
new file mode 100644
index 0000000000..6abd2a5bd6
--- /dev/null
+++ b/test/Transforms/TailDup/2009-07-31-phicrash.ll
@@ -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
+}