1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 12:12:47 +01:00

Fix bug: ConstantMerge/2003-10-28-MergeExternalConstants.ll & PR64

llvm-svn: 9579
This commit is contained in:
Chris Lattner 2003-10-29 06:01:26 +00:00
parent f070b05728
commit 89b33b1999

View File

@ -52,14 +52,25 @@ bool ConstantMerge::run(Module &M) {
if (I == CMap.end()) { // Nope, add it to the map
CMap.insert(I, std::make_pair(Init, GV));
} else { // Yup, this is a duplicate!
} else if (GV->hasInternalLinkage()) { // Yup, this is a duplicate!
// Make all uses of the duplicate constant use the canonical version...
GV->replaceAllUsesWith(I->second);
// Delete the global value from the module... and back up iterator to
// not skip the next global...
GV = --M.getGlobalList().erase(GV);
++NumMerged;
MadeChanges = true;
} else if (I->second->hasInternalLinkage()) {
// Make all uses of the duplicate constant use the canonical version...
I->second->replaceAllUsesWith(GV);
// Delete the global value from the module... and back up iterator to
// not skip the next global...
M.getGlobalList().erase(I->second);
I->second = GV;
++NumMerged;
MadeChanges = true;
}