[llvm-commits] CVS: llvm/lib/Transforms/IPO/ConstantMerge.cpp

Chris Lattner sabre at nondot.org
Fri Apr 13 18:12:15 PDT 2007



Changes in directory llvm/lib/Transforms/IPO:

ConstantMerge.cpp updated: 1.35 -> 1.36
---
Log message:

in addition to merging, constantmerge should also delete trivially dead globals,
in order to clean up after simplifylibcalls.


---
Diffs of the changes:  (+8 -1)

 ConstantMerge.cpp |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/IPO/ConstantMerge.cpp
diff -u llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.35 llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.36
--- llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.35	Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/ConstantMerge.cpp	Fri Apr 13 20:11:54 2007
@@ -61,7 +61,13 @@
     // 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 @@
           Slot = GV;
         }
       }
+    }
 
     if (Replacements.empty())
       return MadeChange;






More information about the llvm-commits mailing list