File indexing completed on 2026-05-10 08:44:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_PGOINSTRUMENTATION_H
0016 #define LLVM_TRANSFORMS_INSTRUMENTATION_PGOINSTRUMENTATION_H
0017
0018 #include "llvm/ADT/ArrayRef.h"
0019 #include "llvm/ADT/IntrusiveRefCntPtr.h"
0020 #include "llvm/IR/PassManager.h"
0021 #include "llvm/Support/CommandLine.h"
0022 #include <cstdint>
0023 #include <string>
0024
0025 namespace llvm {
0026
0027 extern cl::opt<bool> DebugInfoCorrelate;
0028
0029 class Function;
0030 class Instruction;
0031 class Module;
0032
0033 namespace vfs {
0034 class FileSystem;
0035 }
0036
0037
0038
0039
0040
0041
0042
0043 class PGOInstrumentationGenCreateVar
0044 : public PassInfoMixin<PGOInstrumentationGenCreateVar> {
0045 public:
0046 PGOInstrumentationGenCreateVar(std::string CSInstrName = "",
0047 bool Sampling = false)
0048 : CSInstrName(CSInstrName), ProfileSampling(Sampling) {}
0049 PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
0050
0051 private:
0052 std::string CSInstrName;
0053 bool ProfileSampling;
0054 };
0055
0056 enum class PGOInstrumentationType { Invalid = 0, FDO, CSFDO, CTXPROF };
0057
0058 class PGOInstrumentationGen : public PassInfoMixin<PGOInstrumentationGen> {
0059 public:
0060 PGOInstrumentationGen(
0061 PGOInstrumentationType InstrumentationType = PGOInstrumentationType ::FDO)
0062 : InstrumentationType(InstrumentationType) {}
0063 PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
0064
0065 private:
0066
0067 const PGOInstrumentationType InstrumentationType;
0068 };
0069
0070
0071 class PGOInstrumentationUse : public PassInfoMixin<PGOInstrumentationUse> {
0072 public:
0073 PGOInstrumentationUse(std::string Filename = "",
0074 std::string RemappingFilename = "", bool IsCS = false,
0075 IntrusiveRefCntPtr<vfs::FileSystem> FS = nullptr);
0076
0077 PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
0078
0079 private:
0080 std::string ProfileFileName;
0081 std::string ProfileRemappingFileName;
0082
0083 bool IsCS;
0084 IntrusiveRefCntPtr<vfs::FileSystem> FS;
0085 };
0086
0087
0088 class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion> {
0089 public:
0090 PGOIndirectCallPromotion(bool IsInLTO = false, bool SamplePGO = false)
0091 : InLTO(IsInLTO), SamplePGO(SamplePGO) {}
0092
0093 PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);
0094
0095 private:
0096 bool InLTO;
0097 bool SamplePGO;
0098 };
0099
0100
0101 class PGOMemOPSizeOpt : public PassInfoMixin<PGOMemOPSizeOpt> {
0102 public:
0103 PGOMemOPSizeOpt() = default;
0104
0105 PreservedAnalyses run(Function &F, FunctionAnalysisManager &MAM);
0106 };
0107
0108 void setProfMetadata(Module *M, Instruction *TI, ArrayRef<uint64_t> EdgeCounts,
0109 uint64_t MaxCount);
0110
0111 void setIrrLoopHeaderMetadata(Module *M, Instruction *TI, uint64_t Count);
0112
0113 }
0114
0115 #endif