summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-24 21:19:41 +0000
committerChris Lattner <sabre@nondot.org>2002-09-24 21:19:41 +0000
commitb408154f5fd67c184df162a80efe83b7e07eeb65 (patch)
treee3838d328c8765fe4f998bb0478181314e59b39a /llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parent4357e54760c2337560256d0a5da727b5ea845752 (diff)
downloadbcm5719-llvm-b408154f5fd67c184df162a80efe83b7e07eeb65.tar.gz
bcm5719-llvm-b408154f5fd67c184df162a80efe83b7e07eeb65.zip
- Fix bug: Mem2Reg/2002-05-01-ShouldNotPromoteThisAlloca.ll
llvm-svn: 3917
Diffstat (limited to 'llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index b84f1a378fa..70c794e8166 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -79,8 +79,13 @@ static inline bool isSafeAlloca(const AllocaInst *AI) {
// Only allow direct loads and stores...
for (Value::use_const_iterator UI = AI->use_begin(), UE = AI->use_end();
UI != UE; ++UI) // Loop over all of the uses of the alloca
- if (!isa<LoadInst>(*UI) && !isa<StoreInst>(*UI))
- return false; // Not a load or store?
+ if (!isa<LoadInst>(*UI))
+ if (const StoreInst *SI = dyn_cast<StoreInst>(*UI)) {
+ if (SI->getOperand(0) == AI)
+ return false; // Don't allow a store of the AI, only INTO the AI.
+ } else {
+ return false; // Not a load or store?
+ }
return true;
}
OpenPOWER on IntegriCloud