Fix infinite loop due to iteration
authorChris Lattner <sabre@nondot.org>
Sat, 9 Oct 2004 03:32:52 +0000 (03:32 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 9 Oct 2004 03:32:52 +0000 (03:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16864 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/GlobalOpt.cpp

index dcbd87d566604983513c665fcaef249d54ad6a36..22ce82336fb224ca8c83b96992d293eba89267f9 100644 (file)
@@ -374,16 +374,22 @@ static bool ProcessInternalGlobal(GlobalVariable *GV, Module::giterator &GVI) {
     // 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);