LLVM 20.0.0git
MIRFSDiscriminator.h
Go to the documentation of this file.
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/ADT/StringRef.h"
24
25#include <cassert>
26#include <cstdint>
27
28namespace llvm {
29class MachineFunction;
30
31using namespace sampleprof;
33 MachineFunction *MF = nullptr;
35 unsigned LowBit;
36 unsigned HighBit;
37
38public:
39 static char ID;
40 /// PassNum is the sequence number this pass is called, start from 1.
41 MIRAddFSDiscriminators(FSDiscriminatorPass P = FSDiscriminatorPass::Pass1)
43 LowBit = getFSPassBitBegin(P);
44 HighBit = getFSPassBitEnd(P);
45 assert(LowBit < HighBit && "HighBit needs to be greater than Lowbit");
46 }
47
48 StringRef getPassName() const override {
49 return "Add FS discriminators in MIR";
50 }
51
52 /// getNumFSBBs() - Return the number of machine BBs that have FS samples.
53 unsigned getNumFSBBs();
54
55 /// getNumFSSamples() - Return the number of samples that have flow sensitive
56 /// values.
58
59 /// getMachineFunction - Return the current machine function.
60 const MachineFunction *getMachineFunction() const { return MF; }
61
62private:
63 bool runOnMachineFunction(MachineFunction &) override;
64};
65
66} // namespace llvm
67
68#endif // LLVM_CODEGEN_MIRFSDISCRIMINATOR_H
#define P(N)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getNumFSBBs()
getNumFSBBs() - Return the number of machine BBs that have FS samples.
const MachineFunction * getMachineFunction() const
getMachineFunction - Return the current machine function.
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
uint64_t getNumFSSamples()
getNumFSSamples() - Return the number of samples that have flow sensitive values.
MIRAddFSDiscriminators(FSDiscriminatorPass P=FSDiscriminatorPass::Pass1)
PassNum is the sequence number this pass is called, start from 1.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
static unsigned getFSPassBitBegin(sampleprof::FSDiscriminatorPass P)
Definition: Discriminator.h:94
static unsigned getFSPassBitEnd(sampleprof::FSDiscriminatorPass P)
Definition: Discriminator.h:87