From 500606f270ffcbdc199ee581fb2147700a7bb139 Mon Sep 17 00:00:00 2001 From: Wei Mi Date: Thu, 21 Feb 2019 02:57:52 +0000 Subject: [PATCH] [Inliner] Pass nullptr for the ORE param of getInlineCost if RemarkEnabled 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 --- llvm/lib/Transforms/IPO/Inliner.cpp | 5 ++++- llvm/lib/Transforms/IPO/PartialInlining.cpp | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp index d50592d..8ea6d15 100644 --- a/llvm/lib/Transforms/IPO/Inliner.cpp +++ b/llvm/lib/Transforms/IPO/Inliner.cpp @@ -1005,8 +1005,11 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC, auto GetInlineCost = [&](CallSite CS) { Function &Callee = *CS.getCalledFunction(); auto &CalleeTTI = FAM.getResult(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. diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp index 2839d14..a172aada 100644 --- a/llvm/lib/Transforms/IPO/PartialInlining.cpp +++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp @@ -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([&]() { -- 2.7.4