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 | 02137eec8f22363d5412b827162d1ae8356db28d (patch) | |
tree | e201edc62ab9bfaada270228236ddfc7edfec808 /llvm/lib/Transforms | |
parent | efb33d28c6a407f65644604009e7cea56a29e668 (diff) | |
download | bcm5719-llvm-02137eec8f22363d5412b827162d1ae8356db28d.tar.gz bcm5719-llvm-02137eec8f22363d5412b827162d1ae8356db28d.zip |
in addition to merging, constantmerge should also delete trivially dead globals,
in order to clean up after simplifylibcalls.
llvm-svn: 35982
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/ConstantMerge.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/ConstantMerge.cpp b/llvm/lib/Transforms/IPO/ConstantMerge.cpp index 11ec09ab2e6..fc142e16d22 100644 --- a/llvm/lib/Transforms/IPO/ConstantMerge.cpp +++ b/llvm/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; |