Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:32

0001 //===----- MIRSampleProfile.h: SampleFDO Support in MIR ---*- c++ -*-------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file contains the supoorting functions for machine level Sample FDO
0010 // loader. This is used in Flow Sensitive SampelFDO.
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 } // namespace vfs
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   /// FS bits will only use the '1' bits in the Mask.
0047   MIRProfileLoaderPass(std::string FileName = "",
0048                        std::string RemappingFileName = "",
0049                        FSDiscriminatorPass P = FSDiscriminatorPass::Pass1,
0050                        IntrusiveRefCntPtr<vfs::FileSystem> FS = nullptr);
0051 
0052   /// getMachineFunction - Return the last machine function computed.
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   /// Hold the information of the basic block frequency.
0065   MachineBlockFrequencyInfo *MBFI;
0066 };
0067 
0068 } // namespace llvm
0069 
0070 #endif // LLVM_CODEGEN_MIRSAMPLEPROFILE_H