MIRSampleProfile.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===----- MIRSampleProfile.h: SampleFDO Support in MIR ---*- c++ -*-------===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file contains the supoorting functions for machine level Sample FDO
  15. // loader. This is used in Flow Sensitive SampelFDO.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_MIRSAMPLEPROFILE_H
  19. #define LLVM_CODEGEN_MIRSAMPLEPROFILE_H
  20. #include "llvm/ADT/StringRef.h"
  21. #include "llvm/CodeGen/MachineFunctionPass.h"
  22. #include "llvm/Support/Discriminator.h"
  23. #include <memory>
  24. #include <string>
  25. namespace llvm {
  26. class AnalysisUsage;
  27. class MachineBlockFrequencyInfo;
  28. class MachineFunction;
  29. class Module;
  30. using namespace sampleprof;
  31. class MIRProfileLoader;
  32. class MIRProfileLoaderPass : public MachineFunctionPass {
  33. MachineFunction *MF;
  34. std::string ProfileFileName;
  35. FSDiscriminatorPass P;
  36. unsigned LowBit;
  37. unsigned HighBit;
  38. public:
  39. static char ID;
  40. /// FS bits will only use the '1' bits in the Mask.
  41. MIRProfileLoaderPass(std::string FileName = "",
  42. std::string RemappingFileName = "",
  43. FSDiscriminatorPass P = FSDiscriminatorPass::Pass1);
  44. /// getMachineFunction - Return the last machine function computed.
  45. const MachineFunction *getMachineFunction() const { return MF; }
  46. StringRef getPassName() const override { return "SampleFDO loader in MIR"; }
  47. private:
  48. void init(MachineFunction &MF);
  49. bool runOnMachineFunction(MachineFunction &) override;
  50. bool doInitialization(Module &M) override;
  51. void getAnalysisUsage(AnalysisUsage &AU) const override;
  52. std::unique_ptr<MIRProfileLoader> MIRSampleLoader;
  53. /// Hold the information of the basic block frequency.
  54. MachineBlockFrequencyInfo *MBFI;
  55. };
  56. } // namespace llvm
  57. #endif // LLVM_CODEGEN_MIRSAMPLEPROFILE_H
  58. #ifdef __GNUC__
  59. #pragma GCC diagnostic pop
  60. #endif