diff options
author | Mircea Trofin <mtrofin@google.com> | 2020-05-14 22:32:44 -0700 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2020-05-14 22:32:44 -0700 |
commit | 454de99a6fec705e76ed7743bf538f7a77296f59 (patch) | |
tree | cdaa738ebb024948bcb4f85fa333c0bf67d41c0b /llvm/lib/Analysis/InlineCost.cpp | |
parent | 767db5be67cab5aa04d81227725765cad9620611 (diff) | |
download | llvm-454de99a6fec705e76ed7743bf538f7a77296f59.zip llvm-454de99a6fec705e76ed7743bf538f7a77296f59.tar.gz llvm-454de99a6fec705e76ed7743bf538f7a77296f59.tar.bz2 |
Revert "[llvm][NFC] Cleanup uses of std::function in Inlining-related APIs"
This reverts commit 767db5be67cab5aa04d81227725765cad9620611.
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 1f1050d..ce9f030 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -148,10 +148,10 @@ protected: const TargetTransformInfo &TTI; /// Getter for the cache of @llvm.assume intrinsics. - function_ref<AssumptionCache &(Function &)> GetAssumptionCache; + std::function<AssumptionCache &(Function &)> &GetAssumptionCache; /// Getter for BlockFrequencyInfo - function_ref<BlockFrequencyInfo &(Function &)> GetBFI; + Optional<function_ref<BlockFrequencyInfo &(Function &)>> &GetBFI; /// Profile summary information. ProfileSummaryInfo *PSI; @@ -382,12 +382,11 @@ protected: bool visitUnreachableInst(UnreachableInst &I); public: - CallAnalyzer( - Function &Callee, CallBase &Call, const TargetTransformInfo &TTI, - const std::function<AssumptionCache &(Function &)> &GetAssumptionCache, - function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr, - ProfileSummaryInfo *PSI = nullptr, - OptimizationRemarkEmitter *ORE = nullptr) + CallAnalyzer(const TargetTransformInfo &TTI, + std::function<AssumptionCache &(Function &)> &GetAssumptionCache, + Optional<function_ref<BlockFrequencyInfo &(Function &)>> &GetBFI, + ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE, + Function &Callee, CallBase &Call) : TTI(TTI), GetAssumptionCache(GetAssumptionCache), GetBFI(GetBFI), PSI(PSI), F(Callee), DL(F.getParent()->getDataLayout()), ORE(ORE), CandidateCall(Call), EnableLoadElimination(true) {} @@ -505,8 +504,8 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { InlineConstants::IndirectCallThreshold; /// FIXME: if InlineCostCallAnalyzer is derived from, this may need /// to instantiate the derived class. - InlineCostCallAnalyzer CA(*F, Call, IndirectCallParams, TTI, - GetAssumptionCache, GetBFI, PSI, ORE, false); + InlineCostCallAnalyzer CA(TTI, GetAssumptionCache, GetBFI, PSI, ORE, *F, + Call, IndirectCallParams, false); if (CA.analyze().isSuccess()) { // We were able to inline the indirect call! Subtract the cost from the // threshold to get the bonus we want to apply, but don't go below zero. @@ -694,14 +693,13 @@ class InlineCostCallAnalyzer final : public CallAnalyzer { public: InlineCostCallAnalyzer( - Function &Callee, CallBase &Call, const InlineParams &Params, const TargetTransformInfo &TTI, - function_ref<AssumptionCache &(Function &)> GetAssumptionCache, - function_ref<BlockFrequencyInfo &(Function &)> GetBFI = nullptr, - ProfileSummaryInfo *PSI = nullptr, - OptimizationRemarkEmitter *ORE = nullptr, bool BoostIndirect = true, + std::function<AssumptionCache &(Function &)> &GetAssumptionCache, + Optional<function_ref<BlockFrequencyInfo &(Function &)>> &GetBFI, + ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE, Function &Callee, + CallBase &Call, const InlineParams &Params, bool BoostIndirect = true, bool IgnoreThreshold = false) - : CallAnalyzer(Callee, Call, TTI, GetAssumptionCache, GetBFI, PSI, ORE), + : CallAnalyzer(TTI, GetAssumptionCache, GetBFI, PSI, ORE, Callee, Call), ComputeFullInlineCost(OptComputeFullInlineCost || Params.ComputeFullInlineCost || ORE), Params(Params), Threshold(Params.DefaultThreshold), @@ -1300,7 +1298,7 @@ void InlineCostCallAnalyzer::updateThreshold(CallBase &Call, Function &Callee) { // Callsite hotness and coldness can be determined if sample profile is // used (which adds hotness metadata to calls) or if caller's // BlockFrequencyInfo is available. - BlockFrequencyInfo *CallerBFI = GetBFI ? &(GetBFI(*Caller)) : nullptr; + BlockFrequencyInfo *CallerBFI = GetBFI ? &((*GetBFI)(*Caller)) : nullptr; auto HotCallSiteThreshold = getHotCallSiteThreshold(Call, CallerBFI); if (!Caller->hasOptSize() && HotCallSiteThreshold) { LLVM_DEBUG(dbgs() << "Hot callsite.\n"); @@ -1767,7 +1765,7 @@ bool CallAnalyzer::visitSwitchInst(SwitchInst &SI) { // does not (yet) fire. unsigned JumpTableSize = 0; - BlockFrequencyInfo *BFI = GetBFI ? &(GetBFI(F)) : nullptr; + BlockFrequencyInfo *BFI = GetBFI ? &((*GetBFI)(F)) : nullptr; unsigned NumCaseCluster = TTI.getEstimatedNumberOfCaseClusters(SI, JumpTableSize, PSI, BFI); @@ -2221,18 +2219,18 @@ int llvm::getCallsiteCost(CallBase &Call, const DataLayout &DL) { InlineCost llvm::getInlineCost( CallBase &Call, const InlineParams &Params, TargetTransformInfo &CalleeTTI, - function_ref<AssumptionCache &(Function &)> GetAssumptionCache, + std::function<AssumptionCache &(Function &)> &GetAssumptionCache, + Optional<function_ref<BlockFrequencyInfo &(Function &)>> GetBFI, function_ref<const TargetLibraryInfo &(Function &)> GetTLI, - function_ref<BlockFrequencyInfo &(Function &)> GetBFI, ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) { return getInlineCost(Call, Call.getCalledFunction(), Params, CalleeTTI, - GetAssumptionCache, GetTLI, GetBFI, PSI, ORE); + GetAssumptionCache, GetBFI, GetTLI, PSI, ORE); } Optional<int> llvm::getInliningCostEstimate( CallBase &Call, TargetTransformInfo &CalleeTTI, - function_ref<AssumptionCache &(Function &)> GetAssumptionCache, - function_ref<BlockFrequencyInfo &(Function &)> GetBFI, + std::function<AssumptionCache &(Function &)> &GetAssumptionCache, + Optional<function_ref<BlockFrequencyInfo &(Function &)>> GetBFI, ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) { const InlineParams Params = {/* DefaultThreshold*/ 0, /*HintThreshold*/ {}, @@ -2244,8 +2242,8 @@ Optional<int> llvm::getInliningCostEstimate( /*ColdCallSiteThreshold*/ {}, /* ComputeFullInlineCost*/ true}; - InlineCostCallAnalyzer CA(*Call.getCalledFunction(), Call, Params, CalleeTTI, - GetAssumptionCache, GetBFI, PSI, ORE, true, + InlineCostCallAnalyzer CA(CalleeTTI, GetAssumptionCache, GetBFI, PSI, ORE, + *Call.getCalledFunction(), Call, Params, true, /*IgnoreThreshold*/ true); auto R = CA.analyze(); if (!R.isSuccess()) @@ -2317,9 +2315,9 @@ Optional<InlineResult> llvm::getAttributeBasedInliningDecision( InlineCost llvm::getInlineCost( CallBase &Call, Function *Callee, const InlineParams &Params, TargetTransformInfo &CalleeTTI, - function_ref<AssumptionCache &(Function &)> GetAssumptionCache, + std::function<AssumptionCache &(Function &)> &GetAssumptionCache, + Optional<function_ref<BlockFrequencyInfo &(Function &)>> GetBFI, function_ref<const TargetLibraryInfo &(Function &)> GetTLI, - function_ref<BlockFrequencyInfo &(Function &)> GetBFI, ProfileSummaryInfo *PSI, OptimizationRemarkEmitter *ORE) { auto UserDecision = @@ -2335,8 +2333,8 @@ InlineCost llvm::getInlineCost( << "... (caller:" << Call.getCaller()->getName() << ")\n"); - InlineCostCallAnalyzer CA(*Callee, Call, Params, CalleeTTI, - GetAssumptionCache, GetBFI, PSI, ORE); + InlineCostCallAnalyzer CA(CalleeTTI, GetAssumptionCache, GetBFI, PSI, ORE, + *Callee, Call, Params); InlineResult ShouldInline = CA.analyze(); LLVM_DEBUG(CA.dump()); |