diff options
author | Chris Lattner <sabre@nondot.org> | 2004-06-19 02:02:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-06-19 02:02:22 +0000 |
commit | b5f8eb8315ca590baa2fa607f5fcc68042af7df6 (patch) | |
tree | a358fbe2e63fb02908ce819cc21a0b52a2d19025 /llvm/lib/Transforms | |
parent | 2ef024b2c2dfb061e92996b094ba4dae416967cf (diff) | |
download | bcm5719-llvm-b5f8eb8315ca590baa2fa607f5fcc68042af7df6.tar.gz bcm5719-llvm-b5f8eb8315ca590baa2fa607f5fcc68042af7df6.zip |
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.
llvm-svn: 14242
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 9598918880a..aeba94afa1d 100644 --- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -171,9 +171,8 @@ bool SROA::performScalarRepl(Function &F) { // 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(); |