@@ -148,10 +148,10 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
148148 const TargetTransformInfo &TTI;
149149
150150 // / Getter for the cache of @llvm.assume intrinsics.
151- std::function <AssumptionCache &(Function &)> & GetAssumptionCache;
151+ function_ref <AssumptionCache &(Function &)> GetAssumptionCache;
152152
153153 // / Getter for BlockFrequencyInfo
154- Optional< function_ref<BlockFrequencyInfo &(Function &)>> & GetBFI;
154+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI;
155155
156156 // / Profile summary information.
157157 ProfileSummaryInfo *PSI;
@@ -382,11 +382,12 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
382382 bool visitUnreachableInst (UnreachableInst &I);
383383
384384public:
385- CallAnalyzer (const TargetTransformInfo &TTI,
386- std::function<AssumptionCache &(Function &)> &GetAssumptionCache,
387- Optional<function_ref<BlockFrequencyInfo &(Function &)>> &GetBFI,
388- ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE,
389- Function &Callee, CallBase &Call)
385+ CallAnalyzer (
386+ Function &Callee, CallBase &Call, const TargetTransformInfo &TTI,
387+ const std::function<AssumptionCache &(Function &)> &GetAssumptionCache,
388+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
389+ ProfileSummaryInfo *PSI = nullptr ,
390+ OptimizationRemarkEmitter *ORE = nullptr )
390391 : TTI(TTI), GetAssumptionCache(GetAssumptionCache), GetBFI(GetBFI),
391392 PSI (PSI), F(Callee), DL(F.getParent()->getDataLayout()), ORE(ORE),
392393 CandidateCall(Call), EnableLoadElimination(true ) {}
@@ -504,8 +505,8 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
504505 InlineConstants::IndirectCallThreshold;
505506 // / FIXME: if InlineCostCallAnalyzer is derived from, this may need
506507 // / to instantiate the derived class.
507- InlineCostCallAnalyzer CA (TTI, GetAssumptionCache, GetBFI, PSI, ORE, *F ,
508- Call, IndirectCallParams , false );
508+ InlineCostCallAnalyzer CA (*F, Call, IndirectCallParams, TTI ,
509+ GetAssumptionCache, GetBFI, PSI, ORE , false );
509510 if (CA.analyze ().isSuccess ()) {
510511 // We were able to inline the indirect call! Subtract the cost from the
511512 // threshold to get the bonus we want to apply, but don't go below zero.
@@ -693,13 +694,14 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
693694
694695public:
695696 InlineCostCallAnalyzer (
697+ Function &Callee, CallBase &Call, const InlineParams &Params,
696698 const TargetTransformInfo &TTI,
697- std::function <AssumptionCache &(Function &)> & GetAssumptionCache,
698- Optional< function_ref<BlockFrequencyInfo &(Function &)>> & GetBFI,
699- ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE, Function &Callee ,
700- CallBase &Call, const InlineParams &Params , bool BoostIndirect = true ,
699+ function_ref <AssumptionCache &(Function &)> GetAssumptionCache,
700+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr ,
701+ ProfileSummaryInfo *PSI = nullptr ,
702+ OptimizationRemarkEmitter *ORE = nullptr , bool BoostIndirect = true ,
701703 bool IgnoreThreshold = false )
702- : CallAnalyzer(TTI, GetAssumptionCache, GetBFI, PSI, ORE, Callee, Call ),
704+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI, ORE),
703705 ComputeFullInlineCost (OptComputeFullInlineCost ||
704706 Params.ComputeFullInlineCost || ORE),
705707 Params(Params), Threshold(Params.DefaultThreshold),
@@ -1298,7 +1300,7 @@ void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) {
12981300 // Callsite hotness and coldness can be determined if sample profile is
12991301 // used (which adds hotness metadata to calls) or if caller's
13001302 // BlockFrequencyInfo is available.
1301- BlockFrequencyInfo *CallerBFI = GetBFI ? &((* GetBFI) (*Caller)) : nullptr ;
1303+ BlockFrequencyInfo *CallerBFI = GetBFI ? &(GetBFI (*Caller)) : nullptr ;
13021304 auto HotCallSiteThreshold = getHotCallSiteThreshold (Call, CallerBFI);
13031305 if (!Caller->hasOptSize () && HotCallSiteThreshold) {
13041306 LLVM_DEBUG (dbgs () << " Hot callsite.\n " );
@@ -1765,7 +1767,7 @@ bool CallAnalyzer::visitSwitchInst(SwitchInst &SI) {
17651767 // does not (yet) fire.
17661768
17671769 unsigned JumpTableSize = 0 ;
1768- BlockFrequencyInfo *BFI = GetBFI ? &((* GetBFI) (F)) : nullptr ;
1770+ BlockFrequencyInfo *BFI = GetBFI ? &(GetBFI (F)) : nullptr ;
17691771 unsigned NumCaseCluster =
17701772 TTI.getEstimatedNumberOfCaseClusters (SI, JumpTableSize, PSI, BFI);
17711773
@@ -2219,18 +2221,18 @@ int llvm::getCallsiteCost(CallBase &Call, const DataLayout &DL) {
22192221
22202222InlineCost llvm::getInlineCost (
22212223 CallBase &Call, const InlineParams &Params, TargetTransformInfo &CalleeTTI,
2222- std::function<AssumptionCache &(Function &)> &GetAssumptionCache,
2223- Optional<function_ref<BlockFrequencyInfo &(Function &)>> GetBFI,
2224+ function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
22242225 function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
2226+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
22252227 ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
22262228 return getInlineCost (Call, Call.getCalledFunction (), Params, CalleeTTI,
2227- GetAssumptionCache, GetBFI, GetTLI , PSI, ORE);
2229+ GetAssumptionCache, GetTLI, GetBFI , PSI, ORE);
22282230}
22292231
22302232Optional<int > llvm::getInliningCostEstimate (
22312233 CallBase &Call, TargetTransformInfo &CalleeTTI,
2232- std::function <AssumptionCache &(Function &)> & GetAssumptionCache,
2233- Optional< function_ref<BlockFrequencyInfo &(Function &)> > GetBFI,
2234+ function_ref <AssumptionCache &(Function &)> GetAssumptionCache,
2235+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
22342236 ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
22352237 const InlineParams Params = {/* DefaultThreshold*/ 0 ,
22362238 /* HintThreshold*/ {},
@@ -2242,8 +2244,8 @@ Optional<int> llvm::getInliningCostEstimate(
22422244 /* ColdCallSiteThreshold*/ {},
22432245 /* ComputeFullInlineCost*/ true };
22442246
2245- InlineCostCallAnalyzer CA (CalleeTTI, GetAssumptionCache, GetBFI, PSI, ORE ,
2246- *Call. getCalledFunction (), Call, Params , true ,
2247+ InlineCostCallAnalyzer CA (*Call. getCalledFunction (), Call, Params, CalleeTTI ,
2248+ GetAssumptionCache, GetBFI, PSI, ORE , true ,
22472249 /* IgnoreThreshold*/ true );
22482250 auto R = CA.analyze ();
22492251 if (!R.isSuccess ())
@@ -2315,9 +2317,9 @@ Optional<InlineResult> llvm::getAttributeBasedInliningDecision(
23152317InlineCost llvm::getInlineCost (
23162318 CallBase &Call, Function *Callee, const InlineParams &Params,
23172319 TargetTransformInfo &CalleeTTI,
2318- std::function<AssumptionCache &(Function &)> &GetAssumptionCache,
2319- Optional<function_ref<BlockFrequencyInfo &(Function &)>> GetBFI,
2320+ function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
23202321 function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
2322+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
23212323 ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
23222324
23232325 auto UserDecision =
@@ -2333,8 +2335,8 @@ InlineCost llvm::getInlineCost(
23332335 << " ... (caller:" << Call.getCaller ()->getName ()
23342336 << " )\n " );
23352337
2336- InlineCostCallAnalyzer CA (CalleeTTI, GetAssumptionCache, GetBFI, PSI, ORE ,
2337- *Callee, Call, Params );
2338+ InlineCostCallAnalyzer CA (*Callee, Call, Params, CalleeTTI ,
2339+ GetAssumptionCache, GetBFI, PSI, ORE );
23382340 InlineResult ShouldInline = CA.analyze ();
23392341
23402342 LLVM_DEBUG (CA.dump ());
0 commit comments