[llvm-commits] CVS: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Jun 18 21:10:01 PDT 2004
Changes in directory llvm/lib/Transforms/Scalar:
ScalarReplAggregates.cpp updated: 1.21 -> 1.22
---
Log message:
Do not loop over uses as we delete them. This causes iterators to be
invalidated out from under us. This bug goes back to revision 1.1: scary.
---
Diffs of the changes: (+2 -3)
Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.21 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.22
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.21 Sun Apr 4 20:29:05 2004
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp Fri Jun 18 21:02:22 2004
@@ -171,9 +171,8 @@
// Now that we have created the alloca instructions that we want to use,
// expand the getelementptr instructions to use them.
//
- for (Value::use_iterator I = AI->use_begin(), E = AI->use_end();
- I != E; ++I) {
- Instruction *User = cast<Instruction>(*I);
+ while (!AI->use_empty()) {
+ Instruction *User = cast<Instruction>(AI->use_back());
if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(User)) {
// We now know that the GEP is of the form: GEP <ptr>, 0, <cst>
uint64_t Idx = cast<ConstantInt>(GEPI->getOperand(2))->getRawValue();
More information about the llvm-commits
mailing list