aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/JumpThreading.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-01-09 06:08:12 +0000
committerChris Lattner <sabre@nondot.org>2009-01-09 06:08:12 +0000
commit2a99b482a62e3f1ac3fd716fba430ac32fedade4 (patch)
tree7f3ce7e038b3926f08c48bcce721c39af9b956c0 /lib/Transforms/Scalar/JumpThreading.cpp
parentd62fc8817cc4e7978ed41ba0b7dba85d1805083d (diff)
Fix PR3298, a crash in Jump Threading. Apparently even
jump threading can have bugs, who knew? ;-) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61983 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp
index 59af14b865..94d33aa787 100644
--- a/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/lib/Transforms/Scalar/JumpThreading.cpp
@@ -504,6 +504,10 @@ bool JumpThreading::SimplifyPartiallyRedundantLoad(LoadInst *LI) {
// If the value if the load is locally available within the block, just use
// it. This frequently occurs for reg2mem'd allocas.
//cerr << "LOAD ELIMINATED:\n" << *BBIt << *LI << "\n";
+
+ // If the returned value is the load itself, replace with an undef. This can
+ // only happen in dead loops.
+ if (AvailableVal == LI) AvailableVal = UndefValue::get(LI->getType());
LI->replaceAllUsesWith(AvailableVal);
LI->eraseFromParent();
return true;