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

Chris Lattner lattner at cs.uiuc.edu
Wed Oct 29 00:02:02 PST 2003


Changes in directory llvm/lib/Transforms/IPO:

ConstantMerge.cpp updated: 1.21 -> 1.22

---
Log message:

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


---
Diffs of the changes:  (+13 -2)

Index: llvm/lib/Transforms/IPO/ConstantMerge.cpp
diff -u llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.21 llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.22
--- llvm/lib/Transforms/IPO/ConstantMerge.cpp:1.21	Mon Oct 20 14:43:18 2003
+++ llvm/lib/Transforms/IPO/ConstantMerge.cpp	Wed Oct 29 00:01:26 2003
@@ -52,13 +52,24 @@
 
       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;





More information about the llvm-commits mailing list