LLVM API Documentation
#include <InlinerPass.h>
Public Member Functions | |
Inliner (char &ID) | |
Inliner (char &ID, int Threshold, bool InsertLifetime) | |
void | getAnalysisUsage (AnalysisUsage &Info) const override |
bool | runOnSCC (CallGraphSCC &SCC) override |
bool | doFinalization (CallGraph &CG) override |
unsigned | getInlineThreshold () const |
unsigned | getInlineThreshold (CallSite CS) const |
virtual InlineCost | getInlineCost (CallSite CS)=0 |
bool | removeDeadFunctions (CallGraph &CG, bool AlwaysInlineOnly=false) |
Inliner - This class contains all of the helper code which is used to perform the inlining operations that do not depend on the policy.
Definition at line 32 of file InlinerPass.h.
Inliner::Inliner | ( | char & | ID | ) | [explicit] |
Definition at line 67 of file Inliner.cpp.
Inliner::Inliner | ( | char & | ID, |
int | Threshold, | ||
bool | InsertLifetime | ||
) | [explicit] |
Definition at line 70 of file Inliner.cpp.
bool Inliner::doFinalization | ( | CallGraph & | CG | ) | [override, virtual] |
doFinalization - This method is called after the SCC's of the program has been processed, allowing the pass to do final cleanup as necessary.
Reimplemented from llvm::CallGraphSCCPass.
Definition at line 641 of file Inliner.cpp.
References removeDeadFunctions().
void Inliner::getAnalysisUsage | ( | AnalysisUsage & | AU | ) | const [override, virtual] |
getAnalysisUsage - For this class, we declare that we require and preserve the call graph. If the derived class implements this method, it should always explicitly call the implementation here.
Reimplemented from llvm::CallGraphSCCPass.
Definition at line 78 of file Inliner.cpp.
References llvm::AnalysisUsage::addRequired().
virtual InlineCost llvm::Inliner::getInlineCost | ( | CallSite | CS | ) | [pure virtual] |
getInlineCost - This method must be implemented by the subclass to determine the cost of inlining the specified call site. If the cost returned is greater than the current inline threshold, the call site is not inlined.
unsigned llvm::Inliner::getInlineThreshold | ( | ) | const [inline] |
This method returns the value specified by the -inline-threshold value, specified on the command line. This is typically not directly needed.
Definition at line 53 of file InlinerPass.h.
unsigned Inliner::getInlineThreshold | ( | CallSite | CS | ) | const |
Calculate the inline threshold for given Caller. This threshold is lower if the caller is marked with OptimizeForSize and -inline-threshold is not given on the comand line. It is higher if the callee is marked with the inlinehint attribute.
Definition at line 268 of file Inliner.cpp.
References llvm::Attribute::Cold, ColdThreshold, llvm::AttributeSet::FunctionIndex, llvm::Function::getAttributes(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCaller(), llvm::AttributeSet::hasAttribute(), HintThreshold, llvm::Attribute::InlineHint, InlineLimit, llvm::GlobalValue::isDeclaration(), llvm::Attribute::MinSize, llvm::Attribute::OptimizeForSize, and OptSizeThreshold.
bool Inliner::removeDeadFunctions | ( | CallGraph & | CG, |
bool | AlwaysInlineOnly = false |
||
) |
removeDeadFunctions - Remove dead functions.
This also includes a hack in the form of the 'AlwaysInlineOnly' flag which restricts it to deleting functions with an 'AlwaysInline' attribute. This is useful for the InlineAlways pass that only wants to deal with that subset of the functions.
removeDeadFunctions - Remove dead functions that are not included in DNR (Do Not Remove) list.
Definition at line 647 of file Inliner.cpp.
References llvm::Attribute::AlwaysInline, llvm::array_pod_sort(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::CallGraph::begin(), llvm::SmallVectorBase::empty(), llvm::SmallVectorTemplateCommon< T >::end(), llvm::CallGraph::end(), llvm::SmallVectorImpl< T >::erase(), F(), llvm::AttributeSet::FunctionIndex, llvm::Function::getAttributes(), llvm::CallGraph::getExternalCallingNode(), llvm::CallGraphNode::getFunction(), llvm::AttributeSet::hasAttribute(), I, llvm::GlobalValue::isDeclaration(), llvm::Function::isDefTriviallyDead(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::CallGraphNode::removeAllCalledFunctions(), llvm::CallGraphNode::removeAnyCallEdgeTo(), llvm::Constant::removeDeadConstantUsers(), and llvm::CallGraph::removeFunctionFromModule().
Referenced by doFinalization().
bool Inliner::runOnSCC | ( | CallGraphSCC & | SCC | ) | [override, virtual] |
runOnSCC - This method should be implemented by the subclass to perform whatever action is necessary for the specified SCC. Note that non-recursive (or only self-recursive) functions will have an SCC size of 1, where recursive portions of the call graph will have SCC size > 1.
SCC passes that add or delete functions to the SCC are required to update the SCC list, otherwise stale pointers may be dereferenced.
Implements llvm::CallGraphSCCPass.
Definition at line 444 of file Inliner.cpp.
References llvm::SmallVectorTemplateCommon< T >::back(), llvm::CallGraphSCC::begin(), llvm::SmallVectorTemplateCommon< T >::begin(), llvm::Function::begin(), llvm::dbgs(), DEBUG, DEBUG_TYPE, llvm::emitOptimizationRemark(), llvm::emitOptimizationRemarkMissed(), llvm::SmallVectorBase::empty(), llvm::CallGraphSCC::end(), llvm::Function::end(), llvm::SmallVectorImpl< T >::erase(), llvm::Instruction::eraseFromParent(), F(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCalledFunction(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getCaller(), llvm::Function::getContext(), llvm::Instruction::getDebugLoc(), llvm::CallSiteBase< FunTy, ValTy, UserTy, InstrTy, CallTy, InvokeTy, IterTy >::getInstruction(), llvm::Value::getName(), llvm::GlobalValue::hasLocalLinkage(), I, InlineCallIfPossible(), llvm::InlineFunctionInfo::InlinedCalls, InlineHistoryIncludes(), llvm::GlobalValue::isDeclaration(), llvm::isInstructionTriviallyDead(), llvm::CallGraphSCC::isSingular(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::pop_back(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::CallGraph::removeFunctionFromModule(), llvm::SmallVectorTemplateCommon< T, typename >::size(), llvm::SmallVectorTemplateCommon< T >::size(), std::swap(), and llvm::Value::use_empty().