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
This commit is contained in:
John Criswell 2003-08-07 14:43:13 +00:00
parent eaa5b964bb
commit 449670a8f7
1 changed files with 4 additions and 2 deletions

View File

@ -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;
}