From c8dfbbbf25ea886df52dac3fcb7260a902ea8b22 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 20 Sep 2003 19:00:50 +0000 Subject: [PATCH] Global variables with APPENDING linkage are very important to keep around! llvm-svn: 8632 --- llvm/lib/Transforms/IPO/GlobalDCE.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp index 2e18c43bac37..b47b365d59d1 100644 --- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp +++ b/llvm/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); }