diff options
author | Devang Patel <dpatel@apple.com> | 2007-04-23 22:42:03 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-04-23 22:42:03 +0000 |
commit | 38bc86f057b85ed80f65cc0c9df180f8fe172758 (patch) | |
tree | 4852887e1426788832e0eec4b055ab8f1cffbeb2 /llvm | |
parent | cbb4994f6b6734693d8a13816fd2b3b11b0a085d (diff) | |
download | bcm5719-llvm-38bc86f057b85ed80f65cc0c9df180f8fe172758.tar.gz bcm5719-llvm-38bc86f057b85ed80f65cc0c9df180f8fe172758.zip |
Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048333.html
llvm-svn: 36380
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 38cfd91fe1b..6bece9cfb7e 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -416,12 +416,16 @@ bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L, if (!getSCEVStartAndStride(ISE, L, Start, Stride)) return false; // Non-reducible symbolic expression, bail out. - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;) { - Instruction *User = cast<Instruction>(*UI); + std::vector<Instruction *> IUsers; + // Collect all I uses now because IVUseShouldUsePostIncValue may + // invalidate use_iterator. + for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI) + IUsers.push_back(cast<Instruction>(*UI)); - // Increment iterator now because IVUseShouldUsePostIncValue may remove - // User from the list of I users. - ++UI; + for (unsigned iused_index = 0, iused_size = IUsers.size(); + iused_index != iused_size; ++iused_index) { + + Instruction *User = IUsers[iused_index]; // Do not infinitely recurse on PHI nodes. if (isa<PHINode>(User) && Processed.count(User)) |