23#define DEBUG_TYPE "riscv-indrect-branch-tracking"
24#define PASS_NAME "RISC-V Indirect Branch Tracking"
30 cl::desc(
"Use preferred fixed label for all labels"));
38 StringRef getPassName()
const override {
return PASS_NAME; }
40 bool runOnMachineFunction(MachineFunction &MF)
override;
51char RISCVIndirectBranchTracking::
ID = 0;
54 return new RISCVIndirectBranchTracking();
64bool RISCVIndirectBranchTracking::runOnMachineFunction(
MachineFunction &MF) {
65 const auto &Subtarget = MF.
getSubtarget<RISCVSubtarget>();
66 const RISCVInstrInfo *
TII = Subtarget.getInstrInfo();
67 if (!Subtarget.hasStdExtZicfilp())
70 uint32_t FixedLabel = 0;
79 for (MachineBasicBlock &
MBB : MF) {
83 if (
F.hasFnAttribute(
"interrupt"))
86 if (
F.hasAddressTaken() || !
F.hasLocalLinkage()) {
88 if (MF.getAlignment() < LpadAlign)
89 MF.setAlignment(LpadAlign);
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static void emitLpad(MachineBasicBlock &MBB, const RISCVInstrInfo *TII, uint32_t Label)
cl::opt< uint32_t > PreferredLandingPadLabel("riscv-landing-pad-label", cl::ReallyHidden, cl::desc("Use preferred fixed label for all labels"))
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
FunctionPass class - This class is used to implement most global optimizations.
bool hasAddressTaken() const
Test whether this block is used as something other than the target of a terminator,...
void setAlignment(Align A)
Set alignment of the basic block.
Align getAlignment() const
Return alignment of the basic block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr bool isUInt(uint64_t x)
Checks if an unsigned integer fits into the given bit width.
FunctionPass * createRISCVIndirectBranchTrackingPass()