From 00d982699bcc36408042cd749e34fb09a7c8f93f Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 18 Sep 2022 14:09:21 -0700 Subject: [PATCH] [ModuleInliner] Move getInlineCostWrapper to an anonymous namespace (NFC) This patch moves getInlineCostWrapper to an anonymous namespace. While I am at it, I'm moving the function closer to the beginning of the file so that I can use it elsewhere in the file without a forward declaration. --- llvm/lib/Analysis/InlineOrder.cpp | 58 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/llvm/lib/Analysis/InlineOrder.cpp b/llvm/lib/Analysis/InlineOrder.cpp index c42c959..89df24e 100644 --- a/llvm/lib/Analysis/InlineOrder.cpp +++ b/llvm/lib/Analysis/InlineOrder.cpp @@ -34,6 +34,35 @@ static cl::opt UseInlinePriority( namespace { +llvm::InlineCost getInlineCostWrapper(CallBase &CB, + FunctionAnalysisManager &FAM, + const InlineParams &Params) { + Function &Caller = *CB.getCaller(); + ProfileSummaryInfo *PSI = + FAM.getResult(Caller) + .getCachedResult( + *CB.getParent()->getParent()->getParent()); + + auto &ORE = FAM.getResult(Caller); + auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & { + return FAM.getResult(F); + }; + auto GetBFI = [&](Function &F) -> BlockFrequencyInfo & { + return FAM.getResult(F); + }; + auto GetTLI = [&](Function &F) -> const TargetLibraryInfo & { + return FAM.getResult(F); + }; + + Function &Callee = *CB.getCalledFunction(); + auto &CalleeTTI = FAM.getResult(Callee); + bool RemarksEnabled = + Callee.getContext().getDiagHandlerPtr()->isMissedOptRemarkEnabled( + DEBUG_TYPE); + return getInlineCost(CB, Params, CalleeTTI, GetAssumptionCache, GetTLI, + GetBFI, PSI, RemarksEnabled ? &ORE : nullptr); +} + class InlinePriority { public: virtual ~InlinePriority() = default; @@ -186,35 +215,6 @@ private: } // namespace -static llvm::InlineCost getInlineCostWrapper(CallBase &CB, - FunctionAnalysisManager &FAM, - const InlineParams &Params) { - Function &Caller = *CB.getCaller(); - ProfileSummaryInfo *PSI = - FAM.getResult(Caller) - .getCachedResult( - *CB.getParent()->getParent()->getParent()); - - auto &ORE = FAM.getResult(Caller); - auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & { - return FAM.getResult(F); - }; - auto GetBFI = [&](Function &F) -> BlockFrequencyInfo & { - return FAM.getResult(F); - }; - auto GetTLI = [&](Function &F) -> const TargetLibraryInfo & { - return FAM.getResult(F); - }; - - Function &Callee = *CB.getCalledFunction(); - auto &CalleeTTI = FAM.getResult(Callee); - bool RemarksEnabled = - Callee.getContext().getDiagHandlerPtr()->isMissedOptRemarkEnabled( - DEBUG_TYPE); - return getInlineCost(CB, Params, CalleeTTI, GetAssumptionCache, GetTLI, - GetBFI, PSI, RemarksEnabled ? &ORE : nullptr); -} - std::unique_ptr>> llvm::getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params) { switch (UseInlinePriority) { -- 2.7.4