diff options
author | Chris Lattner <sabre@nondot.org> | 2003-09-12 16:02:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-09-12 16:02:12 +0000 |
commit | 8fce16ef1abd92c59ab2b02d59e6d16a1c0ba0b7 (patch) | |
tree | 97a9ea1b69ac1bf6495f2f1c19ff080de312cd0b /lib | |
parent | 69d903d5becd8ce5c2b9b50d6867a8dc89eb7c78 (diff) | |
download | external_llvm-8fce16ef1abd92c59ab2b02d59e6d16a1c0ba0b7.zip external_llvm-8fce16ef1abd92c59ab2b02d59e6d16a1c0ba0b7.tar.gz external_llvm-8fce16ef1abd92c59ab2b02d59e6d16a1c0ba0b7.tar.bz2 |
Do not return success after checking only the FIRST USE of a gep instruction.
Instead, check all uses.
This fixes bug: ScalarRepl/2003-09-12-IncorrectPromote.ll
This also fixes the miscompilation of Ptrdist/bc
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8493 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/ScalarReplAggregates.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 9f2e20f..2a6bddf 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -234,8 +234,11 @@ bool SROA::isSafeElementUse(Value *Ptr) { I != E; ++I) { Instruction *User = cast<Instruction>(*I); switch (User->getOpcode()) { - case Instruction::Load: return true; - case Instruction::Store: return User->getOperand(0) != Ptr; + case Instruction::Load: break; + case Instruction::Store: + // Store is ok if storing INTO the pointer, not storing the pointer + if (User->getOperand(0) == Ptr) return false; + break; case Instruction::GetElementPtr: { GetElementPtrInst *GEP = cast<GetElementPtrInst>(User); if (GEP->getNumOperands() > 1) { @@ -243,7 +246,8 @@ bool SROA::isSafeElementUse(Value *Ptr) { !cast<Constant>(GEP->getOperand(1))->isNullValue()) return false; // Using pointer arithmetic to navigate the array... } - return isSafeElementUse(GEP); + if (!isSafeElementUse(GEP)) return false; + break; } default: DEBUG(std::cerr << " Transformation preventing inst: " << *User); |