forked from OSchip/llvm-project
in addition to merging, constantmerge should also delete trivially dead globals,
in order to clean up after simplifylibcalls. llvm-svn: 35982
This commit is contained in:
parent
efb33d28c6
commit
02137eec8f
|
@ -61,7 +61,13 @@ bool ConstantMerge::runOnModule(Module &M) {
|
|||
// invalidating the Constant* pointers in CMap.
|
||||
//
|
||||
for (Module::global_iterator GV = M.global_begin(), E = M.global_end();
|
||||
GV != E; ++GV)
|
||||
GV != E; ++GV) {
|
||||
// If this GV is dead, remove it.
|
||||
GV->removeDeadConstantUsers();
|
||||
if (GV->use_empty() && GV->hasInternalLinkage()) {
|
||||
(GV++)->eraseFromParent();
|
||||
}
|
||||
|
||||
// Only process constants with initializers.
|
||||
if (GV->isConstant() && GV->hasInitializer()) {
|
||||
Constant *Init = GV->getInitializer();
|
||||
|
@ -80,6 +86,7 @@ bool ConstantMerge::runOnModule(Module &M) {
|
|||
Slot = GV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Replacements.empty())
|
||||
return MadeChange;
|
||||
|
|
Loading…
Reference in New Issue