77#define DEBUG_TYPE "safe-stack"
79STATISTIC(NumFunctions,
"Total number of functions");
80STATISTIC(NumUnsafeStackFunctions,
"Number of functions with unsafe stack");
82 "Number of functions that use setjmp or exceptions");
85STATISTIC(NumUnsafeStaticAllocas,
"Number of unsafe static allocas");
86STATISTIC(NumUnsafeDynamicAllocas,
"Number of unsafe dynamic allocas");
87STATISTIC(NumUnsafeByValArguments,
"Number of unsafe byval arguments");
88STATISTIC(NumUnsafeStackRestorePoints,
"Number of setjmps and landingpads");
97 cl::desc(
"enable safe stack coloring"),
118 Value *UnsafeStackPtr =
nullptr;
167 Value *StaticTop,
bool NeedDynamicTop);
172 void moveDynamicAllocasToUnsafeStack(
Function &
F,
Value *UnsafeStackPtr,
176 bool IsSafeStackAlloca(
const Value *AllocaPtr,
uint64_t AllocaSize);
183 bool ShouldInlinePointerAddress(
CallInst &CI);
184 void TryInlinePointerAddress();
189 :
F(
F), TL(TL),
DL(
DL), DTU(DTU), SE(SE),
190 StackPtrTy(
DL.getAllocaPtrType(
F.getContext())),
191 IntPtrTy(
DL.getIntPtrType(
F.getContext())),
199constexpr Align SafeStack::StackAlignment;
207 Size *=
C->getZExtValue();
212bool SafeStack::IsAccessSafe(
Value *Addr, uint64_t AccessSize,
213 const Value *AllocaPtr, uint64_t AllocaSize) {
214 const SCEV *AddrExpr = SE.
getSCEV(Addr);
216 if (!
Base ||
Base->getValue() != AllocaPtr) {
218 dbgs() <<
"[SafeStack] "
220 << *AllocaPtr <<
"\n"
221 <<
"SCEV " << *AddrExpr <<
" not directly based on alloca\n");
228 ConstantRange SizeRange =
230 ConstantRange AccessRange = AccessStartRange.
add(SizeRange);
231 ConstantRange AllocaRange =
233 bool Safe = AllocaRange.
contains(AccessRange);
236 dbgs() <<
"[SafeStack] "
238 << *AllocaPtr <<
"\n"
239 <<
" Access " << *Addr <<
"\n"
243 <<
" Range " << AccessRange <<
"\n"
244 <<
" AllocaRange " << AllocaRange <<
"\n"
245 <<
" " << (Safe ?
"safe" :
"unsafe") <<
"\n");
250bool SafeStack::IsMemIntrinsicSafe(
const MemIntrinsic *
MI,
const Use &U,
251 const Value *AllocaPtr,
252 uint64_t AllocaSize) {
254 if (MTI->getRawSource() != U && MTI->getRawDest() != U)
257 if (
MI->getRawDest() != U)
261 auto Len =
MI->getLengthInBytes();
263 if (!Len)
return false;
264 return IsAccessSafe(U,
Len->getZExtValue(), AllocaPtr, AllocaSize);
270bool SafeStack::IsSafeStackAlloca(
const Value *AllocaPtr, uint64_t AllocaSize) {
274 SmallPtrSet<const Value *, 16> Visited;
275 SmallVector<const Value *, 8> WorkList;
279 while (!WorkList.
empty()) {
281 for (
const Use &UI :
V->uses()) {
285 switch (
I->getOpcode()) {
286 case Instruction::Load:
287 if (!IsAccessSafe(UI,
DL.getTypeStoreSize(
I->getType()), AllocaPtr,
292 case Instruction::VAArg:
295 case Instruction::Store:
296 if (V ==
I->getOperand(0)) {
299 <<
"[SafeStack] Unsafe alloca: " << *AllocaPtr
300 <<
"\n store of address: " << *
I <<
"\n");
304 if (!IsAccessSafe(UI,
DL.getTypeStoreSize(
I->getOperand(0)->getType()),
305 AllocaPtr, AllocaSize))
309 case Instruction::Ret:
313 case Instruction::Call:
314 case Instruction::Invoke: {
317 if (
I->isLifetimeStartOrEnd())
321 if (!IsMemIntrinsicSafe(
MI, UI, AllocaPtr, AllocaSize)) {
323 <<
"[SafeStack] Unsafe alloca: " << *AllocaPtr
324 <<
"\n unsafe memintrinsic: " << *
I <<
"\n");
338 for (
const auto *
A =
B;
A !=
E; ++
A)
343 <<
"\n unsafe call: " << *
I <<
"\n");
364 if (!StackGuardVar) {
369 return IRB.
CreateLoad(StackPtrTy, StackGuardVar,
"StackGuard");
372void SafeStack::findInsts(Function &
F,
373 SmallVectorImpl<AllocaInst *> &StaticAllocas,
374 SmallVectorImpl<AllocaInst *> &DynamicAllocas,
375 SmallVectorImpl<Argument *> &ByValArguments,
376 SmallVectorImpl<Instruction *> &Returns,
377 SmallVectorImpl<Instruction *> &StackRestorePoints) {
382 uint64_t
Size = getStaticAllocaAllocationSize(AI);
383 if (IsSafeStackAlloca(AI,
Size))
387 ++NumUnsafeStaticAllocas;
390 ++NumUnsafeDynamicAllocas;
394 if (CallInst *CI =
I.getParent()->getTerminatingMustTailCall())
400 if (CI->getCalledFunction() && CI->canReturnTwice())
406 if (
II->getIntrinsicID() == Intrinsic::gcroot)
408 "gcroot intrinsic not compatible with safestack attribute");
411 for (Argument &Arg :
F.args()) {
412 if (!Arg.hasByValAttr())
414 uint64_t
Size =
DL.getTypeStoreSize(Arg.getParamByValType());
415 if (IsSafeStackAlloca(&Arg,
Size))
418 ++NumUnsafeByValArguments;
424SafeStack::createStackRestorePoints(
IRBuilder<> &IRB, Function &
F,
426 Value *StaticTop,
bool NeedDynamicTop) {
427 assert(StaticTop &&
"The stack top isn't set.");
429 if (StackRestorePoints.
empty())
438 AllocaInst *DynamicTop =
nullptr;
439 if (NeedDynamicTop) {
443 "unsafe_stack_dynamic_ptr");
448 for (Instruction *
I : StackRestorePoints) {
449 ++NumUnsafeStackRestorePoints;
453 DynamicTop ? IRB.
CreateLoad(StackPtrTy, DynamicTop) : StaticTop;
460void SafeStack::checkStackGuard(
IRBuilder<> &IRB, Function &
F, Instruction &RI,
461 AllocaInst *StackGuardSlot,
Value *StackGuard) {
467 MDNode *Weights = MDBuilder(
F.getContext())
468 .createBranchWeights(SuccessProb.getNumerator(),
469 FailureProb.getNumerator());
474 const char *StackChkFailName =
476 if (!StackChkFailName) {
477 F.getContext().emitError(
478 "no libcall available for stackprotector check fail");
482 FunctionCallee StackChkFail =
483 F.getParent()->getOrInsertFunction(StackChkFailName, IRB.
getVoidTy());
484 IRBFail.CreateCall(StackChkFail, {});
490Value *SafeStack::moveStaticAllocasToUnsafeStack(
493 AllocaInst *StackGuardSlot) {
494 if (StaticAllocas.
empty() && ByValArguments.
empty())
497 DIBuilder DIB(*
F.getParent());
499 StackLifetime SSC(
F, StaticAllocas, StackLifetime::LivenessType::May);
500 static const StackLifetime::LiveRange NoColoringRange(1,
true);
504 for (
const auto *
I : SSC.getMarkers()) {
506 const_cast<IntrinsicInst *
>(
I)->eraseFromParent();
508 if (
Op &&
Op->use_empty())
509 Op->eraseFromParent();
513 StackLayout SSL(StackAlignment);
514 if (StackGuardSlot) {
517 SSL.addObject(StackGuardSlot, getStaticAllocaAllocationSize(StackGuardSlot),
518 Align, SSC.getFullLiveRange());
521 for (Argument *Arg : ByValArguments) {
522 Type *Ty = Arg->getParamByValType();
523 uint64_t
Size =
DL.getTypeStoreSize(Ty);
529 if (
auto A = Arg->getParamAlign())
530 Align = std::max(Align, *
A);
531 SSL.addObject(Arg,
Size, Align, SSC.getFullLiveRange());
534 for (AllocaInst *AI : StaticAllocas) {
536 uint64_t
Size = getStaticAllocaAllocationSize(AI);
543 SSL.addObject(AI,
Size, Align,
544 ClColoring ? SSC.getLiveRange(AI) : NoColoringRange);
548 Align FrameAlignment = SSL.getFrameAlignment();
552 if (FrameAlignment > StackAlignment) {
558 ConstantInt::get(IntPtrTy, ~(FrameAlignment.
value() - 1))),
564 if (StackGuardSlot) {
565 unsigned Offset = SSL.getObjectOffset(StackGuardSlot);
576 for (Argument *Arg : ByValArguments) {
577 unsigned Offset = SSL.getObjectOffset(Arg);
578 MaybeAlign
Align(SSL.getObjectAlignment(Arg));
579 Type *Ty = Arg->getParamByValType();
581 uint64_t
Size =
DL.getTypeStoreSize(Ty);
588 Arg->getName() +
".unsafe-byval");
593 Arg->replaceAllUsesWith(NewArg);
599 for (AllocaInst *AI : StaticAllocas) {
601 unsigned Offset = SSL.getObjectOffset(AI);
608 std::string
Name = std::string(AI->
getName()) +
".unsafe";
615 if (
User->isLifetimeStartOrEnd()) {
616 User->eraseFromParent();
622 InsertBefore =
PHI->getIncomingBlock(U)->getTerminator();
628 IRBUser.CreatePtrAdd(BasePointer, ConstantInt::get(
Int32Ty, -
Offset));
630 IRBUser.CreateAddrSpaceCast(Off, AI->
getType(), Name);
635 PHI->setIncomingValueForBlock(
PHI->getIncomingBlock(U), Replacement);
646 unsigned FrameSize =
alignTo(SSL.getFrameSize(), StackAlignment);
648 MDBuilder MDB(
F.getContext());
650 Data.push_back(MDB.createString(
"unsafe-stack-size"));
651 Data.push_back(MDB.createConstant(ConstantInt::get(
Int32Ty, FrameSize)));
653 F.setMetadata(LLVMContext::MD_annotation, MD);
660 "unsafe_stack_static_top");
665void SafeStack::moveDynamicAllocasToUnsafeStack(
666 Function &
F,
Value *UnsafeStackPtr, AllocaInst *DynamicTop,
668 DIBuilder DIB(*
F.getParent());
670 for (AllocaInst *AI : DynamicAllocas) {
675 if (ArraySize->
getType() != IntPtrTy)
679 uint64_t TySize =
DL.getTypeAllocSize(Ty);
687 auto Align = std::max(std::max(
DL.getPrefTypeAlign(Ty), AI->
getAlign()),
692 ConstantInt::get(IntPtrTy, ~uint64_t(
Align.value() - 1))),
709 if (!DynamicAllocas.empty()) {
716 if (
II->getIntrinsicID() == Intrinsic::stacksave) {
720 II->replaceAllUsesWith(LI);
721 II->eraseFromParent();
722 }
else if (
II->getIntrinsicID() == Intrinsic::stackrestore) {
727 II->eraseFromParent();
733bool SafeStack::ShouldInlinePointerAddress(CallInst &CI) {
735 if (CI.
hasFnAttr(Attribute::AlwaysInline) &&
738 if (
Callee->isInterposable() ||
Callee->hasFnAttribute(Attribute::NoInline) ||
744void SafeStack::TryInlinePointerAddress() {
753 if (!Callee ||
Callee->isDeclaration())
756 if (!ShouldInlinePointerAddress(*CI))
759 InlineFunctionInfo IFI;
763bool SafeStack::run() {
764 assert(
F.hasFnAttribute(Attribute::SafeStack) &&
765 "Can't run SafeStack on a function without the attribute");
766 assert(!
F.isDeclaration() &&
"Can't run SafeStack on a function declaration");
773 SmallVector<Instruction *, 4> Returns;
780 SmallVector<Instruction *, 4> StackRestorePoints;
784 findInsts(
F, StaticAllocas, DynamicAllocas, ByValArguments, Returns,
787 if (StaticAllocas.
empty() && DynamicAllocas.
empty() &&
788 ByValArguments.
empty() && StackRestorePoints.
empty())
791 if (!StaticAllocas.
empty() || !DynamicAllocas.
empty() ||
792 !ByValArguments.
empty())
793 ++NumUnsafeStackFunctions;
795 if (!StackRestorePoints.
empty())
796 ++NumUnsafeStackRestorePointsFunctions;
798 IRBuilder<> IRB(&
F.front(),
F.begin()->getFirstInsertionPt());
801 if (DISubprogram *SP =
F.getSubprogram())
803 DILocation::get(
SP->getContext(),
SP->getScopeLine(), 0, SP));
805 const char *SafestackPointerAddressName =
807 if (!SafestackPointerAddressName) {
808 F.getContext().emitError(
809 "no libcall available for safestack pointer address");
813 FunctionCallee Fn =
F.getParent()->getOrInsertFunction(
814 SafestackPointerAddressName, IRB.
getPtrTy(0));
823 IRB.
CreateLoad(StackPtrTy, UnsafeStackPtr,
false,
"unsafe_stack_ptr");
826 AllocaInst *StackGuardSlot =
nullptr;
828 if (
F.hasFnAttribute(Attribute::StackProtect) ||
829 F.hasFnAttribute(Attribute::StackProtectStrong) ||
830 F.hasFnAttribute(Attribute::StackProtectReq)) {
835 for (Instruction *RI : Returns) {
837 checkStackGuard(IRBRet,
F, *RI, StackGuardSlot, StackGuard);
843 Value *StaticTop = moveStaticAllocasToUnsafeStack(
844 IRB,
F, StaticAllocas, ByValArguments, BasePointer, StackGuardSlot);
852 AllocaInst *DynamicTop = createStackRestorePoints(
853 IRB,
F, StackRestorePoints, StaticTop, !DynamicAllocas.
empty());
856 moveDynamicAllocasToUnsafeStack(
F, UnsafeStackPtr, DynamicTop,
860 for (Instruction *RI : Returns) {
865 TryInlinePointerAddress();
871class SafeStackLegacyPass :
public FunctionPass {
872 const TargetMachine *TM =
nullptr;
877 SafeStackLegacyPass() : FunctionPass(
ID) {
881 void getAnalysisUsage(AnalysisUsage &AU)
const override {
891 if (!
F.hasFnAttribute(Attribute::SafeStack)) {
893 " for this function\n");
897 if (
F.isDeclaration()) {
899 " is not available\n");
903 TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
904 auto *TL =
TM->getSubtargetImpl(
F)->getTargetLowering();
908 auto *
DL = &
F.getDataLayout();
909 auto &TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
910 auto &ACT = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
F);
917 bool ShouldPreserveDominatorTree;
918 std::optional<DominatorTree> LazilyComputedDomTree;
923 if (
auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>()) {
924 DT = &DTWP->getDomTree();
925 ShouldPreserveDominatorTree =
true;
928 LazilyComputedDomTree.emplace(
F);
929 DT = &*LazilyComputedDomTree;
930 ShouldPreserveDominatorTree =
false;
936 DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
938 ScalarEvolution SE(
F, TLI, ACT, *DT, LI);
940 return SafeStack(
F, *TL, *
DL, ShouldPreserveDominatorTree ? &DTU :
nullptr,
952 if (!
F.hasFnAttribute(Attribute::SafeStack)) {
954 " for this function\n");
958 if (
F.isDeclaration()) {
960 " is not available\n");
968 auto &
DL =
F.getDataLayout();
975 bool Changed = SafeStack(
F, *TL,
DL, &DTU, SE).run();
984char SafeStackLegacyPass::ID = 0;
987 "Safe Stack instrumentation pass",
false,
false)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
VarLocInsertPt getNextNode(const DbgRecord *DVR)
Expand Atomic instructions
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool runOnFunction(Function &F, bool PostInlining)
Module.h This file contains the declarations for the Module class.
This defines the Use class.
Machine Check Debug Module
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
static cl::opt< bool > SafeStackUsePointerAddress("safestack-use-pointer-address", cl::init(false), cl::Hidden)
Use __safestack_pointer_address even if the platform has a faster way of access safe stack pointer.
static cl::opt< bool > ClColoring("safe-stack-coloring", cl::desc("enable safe stack coloring"), cl::Hidden, cl::init(true))
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
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.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
This file describes how to lower LLVM code to machine code.
Target-Independent Code Generator Pass Configuration Options pass.
an instruction to allocate memory on the stack
LLVM_ABI bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
PointerType * getType() const
Overload to return most specific pointer type.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
LLVM_ABI bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
const Value * getArraySize() const
Get the number of elements allocated.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
static BranchProbability getBranchProbStackProtector(bool IsLikely)
bool doesNotCapture(unsigned OpNo) const
Determine whether this data operand is not captured.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
bool doesNotAccessMemory(unsigned OpNo) const
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
bool isNoInline() const
Return true if the call should not be inlined.
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
This class represents a function call, abstracting a target machine's calling convention.
LLVM_ABI ConstantRange add(const ConstantRange &Other) const
Return a new range representing the possible values resulting from an addition of a value in this ran...
LLVM_ABI bool contains(const APInt &Val) const
Return true if the specified value is in the set.
A parsed version of the target data layout string in and methods for querying it.
Analysis pass which computes a DominatorTree.
Legacy analysis pass which computes a DominatorTree.
FunctionPass class - This class is used to implement most global optimizations.
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
CallInst * CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src, MaybeAlign SrcAlign, uint64_t Size, bool isVolatile=false, const AAMDNodes &AAInfo=AAMDNodes())
Create and insert a memcpy between the specified pointers.
Value * CreatePointerCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Value * CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
void SetCurrentDebugLocation(DebugLoc L)
Set location information used by debugging information.
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
LLVM_ABI CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with Args, mangled using Types.
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Value * CreatePtrToInt(Value *V, Type *DestTy, const Twine &Name="")
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Type * getVoidTy()
Fetch the type representing void.
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
This is the common base class for memset/memcpy/memmove.
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserve()
Mark an analysis as preserved.
LLVM_ABI Type * getType() const
Return the LLVM type of this SCEV expression.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
Analysis pass that exposes the ScalarEvolution for a function.
The main scalar evolution driver.
LLVM_ABI const SCEV * removePointerBase(const SCEV *S)
Compute an expression equivalent to S - getPointerBase(S).
LLVM_ABI uint64_t getTypeSizeInBits(Type *Ty) const
Return the size in bits of the specified type, for which isSCEVable must return true.
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
ConstantRange getSignedRange(const SCEV *S)
Determine the signed range for a particular SCEV.
ConstantRange getUnsignedRange(const SCEV *S)
Determine the unsigned range for a particular SCEV.
LLVM_ABI const SCEV * getPointerBase(const SCEV *V)
Transitively follow the chain of pointer-type operands until reaching a SCEV that does not have a sin...
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
virtual Value * getSafeStackPointerLocation(IRBuilderBase &IRB) const
Returns the target-specific address of the unsafe stack pointer.
virtual Value * getIRStackGuard(IRBuilderBase &IRB) const
If the target has a standard location for the stack protector guard, returns the address of that loca...
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.
virtual void insertSSPDeclarations(Module &M) const
Inserts necessary declarations for SSP (stack protection) purpose.
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
Target-Independent Code Generator Pass Configuration Options.
virtual const TargetLowering * getTargetLowering() const
The instances of the Type class are immutable: once they are created, they are never changed.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
LLVM_ABI void takeName(Value *V)
Transfer the name from V to this value.
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
initializer< Ty > init(const Ty &Val)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
@ User
could "use" a pointer
NodeAddr< UseNode * > Use
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
LLVM_ABI InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This function inlines the called function into the basic block of the caller.
LLVM_ABI FunctionPass * createSafeStackPass()
This pass splits the stack into a safe stack and an unsafe stack to protect against stack-based overf...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
FunctionAddr VTableAddr uintptr_t uintptr_t Int32Ty
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
LLVM_ABI InlineResult isInlineViable(Function &Callee)
Check if it is mechanically possible to inline the function Callee, based on the contents of the func...
LLVM_ABI void initializeSafeStackLegacyPassPass(PassRegistry &)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
FunctionAddr VTableAddr uintptr_t uintptr_t Data
IRBuilder(LLVMContext &, FolderTy, InserterTy, MDNode *, ArrayRef< OperandBundleDef >) -> IRBuilder< FolderTy, InserterTy >
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
DWARFExpression::Operation Op
LLVM_ABI void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress, DIBuilder &Builder, int Offset=0)
Replaces multiple dbg.value records when the alloca it describes is replaced with a new value.
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI Instruction * SplitBlockAndInsertIfThen(Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI bool replaceDbgDeclare(Value *Address, Value *NewAddress, DIBuilder &Builder, uint8_t DIExprFlags, int Offset)
Replaces dbg.declare record when the address it describes is replaced with a new value.
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
static constexpr Align Constant()
Allow constructions of constexpr Align.