Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
StackProtector.cpp
Go to the documentation of this file.
1//===- StackProtector.cpp - Stack Protector Insertion ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This pass inserts stack protectors into functions which need them. A variable
10// with a random value in it is stored onto the stack before the local variables
11// are allocated. Upon exiting the block, the stored value is checked. If it's
12// changed, then there was some sort of violation and the program aborts.
13//
14//===----------------------------------------------------------------------===//
15
16#include "llvm/CodeGen/StackProtector.h"
17#include "llvm/ADT/SmallPtrSet.h"
18#include "llvm/ADT/SmallVector.h"
19#include "llvm/ADT/Statistic.h"
20#include "llvm/Analysis/BranchProbabilityInfo.h"
21#include "llvm/Analysis/MemoryLocation.h"
22#include "llvm/Analysis/OptimizationRemarkEmitter.h"
23#include "llvm/CodeGen/Passes.h"
24#include "llvm/CodeGen/TargetLowering.h"
25#include "llvm/CodeGen/TargetPassConfig.h"
26#include "llvm/CodeGen/TargetSubtargetInfo.h"
27#include "llvm/IR/Attributes.h"
28#include "llvm/IR/BasicBlock.h"
29#include "llvm/IR/Constants.h"
30#include "llvm/IR/DataLayout.h"
31#include "llvm/IR/DerivedTypes.h"
32#include "llvm/IR/Dominators.h"
33#include "llvm/IR/EHPersonalities.h"
34#include "llvm/IR/Function.h"
35#include "llvm/IR/IRBuilder.h"
36#include "llvm/IR/Instruction.h"
37#include "llvm/IR/Instructions.h"
38#include "llvm/IR/IntrinsicInst.h"
39#include "llvm/IR/Intrinsics.h"
40#include "llvm/IR/MDBuilder.h"
41#include "llvm/IR/Module.h"
42#include "llvm/IR/Type.h"
43#include "llvm/IR/User.h"
44#include "llvm/InitializePasses.h"
45#include "llvm/Pass.h"
46#include "llvm/Support/Casting.h"
47#include "llvm/Support/CommandLine.h"
48#include "llvm/Target/TargetMachine.h"
49#include "llvm/Target/TargetOptions.h"
50#include "llvm/Transforms/Utils/BasicBlockUtils.h"
51#include <optional>
52#include <utility>
53
54using namespacellvm;
55
56#define DEBUG_TYPE "stack-protector"
57
58STATISTIC(NumFunProtected,"Number of functions protected");
59STATISTIC(NumAddrTaken,"Number of local variables that have their address"
60" taken.");
61
62staticcl::opt<bool>EnableSelectionDAGSP("enable-selectiondag-sp",
63cl::init(true),cl::Hidden);
64staticcl::opt<bool>DisableCheckNoReturn("disable-check-noreturn-call",
65cl::init(false),cl::Hidden);
66
67/// InsertStackProtectors - Insert code into the prologue and epilogue of the
68/// function.
69///
70/// - The prologue code loads and stores the stack guard onto the stack.
71/// - The epilogue checks the value stored in the prologue against the original
72/// value. It calls __stack_chk_fail if they differ.
73staticboolInsertStackProtectors(constTargetMachine *TM,Function *F,
74DomTreeUpdater *DTU,bool &HasPrologue,
75bool &HasIRCheck);
76
77/// CreateFailBB - Create a basic block to jump to when the stack protector
78/// check fails.
79staticBasicBlock *CreateFailBB(Function *F,constTriple &Trip);
80
81boolSSPLayoutInfo::shouldEmitSDCheck(constBasicBlock &BB) const{
82return HasPrologue && !HasIRCheck && isa<ReturnInst>(BB.getTerminator());
83}
84
85voidSSPLayoutInfo::copyToMachineFrameInfo(MachineFrameInfo &MFI) const{
86if (Layout.empty())
87return;
88
89for (intI = 0, E = MFI.getObjectIndexEnd();I != E; ++I) {
90if (MFI.isDeadObjectIndex(I))
91continue;
92
93constAllocaInst *AI = MFI.getObjectAllocation(I);
94if (!AI)
95continue;
96
97SSPLayoutMap::const_iterator LI = Layout.find(AI);
98if (LI == Layout.end())
99continue;
100
101 MFI.setObjectSSPLayout(I, LI->second);
102 }
103}
104
105SSPLayoutInfoSSPLayoutAnalysis::run(Function &F,
106FunctionAnalysisManager &FAM) {
107
108SSPLayoutInfoInfo;
109Info.RequireStackProtector =
110SSPLayoutAnalysis::requiresStackProtector(&F, &Info.Layout);
111Info.SSPBufferSize =F.getFnAttributeAsParsedInteger(
112"stack-protector-buffer-size", SSPLayoutInfo::DefaultSSPBufferSize);
113returnInfo;
114}
115
116AnalysisKey SSPLayoutAnalysis::Key;
117
118PreservedAnalysesStackProtectorPass::run(Function &F,
119FunctionAnalysisManager &FAM) {
120auto &Info =FAM.getResult<SSPLayoutAnalysis>(F);
121auto *DT =FAM.getCachedResult<DominatorTreeAnalysis>(F);
122DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Lazy);
123
124if (!Info.RequireStackProtector)
125returnPreservedAnalyses::all();
126
127// TODO(etienneb): Functions with funclets are not correctly supported now.
128// Do nothing if this is funclet-based personality.
129if (F.hasPersonalityFn()) {
130EHPersonality Personality =classifyEHPersonality(F.getPersonalityFn());
131if (isFuncletEHPersonality(Personality))
132returnPreservedAnalyses::all();
133 }
134
135 ++NumFunProtected;
136bool Changed =InsertStackProtectors(TM, &F, DT ? &DTU :nullptr,
137Info.HasPrologue,Info.HasIRCheck);
138#ifdef EXPENSIVE_CHECKS
139assert((!DT || DT->verify(DominatorTree::VerificationLevel::Full)) &&
140"Failed to maintain validity of domtree!");
141#endif
142
143if (!Changed)
144returnPreservedAnalyses::all();
145PreservedAnalyses PA;
146 PA.preserve<SSPLayoutAnalysis>();
147 PA.preserve<DominatorTreeAnalysis>();
148return PA;
149}
150
151charStackProtector::ID = 0;
152
153StackProtector::StackProtector() :FunctionPass(ID) {
154initializeStackProtectorPass(*PassRegistry::getPassRegistry());
155}
156
157INITIALIZE_PASS_BEGIN(StackProtector,DEBUG_TYPE,
158"Insert stack protectors",false,true)
159INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
160INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
161INITIALIZE_PASS_END(StackProtector,DEBUG_TYPE,
162 "Insert stackprotectors",false,true)
163
164FunctionPass *llvm::createStackProtectorPass() {returnnewStackProtector(); }
165
166voidStackProtector::getAnalysisUsage(AnalysisUsage &AU) const{
167 AU.addRequired<TargetPassConfig>();
168 AU.addPreserved<DominatorTreeWrapperPass>();
169}
170
171boolStackProtector::runOnFunction(Function &Fn) {
172 F = &Fn;
173 M = F->getParent();
174if (auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
175 DTU.emplace(DTWP->getDomTree(), DomTreeUpdater::UpdateStrategy::Lazy);
176 TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
177 LayoutInfo.HasPrologue =false;
178 LayoutInfo.HasIRCheck =false;
179
180 LayoutInfo.SSPBufferSize = Fn.getFnAttributeAsParsedInteger(
181"stack-protector-buffer-size", SSPLayoutInfo::DefaultSSPBufferSize);
182if (!requiresStackProtector(F, &LayoutInfo.Layout))
183returnfalse;
184
185// TODO(etienneb): Functions with funclets are not correctly supported now.
186// Do nothing if this is funclet-based personality.
187if (Fn.hasPersonalityFn()) {
188EHPersonality Personality =classifyEHPersonality(Fn.getPersonalityFn());
189if (isFuncletEHPersonality(Personality))
190returnfalse;
191 }
192
193 ++NumFunProtected;
194bool Changed =
195InsertStackProtectors(TM, F, DTU ? &*DTU :nullptr,
196 LayoutInfo.HasPrologue, LayoutInfo.HasIRCheck);
197#ifdef EXPENSIVE_CHECKS
198assert((!DTU ||
199 DTU->getDomTree().verify(DominatorTree::VerificationLevel::Full)) &&
200"Failed to maintain validity of domtree!");
201#endif
202 DTU.reset();
203return Changed;
204}
205
206/// \param [out] IsLarge is set to true if a protectable array is found and
207/// it is "large" ( >= ssp-buffer-size). In the case of a structure with
208/// multiple arrays, this gets set if any of them is large.
209staticboolContainsProtectableArray(Type *Ty,Module *M,unsigned SSPBufferSize,
210bool &IsLarge,bool Strong,
211bool InStruct) {
212if (!Ty)
213returnfalse;
214if (ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
215if (!AT->getElementType()->isIntegerTy(8)) {
216// If we're on a non-Darwin platform or we're inside of a structure, don't
217// add stack protectors unless the array is a character array.
218// However, in strong mode any array, regardless of type and size,
219// triggers a protector.
220if (!Strong && (InStruct || !Triple(M->getTargetTriple()).isOSDarwin()))
221returnfalse;
222 }
223
224// If an array has more than SSPBufferSize bytes of allocated space, then we
225// emit stack protectors.
226if (SSPBufferSize <= M->getDataLayout().getTypeAllocSize(AT)) {
227 IsLarge =true;
228returntrue;
229 }
230
231if (Strong)
232// Require a protector for all arrays in strong mode
233returntrue;
234 }
235
236constStructType *ST = dyn_cast<StructType>(Ty);
237if (!ST)
238returnfalse;
239
240bool NeedsProtector =false;
241for (Type *ET : ST->elements())
242if (ContainsProtectableArray(ET, M, SSPBufferSize, IsLarge, Strong,true)) {
243// If the element is a protectable array and is large (>= SSPBufferSize)
244// then we are done. If the protectable array is not large, then
245// keep looking in case a subsequent element is a large array.
246if (IsLarge)
247returntrue;
248 NeedsProtector =true;
249 }
250
251return NeedsProtector;
252}
253
254/// Check whether a stack allocation has its address taken.
255staticboolHasAddressTaken(constInstruction *AI,TypeSize AllocSize,
256Module *M,
257SmallPtrSet<const PHINode *, 16> &VisitedPHIs) {
258constDataLayout &DL = M->getDataLayout();
259for (constUser *U : AI->users()) {
260constauto *I = cast<Instruction>(U);
261// If this instruction accesses memory make sure it doesn't access beyond
262// the bounds of the allocated object.
263 std::optional<MemoryLocation> MemLoc =MemoryLocation::getOrNone(I);
264if (MemLoc && MemLoc->Size.hasValue() &&
265 !TypeSize::isKnownGE(AllocSize, MemLoc->Size.getValue()))
266returntrue;
267switch (I->getOpcode()) {
268case Instruction::Store:
269if (AI == cast<StoreInst>(I)->getValueOperand())
270returntrue;
271break;
272case Instruction::AtomicCmpXchg:
273// cmpxchg conceptually includes both a load and store from the same
274// location. So, like store, the value being stored is what matters.
275if (AI == cast<AtomicCmpXchgInst>(I)->getNewValOperand())
276returntrue;
277break;
278case Instruction::PtrToInt:
279if (AI == cast<PtrToIntInst>(I)->getOperand(0))
280returntrue;
281break;
282case Instruction::Call: {
283// Ignore intrinsics that do not become real instructions.
284// TODO: Narrow this to intrinsics that have store-like effects.
285constauto *CI = cast<CallInst>(I);
286if (!CI->isDebugOrPseudoInst() && !CI->isLifetimeStartOrEnd())
287returntrue;
288break;
289 }
290case Instruction::Invoke:
291returntrue;
292case Instruction::GetElementPtr: {
293// If the GEP offset is out-of-bounds, or is non-constant and so has to be
294// assumed to be potentially out-of-bounds, then any memory access that
295// would use it could also be out-of-bounds meaning stack protection is
296// required.
297constGetElementPtrInst *GEP = cast<GetElementPtrInst>(I);
298unsigned IndexSize =DL.getIndexTypeSizeInBits(I->getType());
299APIntOffset(IndexSize, 0);
300if (!GEP->accumulateConstantOffset(DL,Offset))
301returntrue;
302TypeSize OffsetSize =TypeSize::getFixed(Offset.getLimitedValue());
303if (!TypeSize::isKnownGT(AllocSize, OffsetSize))
304returntrue;
305// Adjust AllocSize to be the space remaining after this offset.
306// We can't subtract a fixed size from a scalable one, so in that case
307// assume the scalable value is of minimum size.
308TypeSize NewAllocSize =
309TypeSize::getFixed(AllocSize.getKnownMinValue()) - OffsetSize;
310if (HasAddressTaken(I, NewAllocSize, M, VisitedPHIs))
311returntrue;
312break;
313 }
314case Instruction::BitCast:
315case Instruction::Select:
316case Instruction::AddrSpaceCast:
317if (HasAddressTaken(I, AllocSize, M, VisitedPHIs))
318returntrue;
319break;
320case Instruction::PHI: {
321// Keep track of what PHI nodes we have already visited to ensure
322// they are only visited once.
323constauto *PN = cast<PHINode>(I);
324if (VisitedPHIs.insert(PN).second)
325if (HasAddressTaken(PN, AllocSize, M, VisitedPHIs))
326returntrue;
327break;
328 }
329case Instruction::Load:
330case Instruction::AtomicRMW:
331case Instruction::Ret:
332// These instructions take an address operand, but have load-like or
333// other innocuous behavior that should not trigger a stack protector.
334// atomicrmw conceptually has both load and store semantics, but the
335// value being stored must be integer; so if a pointer is being stored,
336// we'll catch it in the PtrToInt case above.
337break;
338default:
339// Conservatively return true for any instruction that takes an address
340// operand, but is not handled above.
341returntrue;
342 }
343 }
344returnfalse;
345}
346
347/// Search for the first call to the llvm.stackprotector intrinsic and return it
348/// if present.
349staticconstCallInst *findStackProtectorIntrinsic(Function &F) {
350for (constBasicBlock &BB :F)
351for (constInstruction &I : BB)
352if (constauto *II = dyn_cast<IntrinsicInst>(&I))
353if (II->getIntrinsicID() == Intrinsic::stackprotector)
354returnII;
355returnnullptr;
356}
357
358/// Check whether or not this function needs a stack protector based
359/// upon the stack protector level.
360///
361/// We use two heuristics: a standard (ssp) and strong (sspstrong).
362/// The standard heuristic which will add a guard variable to functions that
363/// call alloca with a either a variable size or a size >= SSPBufferSize,
364/// functions with character buffers larger than SSPBufferSize, and functions
365/// with aggregates containing character buffers larger than SSPBufferSize. The
366/// strong heuristic will add a guard variables to functions that call alloca
367/// regardless of size, functions with any buffer regardless of type and size,
368/// functions with aggregates that contain any buffer regardless of type and
369/// size, and functions that contain stack-based variables that have had their
370/// address taken.
371boolSSPLayoutAnalysis::requiresStackProtector(Function *F,
372SSPLayoutMap *Layout) {
373Module *M =F->getParent();
374bool Strong =false;
375bool NeedsProtector =false;
376
377// The set of PHI nodes visited when determining if a variable's reference has
378// been taken. This set is maintained to ensure we don't visit the same PHI
379// node multiple times.
380SmallPtrSet<const PHINode *, 16> VisitedPHIs;
381
382unsigned SSPBufferSize =F->getFnAttributeAsParsedInteger(
383"stack-protector-buffer-size", SSPLayoutInfo::DefaultSSPBufferSize);
384
385if (F->hasFnAttribute(Attribute::SafeStack))
386returnfalse;
387
388// We are constructing the OptimizationRemarkEmitter on the fly rather than
389// using the analysis pass to avoid building DominatorTree and LoopInfo which
390// are not available this late in the IR pipeline.
391OptimizationRemarkEmitter ORE(F);
392
393if (F->hasFnAttribute(Attribute::StackProtectReq)) {
394if (!Layout)
395returntrue;
396 ORE.emit([&]() {
397returnOptimizationRemark(DEBUG_TYPE,"StackProtectorRequested",F)
398 <<"Stack protection applied to function "
399 <<ore::NV("Function",F)
400 <<" due to a function attribute or command-line switch";
401 });
402 NeedsProtector =true;
403 Strong =true;// Use the same heuristic as strong to determine SSPLayout
404 }elseif (F->hasFnAttribute(Attribute::StackProtectStrong))
405 Strong =true;
406elseif (!F->hasFnAttribute(Attribute::StackProtect))
407returnfalse;
408
409for (constBasicBlock &BB : *F) {
410for (constInstruction &I : BB) {
411if (constAllocaInst *AI = dyn_cast<AllocaInst>(&I)) {
412if (AI->isArrayAllocation()) {
413auto RemarkBuilder = [&]() {
414returnOptimizationRemark(DEBUG_TYPE,"StackProtectorAllocaOrArray",
415 &I)
416 <<"Stack protection applied to function "
417 <<ore::NV("Function",F)
418 <<" due to a call to alloca or use of a variable length "
419"array";
420 };
421if (constauto *CI = dyn_cast<ConstantInt>(AI->getArraySize())) {
422if (CI->getLimitedValue(SSPBufferSize) >= SSPBufferSize) {
423// A call to alloca with size >= SSPBufferSize requires
424// stack protectors.
425if (!Layout)
426returntrue;
427 Layout->insert(
428 std::make_pair(AI,MachineFrameInfo::SSPLK_LargeArray));
429 ORE.emit(RemarkBuilder);
430 NeedsProtector =true;
431 }elseif (Strong) {
432// Require protectors for all alloca calls in strong mode.
433if (!Layout)
434returntrue;
435 Layout->insert(
436 std::make_pair(AI,MachineFrameInfo::SSPLK_SmallArray));
437 ORE.emit(RemarkBuilder);
438 NeedsProtector =true;
439 }
440 }else {
441// A call to alloca with a variable size requires protectors.
442if (!Layout)
443returntrue;
444 Layout->insert(
445 std::make_pair(AI,MachineFrameInfo::SSPLK_LargeArray));
446 ORE.emit(RemarkBuilder);
447 NeedsProtector =true;
448 }
449continue;
450 }
451
452bool IsLarge =false;
453if (ContainsProtectableArray(AI->getAllocatedType(), M, SSPBufferSize,
454 IsLarge, Strong,false)) {
455if (!Layout)
456returntrue;
457 Layout->insert(std::make_pair(
458 AI, IsLarge ?MachineFrameInfo::SSPLK_LargeArray
459 :MachineFrameInfo::SSPLK_SmallArray));
460 ORE.emit([&]() {
461returnOptimizationRemark(DEBUG_TYPE,"StackProtectorBuffer", &I)
462 <<"Stack protection applied to function "
463 <<ore::NV("Function",F)
464 <<" due to a stack allocated buffer or struct containing a "
465"buffer";
466 });
467 NeedsProtector =true;
468continue;
469 }
470
471if (Strong &&
472HasAddressTaken(
473 AI, M->getDataLayout().getTypeAllocSize(AI->getAllocatedType()),
474 M, VisitedPHIs)) {
475 ++NumAddrTaken;
476if (!Layout)
477returntrue;
478 Layout->insert(std::make_pair(AI,MachineFrameInfo::SSPLK_AddrOf));
479 ORE.emit([&]() {
480returnOptimizationRemark(DEBUG_TYPE,"StackProtectorAddressTaken",
481 &I)
482 <<"Stack protection applied to function "
483 <<ore::NV("Function",F)
484 <<" due to the address of a local variable being taken";
485 });
486 NeedsProtector =true;
487 }
488// Clear any PHIs that we visited, to make sure we examine all uses of
489// any subsequent allocas that we look at.
490 VisitedPHIs.clear();
491 }
492 }
493 }
494
495return NeedsProtector;
496}
497
498/// Create a stack guard loading and populate whether SelectionDAG SSP is
499/// supported.
500staticValue *getStackGuard(constTargetLoweringBase *TLI,Module *M,
501IRBuilder<> &B,
502bool *SupportsSelectionDAGSP =nullptr) {
503Value *Guard = TLI->getIRStackGuard(B);
504StringRef GuardMode = M->getStackProtectorGuard();
505if ((GuardMode =="tls" || GuardMode.empty()) && Guard)
506returnB.CreateLoad(B.getPtrTy(), Guard,true,"StackGuard");
507
508// Use SelectionDAG SSP handling, since there isn't an IR guard.
509//
510// This is more or less weird, since we optionally output whether we
511// should perform a SelectionDAG SP here. The reason is that it's strictly
512// defined as !TLI->getIRStackGuard(B), where getIRStackGuard is also
513// mutating. There is no way to get this bit without mutating the IR, so
514// getting this bit has to happen in this right time.
515//
516// We could have define a new function TLI::supportsSelectionDAGSP(), but that
517// will put more burden on the backends' overriding work, especially when it
518// actually conveys the same information getIRStackGuard() already gives.
519if (SupportsSelectionDAGSP)
520 *SupportsSelectionDAGSP =true;
521 TLI->insertSSPDeclarations(*M);
522returnB.CreateIntrinsic(Intrinsic::stackguard, {}, {});
523}
524
525/// Insert code into the entry block that stores the stack guard
526/// variable onto the stack:
527///
528/// entry:
529/// StackGuardSlot = alloca i8*
530/// StackGuard = <stack guard>
531/// call void @llvm.stackprotector(StackGuard, StackGuardSlot)
532///
533/// Returns true if the platform/triple supports the stackprotectorcreate pseudo
534/// node.
535staticboolCreatePrologue(Function *F,Module *M,Instruction *CheckLoc,
536constTargetLoweringBase *TLI,AllocaInst *&AI) {
537bool SupportsSelectionDAGSP =false;
538IRBuilder<>B(&F->getEntryBlock().front());
539PointerType *PtrTy =PointerType::getUnqual(CheckLoc->getContext());
540 AI =B.CreateAlloca(PtrTy,nullptr,"StackGuardSlot");
541
542Value *GuardSlot =getStackGuard(TLI, M,B, &SupportsSelectionDAGSP);
543B.CreateIntrinsic(Intrinsic::stackprotector, {}, {GuardSlot, AI});
544return SupportsSelectionDAGSP;
545}
546
547boolInsertStackProtectors(constTargetMachine *TM,Function *F,
548DomTreeUpdater *DTU,bool &HasPrologue,
549bool &HasIRCheck) {
550auto *M =F->getParent();
551auto *TLI = TM->getSubtargetImpl(*F)->getTargetLowering();
552
553// If the target wants to XOR the frame pointer into the guard value, it's
554// impossible to emit the check in IR, so the target *must* support stack
555// protection in SDAG.
556bool SupportsSelectionDAGSP =
557 TLI->useStackGuardXorFP() ||
558 (EnableSelectionDAGSP && !TM->Options.EnableFastISel);
559AllocaInst *AI =nullptr;// Place on stack that stores the stack guard.
560BasicBlock *FailBB =nullptr;
561
562for (BasicBlock &BB :llvm::make_early_inc_range(*F)) {
563// This is stack protector auto generated check BB, skip it.
564if (&BB == FailBB)
565continue;
566Instruction *CheckLoc = dyn_cast<ReturnInst>(BB.getTerminator());
567if (!CheckLoc && !DisableCheckNoReturn)
568for (auto &Inst : BB)
569if (auto *CB = dyn_cast<CallBase>(&Inst))
570// Do stack check before noreturn calls that aren't nounwind (e.g:
571// __cxa_throw).
572if (CB->doesNotReturn() && !CB->doesNotThrow()) {
573 CheckLoc = CB;
574break;
575 }
576
577if (!CheckLoc)
578continue;
579
580// Generate prologue instrumentation if not already generated.
581if (!HasPrologue) {
582 HasPrologue =true;
583 SupportsSelectionDAGSP &=CreatePrologue(F, M, CheckLoc, TLI, AI);
584 }
585
586// SelectionDAG based code generation. Nothing else needs to be done here.
587// The epilogue instrumentation is postponed to SelectionDAG.
588if (SupportsSelectionDAGSP)
589break;
590
591// Find the stack guard slot if the prologue was not created by this pass
592// itself via a previous call to CreatePrologue().
593if (!AI) {
594constCallInst *SPCall =findStackProtectorIntrinsic(*F);
595assert(SPCall &&"Call to llvm.stackprotector is missing");
596 AI = cast<AllocaInst>(SPCall->getArgOperand(1));
597 }
598
599// Set HasIRCheck to true, so that SelectionDAG will not generate its own
600// version. SelectionDAG called 'shouldEmitSDCheck' to check whether
601// instrumentation has already been generated.
602 HasIRCheck =true;
603
604// If we're instrumenting a block with a tail call, the check has to be
605// inserted before the call rather than between it and the return. The
606// verifier guarantees that a tail call is either directly before the
607// return or with a single correct bitcast of the return value in between so
608// we don't need to worry about many situations here.
609Instruction *Prev = CheckLoc->getPrevNonDebugInstruction();
610if (Prev && isa<CallInst>(Prev) && cast<CallInst>(Prev)->isTailCall())
611 CheckLoc = Prev;
612elseif (Prev) {
613 Prev = Prev->getPrevNonDebugInstruction();
614if (Prev && isa<CallInst>(Prev) && cast<CallInst>(Prev)->isTailCall())
615 CheckLoc = Prev;
616 }
617
618// Generate epilogue instrumentation. The epilogue intrumentation can be
619// function-based or inlined depending on which mechanism the target is
620// providing.
621if (Function *GuardCheck = TLI->getSSPStackGuardCheck(*M)) {
622// Generate the function-based epilogue instrumentation.
623// The target provides a guard check function, generate a call to it.
624IRBuilder<>B(CheckLoc);
625LoadInst *Guard =B.CreateLoad(B.getPtrTy(), AI,true,"Guard");
626CallInst *Call =B.CreateCall(GuardCheck, {Guard});
627 Call->setAttributes(GuardCheck->getAttributes());
628 Call->setCallingConv(GuardCheck->getCallingConv());
629 }else {
630// Generate the epilogue with inline instrumentation.
631// If we do not support SelectionDAG based calls, generate IR level
632// calls.
633//
634// For each block with a return instruction, convert this:
635//
636// return:
637// ...
638// ret ...
639//
640// into this:
641//
642// return:
643// ...
644// %1 = <stack guard>
645// %2 = load StackGuardSlot
646// %3 = icmp ne i1 %1, %2
647// br i1 %3, label %CallStackCheckFailBlk, label %SP_return
648//
649// SP_return:
650// ret ...
651//
652// CallStackCheckFailBlk:
653// call void @__stack_chk_fail()
654// unreachable
655
656// Create the FailBB. We duplicate the BB every time since the MI tail
657// merge pass will merge together all of the various BB into one including
658// fail BB generated by the stack protector pseudo instruction.
659if (!FailBB)
660 FailBB =CreateFailBB(F, TM->getTargetTriple());
661
662IRBuilder<>B(CheckLoc);
663Value *Guard =getStackGuard(TLI, M,B);
664LoadInst *LI2 =B.CreateLoad(B.getPtrTy(), AI,true);
665auto *Cmp = cast<ICmpInst>(B.CreateICmpNE(Guard, LI2));
666auto SuccessProb =
667BranchProbabilityInfo::getBranchProbStackProtector(true);
668auto FailureProb =
669BranchProbabilityInfo::getBranchProbStackProtector(false);
670MDNode *Weights =MDBuilder(F->getContext())
671 .createBranchWeights(FailureProb.getNumerator(),
672 SuccessProb.getNumerator());
673
674SplitBlockAndInsertIfThen(Cmp, CheckLoc,
675/*Unreachable=*/false, Weights, DTU,
676/*LI=*/nullptr,/*ThenBlock=*/FailBB);
677
678auto *BI = cast<BranchInst>(Cmp->getParent()->getTerminator());
679BasicBlock *NewBB = BI->getSuccessor(1);
680 NewBB->setName("SP_return");
681 NewBB->moveAfter(&BB);
682
683 Cmp->setPredicate(Cmp->getInversePredicate());
684 BI->swapSuccessors();
685 }
686 }
687
688// Return if we didn't modify any basic blocks. i.e., there are no return
689// statements in the function.
690return HasPrologue;
691}
692
693BasicBlock *CreateFailBB(Function *F,constTriple &Trip) {
694auto *M =F->getParent();
695LLVMContext &Context =F->getContext();
696BasicBlock *FailBB =BasicBlock::Create(Context,"CallStackCheckFailBlk",F);
697IRBuilder<>B(FailBB);
698if (F->getSubprogram())
699B.SetCurrentDebugLocation(
700DILocation::get(Context, 0, 0,F->getSubprogram()));
701FunctionCallee StackChkFail;
702SmallVector<Value *, 1> Args;
703if (Trip.isOSOpenBSD()) {
704 StackChkFail = M->getOrInsertFunction("__stack_smash_handler",
705Type::getVoidTy(Context),
706PointerType::getUnqual(Context));
707 Args.push_back(B.CreateGlobalString(F->getName(),"SSH"));
708 }else {
709 StackChkFail =
710 M->getOrInsertFunction("__stack_chk_fail",Type::getVoidTy(Context));
711 }
712 cast<Function>(StackChkFail.getCallee())->addFnAttr(Attribute::NoReturn);
713B.CreateCall(StackChkFail, Args);
714B.CreateUnreachable();
715return FailBB;
716}
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
Attributes.h
This file contains the simple types necessary to represent the attributes associated with functions a...
true
basic Basic Alias true
Definition:BasicAliasAnalysis.cpp:1981
BasicBlockUtils.h
BranchProbabilityInfo.h
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Info
Analysis containing CSE Info
Definition:CSEInfo.cpp:27
Casting.h
Passes.h
CommandLine.h
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DataLayout.h
DerivedTypes.h
Dominators.h
EHPersonalities.h
DEBUG_TYPE
#define DEBUG_TYPE
Definition:GenericCycleImpl.h:31
GEP
Hexagon Common GEP
Definition:HexagonCommonGEP.cpp:170
IRBuilder.h
BasicBlock.h
Function.h
Instruction.h
IntrinsicInst.h
Module.h
Module.h This file contains the declarations for the Module class.
Type.h
User.h
InitializePasses.h
Instructions.h
Intrinsics.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
MDBuilder.h
MemoryLocation.h
This file provides utility analysis objects describing memory locations.
II
uint64_t IntrinsicInst * II
Definition:NVVMIntrRange.cpp:51
OptimizationRemarkEmitter.h
FAM
FunctionAnalysisManager FAM
Definition:PassBuilderBindings.cpp:61
INITIALIZE_PASS_DEPENDENCY
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition:PassSupport.h:55
INITIALIZE_PASS_END
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:57
INITIALIZE_PASS_BEGIN
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:52
Pass.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SmallPtrSet.h
This file defines the SmallPtrSet class.
SmallVector.h
This file defines the SmallVector class.
HasAddressTaken
static bool HasAddressTaken(const Instruction *AI, TypeSize AllocSize, Module *M, SmallPtrSet< const PHINode *, 16 > &VisitedPHIs)
Check whether a stack allocation has its address taken.
Definition:StackProtector.cpp:255
getStackGuard
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.
Definition:StackProtector.cpp:500
InsertStackProtectors
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.
Definition:StackProtector.cpp:547
CreateFailBB
static BasicBlock * CreateFailBB(Function *F, const Triple &Trip)
CreateFailBB - Create a basic block to jump to when the stack protector check fails.
Definition:StackProtector.cpp:693
DisableCheckNoReturn
static cl::opt< bool > DisableCheckNoReturn("disable-check-noreturn-call", cl::init(false), cl::Hidden)
CreatePrologue
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:
Definition:StackProtector.cpp:535
protectors
Insert stack protectors
Definition:StackProtector.cpp:162
ContainsProtectableArray
static bool ContainsProtectableArray(Type *Ty, Module *M, unsigned SSPBufferSize, bool &IsLarge, bool Strong, bool InStruct)
Definition:StackProtector.cpp:209
EnableSelectionDAGSP
static cl::opt< bool > EnableSelectionDAGSP("enable-selectiondag-sp", cl::init(true), cl::Hidden)
findStackProtectorIntrinsic
static const CallInst * findStackProtectorIntrinsic(Function &F)
Search for the first call to the llvm.stackprotector intrinsic and return it if present.
Definition:StackProtector.cpp:349
StackProtector.h
Statistic.h
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
STATISTIC
#define STATISTIC(VARNAME, DESC)
Definition:Statistic.h:166
TargetLowering.h
This file describes how to lower LLVM code to machine code.
TargetOptions.h
TargetPassConfig.h
Target-Independent Code Generator Pass Configuration Options pass.
TargetSubtargetInfo.h
ArrayType
Definition:ItaniumDemangle.h:785
PointerType
Definition:ItaniumDemangle.h:627
llvm::APInt
Class for arbitrary precision integers.
Definition:APInt.h:78
llvm::AllocaInst
an instruction to allocate memory on the stack
Definition:Instructions.h:63
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
llvm::AnalysisManager::getCachedResult
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
Definition:PassManager.h:429
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition:PassManager.h:410
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::AnalysisUsage::addRequired
AnalysisUsage & addRequired()
Definition:PassAnalysisSupport.h:75
llvm::AnalysisUsage::addPreserved
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
Definition:PassAnalysisSupport.h:98
llvm::BasicBlock
LLVM Basic Block Representation.
Definition:BasicBlock.h:61
llvm::BasicBlock::Create
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Definition:BasicBlock.h:213
llvm::BasicBlock::moveAfter
void moveAfter(BasicBlock *MovePos)
Unlink this basic block from its current function and insert it right after MovePos in the function M...
Definition:BasicBlock.cpp:287
llvm::BasicBlock::getTerminator
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
Definition:BasicBlock.h:240
llvm::BranchProbabilityInfo::getBranchProbStackProtector
static BranchProbability getBranchProbStackProtector(bool IsLikely)
Definition:BranchProbabilityInfo.h:201
llvm::CallBase::getArgOperand
Value * getArgOperand(unsigned i) const
Definition:InstrTypes.h:1286
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition:Instructions.h:1479
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition:DenseMap.h:156
llvm::DenseMapBase::empty
bool empty() const
Definition:DenseMap.h:98
llvm::DenseMapBase::end
iterator end()
Definition:DenseMap.h:84
llvm::DenseMapBase::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition:DenseMap.h:211
llvm::DenseMapIterator
Definition:DenseMap.h:1189
llvm::DenseMap< const AllocaInst *, MachineFrameInfo::SSPLayoutKind >
llvm::DomTreeUpdater
Definition:DomTreeUpdater.h:30
llvm::DominatorTreeAnalysis
Analysis pass which computes a DominatorTree.
Definition:Dominators.h:279
llvm::DominatorTreeBase::verify
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
Definition:GenericDomTree.h:905
llvm::DominatorTreeWrapperPass
Legacy analysis pass which computes a DominatorTree.
Definition:Dominators.h:317
llvm::FunctionCallee
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Definition:DerivedTypes.h:170
llvm::FunctionCallee::getCallee
Value * getCallee()
Definition:DerivedTypes.h:189
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition:Pass.h:310
llvm::Function
Definition:Function.h:63
llvm::Function::getFnAttributeAsParsedInteger
uint64_t getFnAttributeAsParsedInteger(StringRef Kind, uint64_t Default=0) const
For a string attribute Kind, parse attribute as an integer.
Definition:Function.cpp:778
llvm::Function::hasPersonalityFn
bool hasPersonalityFn() const
Check whether this function has a personality function.
Definition:Function.h:905
llvm::Function::getPersonalityFn
Constant * getPersonalityFn() const
Get the personality function associated with this function.
Definition:Function.cpp:1048
llvm::GetElementPtrInst
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
Definition:Instructions.h:933
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition:GlobalValue.h:657
llvm::IRBuilder
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition:IRBuilder.h:2705
llvm::Instruction
Definition:Instruction.h:68
llvm::Instruction::getPrevNonDebugInstruction
const Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the previous non-debug instruction in the same basic block as 'this',...
Definition:Instruction.cpp:1234
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::LoadInst
An instruction for reading from memory.
Definition:Instructions.h:176
llvm::MDBuilder
Definition:MDBuilder.h:36
llvm::MDBuilder::createBranchWeights
MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)
Return metadata containing two branch weights.
Definition:MDBuilder.cpp:37
llvm::MDNode
Metadata node.
Definition:Metadata.h:1073
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition:Metadata.h:1549
llvm::MachineFrameInfo
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Definition:MachineFrameInfo.h:106
llvm::MachineFrameInfo::getObjectAllocation
const AllocaInst * getObjectAllocation(int ObjectIdx) const
Return the underlying Alloca of the specified stack object if it exists.
Definition:MachineFrameInfo.h:512
llvm::MachineFrameInfo::SSPLK_SmallArray
@ SSPLK_SmallArray
Array or nested array < SSP-buffer-size.
Definition:MachineFrameInfo.h:115
llvm::MachineFrameInfo::SSPLK_LargeArray
@ SSPLK_LargeArray
Array or nested array >= SSP-buffer-size.
Definition:MachineFrameInfo.h:113
llvm::MachineFrameInfo::SSPLK_AddrOf
@ SSPLK_AddrOf
The address of this allocation is exposed and triggered protection.
Definition:MachineFrameInfo.h:117
llvm::MachineFrameInfo::setObjectSSPLayout
void setObjectSSPLayout(int ObjectIdx, SSPLayoutKind Kind)
Definition:MachineFrameInfo.h:576
llvm::MachineFrameInfo::getObjectIndexEnd
int getObjectIndexEnd() const
Return one past the maximum frame object index.
Definition:MachineFrameInfo.h:412
llvm::MachineFrameInfo::isDeadObjectIndex
bool isDeadObjectIndex(int ObjectIdx) const
Returns true if the specified index corresponds to a dead object.
Definition:MachineFrameInfo.h:764
llvm::MemoryLocation::getOrNone
static std::optional< MemoryLocation > getOrNone(const Instruction *Inst)
Definition:MemoryLocation.cpp:77
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::OptimizationRemarkEmitter
The optimization diagnostic interface.
Definition:OptimizationRemarkEmitter.h:32
llvm::OptimizationRemarkEmitter::emit
void emit(DiagnosticInfoOptimizationBase &OptDiag)
Output the remark via the diagnostic handler and to the optimization record file.
Definition:OptimizationRemarkEmitter.cpp:79
llvm::OptimizationRemark
Diagnostic information for applied optimization remarks.
Definition:DiagnosticInfo.h:762
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition:PassRegistry.cpp:24
llvm::PointerType::getUnqual
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
Definition:DerivedTypes.h:686
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:Analysis.h:111
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition:Analysis.h:117
llvm::PreservedAnalyses::preserve
void preserve()
Mark an analysis as preserved.
Definition:Analysis.h:131
llvm::SSPLayoutAnalysis
Definition:StackProtector.h:68
llvm::SSPLayoutAnalysis::requiresStackProtector
static bool requiresStackProtector(Function *F, SSPLayoutMap *Layout=nullptr)
Check whether or not F needs a stack protector based upon the stack protector level.
Definition:StackProtector.cpp:371
llvm::SSPLayoutAnalysis::run
Result run(Function &F, FunctionAnalysisManager &FAM)
Definition:StackProtector.cpp:105
llvm::SSPLayoutInfo
Definition:StackProtector.h:34
llvm::SSPLayoutInfo::copyToMachineFrameInfo
void copyToMachineFrameInfo(MachineFrameInfo &MFI) const
Definition:StackProtector.cpp:85
llvm::SSPLayoutInfo::shouldEmitSDCheck
bool shouldEmitSDCheck(const BasicBlock &BB) const
Definition:StackProtector.cpp:81
llvm::SmallPtrSetImplBase::clear
void clear()
Definition:SmallPtrSet.h:97
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition:SmallPtrSet.h:384
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition:SmallPtrSet.h:519
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StackProtectorPass::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
Definition:StackProtector.cpp:118
llvm::StackProtector
Definition:StackProtector.h:93
llvm::StackProtector::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition:StackProtector.cpp:166
llvm::StackProtector::ID
static char ID
Definition:StackProtector.h:108
llvm::StackProtector::StackProtector
StackProtector()
Definition:StackProtector.cpp:153
llvm::StackProtector::requiresStackProtector
static bool requiresStackProtector(Function *F, SSPLayoutMap *Layout=nullptr)
Check whether or not F needs a stack protector based upon the stack protector level.
Definition:StackProtector.h:129
llvm::StackProtector::runOnFunction
bool runOnFunction(Function &Fn) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Definition:StackProtector.cpp:171
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringRef::empty
constexpr bool empty() const
empty - Check if the string is empty.
Definition:StringRef.h:147
llvm::StructType
Class to represent struct types.
Definition:DerivedTypes.h:218
llvm::TargetLoweringBase
This base class for TargetLowering contains the SelectionDAG-independent parts that can be used from ...
Definition:TargetLowering.h:195
llvm::TargetLoweringBase::getIRStackGuard
virtual Value * getIRStackGuard(IRBuilderBase &IRB) const
If the target has a standard location for the stack protector guard, returns the address of that loca...
Definition:TargetLoweringBase.cpp:1956
llvm::TargetLoweringBase::insertSSPDeclarations
virtual void insertSSPDeclarations(Module &M) const
Inserts necessary declarations for SSP (stack protection) purpose.
Definition:TargetLoweringBase.cpp:1970
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition:TargetMachine.h:77
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition:TargetPassConfig.h:85
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition:Triple.h:44
llvm::Triple::isOSOpenBSD
bool isOSOpenBSD() const
Definition:Triple.h:610
llvm::Triple::isOSDarwin
bool isOSDarwin() const
Is this a "Darwin" OS (macOS, iOS, tvOS, watchOS, XROS, or DriverKit).
Definition:Triple.h:588
llvm::TypeSize
Definition:TypeSize.h:334
llvm::TypeSize::getFixed
static constexpr TypeSize getFixed(ScalarTy ExactSize)
Definition:TypeSize.h:345
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::getVoidTy
static Type * getVoidTy(LLVMContext &C)
llvm::User
Definition:User.h:44
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition:Value.cpp:377
llvm::Value::users
iterator_range< user_iterator > users()
Definition:Value.h:421
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition:Value.cpp:1075
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::details::FixedOrScalableQuantity::getKnownMinValue
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition:TypeSize.h:168
llvm::details::FixedOrScalableQuantity< TypeSize, uint64_t >::isKnownGT
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition:TypeSize.h:225
llvm::details::FixedOrScalableQuantity< TypeSize, uint64_t >::isKnownGE
static constexpr bool isKnownGE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition:TypeSize.h:239
unsigned
TargetMachine.h
false
Definition:StackSlotColoring.cpp:193
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm::ore::NV
DiagnosticInfoOptimizationBase::Argument NV
Definition:OptimizationRemarkEmitter.h:135
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::Offset
@ Offset
Definition:DWP.cpp:480
llvm::make_early_inc_range
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...
Definition:STLExtras.h:657
llvm::createStackProtectorPass
FunctionPass * createStackProtectorPass()
createStackProtectorPass - This pass adds stack protectors to functions.
Definition:StackProtector.cpp:164
llvm::initializeStackProtectorPass
void initializeStackProtectorPass(PassRegistry &)
llvm::EHPersonality
EHPersonality
Definition:EHPersonalities.h:21
llvm::classifyEHPersonality
EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
Definition:EHPersonalities.cpp:23
llvm::isFuncletEHPersonality
bool isFuncletEHPersonality(EHPersonality Pers)
Returns true if this is a personality function that invokes handler funclets (which must return to it...
Definition:EHPersonalities.h:65
llvm::SplitBlockAndInsertIfThen
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 ...
Definition:BasicBlockUtils.cpp:1609
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition:Analysis.h:28

Generated on Fri Jul 18 2025 11:03:28 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp