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

Chris Lattner lattner at cs.uiuc.edu
Sat Sep 20 14:02:01 PDT 2003


Changes in directory llvm/lib/Transforms/IPO:

GlobalDCE.cpp updated: 1.27 -> 1.28

---
Log message:

Global variables with APPENDING linkage are very important to keep around!


---
Diffs of the changes:

Index: llvm/lib/Transforms/IPO/GlobalDCE.cpp
diff -u llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.27 llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.28
--- llvm/lib/Transforms/IPO/GlobalDCE.cpp:1.27	Tue Sep 16 14:27:31 2003
+++ llvm/lib/Transforms/IPO/GlobalDCE.cpp	Sat Sep 20 14:00:50 2003
@@ -48,14 +48,17 @@
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
     Changed |= RemoveUnusedConstantPointerRef(*I);
     // Functions with external linkage are needed if they have a body
-    if (I->hasExternalLinkage() && !I->isExternal())
+    if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) &&
+        !I->isExternal())
       GlobalIsNeeded(I);
   }
 
   for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I) {
     Changed |= RemoveUnusedConstantPointerRef(*I);
-    // Externally visible globals are needed, if they have an initializer.
-    if (I->hasExternalLinkage() && !I->isExternal())
+    // Externally visible & appending globals are needed, if they have an
+    // initializer.
+    if ((!I->hasInternalLinkage() && !I->hasLinkOnceLinkage()) &&
+        !I->isExternal())
       GlobalIsNeeded(I);
   }
 





More information about the llvm-commits mailing list