Skip to content

Commit a693cca

Browse files
Camsynvar-const
authored andcommitted
[CaptureTracking][NFC] Clarify usage expectations in PointerMayBeCaptured comments (llvm#132744)
Fixes issue llvm#132739. CaptureAnalysis only considers captures through the def-use chain of the provided pointer, explicitly excluding captures of underlying values or implicit captures like those involving external globals. The previous comment for `PointerMayBeCaptured` did not clearly state this limitation, leading to its incorrect usage in files such as ThreadSanitizer.cpp and SanitizerMetadata.cpp. This PR addresses this by refining the comments for the relevant APIs within `PointerMayBeCaptured` to explicitly document this behavior.
1 parent 9c8d8b2 commit a693cca

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

llvm/include/llvm/Analysis/CaptureTracking.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ namespace llvm {
4141
/// MaxUsesToExplore specifies how many uses the analysis should explore for
4242
/// one value before giving up due too "too many uses". If MaxUsesToExplore
4343
/// is zero, a default value is assumed.
44+
/// This function only considers captures of the passed value via its def-use
45+
/// chain, without considering captures of values it may be based on, or
46+
/// implicit captures such as for external globals.
4447
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures,
4548
unsigned MaxUsesToExplore = 0);
4649

4750
/// Return which components of the pointer may be captured. Only consider
4851
/// components that are part of \p Mask. Once \p StopFn on the accumulated
4952
/// components returns true, the traversal is aborted early. By default, this
5053
/// happens when *any* of the components in \p Mask are captured.
54+
/// This function only considers captures of the passed value via its def-use
55+
/// chain, without considering captures of values it may be based on, or
56+
/// implicit captures such as for external globals.
5157
CaptureComponents PointerMayBeCaptured(
5258
const Value *V, bool ReturnCaptures, CaptureComponents Mask,
5359
function_ref<bool(CaptureComponents)> StopFn = capturesAnything,
@@ -64,6 +70,9 @@ namespace llvm {
6470
/// MaxUsesToExplore specifies how many uses the analysis should explore for
6571
/// one value before giving up due too "too many uses". If MaxUsesToExplore
6672
/// is zero, a default value is assumed.
73+
/// This function only considers captures of the passed value via its def-use
74+
/// chain, without considering captures of values it may be based on, or
75+
/// implicit captures such as for external globals.
6776
bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures,
6877
const Instruction *I, const DominatorTree *DT,
6978
bool IncludeI = false,
@@ -75,6 +84,9 @@ namespace llvm {
7584
/// on the accumulated components returns true, the traversal is aborted
7685
/// early. By default, this happens when *any* of the components in \p Mask
7786
/// are captured.
87+
/// This function only considers captures of the passed value via its def-use
88+
/// chain, without considering captures of values it may be based on, or
89+
/// implicit captures such as for external globals.
7890
CaptureComponents PointerMayBeCapturedBefore(
7991
const Value *V, bool ReturnCaptures, const Instruction *I,
8092
const DominatorTree *DT, bool IncludeI, CaptureComponents Mask,
@@ -184,6 +196,9 @@ namespace llvm {
184196
/// MaxUsesToExplore specifies how many uses the analysis should explore for
185197
/// one value before giving up due too "too many uses". If MaxUsesToExplore
186198
/// is zero, a default value is assumed.
199+
/// This function only considers captures of the passed value via its def-use
200+
/// chain, without considering captures of values it may be based on, or
201+
/// implicit captures such as for external globals.
187202
void PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker,
188203
unsigned MaxUsesToExplore = 0);
189204

0 commit comments

Comments
 (0)