LLVM  14.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 #include "llvm/IR/LLVMContext.h"
15 
16 namespace llvm {
17 class BasicBlock;
18 class CallBase;
19 class Function;
20 class Module;
21 class OptimizationRemarkEmitter;
22 
24  enum class Format : int {
25  Line,
26  LineColumn,
29  };
30 
31  bool outputColumn() const {
32  return OutputFormat == Format::LineColumn ||
34  }
35 
36  bool outputDiscriminator() const {
39  }
40 
42 };
43 
44 /// Replay Inliner Setup
46  enum class Scope : int { Function, Module };
48 
53 };
54 
55 /// Get call site location as a string with the given format
56 std::string formatCallSiteLocation(DebugLoc DLoc, const CallSiteFormat &Format);
57 
58 std::unique_ptr<InlineAdvisor> getReplayInlineAdvisor(
60  std::unique_ptr<InlineAdvisor> OriginalAdvisor,
61  const ReplayInlinerSettings &ReplaySettings, bool EmitRemarks);
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.
66 public:
69  std::unique_ptr<InlineAdvisor> OriginalAdvisor,
70  const ReplayInlinerSettings &ReplaySettings,
71  bool EmitRemarks);
72  std::unique_ptr<InlineAdvice> getAdviceImpl(CallBase &CB) override;
73  bool areReplayRemarksLoaded() const { return HasReplayRemarks; }
74 
75 private:
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
llvm::ReplayInlineAdvisor::ReplayInlineAdvisor
ReplayInlineAdvisor(Module &M, FunctionAnalysisManager &FAM, LLVMContext &Context, std::unique_ptr< InlineAdvisor > OriginalAdvisor, const ReplayInlinerSettings &ReplaySettings, bool EmitRemarks)
Definition: ReplayInlineAdvisor.cpp:26
llvm::ReplayInlinerSettings::Scope
Scope
Definition: ReplayInlineAdvisor.h:46
llvm::getReplayInlineAdvisor
std::unique_ptr< InlineAdvisor > getReplayInlineAdvisor(Module &M, FunctionAnalysisManager &FAM, LLVMContext &Context, std::unique_ptr< InlineAdvisor > OriginalAdvisor, const ReplayInlinerSettings &ReplaySettings, bool EmitRemarks)
Definition: ReplayInlineAdvisor.cpp:79
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::ReplayInlinerSettings::ReplayFormat
CallSiteFormat ReplayFormat
Definition: ReplayInlineAdvisor.h:52
llvm::InlineAdvisor::M
Module & M
Definition: InlineAdvisor.h:177
llvm::Function
Definition: Function.h:62
FAM
FunctionAnalysisManager FAM
Definition: PassBuilderBindings.cpp:59
llvm::CallSiteFormat::OutputFormat
Format OutputFormat
Definition: ReplayInlineAdvisor.h:41
llvm::CallSiteFormat::Format::LineDiscriminator
@ LineDiscriminator
llvm::ReplayInlinerSettings::Fallback::Original
@ Original
F
#define F(x, y, z)
Definition: MD5.cpp:56
Context
ManagedStatic< detail::RecordContext > Context
Definition: Record.cpp:96
llvm::CallSiteFormat::outputColumn
bool outputColumn() const
Definition: ReplayInlineAdvisor.h:31
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
llvm::StringSet::contains
bool contains(StringRef key) const
Check if the set contains the given key.
Definition: StringSet.h:50
InlineAdvisor.h
llvm::CallSiteFormat::Format::LineColumnDiscriminator
@ LineColumnDiscriminator
llvm::ReplayInlinerSettings::Fallback::NeverInline
@ NeverInline
llvm::CallSiteFormat::Format::LineColumn
@ LineColumn
llvm::formatCallSiteLocation
std::string formatCallSiteLocation(DebugLoc DLoc, const CallSiteFormat &Format)
Get call site location as a string with the given format.
Definition: InlineAdvisor.cpp:422
llvm::ReplayInlinerSettings::ReplayFile
StringRef ReplayFile
Definition: ReplayInlineAdvisor.h:49
llvm::ReplayInlineAdvisor::areReplayRemarksLoaded
bool areReplayRemarksLoaded() const
Definition: ReplayInlineAdvisor.h:73
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::ReplayInlinerSettings::ReplayScope
Scope ReplayScope
Definition: ReplayInlineAdvisor.h:50
llvm::ReplayInlinerSettings::Scope::Module
@ Module
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::CallSiteFormat::Format::Line
@ Line
llvm::ReplayInlinerSettings::ReplayFallback
Fallback ReplayFallback
Definition: ReplayInlineAdvisor.h:51
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::CallSiteFormat
Definition: ReplayInlineAdvisor.h:23
llvm::InlineAdvisor
Interface for deciding whether to inline a call site or not.
Definition: InlineAdvisor.h:137
llvm::ReplayInlineAdvisor
Replay inline advisor that uses optimization remarks from inlining of previous build to guide current...
Definition: ReplayInlineAdvisor.h:65
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
StringSet.h
llvm::InlineAdvisor::FAM
FunctionAnalysisManager & FAM
Definition: InlineAdvisor.h:178
llvm::ReplayInlinerSettings::Scope::Function
@ Function
llvm::ReplayInlineAdvisor::getAdviceImpl
std::unique_ptr< InlineAdvice > getAdviceImpl(CallBase &CB) override
Definition: ReplayInlineAdvisor.cpp:90
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1176
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::ReplayInlinerSettings::Fallback
Fallback
Definition: ReplayInlineAdvisor.h:47
LLVMContext.h
llvm::DebugLoc
A debug info location.
Definition: DebugLoc.h:33
llvm::CallSiteFormat::Format
Format
Definition: ReplayInlineAdvisor.h:24
llvm::ReplayInlinerSettings::Fallback::AlwaysInline
@ AlwaysInline
llvm::CallSiteFormat::outputDiscriminator
bool outputDiscriminator() const
Definition: ReplayInlineAdvisor.h:36
llvm::ReplayInlinerSettings
Replay Inliner Setup.
Definition: ReplayInlineAdvisor.h:45
llvm::codeview::PublicSymFlags::Function
@ Function