[llvm] 00d9826 - [ModuleInliner] Move getInlineCostWrapper to an anonymous namespace (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 18 14:09:31 PDT 2022
Author: Kazu Hirata
Date: 2022-09-18T14:09:21-07:00
New Revision: 00d982699bcc36408042cd749e34fb09a7c8f93f
URL: https://github.com/llvm/llvm-project/commit/00d982699bcc36408042cd749e34fb09a7c8f93f
DIFF: https://github.com/llvm/llvm-project/commit/00d982699bcc36408042cd749e34fb09a7c8f93f.diff
LOG: [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.
Added:
Modified:
llvm/lib/Analysis/InlineOrder.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InlineOrder.cpp b/llvm/lib/Analysis/InlineOrder.cpp
index c42c9594e02b7..89df24ed34033 100644
--- a/llvm/lib/Analysis/InlineOrder.cpp
+++ b/llvm/lib/Analysis/InlineOrder.cpp
@@ -34,6 +34,35 @@ static cl::opt<InlinePriorityMode> UseInlinePriority(
namespace {
+llvm::InlineCost getInlineCostWrapper(CallBase &CB,
+ FunctionAnalysisManager &FAM,
+ const InlineParams &Params) {
+ Function &Caller = *CB.getCaller();
+ ProfileSummaryInfo *PSI =
+ FAM.getResult<ModuleAnalysisManagerFunctionProxy>(Caller)
+ .getCachedResult<ProfileSummaryAnalysis>(
+ *CB.getParent()->getParent()->getParent());
+
+ auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(Caller);
+ auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & {
+ return FAM.getResult<AssumptionAnalysis>(F);
+ };
+ auto GetBFI = [&](Function &F) -> BlockFrequencyInfo & {
+ return FAM.getResult<BlockFrequencyAnalysis>(F);
+ };
+ auto GetTLI = [&](Function &F) -> const TargetLibraryInfo & {
+ return FAM.getResult<TargetLibraryAnalysis>(F);
+ };
+
+ Function &Callee = *CB.getCalledFunction();
+ auto &CalleeTTI = FAM.getResult<TargetIRAnalysis>(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 @@ class PriorityInlineOrder : public InlineOrder<std::pair<CallBase *, int>> {
} // namespace
-static llvm::InlineCost getInlineCostWrapper(CallBase &CB,
- FunctionAnalysisManager &FAM,
- const InlineParams &Params) {
- Function &Caller = *CB.getCaller();
- ProfileSummaryInfo *PSI =
- FAM.getResult<ModuleAnalysisManagerFunctionProxy>(Caller)
- .getCachedResult<ProfileSummaryAnalysis>(
- *CB.getParent()->getParent()->getParent());
-
- auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(Caller);
- auto GetAssumptionCache = [&](Function &F) -> AssumptionCache & {
- return FAM.getResult<AssumptionAnalysis>(F);
- };
- auto GetBFI = [&](Function &F) -> BlockFrequencyInfo & {
- return FAM.getResult<BlockFrequencyAnalysis>(F);
- };
- auto GetTLI = [&](Function &F) -> const TargetLibraryInfo & {
- return FAM.getResult<TargetLibraryAnalysis>(F);
- };
-
- Function &Callee = *CB.getCalledFunction();
- auto &CalleeTTI = FAM.getResult<TargetIRAnalysis>(Callee);
- bool RemarksEnabled =
- Callee.getContext().getDiagHandlerPtr()->isMissedOptRemarkEnabled(
- DEBUG_TYPE);
- return getInlineCost(CB, Params, CalleeTTI, GetAssumptionCache, GetTLI,
- GetBFI, PSI, RemarksEnabled ? &ORE : nullptr);
-}
-
std::unique_ptr<InlineOrder<std::pair<CallBase *, int>>>
llvm::getInlineOrder(FunctionAnalysisManager &FAM, const InlineParams &Params) {
switch (UseInlinePriority) {
More information about the llvm-commits
mailing list