[llvm] 9a913a3 - InlineCostAnnotationPrinter: Fix constructing random TargetTransformInfo (#133637)

via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 30 08:05:02 PDT 2025


Author: Matt Arsenault
Date: 2025-03-30T22:04:59+07:00
New Revision: 9a913a39442d986cf8315f88666f8f5ebd6a4a94

URL: https://github.com/llvm/llvm-project/commit/9a913a39442d986cf8315f88666f8f5ebd6a4a94
DIFF: https://github.com/llvm/llvm-project/commit/9a913a39442d986cf8315f88666f8f5ebd6a4a94.diff

LOG: InlineCostAnnotationPrinter: Fix constructing random TargetTransformInfo (#133637)

Query the correct TTI for the current target instead of constructing
some random default one. Also query the pass manager for
ProfileSummaryInfo.
This should only change the printing, not the actual result.

Added: 
    

Modified: 
    llvm/lib/Analysis/InlineCost.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index e42b2bd82cf2e..9f193b610328b 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -3295,9 +3295,12 @@ InlineCostAnnotationPrinterPass::run(Function &F,
       [&](Function &F) -> AssumptionCache & {
     return FAM.getResult<AssumptionAnalysis>(F);
   };
-  Module *M = F.getParent();
-  ProfileSummaryInfo PSI(*M);
-  TargetTransformInfo TTI(M->getDataLayout());
+
+  auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
+  ProfileSummaryInfo *PSI =
+      MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
+  const TargetTransformInfo &TTI = FAM.getResult<TargetIRAnalysis>(F);
+
   // FIXME: Redesign the usage of InlineParams to expand the scope of this pass.
   // In the current implementation, the type of InlineParams doesn't matter as
   // the pass serves only for verification of inliner's decisions.
@@ -3312,7 +3315,7 @@ InlineCostAnnotationPrinterPass::run(Function &F,
           continue;
         OptimizationRemarkEmitter ORE(CalledFunction);
         InlineCostCallAnalyzer ICCA(*CalledFunction, *CB, Params, TTI,
-                                    GetAssumptionCache, nullptr, nullptr, &PSI,
+                                    GetAssumptionCache, nullptr, nullptr, PSI,
                                     &ORE);
         ICCA.analyze();
         OS << "      Analyzing call of " << CalledFunction->getName()


        


More information about the llvm-commits mailing list