[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Devang Patel dpatel at apple.com
Mon Apr 23 15:42:23 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.130 -> 1.131
---
Log message:

Fix
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20070423/048333.html


---
Diffs of the changes:  (+9 -5)

 LoopStrengthReduce.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.130 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.131
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.130	Sun Apr 15 03:47:27 2007
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Mon Apr 23 17:42:03 2007
@@ -416,12 +416,16 @@
   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))






More information about the llvm-commits mailing list