File indexing completed on 2026-05-10 08:43:32
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_CODEGEN_MIRSAMPLEPROFILE_H
0015 #define LLVM_CODEGEN_MIRSAMPLEPROFILE_H
0016
0017 #include "llvm/ADT/IntrusiveRefCntPtr.h"
0018 #include "llvm/ADT/StringRef.h"
0019 #include "llvm/CodeGen/MachineFunctionPass.h"
0020 #include "llvm/Support/Discriminator.h"
0021 #include <memory>
0022 #include <string>
0023
0024 namespace llvm {
0025 class AnalysisUsage;
0026 class MachineBlockFrequencyInfo;
0027 class MachineFunction;
0028 class Module;
0029
0030 namespace vfs {
0031 class FileSystem;
0032 }
0033
0034 using namespace sampleprof;
0035
0036 class MIRProfileLoader;
0037 class MIRProfileLoaderPass : public MachineFunctionPass {
0038 MachineFunction *MF;
0039 std::string ProfileFileName;
0040 FSDiscriminatorPass P;
0041 unsigned LowBit;
0042 unsigned HighBit;
0043
0044 public:
0045 static char ID;
0046
0047 MIRProfileLoaderPass(std::string FileName = "",
0048 std::string RemappingFileName = "",
0049 FSDiscriminatorPass P = FSDiscriminatorPass::Pass1,
0050 IntrusiveRefCntPtr<vfs::FileSystem> FS = nullptr);
0051
0052
0053 const MachineFunction *getMachineFunction() const { return MF; }
0054
0055 StringRef getPassName() const override { return "SampleFDO loader in MIR"; }
0056
0057 private:
0058 void init(MachineFunction &MF);
0059 bool runOnMachineFunction(MachineFunction &) override;
0060 bool doInitialization(Module &M) override;
0061 void getAnalysisUsage(AnalysisUsage &AU) const override;
0062
0063 std::unique_ptr<MIRProfileLoader> MIRSampleLoader;
0064
0065 MachineBlockFrequencyInfo *MBFI;
0066 };
0067
0068 }
0069
0070 #endif