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");
98 const CodeGenOptions &Opts;
110 Value *UnsafeStackPtr =
nullptr;
159 Value *StaticTop,
bool NeedDynamicTop);
164 void moveDynamicAllocasToUnsafeStack(
Function &
F,
Value *UnsafeStackPtr,
168 bool IsSafeStackAlloca(
const Value *AllocaPtr,
uint64_t AllocaSize);
177 bool ShouldInlinePointerAddress(
CallInst &CI);
178 void TryInlinePointerAddress();
185 DTU(DTU), SE(SE), StackPtrTy(
DL.getAllocaPtrType(
F.
getContext())),
186 AddrTy(
DL.getAddressType(StackPtrTy)),
197 return Size->getFixedValue();
201bool SafeStack::IsAccessSafe(
Value *Addr, TypeSize AccessSize,
208 return IsAccessSafe(Addr, AccessSize.
getFixedValue(), AllocaPtr, AllocaSize);
211bool SafeStack::IsAccessSafe(
Value *Addr,
uint64_t AccessSize,
213 const SCEV *AddrExpr = SE.
getSCEV(Addr);
215 if (!
Base ||
Base->getValue() != AllocaPtr) {
217 dbgs() <<
"[SafeStack] "
219 << *AllocaPtr <<
"\n"
220 <<
"SCEV " << *AddrExpr <<
" not directly based on alloca\n");
227 ConstantRange SizeRange =
229 ConstantRange AccessRange = AccessStartRange.
add(SizeRange);
230 ConstantRange AllocaRange =
235 dbgs() <<
"[SafeStack] "
237 << *AllocaPtr <<
"\n"
238 <<
" Access " << *Addr <<
"\n"
242 <<
" Range " << AccessRange <<
"\n"
243 <<
" AllocaRange " << AllocaRange <<
"\n"
244 <<
" " << (Safe ?
"safe" :
"unsafe") <<
"\n");
249bool SafeStack::IsMemIntrinsicSafe(
const MemIntrinsic *
MI,
const Use &U,
250 const Value *AllocaPtr,
253 if (MTI->getRawSource() != U && MTI->getRawDest() != U)
256 if (
MI->getRawDest() != U)
260 auto Len =
MI->getLengthInBytes();
262 if (!Len)
return false;
263 return IsAccessSafe(U,
Len->getZExtValue(), AllocaPtr, AllocaSize);
269bool SafeStack::IsSafeStackAlloca(
const Value *AllocaPtr,
uint64_t AllocaSize) {
273 SmallPtrSet<const Value *, 16> Visited;
274 SmallVector<const Value *, 8> WorkList;
278 while (!WorkList.
empty()) {
280 for (
const Use &UI :
V->uses()) {
284 switch (
I->getOpcode()) {
285 case Instruction::Load:
286 if (!IsAccessSafe(UI,
DL.getTypeStoreSize(
I->getType()), AllocaPtr,
291 case Instruction::VAArg:
294 case Instruction::Store:
295 if (
V ==
I->getOperand(0)) {
298 <<
"[SafeStack] Unsafe alloca: " << *AllocaPtr
299 <<
"\n store of address: " << *
I <<
"\n");
303 if (!IsAccessSafe(UI,
DL.getTypeStoreSize(
I->getOperand(0)->getType()),
304 AllocaPtr, AllocaSize))
308 case Instruction::Ret:
312 case Instruction::Call:
313 case Instruction::Invoke: {
316 if (
I->isLifetimeStartOrEnd())
320 if (!IsMemIntrinsicSafe(
MI, UI, AllocaPtr, AllocaSize)) {
322 <<
"[SafeStack] Unsafe alloca: " << *AllocaPtr
323 <<
"\n unsafe memintrinsic: " << *
I <<
"\n");
337 for (
const auto *
A =
B;
A !=
E; ++
A)
342 <<
"\n unsafe call: " << *
I <<
"\n");
363 if (!StackGuardVar) {
368 return IRB.
CreateLoad(StackPtrTy, StackGuardVar,
"StackGuard");
372 SmallVectorImpl<AllocaInst *> &StaticAllocas,
373 SmallVectorImpl<AllocaInst *> &DynamicAllocas,
374 SmallVectorImpl<Argument *> &ByValArguments,
375 SmallVectorImpl<Instruction *> &Returns,
376 SmallVectorImpl<Instruction *> &StackRestorePoints) {
382 if (IsSafeStackAlloca(AI,
Size))
386 ++NumUnsafeStaticAllocas;
389 ++NumUnsafeDynamicAllocas;
393 if (CallInst *CI =
I.getParent()->getTerminatingMustTailCall())
399 if (CI->getCalledFunction() && CI->canReturnTwice())
405 if (
II->getIntrinsicID() == Intrinsic::gcroot)
407 "gcroot intrinsic not compatible with safestack attribute");
410 for (Argument &Arg :
F.args()) {
411 if (!Arg.hasByValAttr())
414 if (IsSafeStackAlloca(&Arg,
Size))
417 ++NumUnsafeByValArguments;
424 ArrayRef<Instruction *> StackRestorePoints,
425 Value *StaticTop,
bool NeedDynamicTop) {
426 assert(StaticTop &&
"The stack top isn't set.");
428 if (StackRestorePoints.
empty())
437 AllocaInst *DynamicTop =
nullptr;
438 if (NeedDynamicTop) {
442 "unsafe_stack_dynamic_ptr");
447 for (Instruction *
I : StackRestorePoints) {
448 ++NumUnsafeStackRestorePoints;
452 DynamicTop ? IRB.
CreateLoad(StackPtrTy, DynamicTop) : StaticTop;
460 AllocaInst *StackGuardSlot,
Value *StackGuard) {
466 MDNode *Weights = MDBuilder(
F.getContext())
467 .createBranchWeights(SuccessProb.getNumerator(),
468 FailureProb.getNumerator());
473 RTLIB::LibcallImpl StackChkFailImpl =
475 if (StackChkFailImpl == RTLIB::Unsupported) {
476 F.getContext().emitError(
477 "no libcall available for stackprotector check fail");
481 FunctionCallee StackChkFail =
483 *
F.getParent(), StackChkFailImpl);
484 CallInst *
Call = IRBFail.CreateCall(StackChkFail, {});
491Value *SafeStack::moveStaticAllocasToUnsafeStack(
494 AllocaInst *StackGuardSlot) {
495 if (StaticAllocas.
empty() && ByValArguments.
empty())
498 DIBuilder DIB(*
F.getParent());
500 StackLifetime SSC(
F, StaticAllocas, StackLifetime::LivenessType::May);
501 static const StackLifetime::LiveRange NoColoringRange(1,
true);
502 if (Opts.safe_stack_coloring)
505 for (
const auto *
I : SSC.getMarkers()) {
507 const_cast<IntrinsicInst *
>(
I)->eraseFromParent();
509 if (
Op &&
Op->use_empty())
510 Op->eraseFromParent();
514 StackLayout SSL(Opts, StackAlignment);
515 if (StackGuardSlot) {
516 SSL.addObject(StackGuardSlot, getStaticAllocaAllocationSize(StackGuardSlot),
517 StackGuardSlot->
getAlign(), SSC.getFullLiveRange());
520 for (Argument *Arg : ByValArguments) {
521 Type *Ty = Arg->getParamByValType();
528 if (
auto A = Arg->getParamAlign())
529 Align = std::max(Align, *
A);
530 SSL.addObject(Arg,
Size, Align, SSC.getFullLiveRange());
533 for (AllocaInst *AI : StaticAllocas) {
539 Opts.safe_stack_coloring ? SSC.getLiveRange(AI)
544 Align FrameAlignment = SSL.getFrameAlignment();
548 if (FrameAlignment > StackAlignment) {
552 StackPtrTy, Intrinsic::ptrmask,
553 {BasePointer, ConstantInt::get(AddrTy, ~(FrameAlignment.
value() - 1))});
558 if (StackGuardSlot) {
559 unsigned Offset = SSL.getObjectOffset(StackGuardSlot);
570 for (Argument *Arg : ByValArguments) {
571 unsigned Offset = SSL.getObjectOffset(Arg);
572 MaybeAlign
Align(SSL.getObjectAlignment(Arg));
573 Type *Ty = Arg->getParamByValType();
582 Arg->getName() +
".unsafe-byval");
587 Arg->replaceAllUsesWith(NewArg);
593 for (AllocaInst *AI : StaticAllocas) {
595 unsigned Offset = SSL.getObjectOffset(AI);
602 std::string
Name = std::string(AI->
getName()) +
".unsafe";
609 if (
User->isLifetimeStartOrEnd()) {
610 User->eraseFromParent();
616 InsertBefore =
PHI->getIncomingBlock(U)->getTerminator();
622 IRBUser.CreatePtrAddWithSignedOffset(BasePointer, -(int64_t)
Offset);
624 IRBUser.CreateAddrSpaceCast(
Off, AI->
getType(), Name);
629 PHI->setIncomingValueForBlock(
PHI->getIncomingBlock(U), Replacement);
640 unsigned FrameSize =
alignTo(SSL.getFrameSize(), StackAlignment);
642 F.addFnAttr(
"unsafe-stack-size",
utostr(FrameSize));
648 BasePointer, -(int64_t)FrameSize,
"unsafe_stack_static_top");
653void SafeStack::moveDynamicAllocasToUnsafeStack(
656 DIBuilder DIB(*
F.getParent());
658 for (AllocaInst *AI : DynamicAllocas) {
670 StackPtrTy, Intrinsic::ptrmask,
687 if (!DynamicAllocas.empty()) {
694 if (
II->getIntrinsicID() == Intrinsic::stacksave) {
698 II->replaceAllUsesWith(LI);
699 II->eraseFromParent();
700 }
else if (
II->getIntrinsicID() == Intrinsic::stackrestore) {
705 II->eraseFromParent();
711bool SafeStack::ShouldInlinePointerAddress(CallInst &CI) {
713 if (CI.
hasFnAttr(Attribute::AlwaysInline) &&
721void SafeStack::TryInlinePointerAddress() {
730 if (!Callee ||
Callee->isDeclaration())
733 if (!ShouldInlinePointerAddress(*CI))
739 InlineFunctionInfo IFI;
744bool SafeStack::run() {
745 assert(
F.hasFnAttribute(Attribute::SafeStack) &&
746 "Can't run SafeStack on a function without the attribute");
747 assert(!
F.isDeclaration() &&
"Can't run SafeStack on a function declaration");
754 SmallVector<Instruction *, 4> Returns;
761 SmallVector<Instruction *, 4> StackRestorePoints;
765 findInsts(
F, StaticAllocas, DynamicAllocas, ByValArguments, Returns,
768 if (StaticAllocas.
empty() && DynamicAllocas.
empty() &&
769 ByValArguments.
empty() && StackRestorePoints.
empty())
772 if (!StaticAllocas.
empty() || !DynamicAllocas.
empty() ||
773 !ByValArguments.
empty())
774 ++NumUnsafeStackFunctions;
776 if (!StackRestorePoints.
empty())
777 ++NumUnsafeStackRestorePointsFunctions;
783 if (DISubprogram *SP =
F.getSubprogram())
785 DILocation::get(
SP->getContext(),
SP->getScopeLine(), 0, SP));
786 if (Opts.safe_stack_use_pointer_address)
791 if (!UnsafeStackPtr) {
792 F.getContext().emitError(
793 "no location available for safestack pointer address");
800 IRB.
CreateLoad(StackPtrTy, UnsafeStackPtr,
false,
"unsafe_stack_ptr");
803 AllocaInst *StackGuardSlot =
nullptr;
805 if (
F.hasFnAttribute(Attribute::StackProtect) ||
806 F.hasFnAttribute(Attribute::StackProtectStrong) ||
807 F.hasFnAttribute(Attribute::StackProtectReq)) {
812 for (Instruction *RI : Returns) {
814 checkStackGuard(IRBRet,
F, *RI, StackGuardSlot, StackGuard);
820 Value *StaticTop = moveStaticAllocasToUnsafeStack(
821 IRB,
F, StaticAllocas, ByValArguments, BasePointer, StackGuardSlot);
829 AllocaInst *DynamicTop = createStackRestorePoints(
830 IRB,
F, StackRestorePoints, StaticTop, !DynamicAllocas.
empty());
833 moveDynamicAllocasToUnsafeStack(
F, UnsafeStackPtr, DynamicTop,
837 for (Instruction *RI : Returns) {
842 TryInlinePointerAddress();
848class SafeStackLegacyPass :
public FunctionPass {
849 const TargetMachine *TM =
nullptr;
854 SafeStackLegacyPass() : FunctionPass(
ID) {}
856 void getAnalysisUsage(AnalysisUsage &AU)
const override {
867 if (!
F.hasFnAttribute(Attribute::SafeStack)) {
869 " for this function\n");
873 if (
F.isDeclaration()) {
875 " is not available\n");
879 TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
885 const LibcallLoweringInfo &Libcalls =
886 getAnalysis<LibcallLoweringInfoWrapper>().getLibcallLowering(
889 auto *
DL = &
F.getDataLayout();
890 auto &
TLI = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
891 auto &ACT = getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
F);
898 bool ShouldPreserveDominatorTree;
899 std::optional<DominatorTree> LazilyComputedDomTree;
904 if (
auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>()) {
905 DT = &DTWP->getDomTree();
906 ShouldPreserveDominatorTree =
true;
909 LazilyComputedDomTree.emplace(
F);
910 DT = &*LazilyComputedDomTree;
911 ShouldPreserveDominatorTree =
false;
917 DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
919 ScalarEvolution SE(
F,
TLI, ACT, *DT, LI);
921 return SafeStack(
F, *TL, Libcalls, *
DL,
922 ShouldPreserveDominatorTree ? &DTU :
nullptr, SE)
933 if (!
F.hasFnAttribute(Attribute::SafeStack)) {
935 " for this function\n");
939 if (
F.isDeclaration()) {
941 " is not available\n");
946 auto *TL =
Subtarget->getTargetLowering();
948 auto &
DL =
F.getDataLayout();
958 if (!LibcallLowering) {
960 "' analysis required");
969 bool Changed = SafeStack(
F, *TL, Libcalls,
DL, &DTU, SE).run();
978char SafeStackLegacyPass::ID = 0;
981 "Safe Stack instrumentation pass",
false,
false)
const AArch64Subtarget & Subtarget
const TargetLowering & TLI
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)
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static Value * getStackGuard(const TargetLoweringBase &TLI, const LibcallLoweringInfo &Libcalls, 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.
const AArch64TargetLowering * getTargetLowering() const override
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.
LLVM_ABI std::optional< TypeSize > getAllocationSize(const DataLayout &DL) const
Get allocation size in bytes.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
static BranchProbability getBranchProbStackProtector(bool IsLikely)
void setCallingConv(CallingConv::ID CC)
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.
LLVM_ABI bool isNoInline() const
Return true if the call should not be inlined, either because the call site is marked noinline or bec...
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.
static ConstantInt * getSigned(IntegerType *Ty, int64_t V, bool ImplicitTrunc=false)
Return a ConstantInt with the specified value for the specified type.
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.
void recalculate(FuncT &F)
Notify DTU that the entry block was replaced.
LLVM_ABI CallInst * CreateIntrinsicWithoutFolding(Intrinsic::ID ID, ArrayRef< Type * > OverloadTypes, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", ArrayRef< OperandBundleDef > OpBundles={})
Create a call to intrinsic ID with Args, mangled using OverloadTypes.
AllocaInst * CreateAlloca(Type *Ty, unsigned AddrSpace, Value *ArraySize=nullptr, const Twine &Name="")
LLVM_ABI Value * CreateAllocationSize(Type *DestTy, AllocaInst *AI)
Get allocation size of an alloca as a runtime Value* (handles both static and dynamic allocas and vsc...
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="")
void SetCurrentDebugLocation(const DebugLoc &L)
Set location information used by debugging information.
Value * CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNSW=false)
void disableGEPCanonicalization()
Disable canonicalization of getelementptr instructions to ptradd form.
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...
LLVM_ABI Value * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > OverloadTypes, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="", ArrayRef< OperandBundleDef > OpBundles={}, function_ref< void(CallInst *)> SetFn=[](CallInst *) {})
Variant to create a possibly constant-folded intrinsic.
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
Value * CreatePtrAddWithSignedOffset(Value *Ptr, int64_t Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Create a ptradd with a signed constant offset.
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.
Tracks which library functions to use for a particular subtarget or function.
const RTLIB::RuntimeLibcallsInfo & getRuntimeLibcallsInfo() const
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const
Get the CallingConv that should be used for the specified libcall.
RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const
Return the lowering's selection of implementation call for Call.
This is the common base class for memset/memcpy/memmove.
Records a mapping from an opaque lowering context to its LibcallLoweringInfo.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
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.
Type * getType() const
Return the LLVM type of this SCEV expression.
LLVM_ABI 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 ...
Value * getSafeStackPointerAddressCall(IRBuilderBase &IRB, const LibcallLoweringInfo &Libcalls) const
Emits a call to the libcall returning the address of the unsafe stack pointer.
virtual Value * getIRStackGuard(IRBuilderBase &IRB, const LibcallLoweringInfo &Libcalls) const
If the target has a standard location for the stack protector guard, returns the address of that loca...
virtual void insertSSPDeclarations(Module &M, const LibcallLoweringInfo &Libcalls) const
Inserts necessary declarations for SSP (stack protection) purpose.
virtual Value * getSafeStackPointerLocation(IRBuilderBase &IRB, const LibcallLoweringInfo &Libcalls) const
Returns the target-specific address of the unsafe stack pointer.
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.
TargetSubtargetInfo - Generic base class for all target subtargets.
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.
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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.
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.
OuterAnalysisManagerProxy< ModuleAnalysisManager, Function > ModuleAnalysisManagerFunctionProxy
Provide the ModuleAnalysisManager to Function proxy.
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...
std::string utostr(uint64_t X, bool isNeg=false)
LLVM_ABI InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI, bool MergeAttributes=false, AAResults *CalleeAAR=nullptr, bool InsertLifetime=true, bool TrackInlineHistory=false, Function *ForwardVarArgsTo=nullptr, OptimizationRemarkEmitter *ORE=nullptr)
This function inlines the called function into the basic block of the caller.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
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 const LibcallLoweringInfo & getLibcallLowering(const ModuleLibcallLoweringInfo &ModuleInfo, const TargetSubtargetInfo &Subtarget)
Resolve the LibcallLoweringInfo for Subtarget from the module-level ModuleInfo, applying the subtarge...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
IRBuilder(LLVMContext &, FolderTy, InserterTy) -> IRBuilder< FolderTy, InserterTy >
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
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...
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.
const CodeGenOptions & getCodeGenOptions(const LLVMContext &C)
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.
LLVM_ABI FunctionCallee getOrInsertLibcallDecl(Module &M, RTLIB::LibcallImpl LibcallImpl) const