| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef LLVM_CODEGEN_MIRFSDISCRIMINATOR_H |
| 18 |
#define LLVM_CODEGEN_MIRFSDISCRIMINATOR_H |
| 19 |
|
| 20 |
#include "llvm/Analysis/ProfileSummaryInfo.h" |
| 21 |
#include "llvm/CodeGen/MachineBasicBlock.h" |
| 22 |
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h" |
| 23 |
#include "llvm/CodeGen/MachineBranchProbabilityInfo.h" |
| 24 |
#include "llvm/CodeGen/MachineDominators.h" |
| 25 |
#include "llvm/CodeGen/MachineFunction.h" |
| 26 |
#include "llvm/CodeGen/MachineFunctionPass.h" |
| 27 |
#include "llvm/CodeGen/MachineInstr.h" |
| 28 |
#include "llvm/CodeGen/MachineLoopInfo.h" |
| 29 |
#include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h" |
| 30 |
#include "llvm/CodeGen/MachinePostDominators.h" |
| 31 |
#include "llvm/CodeGen/Passes.h" |
| 32 |
#include "llvm/IR/DebugInfoMetadata.h" |
| 33 |
#include "llvm/IR/Function.h" |
| 34 |
#include "llvm/IR/Module.h" |
| 35 |
#include "llvm/InitializePasses.h" |
| 36 |
#include "llvm/ProfileData/InstrProf.h" |
| 37 |
#include "llvm/ProfileData/SampleProf.h" |
| 38 |
#include "llvm/ProfileData/SampleProfReader.h" |
| 39 |
|
| 40 |
#include <cassert> |
| 41 |
|
| 42 |
namespace llvm { |
| 43 |
|
| 44 |
using namespace sampleprof; |
| 45 |
class MIRAddFSDiscriminators : public MachineFunctionPass { |
| 46 |
MachineFunction *MF; |
| 47 |
unsigned LowBit; |
| 48 |
unsigned HighBit; |
| 49 |
|
| 50 |
public: |
| 51 |
static char ID; |
| 52 |
|
| 53 |
MIRAddFSDiscriminators(FSDiscriminatorPass P = FSDiscriminatorPass::Pass1) |
| 54 |
: MachineFunctionPass(ID) { |
| 55 |
LowBit = getFSPassBitBegin(P); |
| 56 |
HighBit = getFSPassBitEnd(P); |
| 57 |
assert(LowBit < HighBit && "HighBit needs to be greater than Lowbit"); |
| 58 |
} |
| 59 |
|
| 60 |
StringRef getPassName() const override { |
| 61 |
return "Add FS discriminators in MIR"; |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
unsigned getNumFSBBs(); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
uint64_t getNumFSSamples(); |
| 70 |
|
| 71 |
|
| 72 |
const MachineFunction *getMachineFunction() const { return MF; } |
| 73 |
|
| 74 |
private: |
| 75 |
bool runOnMachineFunction(MachineFunction &) override; |
| 76 |
}; |
| 77 |
|
| 78 |
} |
| 79 |
|
| 80 |
#endif |