29#define DEBUG_TYPE "cfguard-longjmp"
32 "Number of Control Flow Guard longjmp targets");
47 return "Control Flow Guard longjmp targets";
55char CFGuardLongjmp::ID = 0;
58 "Insert symbols at valid longjmp targets for /guard:cf",
false,
80 if (!
MI.isCall() ||
MI.getNumOperands() < 1)
88 auto *
F = dyn_cast<Function>(MO.getGlobal());
94 if (
F->hasFnAttribute(Attribute::ReturnsTwice)) {
102 if (SetjmpCalls.
empty())
105 unsigned SetjmpNum = 0;
113 MCSymbol *SjSymbol = MF.getContext().getOrCreateSymbol(SymbolName);
115 Setjmp->setPostInstrSymbol(MF, SjSymbol);
116 MF.addLongjmpTarget(SjSymbol);
117 CFGuardLongjmpTargets++;
Module.h This file contains the declarations for the Module class.
#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...
Module * getParent()
Get the module that this global value is contained inside of...
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.
Representation of each machine instruction.
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.