[llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalOpt.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Oct 8 20:33:05 PDT 2004



Changes in directory llvm/lib/Transforms/IPO:

GlobalOpt.cpp updated: 1.16 -> 1.17
---
Log message:

Fix infinite loop due to iteration


---
Diffs of the changes:  (+7 -1)

Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.16 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.17
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.16	Fri Oct  8 17:05:31 2004
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp	Fri Oct  8 22:32:52 2004
@@ -374,16 +374,22 @@
     // Delete it now.
     if (!GS.isLoaded) {
       DEBUG(std::cerr << "GLOBAL NEVER LOADED: " << *GV);
+      unsigned NumUsers = GV->use_size();
+
       // Delete any stores we can find to the global.  We may not be able to
       // make it completely dead though.
       CleanupConstantGlobalUsers(GV, GV->getInitializer());
 
+      // Did we delete any stores?
+      bool Changed = NumUsers != GV->use_size();
+
       // If the global is dead now, delete it.
       if (GV->use_empty()) {
         GV->getParent()->getGlobalList().erase(GV);
         ++NumDeleted;
+        Changed = true;
       }
-      return true;
+      return Changed;
           
     } else if (GS.StoredType <= GlobalStatus::isInitializerStored) {
       DEBUG(std::cerr << "MARKING CONSTANT: " << *GV);






More information about the llvm-commits mailing list