| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
#ifndef LLVM_CODEGEN_MIRSAMPLEPROFILE_H |
| 15 |
#define LLVM_CODEGEN_MIRSAMPLEPROFILE_H |
| 16 |
|
| 17 |
#include "llvm/Analysis/ProfileSummaryInfo.h" |
| 18 |
#include "llvm/CodeGen/MachineBasicBlock.h" |
| 19 |
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h" |
| 20 |
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h" |
| 21 |
#include "llvm/CodeGen/MachineDominators.h" |
| 22 |
#include "llvm/CodeGen/MachineFunction.h" |
| 23 |
#include "llvm/CodeGen/MachineFunctionPass.h" |
| 24 |
#include "llvm/CodeGen/MachineInstr.h" |
| 25 |
#include "llvm/CodeGen/MachineLoopInfo.h" |
| 26 |
#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" |
| 27 |
#include "llvm/CodeGen/MachinePostDominators.h" |
| 28 |
#include "llvm/CodeGen/Passes.h" |
| 29 |
#include "llvm/IR/DebugInfoMetadata.h" |
| 30 |
#include "llvm/IR/Function.h" |
| 31 |
#include "llvm/IR/Module.h" |
| 32 |
#include "llvm/InitializePasses.h" |
| 33 |
#include "llvm/ProfileData/InstrProf.h" |
| 34 |
#include "llvm/ProfileData/SampleProf.h" |
| 35 |
#include "llvm/ProfileData/SampleProfReader.h" |
| 36 |
|
| 37 |
#include <cassert> |
| 38 |
|
| 39 |
namespace llvm { |
| 40 |
|
| 41 |
using namespace sampleprof; |
| 42 |
|
| 43 |
class MIRProfileLoader; |
| 44 |
class MIRProfileLoaderPass : public MachineFunctionPass { |
| 45 |
MachineFunction *MF; |
| 46 |
std::string ProfileFileName; |
| 47 |
FSDiscriminatorPass P; |
| 48 |
unsigned LowBit; |
| 49 |
unsigned HighBit; |
| 50 |
|
| 51 |
public: |
| 52 |
static char ID; |
| 53 |
|
| 54 |
MIRProfileLoaderPass(std::string FileName = "", |
| 55 |
std::string RemappingFileName = "", |
| 56 |
FSDiscriminatorPass P = FSDiscriminatorPass::Pass1); |
| 57 |
|
| 58 |
|
| 59 |
const MachineFunction *getMachineFunction() const { return MF; } |
| 60 |
|
| 61 |
StringRef getPassName() const override { return "SampleFDO loader in MIR"; } |
| 62 |
|
| 63 |
private: |
| 64 |
void init(MachineFunction &MF); |
| 65 |
bool runOnMachineFunction(MachineFunction &) override; |
| 66 |
bool doInitialization(Module &M) override; |
| 67 |
void getAnalysisUsage(AnalysisUsage &AU) const override; |
| 68 |
|
| 69 |
std::unique_ptr<MIRProfileLoader> MIRSampleLoader; |
| 70 |
|
| 71 |
MachineBlockFrequencyInfo *MBFI; |
| 72 |
}; |
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
#endif |