From: Davide Italiano Date: Fri, 25 Aug 2017 22:01:42 +0000 (+0000) Subject: [Inliner] Only compute fully inline cost when remarks are enabled. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce5cab1140eb5d807d328b02747bde4d7b4705b8;p=llvm [Inliner] Only compute fully inline cost when remarks are enabled. Prior to this change (and after r311371), we computed it unconditionally, causin gsevere compile time regressions (in some cases, 5 to 10x). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311804 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 1af40d3dab8..b7a7979bb56 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -57,13 +57,23 @@ public: InlineCost getInlineCost(CallSite CS) override { Function *Callee = CS.getCalledFunction(); TargetTransformInfo &TTI = TTIWP->getTTI(*Callee); + + bool RemarksEnabled = false; + const auto &BBs = CS.getCaller()->getBasicBlockList(); + if (!BBs.empty()) { + auto DI = OptimizationRemark(DEBUG_TYPE, "", DebugLoc(), &BBs.front()); + if (DI.isEnabled()) + RemarksEnabled = true; + } OptimizationRemarkEmitter ORE(CS.getCaller()); + std::function GetAssumptionCache = [&](Function &F) -> AssumptionCache & { return ACT->getAssumptionCache(F); }; return llvm::getInlineCost(CS, Params, TTI, GetAssumptionCache, - /*GetBFI=*/None, PSI, &ORE); + /*GetBFI=*/None, PSI, + RemarksEnabled ? &ORE : nullptr); } bool runOnSCC(CallGraphSCC &SCC) override;