@@ -249,9 +249,6 @@ 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
-
255
252
// / Profile summary information.
256
253
ProfileSummaryInfo *PSI;
257
254
@@ -436,7 +433,6 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
436
433
bool simplifyIntrinsicCallIsConstant (CallBase &CB);
437
434
bool simplifyIntrinsicCallObjectSize (CallBase &CB);
438
435
ConstantInt *stripAndComputeInBoundsConstantOffsets (Value *&V);
439
- bool isLoweredToCall (Function *F, CallBase &Call);
440
436
441
437
// / Return true if the given argument to the function being considered for
442
438
// / inlining has the given attribute set either at the call site or the
@@ -496,15 +492,13 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
496
492
bool visitUnreachableInst (UnreachableInst &I);
497
493
498
494
public:
499
- CallAnalyzer (
500
- Function &Callee, CallBase &Call, const TargetTransformInfo &TTI,
501
- function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
502
- function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
503
- function_ref<const TargetLibraryInfo &(Function &)> GetTLI = nullptr ,
504
- ProfileSummaryInfo *PSI = nullptr ,
505
- OptimizationRemarkEmitter *ORE = nullptr )
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 )
506
500
: TTI(TTI), GetAssumptionCache(GetAssumptionCache), GetBFI(GetBFI),
507
- GetTLI (GetTLI), PSI(PSI), F(Callee), DL(F.getDataLayout()), ORE(ORE),
501
+ PSI (PSI), F(Callee), DL(F.getDataLayout()), ORE(ORE),
508
502
CandidateCall(Call) {}
509
503
510
504
InlineResult analyze ();
@@ -694,8 +688,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
694
688
// / FIXME: if InlineCostCallAnalyzer is derived from, this may need
695
689
// / to instantiate the derived class.
696
690
InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI,
697
- GetAssumptionCache, GetBFI, GetTLI, PSI, ORE,
698
- false );
691
+ GetAssumptionCache, GetBFI, PSI, ORE, false );
699
692
if (CA.analyze ().isSuccess ()) {
700
693
// We were able to inline the indirect call! Subtract the cost from the
701
694
// threshold to get the bonus we want to apply, but don't go below zero.
@@ -1113,12 +1106,10 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
1113
1106
const TargetTransformInfo &TTI,
1114
1107
function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
1115
1108
function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
1116
- function_ref<const TargetLibraryInfo &(Function &)> GetTLI = nullptr ,
1117
1109
ProfileSummaryInfo *PSI = nullptr ,
1118
1110
OptimizationRemarkEmitter *ORE = nullptr , bool BoostIndirect = true ,
1119
1111
bool IgnoreThreshold = false )
1120
- : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, GetTLI, PSI,
1121
- ORE),
1112
+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI, ORE),
1122
1113
ComputeFullInlineCost (OptComputeFullInlineCost ||
1123
1114
Params.ComputeFullInlineCost || ORE ||
1124
1115
isCostBenefitAnalysisEnabled ()),
@@ -1237,8 +1228,8 @@ class InlineCostFeaturesAnalyzer final : public CallAnalyzer {
1237
1228
InlineConstants::IndirectCallThreshold;
1238
1229
1239
1230
InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI,
1240
- GetAssumptionCache, GetBFI, GetTLI, PSI, ORE,
1241
- false , true );
1231
+ GetAssumptionCache, GetBFI, PSI, ORE, false ,
1232
+ true );
1242
1233
if (CA.analyze ().isSuccess ()) {
1243
1234
increment (InlineCostFeatureIndex::nested_inline_cost_estimate,
1244
1235
CA.getCost ());
@@ -1364,11 +1355,9 @@ class InlineCostFeaturesAnalyzer final : public CallAnalyzer {
1364
1355
const TargetTransformInfo &TTI,
1365
1356
function_ref<AssumptionCache &(Function &)> &GetAssumptionCache,
1366
1357
function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
1367
- function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
1368
1358
ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE, Function &Callee,
1369
1359
CallBase &Call)
1370
- : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, GetTLI,
1371
- PSI) {}
1360
+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI) {}
1372
1361
1373
1362
const InlineCostFeatures &features () const { return Cost; }
1374
1363
};
@@ -2271,44 +2260,6 @@ bool CallAnalyzer::simplifyCallSite(Function *F, CallBase &Call) {
2271
2260
return false ;
2272
2261
}
2273
2262
2274
- bool CallAnalyzer::isLoweredToCall (Function *F, CallBase &Call) {
2275
- const TargetLibraryInfo *TLI = GetTLI ? &GetTLI (*F) : nullptr ;
2276
- LibFunc LF;
2277
- if (!TLI || !TLI->getLibFunc (*F, LF) || !TLI->has (LF))
2278
- return TTI.isLoweredToCall (F);
2279
-
2280
- switch (LF) {
2281
- case LibFunc_memcpy_chk:
2282
- case LibFunc_memmove_chk:
2283
- case LibFunc_mempcpy_chk:
2284
- case LibFunc_memset_chk: {
2285
- // Calls to __memcpy_chk whose length is known to fit within the object
2286
- // size will eventually be replaced by inline stores. Therefore, these
2287
- // should not incur a call penalty. This is only really relevant on
2288
- // platforms whose headers redirect memcpy to __memcpy_chk (e.g. Darwin), as
2289
- // other platforms use memcpy intrinsics, which are already exempt from the
2290
- // call penalty.
2291
- auto *LenOp = dyn_cast<ConstantInt>(Call.getOperand (2 ));
2292
- if (!LenOp)
2293
- LenOp = dyn_cast_or_null<ConstantInt>(
2294
- SimplifiedValues.lookup (Call.getOperand (2 )));
2295
- auto *ObjSizeOp = dyn_cast<ConstantInt>(Call.getOperand (3 ));
2296
- if (!ObjSizeOp)
2297
- ObjSizeOp = dyn_cast_or_null<ConstantInt>(
2298
- SimplifiedValues.lookup (Call.getOperand (3 )));
2299
- if (LenOp && ObjSizeOp &&
2300
- LenOp->getLimitedValue () <= ObjSizeOp->getLimitedValue ()) {
2301
- return false ;
2302
- }
2303
- break ;
2304
- }
2305
- default :
2306
- break ;
2307
- }
2308
-
2309
- return TTI.isLoweredToCall (F);
2310
- }
2311
-
2312
2263
bool CallAnalyzer::visitCallBase (CallBase &Call) {
2313
2264
if (!onCallBaseVisitStart (Call))
2314
2265
return true ;
@@ -2390,7 +2341,7 @@ bool CallAnalyzer::visitCallBase(CallBase &Call) {
2390
2341
return false ;
2391
2342
}
2392
2343
2393
- if (isLoweredToCall (F, Call )) {
2344
+ if (TTI. isLoweredToCall (F)) {
2394
2345
onLoweredCall (F, Call, IsIndirectCall);
2395
2346
}
2396
2347
@@ -2996,7 +2947,6 @@ std::optional<int> llvm::getInliningCostEstimate(
2996
2947
CallBase &Call, TargetTransformInfo &CalleeTTI,
2997
2948
function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
2998
2949
function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
2999
- function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
3000
2950
ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
3001
2951
const InlineParams Params = {/* DefaultThreshold*/ 0 ,
3002
2952
/* HintThreshold*/ {},
@@ -3010,7 +2960,7 @@ std::optional<int> llvm::getInliningCostEstimate(
3010
2960
/* EnableDeferral*/ true };
3011
2961
3012
2962
InlineCostCallAnalyzer CA (*Call.getCalledFunction (), Call, Params, CalleeTTI,
3013
- GetAssumptionCache, GetBFI, GetTLI, PSI, ORE, true ,
2963
+ GetAssumptionCache, GetBFI, PSI, ORE, true ,
3014
2964
/* IgnoreThreshold*/ true );
3015
2965
auto R = CA.analyze ();
3016
2966
if (!R.isSuccess ())
@@ -3022,10 +2972,9 @@ std::optional<InlineCostFeatures> llvm::getInliningCostFeatures(
3022
2972
CallBase &Call, TargetTransformInfo &CalleeTTI,
3023
2973
function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
3024
2974
function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
3025
- function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
3026
2975
ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
3027
- InlineCostFeaturesAnalyzer CFA (CalleeTTI, GetAssumptionCache, GetBFI, GetTLI ,
3028
- PSI, ORE, *Call.getCalledFunction (), Call);
2976
+ InlineCostFeaturesAnalyzer CFA (CalleeTTI, GetAssumptionCache, GetBFI, PSI ,
2977
+ ORE, *Call.getCalledFunction (), Call);
3029
2978
auto R = CFA.analyze ();
3030
2979
if (!R.isSuccess ())
3031
2980
return std::nullopt;
@@ -3125,7 +3074,7 @@ InlineCost llvm::getInlineCost(
3125
3074
<< " )\n " );
3126
3075
3127
3076
InlineCostCallAnalyzer CA (*Callee, Call, Params, CalleeTTI,
3128
- GetAssumptionCache, GetBFI, GetTLI, PSI, ORE);
3077
+ GetAssumptionCache, GetBFI, PSI, ORE);
3129
3078
InlineResult ShouldInline = CA.analyze ();
3130
3079
3131
3080
LLVM_DEBUG (CA.dump ());
@@ -3316,8 +3265,7 @@ InlineCostAnnotationPrinterPass::run(Function &F,
3316
3265
continue ;
3317
3266
OptimizationRemarkEmitter ORE (CalledFunction);
3318
3267
InlineCostCallAnalyzer ICCA (*CalledFunction, *CB, Params, TTI,
3319
- GetAssumptionCache, nullptr , nullptr , &PSI,
3320
- &ORE);
3268
+ GetAssumptionCache, nullptr , &PSI, &ORE);
3321
3269
ICCA.analyze ();
3322
3270
OS << " Analyzing call of " << CalledFunction->getName ()
3323
3271
<< " ... (caller:" << CB->getCaller ()->getName () << " )\n " ;
0 commit comments