aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/IPO/GlobalDCE.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp
index c7fddc9913..f991229e98 100644
--- a/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/lib/Transforms/IPO/GlobalDCE.cpp
@@ -123,8 +123,10 @@ bool GlobalDCE::RemoveIfDead(GlobalValue *GV) {
// 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;
}