25#define DEBUG_TYPE "aarch64-kcfi"
26#define AARCH64_KCFI_PASS_NAME "Insert KCFI indirect call checks"
28STATISTIC(NumKCFIChecksAdded,
"Number of indirect call checks added");
50char AArch64KCFI::ID = 0;
59 assert(
TII &&
"Target instruction info was not initialized");
63 if (
MBBI->isBundled() && !std::prev(
MBBI)->isBundle())
66 switch (
MBBI->getOpcode()) {
68 case AArch64::BLRNoIP:
69 case AArch64::TCRETURNri:
70 case AArch64::TCRETURNriBTI:
77 assert(
Target.isReg() &&
"Invalid target operand for an indirect call");
78 Target.setIsRenamable(
false);
89 if (!
MBBI->isBundled())
98 if (!
M->getModuleFlag(
"kcfi"))
102 TII = SubTarget.getInstrInfo();
104 bool Changed =
false;
109 if (MII->isCall() && MII->getCFIType())
110 Changed |= emitCheck(
MBB, MII);
#define AARCH64_KCFI_PASS_NAME
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
FunctionPass class - This class is used to implement most global optimizations.
instr_iterator instr_begin()
instr_iterator instr_end()
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineModuleInfo & getMMI() const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
Representation of each machine instruction.
const Module * getModule() const
MachineOperand class - Representation of each machine instruction operand.
A Module instance is used to store all the information related to an LLVM module.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
Iterator for intrusive lists based on ilist_node.
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
void finalizeBundle(MachineBasicBlock &MBB, MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
finalizeBundle - Finalize a machine instruction bundle which includes a sequence of instructions star...
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
FunctionPass * createAArch64KCFIPass()