]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Transforms/Instrumentation/PGOInstrumentation.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Transforms / Instrumentation / PGOInstrumentation.h
1 //===- Transforms/Instrumentation/PGOInstrumentation.h ----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
11 /// This file provides the interface for IR based instrumentation passes (
12 /// (profile-gen, and profile-use).
13 //
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_TRANSFORMS_PGOINSTRUMENTATION_H
17 #define LLVM_TRANSFORMS_PGOINSTRUMENTATION_H
18
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/IR/PassManager.h"
21 #include <cstdint>
22 #include <string>
23
24 namespace llvm {
25
26 class Function;
27 class Instruction;
28 class Module;
29
30 /// The instrumentation (profile-instr-gen) pass for IR based PGO.
31 class PGOInstrumentationGen : public PassInfoMixin<PGOInstrumentationGen> {
32 public:
33   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
34 };
35
36 /// The profile annotation (profile-instr-use) pass for IR based PGO.
37 class PGOInstrumentationUse : public PassInfoMixin<PGOInstrumentationUse> {
38 public:
39   PGOInstrumentationUse(std::string Filename = "",
40                         std::string RemappingFilename = "");
41
42   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
43
44 private:
45   std::string ProfileFileName;
46   std::string ProfileRemappingFileName;
47 };
48
49 /// The indirect function call promotion pass.
50 class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion> {
51 public:
52   PGOIndirectCallPromotion(bool IsInLTO = false, bool SamplePGO = false)
53       : InLTO(IsInLTO), SamplePGO(SamplePGO) {}
54
55   PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
56
57 private:
58   bool InLTO;
59   bool SamplePGO;
60 };
61
62 /// The profile size based optimization pass for memory intrinsics.
63 class PGOMemOPSizeOpt : public PassInfoMixin<PGOMemOPSizeOpt> {
64 public:
65   PGOMemOPSizeOpt() = default;
66
67   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
68 };
69
70 void setProfMetadata(Module *M, Instruction *TI, ArrayRef<uint64_t> EdgeCounts,
71                      uint64_t MaxCount);
72
73 void setIrrLoopHeaderMetadata(Module *M, Instruction *TI, uint64_t Count);
74
75 } // end namespace llvm
76
77 #endif // LLVM_TRANSFORMS_PGOINSTRUMENTATION_H