LLVM  16.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 
19 #include "llvm/ADT/SmallPtrSet.h"
20 #include "llvm/ADT/SmallSet.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/Statistic.h"
24 #include "llvm/Analysis/CFG.h"
26 #include "llvm/IR/Constants.h"
27 #include "llvm/IR/Dominators.h"
28 #include "llvm/IR/Instructions.h"
29 #include "llvm/IR/IntrinsicInst.h"
31 
32 using namespace llvm;
33 
34 #define DEBUG_TYPE "capture-tracking"
35 
36 STATISTIC(NumCaptured, "Number of pointers maybe captured");
37 STATISTIC(NumNotCaptured, "Number of pointers not captured");
38 STATISTIC(NumCapturedBefore, "Number of pointers maybe captured before");
39 STATISTIC(NumNotCapturedBefore, "Number of pointers not captured before");
40 
41 /// The default value for MaxUsesToExplore argument. It's relatively small to
42 /// keep the cost of analysis reasonable for clients like BasicAliasAnalysis,
43 /// where the results can't be cached.
44 /// TODO: we should probably introduce a caching CaptureTracking analysis and
45 /// use it where possible. The caching version can use much higher limit or
46 /// don't have this cap at all.
47 static cl::opt<unsigned>
48  DefaultMaxUsesToExplore("capture-tracking-max-uses-to-explore", cl::Hidden,
49  cl::desc("Maximal number of uses to explore."),
50  cl::init(100));
51 
54 }
55 
57 
58 bool CaptureTracker::shouldExplore(const Use *U) { return true; }
59 
61  // An inbounds GEP can either be a valid pointer (pointing into
62  // or to the end of an allocation), or be null in the default
63  // address space. So for an inbounds GEP there is no way to let
64  // the pointer escape using clever GEP hacking because doing so
65  // would make the pointer point outside of the allocated object
66  // and thus make the GEP result a poison value. Similarly, other
67  // dereferenceable pointers cannot be manipulated without producing
68  // poison.
69  if (auto *GEP = dyn_cast<GetElementPtrInst>(O))
70  if (GEP->isInBounds())
71  return true;
72  bool CanBeNull, CanBeFreed;
73  return O->getPointerDereferenceableBytes(DL, CanBeNull, CanBeFreed);
74 }
75 
76 namespace {
77  struct SimpleCaptureTracker : public CaptureTracker {
78  explicit SimpleCaptureTracker(
79 
80  const SmallPtrSetImpl<const Value *> &EphValues, bool ReturnCaptures)
81  : EphValues(EphValues), ReturnCaptures(ReturnCaptures) {}
82 
83  void tooManyUses() override { Captured = true; }
84 
85  bool captured(const Use *U) override {
86  if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
87  return false;
88 
89  if (EphValues.contains(U->getUser()))
90  return false;
91 
92  Captured = true;
93  return true;
94  }
95 
96  const SmallPtrSetImpl<const Value *> &EphValues;
97 
98  bool ReturnCaptures;
99 
100  bool Captured = false;
101  };
102 
103  /// Only find pointer captures which happen before the given instruction. Uses
104  /// the dominator tree to determine whether one instruction is before another.
105  /// Only support the case where the Value is defined in the same basic block
106  /// as the given instruction and the use.
107  struct CapturesBefore : public CaptureTracker {
108 
109  CapturesBefore(bool ReturnCaptures, const Instruction *I,
110  const DominatorTree *DT, bool IncludeI, const LoopInfo *LI)
111  : BeforeHere(I), DT(DT), ReturnCaptures(ReturnCaptures),
112  IncludeI(IncludeI), LI(LI) {}
113 
114  void tooManyUses() override { Captured = true; }
115 
116  bool isSafeToPrune(Instruction *I) {
117  if (BeforeHere == I)
118  return !IncludeI;
119 
120  // We explore this usage only if the usage can reach "BeforeHere".
121  // If use is not reachable from entry, there is no need to explore.
122  if (!DT->isReachableFromEntry(I->getParent()))
123  return true;
124 
125  // Check whether there is a path from I to BeforeHere.
126  return !isPotentiallyReachable(I, BeforeHere, nullptr, DT, LI);
127  }
128 
129  bool captured(const Use *U) override {
130  Instruction *I = cast<Instruction>(U->getUser());
131  if (isa<ReturnInst>(I) && !ReturnCaptures)
132  return false;
133 
134  // Check isSafeToPrune() here rather than in shouldExplore() to avoid
135  // an expensive reachability query for every instruction we look at.
136  // Instead we only do one for actual capturing candidates.
137  if (isSafeToPrune(I))
138  return false;
139 
140  Captured = true;
141  return true;
142  }
143 
144  const Instruction *BeforeHere;
145  const DominatorTree *DT;
146 
147  bool ReturnCaptures;
148  bool IncludeI;
149 
150  bool Captured = false;
151 
152  const LoopInfo *LI;
153  };
154 
155  /// Find the 'earliest' instruction before which the pointer is known not to
156  /// be captured. Here an instruction A is considered earlier than instruction
157  /// B, if A dominates B. If 2 escapes do not dominate each other, the
158  /// terminator of the common dominator is chosen. If not all uses cannot be
159  /// analyzed, the earliest escape is set to the first instruction in the
160  /// function entry block.
161  // NOTE: Users have to make sure instructions compared against the earliest
162  // escape are not in a cycle.
163  struct EarliestCaptures : public CaptureTracker {
164 
165  EarliestCaptures(bool ReturnCaptures, Function &F, const DominatorTree &DT,
166  const SmallPtrSetImpl<const Value *> &EphValues)
167  : EphValues(EphValues), DT(DT), ReturnCaptures(ReturnCaptures), F(F) {}
168 
169  void tooManyUses() override {
170  Captured = true;
171  EarliestCapture = &*F.getEntryBlock().begin();
172  }
173 
174  bool captured(const Use *U) override {
175  Instruction *I = cast<Instruction>(U->getUser());
176  if (isa<ReturnInst>(I) && !ReturnCaptures)
177  return false;
178 
179  if (EphValues.contains(I))
180  return false;
181 
182  if (!EarliestCapture) {
183  EarliestCapture = I;
184  } else if (EarliestCapture->getParent() == I->getParent()) {
185  if (I->comesBefore(EarliestCapture))
186  EarliestCapture = I;
187  } else {
188  BasicBlock *CurrentBB = I->getParent();
189  BasicBlock *EarliestBB = EarliestCapture->getParent();
190  if (DT.dominates(EarliestBB, CurrentBB)) {
191  // EarliestCapture already comes before the current use.
192  } else if (DT.dominates(CurrentBB, EarliestBB)) {
193  EarliestCapture = I;
194  } else {
195  // Otherwise find the nearest common dominator and use its terminator.
196  auto *NearestCommonDom =
197  DT.findNearestCommonDominator(CurrentBB, EarliestBB);
198  EarliestCapture = NearestCommonDom->getTerminator();
199  }
200  }
201  Captured = true;
202 
203  // Return false to continue analysis; we need to see all potential
204  // captures.
205  return false;
206  }
207 
208  const SmallPtrSetImpl<const Value *> &EphValues;
209 
210  Instruction *EarliestCapture = nullptr;
211 
212  const DominatorTree &DT;
213 
214  bool ReturnCaptures;
215 
216  bool Captured = false;
217 
218  Function &F;
219  };
220 }
221 
222 /// PointerMayBeCaptured - Return true if this pointer value may be captured
223 /// by the enclosing function (which is required to exist). This routine can
224 /// be expensive, so consider caching the results. The boolean ReturnCaptures
225 /// specifies whether returning the value (or part of it) from the function
226 /// counts as capturing it or not. The boolean StoreCaptures specified whether
227 /// storing the value (or part of it) into memory anywhere automatically
228 /// counts as capturing it or not.
229 bool llvm::PointerMayBeCaptured(const Value *V, bool ReturnCaptures,
230  bool StoreCaptures, unsigned MaxUsesToExplore) {
232  return PointerMayBeCaptured(V, ReturnCaptures, StoreCaptures, Empty,
233  MaxUsesToExplore);
234 }
235 
236 /// Variant of the above function which accepts a set of Values that are
237 /// ephemeral and cannot cause pointers to escape.
238 bool llvm::PointerMayBeCaptured(const Value *V, bool ReturnCaptures,
239  bool StoreCaptures,
240  const SmallPtrSetImpl<const Value *> &EphValues,
241  unsigned MaxUsesToExplore) {
242  assert(!isa<GlobalValue>(V) &&
243  "It doesn't make sense to ask whether a global is captured.");
244 
245  // TODO: If StoreCaptures is not true, we could do Fancy analysis
246  // to determine whether this store is not actually an escape point.
247  // In that case, BasicAliasAnalysis should be updated as well to
248  // take advantage of this.
249  (void)StoreCaptures;
250 
251  SimpleCaptureTracker SCT(EphValues, ReturnCaptures);
252  PointerMayBeCaptured(V, &SCT, MaxUsesToExplore);
253  if (SCT.Captured)
254  ++NumCaptured;
255  else
256  ++NumNotCaptured;
257  return SCT.Captured;
258 }
259 
260 /// PointerMayBeCapturedBefore - Return true if this pointer value may be
261 /// captured by the enclosing function (which is required to exist). If a
262 /// DominatorTree is provided, only captures which happen before the given
263 /// instruction are considered. This routine can be expensive, so consider
264 /// caching the results. The boolean ReturnCaptures specifies whether
265 /// returning the value (or part of it) from the function counts as capturing
266 /// it or not. The boolean StoreCaptures specified whether storing the value
267 /// (or part of it) into memory anywhere automatically counts as capturing it
268 /// or not.
269 bool llvm::PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
270  bool StoreCaptures, const Instruction *I,
271  const DominatorTree *DT, bool IncludeI,
272  unsigned MaxUsesToExplore,
273  const LoopInfo *LI) {
274  assert(!isa<GlobalValue>(V) &&
275  "It doesn't make sense to ask whether a global is captured.");
276 
277  if (!DT)
278  return PointerMayBeCaptured(V, ReturnCaptures, StoreCaptures,
279  MaxUsesToExplore);
280 
281  // TODO: See comment in PointerMayBeCaptured regarding what could be done
282  // with StoreCaptures.
283 
284  CapturesBefore CB(ReturnCaptures, I, DT, IncludeI, LI);
285  PointerMayBeCaptured(V, &CB, MaxUsesToExplore);
286  if (CB.Captured)
287  ++NumCapturedBefore;
288  else
289  ++NumNotCapturedBefore;
290  return CB.Captured;
291 }
292 
293 Instruction *
294 llvm::FindEarliestCapture(const Value *V, Function &F, bool ReturnCaptures,
295  bool StoreCaptures, const DominatorTree &DT,
296 
297  const SmallPtrSetImpl<const Value *> &EphValues,
298  unsigned MaxUsesToExplore) {
299  assert(!isa<GlobalValue>(V) &&
300  "It doesn't make sense to ask whether a global is captured.");
301 
302  EarliestCaptures CB(ReturnCaptures, F, DT, EphValues);
303  PointerMayBeCaptured(V, &CB, MaxUsesToExplore);
304  if (CB.Captured)
305  ++NumCapturedBefore;
306  else
307  ++NumNotCapturedBefore;
308  return CB.EarliestCapture;
309 }
310 
312  const Use &U,
313  function_ref<bool(Value *, const DataLayout &)> IsDereferenceableOrNull) {
314  Instruction *I = cast<Instruction>(U.getUser());
315 
316  switch (I->getOpcode()) {
317  case Instruction::Call:
318  case Instruction::Invoke: {
319  auto *Call = cast<CallBase>(I);
320  // Not captured if the callee is readonly, doesn't return a copy through
321  // its return value and doesn't unwind (a readonly function can leak bits
322  // by throwing an exception or not depending on the input value).
323  if (Call->onlyReadsMemory() && Call->doesNotThrow() &&
324  Call->getType()->isVoidTy())
326 
327  // The pointer is not captured if returned pointer is not captured.
328  // NOTE: CaptureTracking users should not assume that only functions
329  // marked with nocapture do not capture. This means that places like
330  // getUnderlyingObject in ValueTracking or DecomposeGEPExpression
331  // in BasicAA also need to know about this property.
334 
335  // Volatile operations effectively capture the memory location that they
336  // load and store to.
337  if (auto *MI = dyn_cast<MemIntrinsic>(Call))
338  if (MI->isVolatile())
340 
341  // Calling a function pointer does not in itself cause the pointer to
342  // be captured. This is a subtle point considering that (for example)
343  // the callee might return its own address. It is analogous to saying
344  // that loading a value from a pointer does not cause the pointer to be
345  // captured, even though the loaded value might be the pointer itself
346  // (think of self-referential objects).
347  if (Call->isCallee(&U))
349 
350  // Not captured if only passed via 'nocapture' arguments.
351  if (Call->isDataOperand(&U) &&
352  !Call->doesNotCapture(Call->getDataOperandNo(&U))) {
353  // The parameter is not marked 'nocapture' - captured.
355  }
357  }
358  case Instruction::Load:
359  // Volatile loads make the address observable.
360  if (cast<LoadInst>(I)->isVolatile())
363  case Instruction::VAArg:
364  // "va-arg" from a pointer does not cause it to be captured.
366  case Instruction::Store:
367  // Stored the pointer - conservatively assume it may be captured.
368  // Volatile stores make the address observable.
369  if (U.getOperandNo() == 0 || cast<StoreInst>(I)->isVolatile())
372  case Instruction::AtomicRMW: {
373  // atomicrmw conceptually includes both a load and store from
374  // the same location.
375  // As with a store, the location being accessed is not captured,
376  // but the value being stored is.
377  // Volatile stores make the address observable.
378  auto *ARMWI = cast<AtomicRMWInst>(I);
379  if (U.getOperandNo() == 1 || ARMWI->isVolatile())
382  }
383  case Instruction::AtomicCmpXchg: {
384  // cmpxchg conceptually includes both a load and store from
385  // the same location.
386  // As with a store, the location being accessed is not captured,
387  // but the value being stored is.
388  // Volatile stores make the address observable.
389  auto *ACXI = cast<AtomicCmpXchgInst>(I);
390  if (U.getOperandNo() == 1 || U.getOperandNo() == 2 || ACXI->isVolatile())
393  }
394  case Instruction::BitCast:
395  case Instruction::GetElementPtr:
396  case Instruction::PHI:
397  case Instruction::Select:
398  case Instruction::AddrSpaceCast:
399  // The original value is not captured via this if the new value isn't.
401  case Instruction::ICmp: {
402  unsigned Idx = U.getOperandNo();
403  unsigned OtherIdx = 1 - Idx;
404  if (auto *CPN = dyn_cast<ConstantPointerNull>(I->getOperand(OtherIdx))) {
405  // Don't count comparisons of a no-alias return value against null as
406  // captures. This allows us to ignore comparisons of malloc results
407  // with null, for example.
408  if (CPN->getType()->getAddressSpace() == 0)
409  if (isNoAliasCall(U.get()->stripPointerCasts()))
411  if (!I->getFunction()->nullPointerIsDefined()) {
412  auto *O = I->getOperand(Idx)->stripPointerCastsSameRepresentation();
413  // Comparing a dereferenceable_or_null pointer against null cannot
414  // lead to pointer escapes, because if it is not null it must be a
415  // valid (in-bounds) pointer.
416  const DataLayout &DL = I->getModule()->getDataLayout();
417  if (IsDereferenceableOrNull && IsDereferenceableOrNull(O, DL))
419  }
420  }
421  // Comparison against value stored in global variable. Given the pointer
422  // does not escape, its value cannot be guessed and stored separately in a
423  // global variable.
424  auto *LI = dyn_cast<LoadInst>(I->getOperand(OtherIdx));
425  if (LI && isa<GlobalVariable>(LI->getPointerOperand()))
427  // Otherwise, be conservative. There are crazy ways to capture pointers
428  // using comparisons.
430  }
431  default:
432  // Something else - be conservative and say it is captured.
434  }
435 }
436 
438  unsigned MaxUsesToExplore) {
439  assert(V->getType()->isPointerTy() && "Capture is for pointers only!");
440  if (MaxUsesToExplore == 0)
441  MaxUsesToExplore = DefaultMaxUsesToExplore;
442 
446 
447  auto AddUses = [&](const Value *V) {
448  for (const Use &U : V->uses()) {
449  // If there are lots of uses, conservatively say that the value
450  // is captured to avoid taking too much compile time.
451  if (Visited.size() >= MaxUsesToExplore) {
452  Tracker->tooManyUses();
453  return false;
454  }
455  if (!Visited.insert(&U).second)
456  continue;
457  if (!Tracker->shouldExplore(&U))
458  continue;
459  Worklist.push_back(&U);
460  }
461  return true;
462  };
463  if (!AddUses(V))
464  return;
465 
466  auto IsDereferenceableOrNull = [Tracker](Value *V, const DataLayout &DL) {
467  return Tracker->isDereferenceableOrNull(V, DL);
468  };
469  while (!Worklist.empty()) {
470  const Use *U = Worklist.pop_back_val();
471  switch (DetermineUseCaptureKind(*U, IsDereferenceableOrNull)) {
473  continue;
475  if (Tracker->captured(U))
476  return;
477  continue;
479  if (!AddUses(U->getUser()))
480  return;
481  continue;
482  }
483  }
484 
485  // All uses examined.
486 }
487 
489  const Value *V, SmallDenseMap<const Value *, bool, 8> *IsCapturedCache) {
491  if (IsCapturedCache) {
492  bool Inserted;
493  std::tie(CacheIt, Inserted) = IsCapturedCache->insert({V, false});
494  if (!Inserted)
495  // Found cached result, return it!
496  return CacheIt->second;
497  }
498 
499  // If this is an identified function-local object, check to see if it escapes.
500  if (isIdentifiedFunctionLocal(V)) {
501  // Set StoreCaptures to True so that we can assume in our callers that the
502  // pointer is not the result of a load instruction. Currently
503  // PointerMayBeCaptured doesn't have any special analysis for the
504  // StoreCaptures=false case; if it did, our callers could be refined to be
505  // more precise.
506  auto Ret = !PointerMayBeCaptured(V, false, /*StoreCaptures=*/true);
507  if (IsCapturedCache)
508  CacheIt->second = Ret;
509  return Ret;
510  }
511 
512  return false;
513 }
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:108
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::getDefaultMaxUsesToExploreForCaptureTracking
unsigned getDefaultMaxUsesToExploreForCaptureTracking()
getDefaultMaxUsesToExploreForCaptureTracking - Return default value of the maximal number of uses to ...
Definition: CaptureTracking.cpp:52
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
PHI
Rewrite undef for PHI
Definition: AMDGPURewriteUndefForPHI.cpp:101
llvm::BasicBlock::getParent
const Function * getParent() const
Return the enclosing method, or null if none.
Definition: BasicBlock.h:104
IntrinsicInst.h
llvm::Type::isPointerTy
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:223
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:488
llvm::UseCaptureKind
UseCaptureKind
Types of use capture kinds, see DetermineUseCaptureKind.
Definition: CaptureTracking.h:118
llvm::Function
Definition: Function.h:60
llvm::CaptureTracker
This callback is used in conjunction with PointerMayBeCaptured.
Definition: CaptureTracking.h:92
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1181
Statistic.h
CaptureTracking.h
llvm::CaptureTracker::captured
virtual bool captured(const Use *U)=0
captured - Information about the pointer was captured by the user of use U.
llvm::Use::get
Value * get() const
Definition: Use.h:66
llvm::SmallDenseMap
Definition: DenseMap.h:880
ValueTracking.h
llvm::DominatorTree
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition: Dominators.h:166
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:140
llvm::UseCaptureKind::MAY_CAPTURE
@ MAY_CAPTURE
llvm::DenseMapIterator
Definition: DenseMap.h:57
llvm::Use::getOperandNo
unsigned getOperandNo() const
Return the operand # of this use in its User.
Definition: Use.cpp:31
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:136
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
llvm::SPII::Load
@ Load
Definition: SparcInstrInfo.h:32
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::CaptureTracker::~CaptureTracker
virtual ~CaptureTracker()
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
AliasAnalysis.h
llvm::isIdentifiedFunctionLocal
bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
Definition: AliasAnalysis.cpp:968
CommandLine.h
llvm::UseCaptureKind::NO_CAPTURE
@ NO_CAPTURE
llvm::isNoAliasCall
bool isNoAliasCall(const Value *V)
Return true if this pointer is returned by a noalias function.
Definition: AliasAnalysis.cpp:944
Constants.h
llvm::CaptureTracker::shouldExplore
virtual bool shouldExplore(const Use *U)
shouldExplore - This is the use of a value derived from the pointer.
Definition: CaptureTracking.cpp:58
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
llvm::Value::uses
iterator_range< use_iterator > uses()
Definition: Value.h:376
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:232
llvm::Instruction
Definition: Instruction.h:42
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
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:60
llvm::Use::getUser
User * getUser() const
Returns the User that contains this Use.
Definition: Use.h:72
SmallPtrSet.h
llvm::MCID::Call
@ Call
Definition: MCInstrDesc.h:155
llvm::UseCaptureKind::PASSTHROUGH
@ PASSTHROUGH
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:311
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::cl::opt
Definition: CommandLine.h:1400
llvm::FindEarliestCapture
Instruction * FindEarliestCapture(const Value *V, Function &F, bool ReturnCaptures, bool StoreCaptures, const DominatorTree &DT, const SmallPtrSetImpl< const Value * > &EphValues, unsigned MaxUsesToExplore=0)
Definition: CaptureTracking.cpp:294
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:264
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.
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:440
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
CFG.h
llvm::LoopInfo
Definition: LoopInfo.h:1105
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:229
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:207
llvm::Value::stripPointerCasts
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition: Value.cpp:685
llvm::MCID::Select
@ Select
Definition: MCInstrDesc.h:164
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:178
Instructions.h
SmallVector.h
llvm::SmallSet::size
size_type size() const
Definition: SmallSet.h:160
Dominators.h
llvm::SmallVectorImpl::pop_back_val
T pop_back_val()
Definition: SmallVector.h:659
llvm::CaptureTracker::tooManyUses
virtual void tooManyUses()=0
tooManyUses - The depth of traversal has breached a limit.
llvm::SmallPtrSetImpl< const Value * >
GEP
Hexagon Common GEP
Definition: HexagonCommonGEP.cpp:171
llvm::cl::desc
Definition: CommandLine.h:413
llvm::SmallVectorImpl::reserve
void reserve(size_type N)
Definition: SmallVector.h:649
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:269
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
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:4458
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
SmallSet.h