mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-10 22:46:25 +00:00
Added a variant of InlineCostAnalyzer::getInlineCost() that takes the called function as an explicit argument, for use when inlining function pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@102841 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
17458a786e
commit
752e259058
@ -176,6 +176,14 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
InlineCost getInlineCost(CallSite CS,
|
InlineCost getInlineCost(CallSite CS,
|
||||||
SmallPtrSet<const Function *, 16> &NeverInline);
|
SmallPtrSet<const Function *, 16> &NeverInline);
|
||||||
|
/// getCalledFunction - The heuristic used to determine if we should inline
|
||||||
|
/// the function call or not. The callee is explicitly specified, to allow
|
||||||
|
/// you to calculate the cost of inlining a function via a pointer. The
|
||||||
|
/// result assumes that the inlined version will always be used. You should
|
||||||
|
/// weight it yourself in cases where this callee will not always be called.
|
||||||
|
InlineCost getInlineCost(CallSite CS,
|
||||||
|
Function *Callee,
|
||||||
|
SmallPtrSet<const Function *, 16> &NeverInline);
|
||||||
|
|
||||||
/// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a
|
/// getInlineFudgeFactor - Return a > 1.0 factor if the inliner should use a
|
||||||
/// higher threshold to determine if the function call should be inlined.
|
/// higher threshold to determine if the function call should be inlined.
|
||||||
|
@ -259,9 +259,15 @@ void InlineCostAnalyzer::FunctionInfo::analyzeFunction(Function *F) {
|
|||||||
//
|
//
|
||||||
InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
|
InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
|
||||||
SmallPtrSet<const Function*, 16> &NeverInline) {
|
SmallPtrSet<const Function*, 16> &NeverInline) {
|
||||||
|
return getInlineCost(CS, CS.getCalledFunction(), NeverInline);
|
||||||
|
}
|
||||||
|
|
||||||
|
InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
|
||||||
|
Function *Callee,
|
||||||
|
SmallPtrSet<const Function*, 16> &NeverInline) {
|
||||||
Instruction *TheCall = CS.getInstruction();
|
Instruction *TheCall = CS.getInstruction();
|
||||||
Function *Callee = CS.getCalledFunction();
|
|
||||||
Function *Caller = TheCall->getParent()->getParent();
|
Function *Caller = TheCall->getParent()->getParent();
|
||||||
|
bool isDirectCall = CS.getCalledFunction() == Callee;
|
||||||
|
|
||||||
// Don't inline functions which can be redefined at link-time to mean
|
// Don't inline functions which can be redefined at link-time to mean
|
||||||
// something else. Don't inline functions marked noinline or call sites
|
// something else. Don't inline functions marked noinline or call sites
|
||||||
@ -280,7 +286,7 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
|
|||||||
// If there is only one call of the function, and it has internal linkage,
|
// If there is only one call of the function, and it has internal linkage,
|
||||||
// make it almost guaranteed to be inlined.
|
// make it almost guaranteed to be inlined.
|
||||||
//
|
//
|
||||||
if (Callee->hasLocalLinkage() && Callee->hasOneUse())
|
if (Callee->hasLocalLinkage() && Callee->hasOneUse() && isDirectCall)
|
||||||
InlineCost += InlineConstants::LastCallToStaticBonus;
|
InlineCost += InlineConstants::LastCallToStaticBonus;
|
||||||
|
|
||||||
// If this function uses the coldcc calling convention, prefer not to inline
|
// If this function uses the coldcc calling convention, prefer not to inline
|
||||||
|
Loading…
x
Reference in New Issue
Block a user