If not internalizing, don't mark llvm.global[cd]tors const, as a fix for a
authorChris Lattner <sabre@nondot.org>
Thu, 19 Jan 2006 00:46:54 +0000 (00:46 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 19 Jan 2006 00:46:54 +0000 (00:46 +0000)
hypothetical future boog.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25430 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/Internalize.cpp

index d583d8886842c1ba0a421e3a23ed0b1cd2382872..861b79a4e0f11fb1c4b5fda3140da0cef27d9be7 100644 (file)
@@ -126,12 +126,15 @@ bool InternalizePass::runOnModule(Module &M) {
       //
       if (I->hasAppendingLinkage() && (I->getName() == "llvm.global_ctors" ||
                                        I->getName() == "llvm.global_dtors")) {
-        I->setConstant(true);
-        
         // If the global ctors/dtors list has no uses, do not internalize it, as
         // there is no __main in this program, so the asmprinter should handle
         // it.
         if (I->use_empty()) continue;
+        // Otherwise, also mark the list constant, as we know that it will not
+        // be mutated any longer, and the makes simple IPO xforms automatically
+        // better.
+        I->setConstant(true);
       }
       
       I->setLinkage(GlobalValue::InternalLinkage);