When internalizing global ctor/dtor list, also mark it constant. This is gross, but
authorChris Lattner <sabre@nondot.org>
Thu, 26 Jun 2003 05:30:40 +0000 (05:30 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 26 Jun 2003 05:30:40 +0000 (05:30 +0000)
until DSA is working all of the time and is totally reliable, we do this.

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

lib/Transforms/IPO/Internalize.cpp

index ec28ecf81d0607ddd0f99af46d35e85ad4ea2dcb..0ed76aba6280d2fc20620e8f11761c99e8f159d3 100644 (file)
@@ -87,6 +87,14 @@ namespace {
       for (Module::giterator I = M.gbegin(), E = M.gend(); I != E; ++I)
         if (!I->isExternal() && !I->hasInternalLinkage() &&
             !ExternalNames.count(I->getName())) {
+          // Special case handling of the global ctor and dtor list.  When we
+          // internalize it, we mark it constant, which allows elimination of
+          // the list if it's empty.
+          //
+          if (I->hasAppendingLinkage() && (I->getName() == "llvm.global_ctors"||
+                                           I->getName() == "llvm.global_dtors"))
+            I->setConstant(true);
+
           I->setLinkage(GlobalValue::InternalLinkage);
           Changed = true;
           ++NumGlobals;