diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index ee8300215f7..294c39a08f2 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -79,6 +79,9 @@ static inline bool isSafeAlloca(const AllocaInst *AI) { // Only allow nonindexed memory access instructions... if (MemAccessInst *MAI = dyn_cast(*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.