LLVM 20.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
21 enum class Format : int {
22 Line,
26 };
27
28 bool outputColumn() const {
31 }
32
33 bool outputDiscriminator() const {
36 }
37
39};
40
41/// Replay Inliner Setup
43 enum class Scope : int { Function, Module };
44 enum class Fallback : int { Original, AlwaysInline, NeverInline };
45
50};
51
52/// Get call site location as a string with the given format
54
55std::unique_ptr<InlineAdvisor>
57 LLVMContext &Context,
58 std::unique_ptr<InlineAdvisor> OriginalAdvisor,
59 const ReplayInlinerSettings &ReplaySettings,
60 bool EmitRemarks, InlineContext IC);
61
62/// Replay inline advisor that uses optimization remarks from inlining of
63/// previous build to guide current inlining. This is useful for inliner tuning.
65public:
67 LLVMContext &Context,
68 std::unique_ptr<InlineAdvisor> OriginalAdvisor,
69 const ReplayInlinerSettings &ReplaySettings,
70 bool EmitRemarks, InlineContext IC);
71 std::unique_ptr<InlineAdvice> getAdviceImpl(CallBase &CB) override;
72 bool areReplayRemarksLoaded() const { return HasReplayRemarks; }
73
74private:
75 bool hasInlineAdvice(Function &F) const {
76 return (ReplaySettings.ReplayScope ==
78 CallersToReplay.contains(F.getName());
79 }
80 std::unique_ptr<InlineAdvisor> OriginalAdvisor;
81 bool HasReplayRemarks = false;
82 const ReplayInlinerSettings ReplaySettings;
83 bool EmitRemarks = false;
84
85 StringMap<bool> InlineSitesFromRemarks;
86 StringSet<> CallersToReplay;
87};
88} // namespace llvm
89#endif // LLVM_ANALYSIS_REPLAYINLINEADVISOR_H
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
FunctionAnalysisManager FAM
StringSet - A set-like wrapper for the StringMap.
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1120
A debug info location.
Definition: DebugLoc.h:33
Interface for deciding whether to inline a call site or not.
const std::optional< InlineContext > IC
FunctionAnalysisManager & FAM
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Replay inline advisor that uses optimization remarks from inlining of previous build to guide current...
std::unique_ptr< InlineAdvice > getAdviceImpl(CallBase &CB) override
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
bool contains(StringRef key) const
Check if the set contains the given key.
Definition: StringSet.h:55
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::unique_ptr< InlineAdvisor > getReplayInlineAdvisor(Module &M, FunctionAnalysisManager &FAM, LLVMContext &Context, std::unique_ptr< InlineAdvisor > OriginalAdvisor, const ReplayInlinerSettings &ReplaySettings, bool EmitRemarks, InlineContext IC)
std::string formatCallSiteLocation(DebugLoc DLoc, const CallSiteFormat &Format)
Get call site location as a string with the given format.
bool outputDiscriminator() const
Provides context on when an inline advisor is constructed in the pipeline (e.g., link phase,...
Definition: InlineAdvisor.h:58