///
virtual float getInlineFudgeFactor(CallSite CS) = 0;
+ /// removeDeadFunctions - Remove dead functions that are not included in
+ /// DNR (Do Not Remove) list.
+ bool removeDeadFunctions(CallGraph &CG,
+ SmallPtrSet<const Function *, 16> *DNR = NULL);
private:
// InlineThreshold - Cache the value here for easy access.
unsigned InlineThreshold;
float getInlineFudgeFactor(CallSite CS) {
return CA.getInlineFudgeFactor(CS);
}
+ virtual bool doFinalization(CallGraph &CG) {
+ return removeDeadFunctions(CG, &NeverInline);
+ }
virtual bool doInitialization(CallGraph &CG);
};
}
// 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
// them.
F->removeDeadConstantUsers();
+ if (DNR && DNR->count(F))
+ continue;
+
if ((F->hasLinkOnceLinkage() || F->hasInternalLinkage()) &&
F->use_empty()) {