28#define DEBUG_TYPE "cfguard-longjmp"
31 "Number of Control Flow Guard longjmp targets");
46 return "Control Flow Guard longjmp targets";
54char CFGuardLongjmp::ID = 0;
57 "Insert symbols at valid longjmp targets for /guard:cf",
false,
79 if (!
MI.isCall() ||
MI.getNumOperands() < 1)
87 auto *
F = dyn_cast<Function>(MO.getGlobal());
93 if (
F->hasFnAttribute(Attribute::ReturnsTwice)) {
101 if (SetjmpCalls.
empty())
104 unsigned SetjmpNum = 0;
112 MCSymbol *SjSymbol = MF.getContext().getOrCreateSymbol(SymbolName);
114 Setjmp->setPostInstrSymbol(MF, SjSymbol);
115 MF.addLongjmpTarget(SjSymbol);
116 CFGuardLongjmpTargets++;
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
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.
bool callsFunctionThatReturnsTwice() const
callsFunctionThatReturnsTwice - Return true if the function has a call to setjmp or other function th...
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
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...
Function & getFunction()
Return the LLVM function that this machine code represents.
MachineModuleInfo & getMMI() const
Representation of each machine instruction.
const Module * getModule() const
MachineOperand class - Representation of each machine instruction operand.
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
A raw_ostream that writes to an SmallVector or SmallString.
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
void initializeCFGuardLongjmpPass(PassRegistry &)
FunctionPass * createCFGuardLongjmpPass()
Creates CFGuard longjmp target identification pass.