Changes in directory llvm/lib/Analysis:

ScalarEvolution.cpp updated: 1.116 -> 1.117
---
Log message:

Fix PR1487: http://llvm.org/PR1487  and 
Transforms/IndVar/2007-06-06-DeleteDanglesPtr.ll



---
Diffs of the changes:  (+22 -3)

 ScalarEvolution.cpp |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)


Index: llvm/lib/Analysis/ScalarEvolution.cpp
diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.116 
llvm/lib/Analysis/ScalarEvolution.cpp:1.117
--- llvm/lib/Analysis/ScalarEvolution.cpp:1.116 Wed May  2 20:11:53 2007
+++ llvm/lib/Analysis/ScalarEvolution.cpp       Tue Jun  5 23:12:20 2007
@@ -1196,9 +1196,28 @@
 /// client before it removes an instruction from the program, to make sure
 /// that no dangling references are left around.
 void ScalarEvolutionsImpl::deleteInstructionFromRecords(Instruction *I) {
-  Scalars.erase(I);
-  if (PHINode *PN = dyn_cast<PHINode>(I))
-    ConstantEvolutionLoopExitValue.erase(PN);
+  SmallVector<Instruction *, 16> Worklist;
+
+  if (Scalars.erase(I)) {
+    if (PHINode *PN = dyn_cast<PHINode>(I))
+      ConstantEvolutionLoopExitValue.erase(PN);
+    Worklist.push_back(I);
+  }
+
+  while (!Worklist.empty()) {
+    Instruction *II = Worklist.back();
+    Worklist.pop_back();
+
+    for (Instruction::use_iterator UI = II->use_begin(), UE = II->use_end();
+         UI != UE; ++UI) {
+      Instruction *Inst = dyn_cast<Instruction>(*UI);
+      if (Inst && hasSCEV(Inst) && Scalars.erase(Inst)) {
+        if (PHINode *PN = dyn_cast<PHINode>(II))
+          ConstantEvolutionLoopExitValue.erase(PN);
+        Worklist.push_back(Inst);
+      }
+    }
+  }
 }
 
 



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to