diff options
author | Devang Patel <dpatel@apple.com> | 2008-11-05 01:39:16 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-11-05 01:39:16 +0000 |
commit | c5456a4974b49ded9f76b217fdce327d24c536d4 (patch) | |
tree | 47b97f45f521011bc4ab5b628557cf32f53303a4 /lib/Transforms/IPO | |
parent | e7eefd67ac41382746bdbf2b9549d997498384b2 (diff) | |
download | external_llvm-c5456a4974b49ded9f76b217fdce327d24c536d4.zip external_llvm-c5456a4974b49ded9f76b217fdce327d24c536d4.tar.gz external_llvm-c5456a4974b49ded9f76b217fdce327d24c536d4.tar.bz2 |
Do now allow InlineAlways pass to remove dead functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58744 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r-- | lib/Transforms/IPO/InlineAlways.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/IPO/Inliner.cpp | 10 |
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/InlineAlways.cpp b/lib/Transforms/IPO/InlineAlways.cpp index d809b5a..9031432 100644 --- a/lib/Transforms/IPO/InlineAlways.cpp +++ b/lib/Transforms/IPO/InlineAlways.cpp @@ -45,6 +45,9 @@ namespace { float getInlineFudgeFactor(CallSite CS) { return CA.getInlineFudgeFactor(CS); } + virtual bool doFinalization(CallGraph &CG) { + return removeDeadFunctions(CG, &NeverInline); + } virtual bool doInitialization(CallGraph &CG); }; } diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 2321047..418b2b7 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -204,6 +204,13 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) { // doFinalization - Remove now-dead linkonce functions at the end of // processing to avoid breaking the SCC traversal. bool Inliner::doFinalization(CallGraph &CG) { + return removeDeadFunctions(CG); +} + + /// removeDeadFunctions - Remove dead functions that are not included in + /// DNR (Do Not Remove) list. +bool Inliner::removeDeadFunctions(CallGraph &CG, + SmallPtrSet<const Function *, 16> *DNR) { std::set<CallGraphNode*> FunctionsToRemove; // Scan for all of the functions, looking for ones that should now be removed @@ -215,6 +222,9 @@ bool Inliner::doFinalization(CallGraph &CG) { // them. F->removeDeadConstantUsers(); + if (DNR && DNR->count(F)) + continue; + if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) && F->use_empty()) { |