From: Chris Lattner Date: Thu, 26 Jun 2003 05:30:40 +0000 (+0000) Subject: When internalizing global ctor/dtor list, also mark it constant. This is gross, but X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=81d4e14449fce69ca3a315685a80bb3c20a3db23;p=oota-llvm.git When internalizing global ctor/dtor list, also mark it constant. This is gross, but 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 --- diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index ec28ecf81d0..0ed76aba628 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -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;