Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
CaptureTracking.cpp
Go to the documentation of this file.
1//===--- CaptureTracking.cpp - Determine whether a pointer is captured ----===//
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 file contains routines that help determine which pointers are captured.
10// A pointer value is captured if the function makes a copy of any part of the
11// pointer that outlives the call. Not being captured means, more or less, that
12// the pointer is only dereferenced and not stored in a global. Returning part
13// of the pointer as the function return value may or may not count as capturing
14// the pointer, depending on the context.
15//
16//===----------------------------------------------------------------------===//
17
18#include "llvm/Analysis/CaptureTracking.h"
19#include "llvm/ADT/SmallSet.h"
20#include "llvm/ADT/SmallVector.h"
21#include "llvm/ADT/Statistic.h"
22#include "llvm/Analysis/AliasAnalysis.h"
23#include "llvm/Analysis/CFG.h"
24#include "llvm/Analysis/ValueTracking.h"
25#include "llvm/IR/Constants.h"
26#include "llvm/IR/Dominators.h"
27#include "llvm/IR/Instructions.h"
28#include "llvm/IR/IntrinsicInst.h"
29#include "llvm/Support/CommandLine.h"
30
31using namespacellvm;
32
33#define DEBUG_TYPE "capture-tracking"
34
35STATISTIC(NumCaptured,"Number of pointers maybe captured");
36STATISTIC(NumNotCaptured,"Number of pointers not captured");
37STATISTIC(NumCapturedBefore,"Number of pointers maybe captured before");
38STATISTIC(NumNotCapturedBefore,"Number of pointers not captured before");
39
40/// The default value for MaxUsesToExplore argument. It's relatively small to
41/// keep the cost of analysis reasonable for clients like BasicAliasAnalysis,
42/// where the results can't be cached.
43/// TODO: we should probably introduce a caching CaptureTracking analysis and
44/// use it where possible. The caching version can use much higher limit or
45/// don't have this cap at all.
46staticcl::opt<unsigned>
47DefaultMaxUsesToExplore("capture-tracking-max-uses-to-explore",cl::Hidden,
48cl::desc("Maximal number of uses to explore."),
49cl::init(100));
50
51unsignedllvm::getDefaultMaxUsesToExploreForCaptureTracking() {
52returnDefaultMaxUsesToExplore;
53}
54
55CaptureTracker::~CaptureTracker() =default;
56
57boolCaptureTracker::shouldExplore(constUse *U) {returntrue; }
58
59boolCaptureTracker::isDereferenceableOrNull(Value *O,constDataLayout &DL) {
60// We want comparisons to null pointers to not be considered capturing,
61// but need to guard against cases like gep(p, -ptrtoint(p2)) == null,
62// which are equivalent to p == p2 and would capture the pointer.
63//
64// A dereferenceable pointer is a case where this is known to be safe,
65// because the pointer resulting from such a construction would not be
66// dereferenceable.
67//
68// It is not sufficient to check for inbounds GEP here, because GEP with
69// zero offset is always inbounds.
70bool CanBeNull, CanBeFreed;
71return O->getPointerDereferenceableBytes(DL, CanBeNull, CanBeFreed);
72}
73
74namespace{
75structSimpleCaptureTracker :publicCaptureTracker {
76explicit SimpleCaptureTracker(bool ReturnCaptures)
77 : ReturnCaptures(ReturnCaptures) {}
78
79void tooManyUses() override{
80LLVM_DEBUG(dbgs() <<"Captured due to too many uses\n");
81 Captured =true;
82 }
83
84bool captured(constUse *U) override{
85if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
86returnfalse;
87
88LLVM_DEBUG(dbgs() <<"Captured by: " << *U->getUser() <<"\n");
89
90 Captured =true;
91returntrue;
92 }
93
94bool ReturnCaptures;
95
96bool Captured =false;
97};
98
99/// Only find pointer captures which happen before the given instruction. Uses
100/// the dominator tree to determine whether one instruction is before another.
101/// Only support the case where the Value is defined in the same basic block
102/// as the given instruction and the use.
103structCapturesBefore :publicCaptureTracker {
104
105 CapturesBefore(bool ReturnCaptures,constInstruction *I,
106constDominatorTree *DT,bool IncludeI,constLoopInfo *LI)
107 : BeforeHere(I), DT(DT), ReturnCaptures(ReturnCaptures),
108 IncludeI(IncludeI), LI(LI) {}
109
110void tooManyUses() override{ Captured =true; }
111
112bool isSafeToPrune(Instruction *I) {
113if (BeforeHere ==I)
114return !IncludeI;
115
116// We explore this usage only if the usage can reach "BeforeHere".
117// If use is not reachable from entry, there is no need to explore.
118if (!DT->isReachableFromEntry(I->getParent()))
119returntrue;
120
121// Check whether there is a path from I to BeforeHere.
122return !isPotentiallyReachable(I, BeforeHere,nullptr, DT, LI);
123 }
124
125bool captured(constUse *U) override{
126Instruction *I = cast<Instruction>(U->getUser());
127if (isa<ReturnInst>(I) && !ReturnCaptures)
128returnfalse;
129
130// Check isSafeToPrune() here rather than in shouldExplore() to avoid
131// an expensive reachability query for every instruction we look at.
132// Instead we only do one for actual capturing candidates.
133if (isSafeToPrune(I))
134returnfalse;
135
136 Captured =true;
137returntrue;
138 }
139
140constInstruction *BeforeHere;
141constDominatorTree *DT;
142
143bool ReturnCaptures;
144bool IncludeI;
145
146bool Captured =false;
147
148constLoopInfo *LI;
149};
150
151/// Find the 'earliest' instruction before which the pointer is known not to
152/// be captured. Here an instruction A is considered earlier than instruction
153/// B, if A dominates B. If 2 escapes do not dominate each other, the
154/// terminator of the common dominator is chosen. If not all uses cannot be
155/// analyzed, the earliest escape is set to the first instruction in the
156/// function entry block.
157// NOTE: Users have to make sure instructions compared against the earliest
158// escape are not in a cycle.
159structEarliestCaptures :publicCaptureTracker {
160
161 EarliestCaptures(bool ReturnCaptures,Function &F,constDominatorTree &DT)
162 : DT(DT), ReturnCaptures(ReturnCaptures),F(F) {}
163
164void tooManyUses() override{
165 Captured =true;
166 EarliestCapture = &*F.getEntryBlock().begin();
167 }
168
169bool captured(constUse *U) override{
170Instruction *I = cast<Instruction>(U->getUser());
171if (isa<ReturnInst>(I) && !ReturnCaptures)
172returnfalse;
173
174if (!EarliestCapture)
175 EarliestCapture =I;
176else
177 EarliestCapture = DT.findNearestCommonDominator(EarliestCapture,I);
178 Captured =true;
179
180// Return false to continue analysis; we need to see all potential
181// captures.
182returnfalse;
183 }
184
185Instruction *EarliestCapture =nullptr;
186
187constDominatorTree &DT;
188
189bool ReturnCaptures;
190
191bool Captured =false;
192
193Function &F;
194};
195}// namespace
196
197/// PointerMayBeCaptured - Return true if this pointer value may be captured
198/// by the enclosing function (which is required to exist). This routine can
199/// be expensive, so consider caching the results. The boolean ReturnCaptures
200/// specifies whether returning the value (or part of it) from the function
201/// counts as capturing it or not. The boolean StoreCaptures specified whether
202/// storing the value (or part of it) into memory anywhere automatically
203/// counts as capturing it or not.
204boolllvm::PointerMayBeCaptured(constValue *V,bool ReturnCaptures,
205bool StoreCaptures,unsigned MaxUsesToExplore) {
206assert(!isa<GlobalValue>(V) &&
207"It doesn't make sense to ask whether a global is captured.");
208
209// TODO: If StoreCaptures is not true, we could do Fancy analysis
210// to determine whether this store is not actually an escape point.
211// In that case, BasicAliasAnalysis should be updated as well to
212// take advantage of this.
213 (void)StoreCaptures;
214
215LLVM_DEBUG(dbgs() <<"Captured?: " << *V <<" = ");
216
217 SimpleCaptureTracker SCT(ReturnCaptures);
218PointerMayBeCaptured(V, &SCT, MaxUsesToExplore);
219if (SCT.Captured)
220 ++NumCaptured;
221else {
222 ++NumNotCaptured;
223LLVM_DEBUG(dbgs() <<"not captured\n");
224 }
225return SCT.Captured;
226}
227
228/// PointerMayBeCapturedBefore - Return true if this pointer value may be
229/// captured by the enclosing function (which is required to exist). If a
230/// DominatorTree is provided, only captures which happen before the given
231/// instruction are considered. This routine can be expensive, so consider
232/// caching the results. The boolean ReturnCaptures specifies whether
233/// returning the value (or part of it) from the function counts as capturing
234/// it or not. The boolean StoreCaptures specified whether storing the value
235/// (or part of it) into memory anywhere automatically counts as capturing it
236/// or not.
237boolllvm::PointerMayBeCapturedBefore(constValue *V,bool ReturnCaptures,
238bool StoreCaptures,constInstruction *I,
239constDominatorTree *DT,bool IncludeI,
240unsigned MaxUsesToExplore,
241constLoopInfo *LI) {
242assert(!isa<GlobalValue>(V) &&
243"It doesn't make sense to ask whether a global is captured.");
244
245if (!DT)
246returnPointerMayBeCaptured(V, ReturnCaptures, StoreCaptures,
247 MaxUsesToExplore);
248
249// TODO: See comment in PointerMayBeCaptured regarding what could be done
250// with StoreCaptures.
251
252 CapturesBefore CB(ReturnCaptures,I, DT, IncludeI, LI);
253PointerMayBeCaptured(V, &CB, MaxUsesToExplore);
254if (CB.Captured)
255 ++NumCapturedBefore;
256else
257 ++NumNotCapturedBefore;
258return CB.Captured;
259}
260
261Instruction *llvm::FindEarliestCapture(constValue *V,Function &F,
262bool ReturnCaptures,bool StoreCaptures,
263constDominatorTree &DT,
264unsigned MaxUsesToExplore) {
265assert(!isa<GlobalValue>(V) &&
266"It doesn't make sense to ask whether a global is captured.");
267
268 EarliestCaptures CB(ReturnCaptures,F, DT);
269PointerMayBeCaptured(V, &CB, MaxUsesToExplore);
270if (CB.Captured)
271 ++NumCapturedBefore;
272else
273 ++NumNotCapturedBefore;
274return CB.EarliestCapture;
275}
276
277UseCaptureKindllvm::DetermineUseCaptureKind(
278constUse &U,
279function_ref<bool(Value *,constDataLayout &)> IsDereferenceableOrNull) {
280Instruction *I = dyn_cast<Instruction>(U.getUser());
281
282// TODO: Investigate non-instruction uses.
283if (!I)
284returnUseCaptureKind::MAY_CAPTURE;
285
286switch (I->getOpcode()) {
287case Instruction::Call:
288case Instruction::Invoke: {
289auto *Call = cast<CallBase>(I);
290// Not captured if the callee is readonly, doesn't return a copy through
291// its return value and doesn't unwind (a readonly function can leak bits
292// by throwing an exception or not depending on the input value).
293if (Call->onlyReadsMemory() && Call->doesNotThrow() &&
294 Call->getType()->isVoidTy())
295returnUseCaptureKind::NO_CAPTURE;
296
297// The pointer is not captured if returned pointer is not captured.
298// NOTE: CaptureTracking users should not assume that only functions
299// marked with nocapture do not capture. This means that places like
300// getUnderlyingObject in ValueTracking or DecomposeGEPExpression
301// in BasicAA also need to know about this property.
302if (isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(Call,true))
303returnUseCaptureKind::PASSTHROUGH;
304
305// Volatile operations effectively capture the memory location that they
306// load and store to.
307if (auto *MI = dyn_cast<MemIntrinsic>(Call))
308if (MI->isVolatile())
309returnUseCaptureKind::MAY_CAPTURE;
310
311// Calling a function pointer does not in itself cause the pointer to
312// be captured. This is a subtle point considering that (for example)
313// the callee might return its own address. It is analogous to saying
314// that loading a value from a pointer does not cause the pointer to be
315// captured, even though the loaded value might be the pointer itself
316// (think of self-referential objects).
317if (Call->isCallee(&U))
318returnUseCaptureKind::NO_CAPTURE;
319
320// Not captured if only passed via 'nocapture' arguments.
321if (Call->isDataOperand(&U) &&
322 !Call->doesNotCapture(Call->getDataOperandNo(&U))) {
323// The parameter is not marked 'nocapture' - captured.
324returnUseCaptureKind::MAY_CAPTURE;
325 }
326returnUseCaptureKind::NO_CAPTURE;
327 }
328case Instruction::Load:
329// Volatile loads make the address observable.
330if (cast<LoadInst>(I)->isVolatile())
331returnUseCaptureKind::MAY_CAPTURE;
332returnUseCaptureKind::NO_CAPTURE;
333case Instruction::VAArg:
334// "va-arg" from a pointer does not cause it to be captured.
335returnUseCaptureKind::NO_CAPTURE;
336case Instruction::Store:
337// Stored the pointer - conservatively assume it may be captured.
338// Volatile stores make the address observable.
339if (U.getOperandNo() == 0 || cast<StoreInst>(I)->isVolatile())
340returnUseCaptureKind::MAY_CAPTURE;
341returnUseCaptureKind::NO_CAPTURE;
342case Instruction::AtomicRMW: {
343// atomicrmw conceptually includes both a load and store from
344// the same location.
345// As with a store, the location being accessed is not captured,
346// but the value being stored is.
347// Volatile stores make the address observable.
348auto *ARMWI = cast<AtomicRMWInst>(I);
349if (U.getOperandNo() == 1 || ARMWI->isVolatile())
350returnUseCaptureKind::MAY_CAPTURE;
351returnUseCaptureKind::NO_CAPTURE;
352 }
353case Instruction::AtomicCmpXchg: {
354// cmpxchg conceptually includes both a load and store from
355// the same location.
356// As with a store, the location being accessed is not captured,
357// but the value being stored is.
358// Volatile stores make the address observable.
359auto *ACXI = cast<AtomicCmpXchgInst>(I);
360if (U.getOperandNo() == 1 || U.getOperandNo() == 2 || ACXI->isVolatile())
361returnUseCaptureKind::MAY_CAPTURE;
362returnUseCaptureKind::NO_CAPTURE;
363 }
364case Instruction::GetElementPtr:
365// AA does not support pointers of vectors, so GEP vector splats need to
366// be considered as captures.
367if (I->getType()->isVectorTy())
368returnUseCaptureKind::MAY_CAPTURE;
369returnUseCaptureKind::PASSTHROUGH;
370case Instruction::BitCast:
371case Instruction::PHI:
372case Instruction::Select:
373case Instruction::AddrSpaceCast:
374// The original value is not captured via this if the new value isn't.
375returnUseCaptureKind::PASSTHROUGH;
376case Instruction::ICmp: {
377unsignedIdx = U.getOperandNo();
378unsigned OtherIdx = 1 -Idx;
379if (auto *CPN = dyn_cast<ConstantPointerNull>(I->getOperand(OtherIdx))) {
380// Don't count comparisons of a no-alias return value against null as
381// captures. This allows us to ignore comparisons of malloc results
382// with null, for example.
383if (CPN->getType()->getAddressSpace() == 0)
384if (isNoAliasCall(U.get()->stripPointerCasts()))
385returnUseCaptureKind::NO_CAPTURE;
386if (!I->getFunction()->nullPointerIsDefined()) {
387auto *O =I->getOperand(Idx)->stripPointerCastsSameRepresentation();
388// Comparing a dereferenceable_or_null pointer against null cannot
389// lead to pointer escapes, because if it is not null it must be a
390// valid (in-bounds) pointer.
391constDataLayout &DL =I->getDataLayout();
392if (IsDereferenceableOrNull && IsDereferenceableOrNull(O,DL))
393returnUseCaptureKind::NO_CAPTURE;
394 }
395 }
396
397// Otherwise, be conservative. There are crazy ways to capture pointers
398// using comparisons.
399returnUseCaptureKind::MAY_CAPTURE;
400 }
401default:
402// Something else - be conservative and say it is captured.
403returnUseCaptureKind::MAY_CAPTURE;
404 }
405}
406
407voidllvm::PointerMayBeCaptured(constValue *V,CaptureTracker *Tracker,
408unsigned MaxUsesToExplore) {
409assert(V->getType()->isPointerTy() &&"Capture is for pointers only!");
410if (MaxUsesToExplore == 0)
411 MaxUsesToExplore =DefaultMaxUsesToExplore;
412
413SmallVector<const Use *, 20> Worklist;
414 Worklist.reserve(getDefaultMaxUsesToExploreForCaptureTracking());
415SmallSet<const Use *, 20> Visited;
416
417auto AddUses = [&](constValue *V) {
418for (constUse &U : V->uses()) {
419// If there are lots of uses, conservatively say that the value
420// is captured to avoid taking too much compile time.
421if (Visited.size() >= MaxUsesToExplore) {
422 Tracker->tooManyUses();
423returnfalse;
424 }
425if (!Visited.insert(&U).second)
426continue;
427if (!Tracker->shouldExplore(&U))
428continue;
429 Worklist.push_back(&U);
430 }
431returntrue;
432 };
433if (!AddUses(V))
434return;
435
436auto IsDereferenceableOrNull = [Tracker](Value *V,constDataLayout &DL) {
437return Tracker->isDereferenceableOrNull(V,DL);
438 };
439while (!Worklist.empty()) {
440constUse *U = Worklist.pop_back_val();
441switch (DetermineUseCaptureKind(*U, IsDereferenceableOrNull)) {
442caseUseCaptureKind::NO_CAPTURE:
443continue;
444caseUseCaptureKind::MAY_CAPTURE:
445if (Tracker->captured(U))
446return;
447continue;
448caseUseCaptureKind::PASSTHROUGH:
449if (!AddUses(U->getUser()))
450return;
451continue;
452 }
453 }
454
455// All uses examined.
456}
457
458boolllvm::isNonEscapingLocalObject(
459constValue *V,SmallDenseMap<const Value *, bool, 8> *IsCapturedCache) {
460SmallDenseMap<const Value *, bool, 8>::iterator CacheIt;
461if (IsCapturedCache) {
462bool Inserted;
463 std::tie(CacheIt, Inserted) = IsCapturedCache->insert({V,false});
464if (!Inserted)
465// Found cached result, return it!
466return CacheIt->second;
467 }
468
469// If this is an identified function-local object, check to see if it escapes.
470if (isIdentifiedFunctionLocal(V)) {
471// Set StoreCaptures to True so that we can assume in our callers that the
472// pointer is not the result of a load instruction. Currently
473// PointerMayBeCaptured doesn't have any special analysis for the
474// StoreCaptures=false case; if it did, our callers could be refined to be
475// more precise.
476auto Ret = !PointerMayBeCaptured(V,false,/*StoreCaptures=*/true);
477if (IsCapturedCache)
478 CacheIt->second = Ret;
479return Ret;
480 }
481
482returnfalse;
483}
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
AliasAnalysis.h
CFG.h
DefaultMaxUsesToExplore
static cl::opt< unsigned > DefaultMaxUsesToExplore("capture-tracking-max-uses-to-explore", cl::Hidden, cl::desc("Maximal number of uses to explore."), cl::init(100))
The default value for MaxUsesToExplore argument.
CaptureTracking.h
CommandLine.h
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Idx
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
Definition:DeadArgumentElimination.cpp:353
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
Dominators.h
MI
IRTranslator LLVM IR MI
Definition:IRTranslator.cpp:112
IntrinsicInst.h
Instructions.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
SmallSet.h
This file defines the SmallSet class.
SmallVector.h
This file defines the SmallVector class.
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
ValueTracking.h
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
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::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition:Dominators.h:162
llvm::DominatorTree::isReachableFromEntry
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
Definition:Dominators.cpp:321
llvm::DominatorTree::findNearestCommonDominator
Instruction * findNearestCommonDominator(Instruction *I1, Instruction *I2) const
Find the nearest instruction I that dominates both I1 and I2, in the sense that a result produced bef...
Definition:Dominators.cpp:344
llvm::Function
Definition:Function.h:63
llvm::Instruction
Definition:Instruction.h:68
llvm::LoopInfo
Definition:LoopInfo.h:407
llvm::SmallDenseMap
Definition:DenseMap.h:883
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition:SmallSet.h:132
llvm::SmallSet::insert
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Definition:SmallSet.h:181
llvm::SmallSet::size
size_type size() const
Definition:SmallSet.h:170
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorImpl::pop_back_val
T pop_back_val()
Definition:SmallVector.h:673
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition:SmallVector.h:663
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
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::Use
A Use represents the edge between a Value definition and its users.
Definition:Use.h:43
llvm::Value
LLVM Value Representation.
Definition:Value.h:74
llvm::cl::opt
Definition:CommandLine.h:1423
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition:STLFunctionalExtras.h:37
llvm::M68k::MemAddrModeKind::U
@ U
llvm::cl::Hidden
@ Hidden
Definition:CommandLine.h:137
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition:CommandLine.h:443
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::DetermineUseCaptureKind
UseCaptureKind DetermineUseCaptureKind(const Use &U, llvm::function_ref< bool(Value *, const DataLayout &)> IsDereferenceableOrNull)
Determine what kind of capture behaviour U may exhibit.
Definition:CaptureTracking.cpp:277
llvm::PointerMayBeCapturedBefore
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, bool StoreCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI=false, unsigned MaxUsesToExplore=0, const LoopInfo *LI=nullptr)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
Definition:CaptureTracking.cpp:237
llvm::isNoAliasCall
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
Definition:AliasAnalysis.cpp:801
llvm::isNonEscapingLocalObject
bool isNonEscapingLocalObject(const Value *V, SmallDenseMap< const Value *, bool, 8 > *IsCapturedCache=nullptr)
Returns true if the pointer is to a function-local object that never escapes from the function.
Definition:CaptureTracking.cpp:458
llvm::getDefaultMaxUsesToExploreForCaptureTracking
unsigned getDefaultMaxUsesToExploreForCaptureTracking()
getDefaultMaxUsesToExploreForCaptureTracking - Return default value of the maximal number of uses to ...
Definition:CaptureTracking.cpp:51
llvm::isIntrinsicReturningPointerAliasingArgumentWithoutCapturing
bool isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(const CallBase *Call, bool MustPreserveNullness)
{launder,strip}.invariant.group returns pointer that aliases its argument, and it only captures point...
Definition:ValueTracking.cpp:6712
llvm::PointerMayBeCaptured
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures, bool StoreCaptures, unsigned MaxUsesToExplore=0)
PointerMayBeCaptured - Return true if this pointer value may be captured by the enclosing function (w...
Definition:CaptureTracking.cpp:204
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::FindEarliestCapture
Instruction * FindEarliestCapture(const Value *V, Function &F, bool ReturnCaptures, bool StoreCaptures, const DominatorTree &DT, unsigned MaxUsesToExplore=0)
Definition:CaptureTracking.cpp:261
llvm::isIdentifiedFunctionLocal
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
Definition:AliasAnalysis.cpp:825
llvm::UseCaptureKind
UseCaptureKind
Types of use capture kinds, see DetermineUseCaptureKind.
Definition:CaptureTracking.h:109
llvm::UseCaptureKind::NO_CAPTURE
@ NO_CAPTURE
llvm::UseCaptureKind::MAY_CAPTURE
@ MAY_CAPTURE
llvm::UseCaptureKind::PASSTHROUGH
@ PASSTHROUGH
llvm::isPotentiallyReachable
bool isPotentiallyReachable(const Instruction *From, const Instruction *To, const SmallPtrSetImpl< BasicBlock * > *ExclusionSet=nullptr, const DominatorTree *DT=nullptr, const LoopInfo *LI=nullptr)
Determine whether instruction 'To' is reachable from 'From', without passing through any blocks in Ex...
Definition:CFG.cpp:281
llvm::CaptureTracker
This callback is used in conjunction with PointerMayBeCaptured.
Definition:CaptureTracking.h:83
llvm::CaptureTracker::shouldExplore
virtual bool shouldExplore(const Use *U)
shouldExplore - This is the use of a value derived from the pointer.
Definition:CaptureTracking.cpp:57
llvm::CaptureTracker::isDereferenceableOrNull
virtual bool isDereferenceableOrNull(Value *O, const DataLayout &DL)
isDereferenceableOrNull - Overload to allow clients with additional knowledge about pointer dereferen...
Definition:CaptureTracking.cpp:59
llvm::CaptureTracker::tooManyUses
virtual void tooManyUses()=0
tooManyUses - The depth of traversal has breached a limit.
llvm::CaptureTracker::~CaptureTracker
virtual ~CaptureTracker()
llvm::CaptureTracker::captured
virtual bool captured(const Use *U)=0
captured - Information about the pointer was captured by the user of use U.
llvm::cl::desc
Definition:CommandLine.h:409

Generated on Thu Jul 17 2025 10:49:32 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp