29#define DEBUG_TYPE "riscv-indirect-branch-tracking"
30#define PASS_NAME "RISC-V Indirect Branch Tracking"
55char RISCVIndirectBranchTrackingLegacy::ID = 0;
58 return new RISCVIndirectBranchTrackingLegacy();
79 if (std::optional<uint32_t> Label = Subtarget.getCLOpts().landing_pad_label) {
91 if (
F.hasFnAttribute(
"interrupt"))
94 if (
F.hasAddressTaken() || !
F.hasLocalLinkage()) {
103 if (
MBB.hasAddressTaken()) {
105 if (
MBB.getAlignment() < LpadAlign)
106 MBB.setAlignment(LpadAlign);
114bool RISCVIndirectBranchTrackingLegacy::runOnMachineFunction(
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool runIndirectBranchTracking(MachineFunction &MF)
static void emitLpad(MachineBasicBlock &MBB, const RISCVInstrInfo *TII, uint32_t Label, MachineBasicBlock::iterator I=MachineBasicBlock::iterator{})
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
Represent the analysis usage information of a pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
FunctionPass class - This class is used to implement most global optimizations.
MachineInstrBundleIterator< MachineInstr > iterator
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void setAlignment(Align A)
setAlignment - Set the alignment of the function.
Align getAlignment() const
getAlignment - Return the alignment of the function.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const MachineBasicBlock & front() const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private RISCV-...
bool hasCFProtectionBranch() const
Represent a constant reference to a string, i.e.
Pass manager infrastructure for declaring and invalidating analyses.
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.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
FunctionPass * createRISCVIndirectBranchTrackingLegacyPass()
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.