LLVM 23.0.0git
ReplayInlineAdvisor.h
Go to the documentation of this file.
1//===- ReplayInlineAdvisor.h - Replay Inline Advisor interface -*- C++ --*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9#ifndef LLVM_ANALYSIS_REPLAYINLINEADVISOR_H
10#define LLVM_ANALYSIS_REPLAYINLINEADVISOR_H
11
12#include "llvm/ADT/StringSet.h"
14
15namespace llvm {
16class CallBase;
17class LLVMContext;
18class Module;
19
40
41/// Replay Inliner Setup
51
52/// Get call site location as a string with the given format
54 const CallSiteFormat &Format);
55
56LLVM_ABI std::unique_ptr<InlineAdvisor>
58 LLVMContext &Context,
59 std::unique_ptr<InlineAdvisor> OriginalAdvisor,
60 const ReplayInlinerSettings &ReplaySettings,
61 bool EmitRemarks, InlineContext IC);
62
63/// Replay inline advisor that uses optimization remarks from inlining of
64/// previous build to guide current inlining. This is useful for inliner tuning.
66public:
68 LLVMContext &Context,
69 std::unique_ptr<InlineAdvisor> OriginalAdvisor,
70 const ReplayInlinerSettings &ReplaySettings,
71 bool EmitRemarks, InlineContext IC);
72 std::unique_ptr<InlineAdvice> getAdviceImpl(CallBase &CB) override;
73 bool areReplayRemarksLoaded() const { return HasReplayRemarks; }
74
75private:
76 bool hasInlineAdvice(Function &F) const {
77 return (ReplaySettings.ReplayScope ==
79 CallersToReplay.contains(F.getName());
80 }
81 std::unique_ptr<InlineAdvisor> OriginalAdvisor;
82 bool HasReplayRemarks = false;
83 const ReplayInlinerSettings ReplaySettings;
84 bool EmitRemarks = false;
85
86 StringMap<bool> InlineSitesFromRemarks;
87 StringSet<> CallersToReplay;
88};
89} // namespace llvm
90#endif // LLVM_ANALYSIS_REPLAYINLINEADVISOR_H
#define LLVM_ABI
Definition Compiler.h:213
#define F(x, y, z)
Definition MD5.cpp:54
FunctionAnalysisManager FAM
StringSet - A set-like wrapper for the StringMap.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A debug info location.
Definition DebugLoc.h:124
const std::optional< InlineContext > IC
FunctionAnalysisManager & FAM
InlineAdvisor(InlineAdvisor &&)=delete
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
ReplayInlineAdvisor(Module &M, FunctionAnalysisManager &FAM, LLVMContext &Context, std::unique_ptr< InlineAdvisor > OriginalAdvisor, const ReplayInlinerSettings &ReplaySettings, bool EmitRemarks, InlineContext IC)
std::unique_ptr< InlineAdvice > getAdviceImpl(CallBase &CB) override
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::unique_ptr< InlineAdvisor > getReplayInlineAdvisor(Module &M, FunctionAnalysisManager &FAM, LLVMContext &Context, std::unique_ptr< InlineAdvisor > OriginalAdvisor, const ReplayInlinerSettings &ReplaySettings, bool EmitRemarks, InlineContext IC)
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI std::string formatCallSiteLocation(DebugLoc DLoc, const CallSiteFormat &Format)
Get call site location as a string with the given format.
Provides context on when an inline advisor is constructed in the pipeline (e.g., link phase,...