LLVM: lib/CodeGen/StackProtector.cpp File Reference (original) (raw)

Go to the source code of this file.

Classes
struct PhiInfo
Maximum remaining allocation size observed for a phi node, and how often the allocation size has already been decreased. More...
Macros
#define DEBUG_TYPE "stack-protector"
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 TargetLowering &TLI)
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, PhiMap &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"

PhiMap

ContainsProtectableArray()

CreateFailBB()

CreatePrologue()

findStackProtectorIntrinsic()

getStackGuard()

HasAddressTaken()

Check whether a stack allocation has its address taken.

Definition at line 266 of file StackProtector.cpp.

References llvm::cast(), DL, GEP, llvm::TypeSize::getFixed(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue(), llvm::MemoryLocation::getOrNone(), HasAddressTaken(), I, llvm::details::FixedOrScalableQuantity< TypeSize, uint64_t >::isKnownGE(), llvm::details::FixedOrScalableQuantity< TypeSize, uint64_t >::isKnownGT(), PhiInfo::MaxNumDecreased, llvm::Offset, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::try_emplace(), 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.

Definition at line 569 of file StackProtector.cpp.

References assert(), B(), Call, llvm::cast(), llvm::MDBuilder::createBranchWeights(), CreateFailBB(), CreatePrologue(), DisableCheckNoReturn, llvm::dyn_cast(), llvm::dyn_cast_if_present(), llvm::TargetOptions::EnableFastISel, EnableSelectionDAGSP, F, findStackProtectorIntrinsic(), llvm::CallBase::getArgOperand(), llvm::BranchProbabilityInfo::getBranchProbStackProtector(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getPrevNode(), getStackGuard(), llvm::TargetMachine::getSubtargetImpl(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::isInTailCallPosition(), llvm::make_early_inc_range(), llvm::BasicBlock::moveAfter(), llvm::TargetMachine::Options, llvm::Value::setName(), llvm::SplitBlockAndInsertIfThen(), and llvm::TargetLoweringBase::useStackGuardXorFP().

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

false

protectors