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 | 449670a8f7ffd364fc0ab5a1e3ee90587e17dcf7 (patch) | |
| tree | ff6eec2d83a06167ae018b5a6780ec24b11ce4ea /llvm/lib/Transforms | |
| parent | eaa5b964bb8fdd5e9c17111887f450c21ed7fe70 (diff) | |
| download | bcm5719-llvm-449670a8f7ffd364fc0ab5a1e3ee90587e17dcf7.tar.gz bcm5719-llvm-449670a8f7ffd364fc0ab5a1e3ee90587e17dcf7.zip | |
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().
llvm-svn: 7673
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/GlobalDCE.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp index c7fddc99139..f991229e985 100644 --- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp +++ b/llvm/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; } |

