]> granicus.if.org Git - llvm/commitdiff
[Inliner] Only compute fully inline cost when remarks are enabled.
authorDavide Italiano <davide@freebsd.org>
Fri, 25 Aug 2017 22:01:42 +0000 (22:01 +0000)
committerDavide Italiano <davide@freebsd.org>
Fri, 25 Aug 2017 22:01:42 +0000 (22:01 +0000)
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

lib/Transforms/IPO/InlineSimple.cpp

index 1af40d3dab82e4d7852721de1e5d94dfb93d35c4..b7a7979bb5620e224aad10f078a68a1e6372c560 100644 (file)
@@ -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<AssumptionCache &(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;