29#define DEBUG_TYPE "kcfi"
30#define KCFI_PASS_NAME "Insert KCFI indirect call checks"
32STATISTIC(NumKCFIChecksAdded,
"Number of indirect call checks added");
66 assert(
TII &&
"Target instruction info was not initialized");
67 assert(TLI &&
"Target lowering was not initialized");
71 if (
MBBI->isBundled() && !std::prev(
MBBI)->isBundle())
79 assert(
MBBI->isCall() &&
"Unexpected instruction type");
84 if (!
MBBI->isBundled())
93 if (!
M->getModuleFlag(
"kcfi"))
97 TII = SubTarget.getInstrInfo();
98 TLI = SubTarget.getTargetLowering();
100 bool Changed =
false;
106 if (MII->isCall() && MII->getCFIType())
107 Changed |= emitCheck(
MBB, MII);
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
Module.h This file contains the declarations for the Module class.
#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)
This file describes how to lower LLVM code to machine code.
FunctionPass class - This class is used to implement most global optimizations.
Module * getParent()
Get the module that this global value is contained inside of...
instr_iterator instr_begin()
Instructions::iterator instr_iterator
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.
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
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.
TargetInstrInfo - Interface to description of machine instruction set.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
self_iterator getIterator()
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...
FunctionPass * createKCFIPass()
Lowers KCFI operand bundles for indirect calls.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.