[llvm-commits] CVS: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Sep 12 11:03:02 PDT 2003
Changes in directory llvm/lib/Transforms/Scalar:
ScalarReplAggregates.cpp updated: 1.12 -> 1.13
---
Log message:
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
---
Diffs of the changes:
Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.12 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.13
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.12 Fri Sep 12 10:36:03 2003
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Sep 12 11:02:12 2003
@@ -234,8 +234,11 @@
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 @@
!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);
More information about the llvm-commits
mailing list