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
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;