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 41 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); 42 43 private: 44 std::string ProfileFileName; 45 }; 46 47 /// The indirect function call promotion pass. 48 class PGOIndirectCallPromotion : public PassInfoMixin<PGOIndirectCallPromotion> { 49 public: 50 PGOIndirectCallPromotion(bool IsInLTO = false, bool SamplePGO = false) InLTO(IsInLTO)51 : InLTO(IsInLTO), SamplePGO(SamplePGO) {} 52 53 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); 54 55 private: 56 bool InLTO; 57 bool SamplePGO; 58 }; 59 60 /// The profile size based optimization pass for memory intrinsics. 61 class PGOMemOPSizeOpt : public PassInfoMixin<PGOMemOPSizeOpt> { 62 public: 63 PGOMemOPSizeOpt() = default; 64 65 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); 66 }; 67 68 void setProfMetadata(Module *M, Instruction *TI, ArrayRef<uint64_t> EdgeCounts, 69 uint64_t MaxCount); 70 71 void setIrrLoopHeaderMetadata(Module *M, Instruction *TI, uint64_t Count); 72 73 } // end namespace llvm 74 75 #endif // LLVM_TRANSFORMS_PGOINSTRUMENTATION_H 76