LLVM: lib/CodeGen/StackProtector.cpp File Reference (original) (raw)
Go to the source code of this file.
Functions | |
---|---|
STATISTIC (NumFunProtected, "Number of functions protected") | |
STATISTIC (NumAddrTaken, "Number of local variables that have their address" " taken.") | |
static bool | InsertStackProtectors (const TargetMachine *TM, Function *F, DomTreeUpdater *DTU, bool &HasPrologue, bool &HasIRCheck) |
InsertStackProtectors - Insert code into the prologue and epilogue of the function. | |
static BasicBlock * | CreateFailBB (Function *F, const Triple &Trip) |
CreateFailBB - Create a basic block to jump to when the stack protector check fails. | |
INITIALIZE_PASS_BEGIN (StackProtector, DEBUG_TYPE, "Insert stack protectors", false, true) INITIALIZE_PASS_END(StackProtector | |
static bool | ContainsProtectableArray (Type *Ty, Module *M, unsigned SSPBufferSize, bool &IsLarge, bool Strong, bool InStruct) |
static bool | HasAddressTaken (const Instruction *AI, TypeSize AllocSize, Module *M, SmallPtrSet< const PHINode *, 16 > &VisitedPHIs) |
Check whether a stack allocation has its address taken. | |
static const CallInst * | findStackProtectorIntrinsic (Function &F) |
Search for the first call to the llvm.stackprotector intrinsic and return it if present. | |
static Value * | getStackGuard (const TargetLoweringBase *TLI, Module *M, IRBuilder<> &B, bool *SupportsSelectionDAGSP=nullptr) |
Create a stack guard loading and populate whether SelectionDAG SSP is supported. | |
static bool | CreatePrologue (Function *F, Module *M, Instruction *CheckLoc, const TargetLoweringBase *TLI, AllocaInst *&AI) |
Insert code into the entry block that stores the stack guard variable onto the stack: | |
Variables | |
---|---|
static cl::opt< bool > | EnableSelectionDAGSP ("enable-selectiondag-sp", cl::init(true), cl::Hidden) |
static cl::opt< bool > | DisableCheckNoReturn ("disable-check-noreturn-call", cl::init(false), cl::Hidden) |
DEBUG_TYPE | |
Insert stack | protectors |
Insert stack | false |
◆ DEBUG_TYPE
#define DEBUG_TYPE "stack-protector"
◆ ContainsProtectableArray()
◆ CreateFailBB()
◆ CreatePrologue()
◆ findStackProtectorIntrinsic()
◆ getStackGuard()
◆ HasAddressTaken()
Check whether a stack allocation has its address taken.
Definition at line 255 of file StackProtector.cpp.
References DL, GEP, llvm::TypeSize::getFixed(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::MemoryLocation::getOrNone(), HasAddressTaken(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::details::FixedOrScalableQuantity< TypeSize, uint64_t >::isKnownGE(), llvm::details::FixedOrScalableQuantity< TypeSize, uint64_t >::isKnownGT(), llvm::Offset, and llvm::Value::users().
Referenced by HasAddressTaken(), and llvm::SSPLayoutAnalysis::requiresStackProtector().
◆ INITIALIZE_PASS_BEGIN()
◆ InsertStackProtectors()
InsertStackProtectors - Insert code into the prologue and epilogue of the function.
- The prologue code loads and stores the stack guard onto the stack.
- The epilogue checks the value stored in the prologue against the original value. It calls __stack_chk_fail if they differ.
Definition at line 547 of file StackProtector.cpp.
References assert(), B, llvm::MDBuilder::createBranchWeights(), CreateFailBB(), CreatePrologue(), DisableCheckNoReturn, EnableSelectionDAGSP, F, findStackProtectorIntrinsic(), llvm::CallBase::getArgOperand(), llvm::BranchProbabilityInfo::getBranchProbStackProtector(), llvm::Instruction::getPrevNonDebugInstruction(), getStackGuard(), llvm::make_early_inc_range(), llvm::BasicBlock::moveAfter(), llvm::Value::setName(), and llvm::SplitBlockAndInsertIfThen().
Referenced by llvm::StackProtectorPass::run(), and llvm::StackProtector::runOnFunction().
◆ STATISTIC() [1/2]
STATISTIC | ( | NumAddrTaken | , |
---|---|---|---|
"Number of local variables that have their address" " taken." | |||
) |
◆ STATISTIC() [2/2]
STATISTIC | ( | NumFunProtected | , |
---|---|---|---|
"Number of functions protected" | |||
) |
◆ DEBUG_TYPE
◆ DisableCheckNoReturn
cl::opt< bool > DisableCheckNoReturn("disable-check-noreturn-call", cl::init(false), cl::Hidden) ( "disable-check-noreturn-call" , cl::init(false) , cl::Hidden ) | static |
---|
◆ EnableSelectionDAGSP
cl::opt< bool > EnableSelectionDAGSP("enable-selectiondag-sp", cl::init(true), cl::Hidden) ( "enable-selectiondag-sp" , cl::init(true) , cl::Hidden ) | static |
---|