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
29class Function;
30class Instruction;
31class Module;
32
33/// The instrumentation (profile-instr-gen) pass for IR based PGO.
34// We use this pass to create COMDAT profile variables for context
35// sensitive PGO (CSPGO). The reason to have a pass for this is CSPGO
36// can be run after LTO/ThinLTO linking. Lld linker needs to see
37// all the COMDAT variables before linking. So we have this pass
38// always run before linking for CSPGO.
40 : public PassInfoMixin<PGOInstrumentationGenCreateVar> {
41public:
42 PGOInstrumentationGenCreateVar(std::string CSInstrName = "",
43 bool Sampling = false)
44 : CSInstrName(CSInstrName), ProfileSampling(Sampling) {}
46
47private:
48 std::string CSInstrName;
49 bool ProfileSampling;
50};
51
53/// The instrumentation (profile-instr-gen) pass for IR based PGO.
54class PGOInstrumentationGen : public PassInfoMixin<PGOInstrumentationGen> {
55public:
57 PGOInstrumentationType InstrumentationType = PGOInstrumentationType ::FDO)
58 : InstrumentationType(InstrumentationType) {}
60
61private:
62 // If this is a context sensitive instrumentation.
63 const PGOInstrumentationType InstrumentationType;
64};
65
66/// The profile annotation (profile-instr-use) pass for IR based PGO.
67class PGOInstrumentationUse : public PassInfoMixin<PGOInstrumentationUse> {
68public:
70 PGOInstrumentationUse(std::string Filename = "",
71 std::string RemappingFilename = "", bool IsCS = false,
73
75
76private:
77 std::string ProfileFileName;
78 std::string ProfileRemappingFileName;
79 // If this is a context sensitive instrumentation.
80 bool IsCS;
82};
83
84/// The indirect function call promotion pass.
85class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion> {
86public:
87 PGOIndirectCallPromotion(bool IsInLTO = false, bool SamplePGO = false)
88 : InLTO(IsInLTO), SamplePGO(SamplePGO) {}
89
91
92private:
93 bool InLTO;
94 bool SamplePGO;
95};
96
97/// The profile size based optimization pass for memory intrinsics.
98class PGOMemOPSizeOpt : public PassInfoMixin<PGOMemOPSizeOpt> {
99public:
100 PGOMemOPSizeOpt() = default;
101
103};
104
106 uint64_t MaxCount);
107
110
111} // end namespace llvm
112
113#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
ModuleAnalysisManager MAM
Defines the virtual file system interface vfs::FileSystem.
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
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PGOIndirectCallPromotion(bool IsInLTO=false, bool SamplePGO=false)
PGOInstrumentationGenCreateVar(std::string CSInstrName="", bool Sampling=false)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
PGOInstrumentationGen(PGOInstrumentationType InstrumentationType=PGOInstrumentationType ::FDO)
LLVM_ABI PGOInstrumentationUse(std::string Filename="", std::string RemappingFilename="", bool IsCS=false, IntrusiveRefCntPtr< vfs::FileSystem > FS=nullptr)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
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
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void setIrrLoopHeaderMetadata(Module *M, Instruction *TI, uint64_t Count)
LLVM_ABI void setProfMetadata(Instruction *TI, ArrayRef< uint64_t > EdgeCounts, uint64_t MaxCount)
FunctionAddr VTableAddr Count
Definition InstrProf.h:139
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition PassManager.h:70