@@ -249,6 +249,9 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
249
249
// / Getter for BlockFrequencyInfo
250
250
function_ref<BlockFrequencyInfo &(Function &)> GetBFI;
251
251
252
+ // / Getter for TargetLibraryInfo
253
+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI;
254
+
252
255
// / Profile summary information.
253
256
ProfileSummaryInfo *PSI;
254
257
@@ -492,13 +495,15 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
492
495
bool visitUnreachableInst (UnreachableInst &I);
493
496
494
497
public:
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 )
500
505
: 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),
502
507
CandidateCall(Call) {}
503
508
504
509
InlineResult analyze ();
@@ -688,7 +693,8 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
688
693
// / FIXME: if InlineCostCallAnalyzer is derived from, this may need
689
694
// / to instantiate the derived class.
690
695
InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI,
691
- GetAssumptionCache, GetBFI, PSI, ORE, false );
696
+ GetAssumptionCache, GetBFI, GetTLI, PSI, ORE,
697
+ false );
692
698
if (CA.analyze ().isSuccess ()) {
693
699
// We were able to inline the indirect call! Subtract the cost from the
694
700
// threshold to get the bonus we want to apply, but don't go below zero.
@@ -1106,10 +1112,12 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
1106
1112
const TargetTransformInfo &TTI,
1107
1113
function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
1108
1114
function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
1115
+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI = nullptr ,
1109
1116
ProfileSummaryInfo *PSI = nullptr ,
1110
1117
OptimizationRemarkEmitter *ORE = nullptr , bool BoostIndirect = true ,
1111
1118
bool IgnoreThreshold = false )
1112
- : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI, ORE),
1119
+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, GetTLI, PSI,
1120
+ ORE),
1113
1121
ComputeFullInlineCost (OptComputeFullInlineCost ||
1114
1122
Params.ComputeFullInlineCost || ORE ||
1115
1123
isCostBenefitAnalysisEnabled ()),
@@ -1228,8 +1236,8 @@ class InlineCostFeaturesAnalyzer final : public CallAnalyzer {
1228
1236
InlineConstants::IndirectCallThreshold;
1229
1237
1230
1238
InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI,
1231
- GetAssumptionCache, GetBFI, PSI, ORE, false ,
1232
- true );
1239
+ GetAssumptionCache, GetBFI, GetTLI, PSI, ORE ,
1240
+ false , true );
1233
1241
if (CA.analyze ().isSuccess ()) {
1234
1242
increment (InlineCostFeatureIndex::nested_inline_cost_estimate,
1235
1243
CA.getCost ());
@@ -1355,9 +1363,11 @@ class InlineCostFeaturesAnalyzer final : public CallAnalyzer {
1355
1363
const TargetTransformInfo &TTI,
1356
1364
function_ref<AssumptionCache &(Function &)> &GetAssumptionCache,
1357
1365
function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
1366
+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
1358
1367
ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE, Function &Callee,
1359
1368
CallBase &Call)
1360
- : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI) {}
1369
+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, GetTLI,
1370
+ PSI) {}
1361
1371
1362
1372
const InlineCostFeatures &features () const { return Cost; }
1363
1373
};
@@ -2945,6 +2955,7 @@ std::optional<int> llvm::getInliningCostEstimate(
2945
2955
CallBase &Call, TargetTransformInfo &CalleeTTI,
2946
2956
function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
2947
2957
function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
2958
+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
2948
2959
ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
2949
2960
const InlineParams Params = {/* DefaultThreshold*/ 0 ,
2950
2961
/* HintThreshold*/ {},
@@ -2958,7 +2969,7 @@ std::optional<int> llvm::getInliningCostEstimate(
2958
2969
/* EnableDeferral*/ true };
2959
2970
2960
2971
InlineCostCallAnalyzer CA (*Call.getCalledFunction (), Call, Params, CalleeTTI,
2961
- GetAssumptionCache, GetBFI, PSI, ORE, true ,
2972
+ GetAssumptionCache, GetBFI, GetTLI, PSI, ORE, true ,
2962
2973
/* IgnoreThreshold*/ true );
2963
2974
auto R = CA.analyze ();
2964
2975
if (!R.isSuccess ())
@@ -2970,9 +2981,10 @@ std::optional<InlineCostFeatures> llvm::getInliningCostFeatures(
2970
2981
CallBase &Call, TargetTransformInfo &CalleeTTI,
2971
2982
function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
2972
2983
function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
2984
+ function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
2973
2985
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);
2976
2988
auto R = CFA.analyze ();
2977
2989
if (!R.isSuccess ())
2978
2990
return std::nullopt;
@@ -3072,7 +3084,7 @@ InlineCost llvm::getInlineCost(
3072
3084
<< " )\n " );
3073
3085
3074
3086
InlineCostCallAnalyzer CA (*Callee, Call, Params, CalleeTTI,
3075
- GetAssumptionCache, GetBFI, PSI, ORE);
3087
+ GetAssumptionCache, GetBFI, GetTLI, PSI, ORE);
3076
3088
InlineResult ShouldInline = CA.analyze ();
3077
3089
3078
3090
LLVM_DEBUG (CA.dump ());
@@ -3263,7 +3275,8 @@ InlineCostAnnotationPrinterPass::run(Function &F,
3263
3275
continue ;
3264
3276
OptimizationRemarkEmitter ORE (CalledFunction);
3265
3277
InlineCostCallAnalyzer ICCA (*CalledFunction, *CB, Params, TTI,
3266
- GetAssumptionCache, nullptr , &PSI, &ORE);
3278
+ GetAssumptionCache, nullptr , nullptr , &PSI,
3279
+ &ORE);
3267
3280
ICCA.analyze ();
3268
3281
OS << " Analyzing call of " << CalledFunction->getName ()
3269
3282
<< " ... (caller:" << CB->getCaller ()->getName () << " )\n " ;
0 commit comments