34#define DEBUG_TYPE "cfguard-longjmp"
37 "Number of Control Flow Guard longjmp targets");
49 StringRef getPassName()
const override {
50 return "Control Flow Guard longjmp targets";
55 void getAnalysisUsage(AnalysisUsage &AU)
const override {
63char CFGuardLongjmpLegacy::ID = 0;
66 "Insert symbols at valid longjmp targets for /guard:cf",
false,
69 return new CFGuardLongjmpLegacy();
91 if (!
MI.isCall() ||
MI.getNumOperands() < 1)
105 if (
F->hasFnAttribute(Attribute::ReturnsTwice)) {
113 if (SetjmpCalls.
empty())
116 unsigned SetjmpNum = 0;
126 Setjmp->setPostInstrSymbol(MF, SjSymbol);
128 CFGuardLongjmpTargets++;
static bool runCFGuardLongjmpOnMachineFunction(MachineFunction &MF)
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)
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.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
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...
LLVM_ABI MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
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...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
void addLongjmpTarget(MCSymbol *Target)
Add the specified symbol to the list of valid longjmp targets for Windows Control Flow Guard.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
MCContext & getContext() const
Function & getFunction()
Return the LLVM function that this machine code represents.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
ControlFlowGuardMode getControlFlowGuardMode() const
Gets the Control Flow Guard mode.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
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.
A raw_ostream that writes to an SmallVector or SmallString.
Pass manager infrastructure for declaring and invalidating analyses.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI FunctionPass * createCFGuardLongjmpLegacyPass()
Creates CFGuard longjmp target identification pass.
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.