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

John Criswell criswell at cs.uiuc.edu
Thu Aug 7 09:44:02 PDT 2003


Changes in directory llvm/lib/Transforms/IPO:

GlobalDCE.cpp updated: 1.24 -> 1.25

---
Log message:

Fixed a segfault in gccld.
The original code does not work because the value from WorkList.end() is
invalidated once WorkList.erase() is called.  To ensure proper functionality,
we must ensure that WorkList.erase() is always called before WorkList.end().



---
Diffs of the changes:

Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp
diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.24 llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.25
--- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.24	Thu Jun 26 00:41:18 2003
+++ llvm/lib/Transforms/IPO/GlobalDCE.cpp	Thu Aug  7 09:43:13 2003
@@ -123,8 +123,10 @@
       // If the global variable is still on the worklist, remove it now.
       std::vector<GlobalValue*>::iterator I = std::find(WorkList.begin(),
                                                         WorkList.end(), GV);
-      while (I != WorkList.end())
-        I = std::find(WorkList.erase(I), WorkList.end(), GV);
+      while (I != WorkList.end()) {
+        I = WorkList.erase(I);
+        I = std::find(I, WorkList.end(), GV);
+      }
 
       return true;
     }





More information about the llvm-commits mailing list