Skip to content

[CaptureTracking][NFC] Clarify usage expectations in PointerMayBeCaptured comments #132744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 14, 2025
15 changes: 15 additions & 0 deletions llvm/include/llvm/Analysis/CaptureTracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ namespace llvm {
/// MaxUsesToExplore specifies how many uses the analysis should explore for
/// one value before giving up due too "too many uses". If MaxUsesToExplore
/// is zero, a default value is assumed.
/// This function only considers captures of the passed value via its def-use
/// chain, without considering captures of values it may be based on, or
/// implicit captures such as for external globals.
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures,
unsigned MaxUsesToExplore = 0);

/// Return which components of the pointer may be captured. Only consider
/// components that are part of \p Mask. Once \p StopFn on the accumulated
/// components returns true, the traversal is aborted early. By default, this
/// happens when *any* of the components in \p Mask are captured.
/// This function only considers captures of the passed value via its def-use
/// chain, without considering captures of values it may be based on, or
/// implicit captures such as for external globals.
CaptureComponents PointerMayBeCaptured(
const Value *V, bool ReturnCaptures, CaptureComponents Mask,
function_ref<bool(CaptureComponents)> StopFn = capturesAnything,
Expand All @@ -64,6 +70,9 @@ namespace llvm {
/// MaxUsesToExplore specifies how many uses the analysis should explore for
/// one value before giving up due too "too many uses". If MaxUsesToExplore
/// is zero, a default value is assumed.
/// This function only considers captures of the passed value via its def-use
/// chain, without considering captures of values it may be based on, or
/// implicit captures such as for external globals.
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
const Instruction *I, const DominatorTree *DT,
bool IncludeI = false,
Expand All @@ -75,6 +84,9 @@ namespace llvm {
/// on the accumulated components returns true, the traversal is aborted
/// early. By default, this happens when *any* of the components in \p Mask
/// are captured.
/// This function only considers captures of the passed value via its def-use
/// chain, without considering captures of values it may be based on, or
/// implicit captures such as for external globals.
CaptureComponents PointerMayBeCapturedBefore(
const Value *V, bool ReturnCaptures, const Instruction *I,
const DominatorTree *DT, bool IncludeI, CaptureComponents Mask,
Expand Down Expand Up @@ -184,6 +196,9 @@ namespace llvm {
/// MaxUsesToExplore specifies how many uses the analysis should explore for
/// one value before giving up due too "too many uses". If MaxUsesToExplore
/// is zero, a default value is assumed.
/// This function only considers captures of the passed value via its def-use
/// chain, without considering captures of values it may be based on, or
/// implicit captures such as for external globals.
void PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker,
unsigned MaxUsesToExplore = 0);

Expand Down
Loading