Skip to content

Commit 7d9d1c6

Browse files
committed
InlineCost: Fix constructing random TargetTransformInfo
Query the correct TTI for the current target instead of constructing some random default one. Also query the pass manager for ProfileSummaryInfo.
1 parent faefb70 commit 7d9d1c6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3295,9 +3295,12 @@ InlineCostAnnotationPrinterPass::run(Function &F,
32953295
[&](Function &F) -> AssumptionCache & {
32963296
return FAM.getResult<AssumptionAnalysis>(F);
32973297
};
3298-
Module *M = F.getParent();
3299-
ProfileSummaryInfo PSI(*M);
3300-
TargetTransformInfo TTI(M->getDataLayout());
3298+
3299+
auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
3300+
ProfileSummaryInfo *PSI =
3301+
MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
3302+
const TargetTransformInfo &TTI = FAM.getResult<TargetIRAnalysis>(F);
3303+
33013304
// FIXME: Redesign the usage of InlineParams to expand the scope of this pass.
33023305
// In the current implementation, the type of InlineParams doesn't matter as
33033306
// the pass serves only for verification of inliner's decisions.
@@ -3312,7 +3315,7 @@ InlineCostAnnotationPrinterPass::run(Function &F,
33123315
continue;
33133316
OptimizationRemarkEmitter ORE(CalledFunction);
33143317
InlineCostCallAnalyzer ICCA(*CalledFunction, *CB, Params, TTI,
3315-
GetAssumptionCache, nullptr, nullptr, &PSI,
3318+
GetAssumptionCache, nullptr, nullptr, PSI,
33163319
&ORE);
33173320
ICCA.analyze();
33183321
OS << " Analyzing call of " << CalledFunction->getName()

0 commit comments

Comments
 (0)