Debian Codegraph @

suite/synctools/tablegen/include/llvm/CodeGen/MIRFSDiscriminator.h

raw symbols SCIP
1 //===----- MIRFSDiscriminator.h: MIR FS Discriminator Support --0-- c++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the supporting functions for adding Machine level IR
10 // Flow Sensitive discriminators to the instruction debug information. With
11 // this, a cloned machine instruction in a different MachineBasicBlock will
12 // have its own discriminator value. This is done in a MIRAddFSDiscriminators
13 // pass.
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 /// PassNum is the sequence number this pass is called, start from 1.
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 /// getNumFSBBs() - Return the number of machine BBs that have FS samples.
65 unsigned getNumFSBBs();
66
67 /// getNumFSSamples() - Return the number of samples that have flow sensitive
68 /// values.
69 uint64_t getNumFSSamples();
70
71 /// getMachineFunction - Return the current machine function.
72 const MachineFunction *getMachineFunction() const { return MF; }
73
74 private:
75 bool runOnMachineFunction(MachineFunction &) override;
76 };
77
78 } // namespace llvm
79
80 #endif // LLVM_CODEGEN_MIRFSDISCRIMINATOR_H