diff options
author | John Criswell <criswell@uiuc.edu> | 2003-08-07 14:43:13 +0000 |
---|---|---|
committer | John Criswell <criswell@uiuc.edu> | 2003-08-07 14:43:13 +0000 |
commit | 7d3c5795f9624cd2fd9cdf9a61a9eb055bbead4b (patch) | |
tree | e4d0f9bc47e8eb13688a99d589d8577b11f8ef70 /lib/Transforms | |
parent | ec4f52317819e24cb2661559af58593f0a444bd8 (diff) |
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().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7673 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/GlobalDCE.cpp | 6 |
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; } |