@@ -249,6 +249,9 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
249249 // / Getter for BlockFrequencyInfo
250250 function_ref<BlockFrequencyInfo &(Function &)> GetBFI;
251251
252+ // / Getter for TargetLibraryInfo
253+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI;
254+
252255 // / Profile summary information.
253256 ProfileSummaryInfo *PSI;
254257
@@ -492,13 +495,15 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
492495 bool visitUnreachableInst (UnreachableInst &I);
493496
494497public:
495- CallAnalyzer (Function &Callee, CallBase &Call, const TargetTransformInfo &TTI,
496- function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
497- function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
498- ProfileSummaryInfo *PSI = nullptr ,
499- OptimizationRemarkEmitter *ORE = nullptr )
498+ CallAnalyzer (
499+ Function &Callee, CallBase &Call, const TargetTransformInfo &TTI,
500+ function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
501+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
502+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI = nullptr ,
503+ ProfileSummaryInfo *PSI = nullptr ,
504+ OptimizationRemarkEmitter *ORE = nullptr )
500505 : TTI(TTI), GetAssumptionCache(GetAssumptionCache), GetBFI(GetBFI),
501- PSI (PSI), F(Callee), DL(F.getDataLayout()), ORE(ORE),
506+ GetTLI (GetTLI), PSI(PSI), F(Callee), DL(F.getDataLayout()), ORE(ORE),
502507 CandidateCall(Call) {}
503508
504509 InlineResult analyze ();
@@ -688,7 +693,8 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
688693 // / FIXME: if InlineCostCallAnalyzer is derived from, this may need
689694 // / to instantiate the derived class.
690695 InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI,
691- GetAssumptionCache, GetBFI, PSI, ORE, false );
696+ GetAssumptionCache, GetBFI, GetTLI, PSI, ORE,
697+ false );
692698 if (CA.analyze ().isSuccess ()) {
693699 // We were able to inline the indirect call! Subtract the cost from the
694700 // threshold to get the bonus we want to apply, but don't go below zero.
@@ -1106,10 +1112,12 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
11061112 const TargetTransformInfo &TTI,
11071113 function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
11081114 function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
1115+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI = nullptr ,
11091116 ProfileSummaryInfo *PSI = nullptr ,
11101117 OptimizationRemarkEmitter *ORE = nullptr , bool BoostIndirect = true ,
11111118 bool IgnoreThreshold = false )
1112- : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI, ORE),
1119+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, GetTLI, PSI,
1120+ ORE),
11131121 ComputeFullInlineCost (OptComputeFullInlineCost ||
11141122 Params.ComputeFullInlineCost || ORE ||
11151123 isCostBenefitAnalysisEnabled ()),
@@ -1228,8 +1236,8 @@ class InlineCostFeaturesAnalyzer final : public CallAnalyzer {
12281236 InlineConstants::IndirectCallThreshold;
12291237
12301238 InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI,
1231- GetAssumptionCache, GetBFI, PSI, ORE, false ,
1232- true );
1239+ GetAssumptionCache, GetBFI, GetTLI, PSI, ORE ,
1240+ false , true );
12331241 if (CA.analyze ().isSuccess ()) {
12341242 increment (InlineCostFeatureIndex::nested_inline_cost_estimate,
12351243 CA.getCost ());
@@ -1355,9 +1363,11 @@ class InlineCostFeaturesAnalyzer final : public CallAnalyzer {
13551363 const TargetTransformInfo &TTI,
13561364 function_ref<AssumptionCache &(Function &)> &GetAssumptionCache,
13571365 function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
1366+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
13581367 ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE, Function &Callee,
13591368 CallBase &Call)
1360- : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI) {}
1369+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, GetTLI,
1370+ PSI) {}
13611371
13621372 const InlineCostFeatures &features () const { return Cost; }
13631373};
@@ -2945,6 +2955,7 @@ std::optional<int> llvm::getInliningCostEstimate(
29452955 CallBase &Call, TargetTransformInfo &CalleeTTI,
29462956 function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
29472957 function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
2958+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
29482959 ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
29492960 const InlineParams Params = {/* DefaultThreshold*/ 0 ,
29502961 /* HintThreshold*/ {},
@@ -2958,7 +2969,7 @@ std::optional<int> llvm::getInliningCostEstimate(
29582969 /* EnableDeferral*/ true };
29592970
29602971 InlineCostCallAnalyzer CA (*Call.getCalledFunction (), Call, Params, CalleeTTI,
2961- GetAssumptionCache, GetBFI, PSI, ORE, true ,
2972+ GetAssumptionCache, GetBFI, GetTLI, PSI, ORE, true ,
29622973 /* IgnoreThreshold*/ true );
29632974 auto R = CA.analyze ();
29642975 if (!R.isSuccess ())
@@ -2970,9 +2981,10 @@ std::optional<InlineCostFeatures> llvm::getInliningCostFeatures(
29702981 CallBase &Call, TargetTransformInfo &CalleeTTI,
29712982 function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
29722983 function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
2984+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
29732985 ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
2974- InlineCostFeaturesAnalyzer CFA (CalleeTTI, GetAssumptionCache, GetBFI, PSI ,
2975- ORE, *Call.getCalledFunction (), Call);
2986+ InlineCostFeaturesAnalyzer CFA (CalleeTTI, GetAssumptionCache, GetBFI, GetTLI ,
2987+ PSI, ORE, *Call.getCalledFunction (), Call);
29762988 auto R = CFA.analyze ();
29772989 if (!R.isSuccess ())
29782990 return std::nullopt ;
@@ -3072,7 +3084,7 @@ InlineCost llvm::getInlineCost(
30723084 << " )\n " );
30733085
30743086 InlineCostCallAnalyzer CA (*Callee, Call, Params, CalleeTTI,
3075- GetAssumptionCache, GetBFI, PSI, ORE);
3087+ GetAssumptionCache, GetBFI, GetTLI, PSI, ORE);
30763088 InlineResult ShouldInline = CA.analyze ();
30773089
30783090 LLVM_DEBUG (CA.dump ());
@@ -3263,7 +3275,8 @@ InlineCostAnnotationPrinterPass::run(Function &F,
32633275 continue ;
32643276 OptimizationRemarkEmitter ORE (CalledFunction);
32653277 InlineCostCallAnalyzer ICCA (*CalledFunction, *CB, Params, TTI,
3266- GetAssumptionCache, nullptr , &PSI, &ORE);
3278+ GetAssumptionCache, nullptr , nullptr , &PSI,
3279+ &ORE);
32673280 ICCA.analyze ();
32683281 OS << " Analyzing call of " << CalledFunction->getName ()
32693282 << " ... (caller:" << CB->getCaller ()->getName () << " )\n " ;
0 commit comments