diff options
author | Chris Lattner <sabre@nondot.org> | 2007-04-14 01:11:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-04-14 01:11:54 +0000 |
commit | 8264a9fccae4d0b8942360f57d9167519d09f220 (patch) | |
tree | bdcf3ed2a8d1ff832281943f889873b884b5b41c /lib/Transforms/IPO/ConstantMerge.cpp | |
parent | 6fe5541003e8781af88120db69ca6b7cc498d841 (diff) | |
download | external_llvm-8264a9fccae4d0b8942360f57d9167519d09f220.zip external_llvm-8264a9fccae4d0b8942360f57d9167519d09f220.tar.gz external_llvm-8264a9fccae4d0b8942360f57d9167519d09f220.tar.bz2 |
in addition to merging, constantmerge should also delete trivially dead globals,
in order to clean up after simplifylibcalls.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35982 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/ConstantMerge.cpp')
-rw-r--r-- | lib/Transforms/IPO/ConstantMerge.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 11ec09a..fc142e1 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -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; |