@@ -148,10 +148,10 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
148
148
const TargetTransformInfo &TTI;
149
149
150
150
// / Getter for the cache of @llvm.assume intrinsics.
151
- std::function <AssumptionCache &(Function &)> & GetAssumptionCache;
151
+ function_ref <AssumptionCache &(Function &)> GetAssumptionCache;
152
152
153
153
// / Getter for BlockFrequencyInfo
154
- Optional< function_ref<BlockFrequencyInfo &(Function &)>> & GetBFI;
154
+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI;
155
155
156
156
// / Profile summary information.
157
157
ProfileSummaryInfo *PSI;
@@ -382,11 +382,12 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
382
382
bool visitUnreachableInst (UnreachableInst &I);
383
383
384
384
public:
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 )
390
391
: TTI(TTI), GetAssumptionCache(GetAssumptionCache), GetBFI(GetBFI),
391
392
PSI (PSI), F(Callee), DL(F.getParent()->getDataLayout()), ORE(ORE),
392
393
CandidateCall(Call), EnableLoadElimination(true ) {}
@@ -504,8 +505,8 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
504
505
InlineConstants::IndirectCallThreshold;
505
506
// / FIXME: if InlineCostCallAnalyzer is derived from, this may need
506
507
// / 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 );
509
510
if (CA.analyze ().isSuccess ()) {
510
511
// We were able to inline the indirect call! Subtract the cost from the
511
512
// threshold to get the bonus we want to apply, but don't go below zero.
@@ -693,13 +694,14 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
693
694
694
695
public:
695
696
InlineCostCallAnalyzer (
697
+ Function &Callee, CallBase &Call, const InlineParams &Params,
696
698
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 ,
701
703
bool IgnoreThreshold = false )
702
- : CallAnalyzer(TTI, GetAssumptionCache, GetBFI, PSI, ORE, Callee, Call ),
704
+ : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI, ORE),
703
705
ComputeFullInlineCost (OptComputeFullInlineCost ||
704
706
Params.ComputeFullInlineCost || ORE),
705
707
Params(Params), Threshold(Params.DefaultThreshold),
@@ -1298,7 +1300,7 @@ void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) {
1298
1300
// Callsite hotness and coldness can be determined if sample profile is
1299
1301
// used (which adds hotness metadata to calls) or if caller's
1300
1302
// BlockFrequencyInfo is available.
1301
- BlockFrequencyInfo *CallerBFI = GetBFI ? &((* GetBFI) (*Caller)) : nullptr ;
1303
+ BlockFrequencyInfo *CallerBFI = GetBFI ? &(GetBFI (*Caller)) : nullptr ;
1302
1304
auto HotCallSiteThreshold = getHotCallSiteThreshold (Call, CallerBFI);
1303
1305
if (!Caller->hasOptSize () && HotCallSiteThreshold) {
1304
1306
LLVM_DEBUG (dbgs () << " Hot callsite.\n " );
@@ -1765,7 +1767,7 @@ bool CallAnalyzer::visitSwitchInst(SwitchInst &SI) {
1765
1767
// does not (yet) fire.
1766
1768
1767
1769
unsigned JumpTableSize = 0 ;
1768
- BlockFrequencyInfo *BFI = GetBFI ? &((* GetBFI) (F)) : nullptr ;
1770
+ BlockFrequencyInfo *BFI = GetBFI ? &(GetBFI (F)) : nullptr ;
1769
1771
unsigned NumCaseCluster =
1770
1772
TTI.getEstimatedNumberOfCaseClusters (SI, JumpTableSize, PSI, BFI);
1771
1773
@@ -2219,18 +2221,18 @@ int llvm::getCallsiteCost(CallBase &Call, const DataLayout &DL) {
2219
2221
2220
2222
InlineCost llvm::getInlineCost (
2221
2223
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,
2224
2225
function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
2226
+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
2225
2227
ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
2226
2228
return getInlineCost (Call, Call.getCalledFunction (), Params, CalleeTTI,
2227
- GetAssumptionCache, GetBFI, GetTLI , PSI, ORE);
2229
+ GetAssumptionCache, GetTLI, GetBFI , PSI, ORE);
2228
2230
}
2229
2231
2230
2232
Optional<int > llvm::getInliningCostEstimate (
2231
2233
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,
2234
2236
ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
2235
2237
const InlineParams Params = {/* DefaultThreshold*/ 0 ,
2236
2238
/* HintThreshold*/ {},
@@ -2242,8 +2244,8 @@ Optional<int> llvm::getInliningCostEstimate(
2242
2244
/* ColdCallSiteThreshold*/ {},
2243
2245
/* ComputeFullInlineCost*/ true };
2244
2246
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 ,
2247
2249
/* IgnoreThreshold*/ true );
2248
2250
auto R = CA.analyze ();
2249
2251
if (!R.isSuccess ())
@@ -2315,9 +2317,9 @@ Optional<InlineResult> llvm::getAttributeBasedInliningDecision(
2315
2317
InlineCost llvm::getInlineCost (
2316
2318
CallBase &Call, Function *Callee, const InlineParams &Params,
2317
2319
TargetTransformInfo &CalleeTTI,
2318
- std::function<AssumptionCache &(Function &)> &GetAssumptionCache,
2319
- Optional<function_ref<BlockFrequencyInfo &(Function &)>> GetBFI,
2320
+ function_ref<AssumptionCache &(Function &)> GetAssumptionCache,
2320
2321
function_ref<const TargetLibraryInfo &(Function &)> GetTLI,
2322
+ function_ref<BlockFrequencyInfo &(Function &)> GetBFI,
2321
2323
ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) {
2322
2324
2323
2325
auto UserDecision =
@@ -2333,8 +2335,8 @@ InlineCost llvm::getInlineCost(
2333
2335
<< " ... (caller:" << Call.getCaller ()->getName ()
2334
2336
<< " )\n " );
2335
2337
2336
- InlineCostCallAnalyzer CA (CalleeTTI, GetAssumptionCache, GetBFI, PSI, ORE ,
2337
- *Callee, Call, Params );
2338
+ InlineCostCallAnalyzer CA (*Callee, Call, Params, CalleeTTI ,
2339
+ GetAssumptionCache, GetBFI, PSI, ORE );
2338
2340
InlineResult ShouldInline = CA.analyze ();
2339
2341
2340
2342
LLVM_DEBUG (CA.dump ());
0 commit comments