diff options
author | Chris Lattner <sabre@nondot.org> | 2002-09-24 21:19:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-09-24 21:19:41 +0000 |
commit | 112e97dbee144fd8e55401f1a785301a9c6c0806 (patch) | |
tree | 0ace1acf48da3c2e2edc4b1699f3d26c78aca6d8 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp | |
parent | 2ada19ea04241eda58a0280aa5e80fe757008821 (diff) |
- Fix bug: Mem2Reg/2002-05-01-ShouldNotPromoteThisAlloca.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3917 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index b84f1a378f..70c794e816 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/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; } |