LLVM  14.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"
19 #include "llvm/IR/PassManager.h"
20 #include <cstdint>
21 #include <string>
22 
23 namespace llvm {
24 
25 class Function;
26 class Instruction;
27 class Module;
28 
29 /// The instrumentation (profile-instr-gen) pass for IR based PGO.
30 // We use this pass to create COMDAT profile variables for context
31 // sensitive PGO (CSPGO). The reason to have a pass for this is CSPGO
32 // can be run after LTO/ThinLTO linking. Lld linker needs to see
33 // all the COMDAT variables before linking. So we have this pass
34 // always run before linking for CSPGO.
36  : public PassInfoMixin<PGOInstrumentationGenCreateVar> {
37 public:
38  PGOInstrumentationGenCreateVar(std::string CSInstrName = "")
39  : CSInstrName(CSInstrName) {}
41 
42 private:
43  std::string CSInstrName;
44 };
45 
46 /// The instrumentation (profile-instr-gen) pass for IR based PGO.
47 class PGOInstrumentationGen : public PassInfoMixin<PGOInstrumentationGen> {
48 public:
49  PGOInstrumentationGen(bool IsCS = false) : IsCS(IsCS) {}
51 
52 private:
53  // If this is a context sensitive instrumentation.
54  bool IsCS;
55 };
56 
57 /// The profile annotation (profile-instr-use) pass for IR based PGO.
58 class PGOInstrumentationUse : public PassInfoMixin<PGOInstrumentationUse> {
59 public:
60  PGOInstrumentationUse(std::string Filename = "",
61  std::string RemappingFilename = "", bool IsCS = false);
62 
64 
65 private:
66  std::string ProfileFileName;
67  std::string ProfileRemappingFileName;
68  // If this is a context sensitive instrumentation.
69  bool IsCS;
70 };
71 
72 /// The indirect function call promotion pass.
73 class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion> {
74 public:
75  PGOIndirectCallPromotion(bool IsInLTO = false, bool SamplePGO = false)
76  : InLTO(IsInLTO), SamplePGO(SamplePGO) {}
77 
79 
80 private:
81  bool InLTO;
82  bool SamplePGO;
83 };
84 
85 /// The profile size based optimization pass for memory intrinsics.
86 class PGOMemOPSizeOpt : public PassInfoMixin<PGOMemOPSizeOpt> {
87 public:
88  PGOMemOPSizeOpt() = default;
89 
91 };
92 
93 void setProfMetadata(Module *M, Instruction *TI, ArrayRef<uint64_t> EdgeCounts,
94  uint64_t MaxCount);
95 
97 
98 } // end namespace llvm
99 
100 #endif // LLVM_TRANSFORMS_INSTRUMENTATION_PGOINSTRUMENTATION_H
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm::PGOInstrumentationUse::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: PGOInstrumentation.cpp:1987
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::Function
Definition: Function.h:61
llvm::PGOInstrumentationUse
The profile annotation (profile-instr-use) pass for IR based PGO.
Definition: PGOInstrumentation.h:58
llvm::PGOInstrumentationGenCreateVar::PGOInstrumentationGenCreateVar
PGOInstrumentationGenCreateVar(std::string CSInstrName="")
Definition: PGOInstrumentation.h:38
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::PGOIndirectCallPromotion::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: IndirectCallPromotion.cpp:440
llvm::PGOInstrumentationGen::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: PGOInstrumentation.cpp:1662
llvm::setIrrLoopHeaderMetadata
void setIrrLoopHeaderMetadata(Module *M, Instruction *TI, uint64_t Count)
Definition: PGOInstrumentation.cpp:2085
llvm::PGOMemOPSizeOpt::PGOMemOPSizeOpt
PGOMemOPSizeOpt()=default
llvm::PGOIndirectCallPromotion
The indirect function call promotion pass.
Definition: PGOInstrumentation.h:73
llvm::Instruction
Definition: Instruction.h:45
llvm::PGOMemOPSizeOpt
The profile size based optimization pass for memory intrinsics.
Definition: PGOInstrumentation.h:86
llvm::PGOInstrumentationGenCreateVar
The instrumentation (profile-instr-gen) pass for IR based PGO.
Definition: PGOInstrumentation.h:35
uint64_t
ArrayRef.h
llvm::PGOIndirectCallPromotion::PGOIndirectCallPromotion
PGOIndirectCallPromotion(bool IsInLTO=false, bool SamplePGO=false)
Definition: PGOInstrumentation.h:75
llvm::PGOInstrumentationGen::PGOInstrumentationGen
PGOInstrumentationGen(bool IsCS=false)
Definition: PGOInstrumentation.h:49
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::ArrayRef< uint64_t >
llvm::PGOInstrumentationUse::PGOInstrumentationUse
PGOInstrumentationUse(std::string Filename="", std::string RemappingFilename="", bool IsCS=false)
Definition: PGOInstrumentation.cpp:1976
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::PGOInstrumentationGenCreateVar::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition: PGOInstrumentation.cpp:1637
PassManager.h
llvm::PGOInstrumentationGen
The instrumentation (profile-instr-gen) pass for IR based PGO.
Definition: PGOInstrumentation.h:47
llvm::setProfMetadata
void setProfMetadata(Module *M, Instruction *TI, ArrayRef< uint64_t > EdgeCounts, uint64_t MaxCount)
Definition: PGOInstrumentation.cpp:2039
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::PGOMemOPSizeOpt::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition: PGOMemOPSizeOpt.cpp:534