@@ -249,9 +249,6 @@ 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-
255252 // / Profile summary information.
256253 ProfileSummaryInfo *PSI;
257254
@@ -436,7 +433,6 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
436433 bool simplifyIntrinsicCallIsConstant (CallBase &CB);
437434 bool simplifyIntrinsicCallObjectSize (CallBase &CB);
438435 ConstantInt *stripAndComputeInBoundsConstantOffsets (Value *&V);
439- bool isLoweredToCall (Function *F, CallBase &Call);
440436
441437 // / Return true if the given argument to the function being considered for
442438 // / inlining has the given attribute set either at the call site or the
@@ -496,15 +492,13 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
496492 bool visitUnreachableInst (UnreachableInst &I);
497493
498494public:
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 )
506500 : 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),
508502 CandidateCall(Call) {}
509503
510504 InlineResult analyze ();
@@ -694,8 +688,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
694688 // / FIXME: if InlineCostCallAnalyzer is derived from, this may need
695689 // / to instantiate the derived class.
696690 InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI,
697- GetAssumptionCache, GetBFI, GetTLI, PSI, ORE,
698- false );
691+ GetAssumptionCache, GetBFI, PSI, ORE, false );
699692 if (CA.analyze ().isSuccess ()) {
700693 // We were able to inline the indirect call! Subtract the cost from the
701694 // threshold to get the bonus we want to apply, but don't go below zero.
@@ -1113,12 +1106,10 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
11131106 const TargetTransformInfo &TTI,
11141107 function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
11151108 function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
1116- function_ref<const TargetLibraryInfo &(Function &)> GetTLI = nullptr ,
11171109 ProfileSummaryInfo *PSI = nullptr ,
11181110 OptimizationRemarkEmitter *ORE = nullptr , bool BoostIndirect = true ,
11191111 bool IgnoreThreshold = false )
1120- : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, GetTLI, PSI,
1121- ORE),
1112+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI, ORE),
11221113 ComputeFullInlineCost (OptComputeFullInlineCost ||
11231114 Params.ComputeFullInlineCost || ORE ||
11241115 isCostBenefitAnalysisEnabled ()),
@@ -1237,8 +1228,8 @@ class InlineCostFeaturesAnalyzer final : public CallAnalyzer {
12371228 InlineConstants::IndirectCallThreshold;
12381229
12391230 InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI,
1240- GetAssumptionCache, GetBFI, GetTLI, PSI, ORE,
1241- false , true );
1231+ GetAssumptionCache, GetBFI, PSI, ORE, false ,
1232+ true );
12421233 if (CA.analyze ().isSuccess ()) {
12431234 increment (InlineCostFeatureIndex::nested_inline_cost_estimate,
12441235 CA.getCost ());
@@ -1364,11 +1355,9 @@ class InlineCostFeaturesAnalyzer final : public CallAnalyzer {
13641355 const TargetTransformInfo &TTI,
13651356 function_ref<AssumptionCache &(Function &)> &GetAssumptionCache,
13661357 function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
1367- function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
13681358 ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE, Function &Callee,
13691359 CallBase &Call)
1370- : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, GetTLI,
1371- PSI) {}
1360+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI) {}
13721361
13731362 const InlineCostFeatures &features () const { return Cost; }
13741363};
@@ -2271,44 +2260,6 @@ bool CallAnalyzer::simplifyCallSite(Function *F, CallBase &Call) {
22712260 return false ;
22722261}
22732262
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-
23122263bool CallAnalyzer::visitCallBase (CallBase &Call) {
23132264 if (!onCallBaseVisitStart (Call))
23142265 return true ;
@@ -2390,7 +2341,7 @@ bool CallAnalyzer::visitCallBase(CallBase &Call) {
23902341 return false ;
23912342 }
23922343
2393- if (isLoweredToCall (F, Call )) {
2344+ if (TTI. isLoweredToCall (F)) {
23942345 onLoweredCall (F, Call, IsIndirectCall);
23952346 }
23962347
@@ -2996,7 +2947,6 @@ std::optional<int> llvm::getInliningCostEstimate(
29962947 CallBase &Call, TargetTransformInfo &CalleeTTI,
29972948 function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
29982949 function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
2999- function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
30002950 ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
30012951 const InlineParams Params = {/* DefaultThreshold*/ 0 ,
30022952 /* HintThreshold*/ {},
@@ -3010,7 +2960,7 @@ std::optional<int> llvm::getInliningCostEstimate(
30102960 /* EnableDeferral*/ true };
30112961
30122962 InlineCostCallAnalyzer CA (*Call.getCalledFunction (), Call, Params, CalleeTTI,
3013- GetAssumptionCache, GetBFI, GetTLI, PSI, ORE, true ,
2963+ GetAssumptionCache, GetBFI, PSI, ORE, true ,
30142964 /* IgnoreThreshold*/ true );
30152965 auto R = CA.analyze ();
30162966 if (!R.isSuccess ())
@@ -3022,10 +2972,9 @@ std::optional<InlineCostFeatures> llvm::getInliningCostFeatures(
30222972 CallBase &Call, TargetTransformInfo &CalleeTTI,
30232973 function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
30242974 function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
3025- function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
30262975 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);
30292978 auto R = CFA.analyze ();
30302979 if (!R.isSuccess ())
30312980 return std::nullopt ;
@@ -3125,7 +3074,7 @@ InlineCost llvm::getInlineCost(
31253074 << " )\n " );
31263075
31273076 InlineCostCallAnalyzer CA (*Callee, Call, Params, CalleeTTI,
3128- GetAssumptionCache, GetBFI, GetTLI, PSI, ORE);
3077+ GetAssumptionCache, GetBFI, PSI, ORE);
31293078 InlineResult ShouldInline = CA.analyze ();
31303079
31313080 LLVM_DEBUG (CA.dump ());
@@ -3316,8 +3265,7 @@ InlineCostAnnotationPrinterPass::run(Function &F,
33163265 continue ;
33173266 OptimizationRemarkEmitter ORE (CalledFunction);
33183267 InlineCostCallAnalyzer ICCA (*CalledFunction, *CB, Params, TTI,
3319- GetAssumptionCache, nullptr , nullptr , &PSI,
3320- &ORE);
3268+ GetAssumptionCache, nullptr , &PSI, &ORE);
33213269 ICCA.analyze ();
33223270 OS << " Analyzing call of " << CalledFunction->getName ()
33233271 << " ... (caller:" << CB->getCaller ()->getName () << " )\n " ;
0 commit comments