summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalDCE.cpp4
-rw-r--r--llvm/lib/Transforms/IPO/Inliner.cpp3
2 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp
index 4f97ae175b1..db378b0d0b2 100644
--- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp
@@ -64,7 +64,7 @@ bool GlobalDCE::runOnModule(Module &M) {
Changed |= RemoveUnusedGlobalValue(*I);
// Functions with external linkage are needed if they have a body
if (!I->hasLocalLinkage() && !I->hasLinkOnceLinkage() &&
- !I->isDeclaration())
+ !I->isDeclaration() && !I->hasAvailableExternallyLinkage())
GlobalIsNeeded(I);
}
@@ -74,7 +74,7 @@ bool GlobalDCE::runOnModule(Module &M) {
// Externally visible & appending globals are needed, if they have an
// initializer.
if (!I->hasLocalLinkage() && !I->hasLinkOnceLinkage() &&
- !I->isDeclaration())
+ !I->isDeclaration() && !I->hasAvailableExternallyLinkage())
GlobalIsNeeded(I);
}
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index b589792022a..b382837289b 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -69,7 +69,8 @@ bool Inliner::InlineCallIfPossible(CallSite CS, CallGraph &CG,
// If we inlined the last possible call site to the function, delete the
// function body now.
- if (Callee->use_empty() && Callee->hasLocalLinkage() &&
+ if (Callee->use_empty() && (Callee->hasLocalLinkage() ||
+ Callee->hasAvailableExternallyLinkage()) &&
!SCCFunctions.count(Callee)) {
DOUT << " -> Deleting dead function: " << Callee->getName() << "\n";
CallGraphNode *CalleeNode = CG[Callee];
OpenPOWER on IntegriCloud