Fixed bug: test/Regression/Transforms/Mem2Reg/2002-05-01-ShouldNotPromoteThisAlloca.ll
authorChris Lattner <sabre@nondot.org>
Wed, 1 May 2002 15:38:23 +0000 (15:38 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 1 May 2002 15:38:23 +0000 (15:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2423 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/PromoteMemoryToRegister.cpp

index ee8300215f731a4d06420537cd21d716b2afa030..294c39a08f2b8a3be135d06ee46202a4b061ce3c 100644 (file)
@@ -79,6 +79,9 @@ static inline bool isSafeAlloca(const AllocaInst *AI) {
 
     // Only allow nonindexed memory access instructions...
     if (MemAccessInst *MAI = dyn_cast<MemAccessInst>(*UI)) {
+      if (MAI->getPointerOperand() != (Value*)AI)
+        return false;  // Reject stores of alloca pointer into some other loc.
+
       if (MAI->hasIndices()) {  // indexed?
         // Allow the access if there is only one index and the index is
         // zero.