From: Chris Lattner Date: Sat, 20 Sep 2003 19:00:50 +0000 (+0000) Subject: Global variables with APPENDING linkage are very important to keep around! X-Git-Tag: android-x86-6.0-r1~1003^2~59213 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a2d51afd79879607e7a1882462df0719d4b40fb8;p=android-x86%2Fexternal-llvm.git Global variables with APPENDING linkage are very important to keep around! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8632 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index 2e18c43bac3..b47b365d59d 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -48,14 +48,17 @@ bool GlobalDCE::run(Module &M) { 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); }