Skip to content

Commit

Permalink
[Inliner] Pass nullptr for the ORE param of getInlineCost if RemarkEn…
Browse files Browse the repository at this point in the history
…abled

is false.

Right now for inliner and partial inliner, we always pass the address of a
valid ORE object to getInlineCost even if RemarkEnabled is false because of
no -Rpass is specified. Since ComputeFullInlineCost will be set to true if
ORE is non-null in getInlineCost, this introduces the problem that in
getInlineCost we cannot return early even if we already know the cost is
definitely higher than the threshold. It is a general problem for compile
time.

This patch fixes that by pass nullptr as the ORE argument if RemarkEnabled is
false.

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

llvm-svn: 354542
  • Loading branch information
wmi-11 committed Feb 21, 2019
1 parent 2d84c00 commit 500606f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion llvm/lib/Transforms/IPO/Inliner.cpp
Expand Up @@ -1005,8 +1005,11 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
auto GetInlineCost = [&](CallSite CS) {
Function &Callee = *CS.getCalledFunction();
auto &CalleeTTI = FAM.getResult<TargetIRAnalysis>(Callee);
bool RemarksEnabled =
Callee.getContext().getDiagHandlerPtr()->isMissedOptRemarkEnabled(
DEBUG_TYPE);
return getInlineCost(CS, Params, CalleeTTI, GetAssumptionCache, {GetBFI},
PSI, &ORE);
PSI, RemarksEnabled ? &ORE : nullptr);
};

// Now process as many calls as we have within this caller in the sequnece.
Expand Down
8 changes: 6 additions & 2 deletions llvm/lib/Transforms/IPO/PartialInlining.cpp
Expand Up @@ -772,8 +772,12 @@ bool PartialInlinerImpl::shouldPartialInline(

Function *Caller = CS.getCaller();
auto &CalleeTTI = (*GetTTI)(*Callee);
InlineCost IC = getInlineCost(CS, getInlineParams(), CalleeTTI,
*GetAssumptionCache, GetBFI, PSI, &ORE);
bool RemarksEnabled =
Callee->getContext().getDiagHandlerPtr()->isMissedOptRemarkEnabled(
DEBUG_TYPE);
InlineCost IC =
getInlineCost(CS, getInlineParams(), CalleeTTI, *GetAssumptionCache,
GetBFI, PSI, RemarksEnabled ? &ORE : nullptr);

if (IC.isAlways()) {
ORE.emit([&]() {
Expand Down

0 comments on commit 500606f

Please sign in to comment.