aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2010-09-14 00:43:35 +0000
committerBill Wendling <isanbard@gmail.com>2010-09-14 00:43:35 +0000
commit19cad46f0910c141e1e2f6b88bf0f16c73c727e8 (patch)
treeff589f546aa686f63facafde97eacf208caf999d
parent078d13e7b6d8933cdcfa3fae9d69b7a91cc5cf8a (diff)
downloadllvm-19cad46f0910c141e1e2f6b88bf0f16c73c727e8.zip
llvm-19cad46f0910c141e1e2f6b88bf0f16c73c727e8.tar.gz
llvm-19cad46f0910c141e1e2f6b88bf0f16c73c727e8.tar.bz2
Approved by Chris:
$ svn merge -c 113820 https://llvm.org/svn/llvm-project/llvm/trunk --- Merging r113820 into '.': U test/Transforms/LICM/crash.ll U lib/Transforms/Scalar/LICM.cpp Log: fix PR8102, a case where we'd copyValue from a value that we already deleted. Fix this by doing the copyValue's before we delete stuff! llvm-svn: 113823
-rw-r--r--llvm/lib/Transforms/Scalar/LICM.cpp22
-rw-r--r--llvm/test/Transforms/LICM/crash.ll20
2 files changed, 31 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index 6cb4845..2ef8544 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -852,6 +852,17 @@ void LICM::PromoteAliasSet(AliasSet &AS) {
ReplacedLoads[ALoad] = NewVal;
}
+ // If the preheader load is itself a pointer, we need to tell alias analysis
+ // about the new pointer we created in the preheader block and about any PHI
+ // nodes that just got inserted.
+ if (PreheaderLoad->getType()->isPointerTy()) {
+ // Copy any value stored to or loaded from a must-alias of the pointer.
+ CurAST->copyValue(SomeValue, PreheaderLoad);
+
+ for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i)
+ CurAST->copyValue(SomeValue, NewPHIs[i]);
+ }
+
// Now that everything is rewritten, delete the old instructions from the body
// of the loop. They should all be dead now.
for (unsigned i = 0, e = LoopUses.size(); i != e; ++i) {
@@ -882,17 +893,6 @@ void LICM::PromoteAliasSet(AliasSet &AS) {
User->eraseFromParent();
}
- // If the preheader load is itself a pointer, we need to tell alias analysis
- // about the new pointer we created in the preheader block and about any PHI
- // nodes that just got inserted.
- if (PreheaderLoad->getType()->isPointerTy()) {
- // Copy any value stored to or loaded from a must-alias of the pointer.
- CurAST->copyValue(SomeValue, PreheaderLoad);
-
- for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i)
- CurAST->copyValue(SomeValue, NewPHIs[i]);
- }
-
// fwew, we're done!
}
diff --git a/llvm/test/Transforms/LICM/crash.ll b/llvm/test/Transforms/LICM/crash.ll
index d0b6d78..88be5c4 100644
--- a/llvm/test/Transforms/LICM/crash.ll
+++ b/llvm/test/Transforms/LICM/crash.ll
@@ -39,3 +39,23 @@ for.body: ; preds = %for.body, %entry
store i32 undef, i32* @g_8, align 4
br label %for.body
}
+
+; PR8102
+define void @test3() {
+entry:
+ %__first = alloca { i32* }
+ br i1 undef, label %for.cond, label %for.end
+
+for.cond: ; preds = %for.cond, %entry
+ %tmp1 = getelementptr { i32*}* %__first, i32 0, i32 0
+ %tmp2 = load i32** %tmp1, align 4
+ %call = tail call i32* @test3helper(i32* %tmp2)
+ %tmp3 = getelementptr { i32*}* %__first, i32 0, i32 0
+ store i32* %call, i32** %tmp3, align 4
+ br i1 false, label %for.cond, label %for.end
+
+for.end: ; preds = %for.cond, %entry
+ ret void
+}
+
+declare i32* @test3helper(i32*)