Skip to content

Commit

Permalink
[Inliner] Add another way to compute full inline cost.
Browse files Browse the repository at this point in the history
Summary:
Full inline cost is computed when -inline-cost-full is true or ORE is
non-null. This patch adds another way to compute full inline cost by
adding a field to InlineParams. This will be used by SampleProfileLoader
to check legality of inlining a callee that it wants to inline.

Reviewers: danielcdh, haicheng

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D37819

llvm-svn: 313185
  • Loading branch information
Easwaran Raman committed Sep 13, 2017
1 parent 3e635f2 commit 4924bb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions llvm/include/llvm/Analysis/InlineCost.h
Expand Up @@ -152,6 +152,9 @@ struct InlineParams {

/// Threshold to use when the callsite is considered cold.
Optional<int> ColdCallSiteThreshold;

/// Compute inline cost even when the cost has exceeded the threshold.
Optional<bool> ComputeFullInlineCost;
};

/// Generate the parameters to tune the inline cost analysis based only on the
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Analysis/InlineCost.cpp
Expand Up @@ -82,7 +82,7 @@ static cl::opt<int> HotCallSiteRelFreq(
"entry frequency, for a callsite to be hot in the absence of "
"profile information."));

static cl::opt<bool> ComputeFullInlineCost(
static cl::opt<bool> OptComputeFullInlineCost(
"inline-cost-full", cl::Hidden, cl::init(false),
cl::desc("Compute the full inline cost of a call site even when the cost "
"exceeds the threshold."));
Expand Down Expand Up @@ -124,6 +124,7 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {

int Threshold;
int Cost;
bool ComputeFullInlineCost;

bool IsCallerRecursive;
bool IsRecursiveCall;
Expand Down Expand Up @@ -256,7 +257,9 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
: TTI(TTI), GetAssumptionCache(GetAssumptionCache), GetBFI(GetBFI),
PSI(PSI), F(Callee), DL(F.getParent()->getDataLayout()), ORE(ORE),
CandidateCS(CSArg), Params(Params), Threshold(Params.DefaultThreshold),
Cost(0), IsCallerRecursive(false), IsRecursiveCall(false),
Cost(0), ComputeFullInlineCost(OptComputeFullInlineCost ||
Params.ComputeFullInlineCost || ORE),
IsCallerRecursive(false), IsRecursiveCall(false),
ExposesReturnsTwice(false), HasDynamicAlloca(false),
ContainsNoDuplicateCall(false), HasReturn(false), HasIndirectBr(false),
HasFrameEscape(false), AllocatedSize(0), NumInstructions(0),
Expand Down Expand Up @@ -1722,9 +1725,6 @@ InlineCost llvm::getInlineCost(
CS.isNoInline())
return llvm::InlineCost::getNever();

if (ORE)
ComputeFullInlineCost = true;

DEBUG(llvm::dbgs() << " Analyzing call of " << Callee->getName()
<< "... (caller:" << Caller->getName() << ")\n");

Expand Down

0 comments on commit 4924bb0

Please sign in to comment.