summaryrefslogtreecommitdiffstats
path: root/lib/Transforms/Scalar/LICM.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-09-14 00:19:00 +0000
committerChris Lattner <sabre@nondot.org>2010-09-14 00:19:00 +0000
commit7abdb22e52e2122cb04479a1129dc68916dece4c (patch)
treeca1e440a64d678b09c1a63a370ad9968d66d49fb /lib/Transforms/Scalar/LICM.cpp
parent3a210e2d302758101ac06946e86027b327c7d0f3 (diff)
downloadexternal_llvm-7abdb22e52e2122cb04479a1129dc68916dece4c.zip
external_llvm-7abdb22e52e2122cb04479a1129dc68916dece4c.tar.gz
external_llvm-7abdb22e52e2122cb04479a1129dc68916dece4c.tar.bz2
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! The testcase only repros the problem on my system with valgrind. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LICM.cpp')
-rw-r--r--lib/Transforms/Scalar/LICM.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp
index 0db7ba7..af9a7ee 100644
--- a/lib/Transforms/Scalar/LICM.cpp
+++ b/lib/Transforms/Scalar/LICM.cpp
@@ -837,6 +837,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) {
@@ -867,17 +878,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!
}