LLVM 22.0.0git
PGOInstrumentation.h
Go to the documentation of this file.
1//===- Transforms/Instrumentation/PGOInstrumentation.h ----------*- 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/// \file
10/// This file provides the interface for IR based instrumentation passes (
11/// (profile-gen, and profile-use).
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_PGOINSTRUMENTATION_H
16#define LLVM_TRANSFORMS_INSTRUMENTATION_PGOINSTRUMENTATION_H
17
18#include "llvm/ADT/ArrayRef.h"
20#include "llvm/IR/PassManager.h"
24#include <cstdint>
25#include <string>
26
27namespace llvm {
28
30
31class Function;
32class Instruction;
33class Module;
34
35/// The instrumentation (profile-instr-gen) pass for IR based PGO.
36// We use this pass to create COMDAT profile variables for context
37// sensitive PGO (CSPGO). The reason to have a pass for this is CSPGO
38// can be run after LTO/ThinLTO linking. Lld linker needs to see
39// all the COMDAT variables before linking. So we have this pass
40// always run before linking for CSPGO.
42 : public PassInfoMixin<PGOInstrumentationGenCreateVar> {
43public:
44 PGOInstrumentationGenCreateVar(std::string CSInstrName = "",
45 bool Sampling = false)
46 : CSInstrName(CSInstrName), ProfileSampling(Sampling) {}
48
49private:
50 std::string CSInstrName;
51 bool ProfileSampling;
52};
53
55/// The instrumentation (profile-instr-gen) pass for IR based PGO.
56class PGOInstrumentationGen : public PassInfoMixin<PGOInstrumentationGen> {
57public:
59 PGOInstrumentationType InstrumentationType = PGOInstrumentationType ::FDO)
60 : InstrumentationType(InstrumentationType) {}
62
63private:
64 // If this is a context sensitive instrumentation.
65 const PGOInstrumentationType InstrumentationType;
66};
67
68/// The profile annotation (profile-instr-use) pass for IR based PGO.
69class PGOInstrumentationUse : public PassInfoMixin<PGOInstrumentationUse> {
70public:
72 PGOInstrumentationUse(std::string Filename = "",
73 std::string RemappingFilename = "", bool IsCS = false,
75
77
78private:
79 std::string ProfileFileName;
80 std::string ProfileRemappingFileName;
81 // If this is a context sensitive instrumentation.
82 bool IsCS;
84};
85
86/// The indirect function call promotion pass.
87class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion> {
88public:
89 PGOIndirectCallPromotion(bool IsInLTO = false, bool SamplePGO = false)
90 : InLTO(IsInLTO), SamplePGO(SamplePGO) {}
91
93
94private:
95 bool InLTO;
96 bool SamplePGO;
97};
98
99/// The profile size based optimization pass for memory intrinsics.
100class PGOMemOPSizeOpt : public PassInfoMixin<PGOMemOPSizeOpt> {
101public:
102 PGOMemOPSizeOpt() = default;
103
105};
106
108 uint64_t MaxCount);
109
111 uint64_t Count);
112
113} // end namespace llvm
114
115#endif // LLVM_TRANSFORMS_INSTRUMENTATION_PGOINSTRUMENTATION_H
#define LLVM_ABI
Definition: Compiler.h:213
This header defines various interfaces for pass management in LLVM.
This file defines the RefCountedBase, ThreadSafeRefCountedBase, and IntrusiveRefCntPtr classes.
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
ModuleAnalysisManager MAM
Defines the virtual file system interface vfs::FileSystem.
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
A smart pointer to a reference-counted object that inherits from RefCountedBase or ThreadSafeRefCount...
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
The indirect function call promotion pass.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PGOIndirectCallPromotion(bool IsInLTO=false, bool SamplePGO=false)
The instrumentation (profile-instr-gen) pass for IR based PGO.
PGOInstrumentationGenCreateVar(std::string CSInstrName="", bool Sampling=false)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
The instrumentation (profile-instr-gen) pass for IR based PGO.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PGOInstrumentationGen(PGOInstrumentationType InstrumentationType=PGOInstrumentationType ::FDO)
The profile annotation (profile-instr-use) pass for IR based PGO.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
The profile size based optimization pass for memory intrinsics.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &MAM)
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:112
template class LLVM_TEMPLATE_ABI opt< bool >
Definition: CommandLine.cpp:79
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
LLVM_ABI void setIrrLoopHeaderMetadata(Module *M, Instruction *TI, uint64_t Count)
LLVM_ABI void setProfMetadata(Instruction *TI, ArrayRef< uint64_t > EdgeCounts, uint64_t MaxCount)
LLVM_ABI cl::opt< bool > DebugInfoCorrelate
PGOInstrumentationType
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:70