1414#define LLVM_ANALYSIS_CAPTURETRACKING_H
1515
1616#include " llvm/ADT/DenseMap.h"
17- #include " llvm/Support/ModRef.h"
1817
1918namespace llvm {
2019
2120 class Value ;
2221 class Use ;
23- class CaptureInfo ;
2422 class DataLayout ;
2523 class Instruction ;
2624 class DominatorTree ;
@@ -79,47 +77,10 @@ namespace llvm {
7977 const DominatorTree &DT,
8078 unsigned MaxUsesToExplore = 0 );
8179
82- // / Capture information for a specific Use.
83- struct UseCaptureInfo {
84- // / Components captured by this use.
85- CaptureComponents UseCC;
86- // / Components captured by the return value of the user of this Use.
87- CaptureComponents ResultCC;
88-
89- UseCaptureInfo (CaptureComponents UseCC,
90- CaptureComponents ResultCC = CaptureComponents::None)
91- : UseCC(UseCC), ResultCC(ResultCC) {}
92-
93- static UseCaptureInfo passthrough () {
94- return UseCaptureInfo (CaptureComponents::None, CaptureComponents::All);
95- }
96-
97- bool isPassthrough () const {
98- return capturesNothing (UseCC) && capturesAnything (ResultCC);
99- }
100-
101- operator CaptureComponents () const { return UseCC | ResultCC; }
102- };
103-
10480 // / This callback is used in conjunction with PointerMayBeCaptured. In
10581 // / addition to the interface here, you'll need to provide your own getters
10682 // / to see whether anything was captured.
10783 struct CaptureTracker {
108- // / Action returned from captures().
109- enum Action {
110- // / Stop the traversal.
111- Stop,
112- // / Continue traversal, and also follow the return value of the user if
113- // / it has additional capture components (that is, if it has capture
114- // / components in Ret that are not part of Other).
115- Continue,
116- // / Continue traversal, but do not follow the return value of the user,
117- // / even if it has additional capture components. Should only be used if
118- // / captures() has already taken the potential return captures into
119- // / account.
120- ContinueIgnoringReturn,
121- };
122-
12384 virtual ~CaptureTracker ();
12485
12586 // / tooManyUses - The depth of traversal has breached a limit. There may be
@@ -133,31 +94,32 @@ namespace llvm {
13394 // / U->getUser() is always an Instruction.
13495 virtual bool shouldExplore (const Use *U);
13596
136- // / Use U directly captures CI.UseCC and additionally CI.ResultCC
137- // / through the return value of the user of U.
138- // /
139- // / Return one of Stop, Continue or ContinueIgnoringReturn to control
140- // / further traversal.
141- virtual Action captured (const Use *U, UseCaptureInfo CI) = 0;
97+ // / captured - Information about the pointer was captured by the user of
98+ // / use U. Return true to stop the traversal or false to continue looking
99+ // / for more capturing instructions.
100+ virtual bool captured (const Use *U) = 0;
142101
143102 // / isDereferenceableOrNull - Overload to allow clients with additional
144103 // / knowledge about pointer dereferenceability to provide it and thereby
145104 // / avoid conservative responses when a pointer is compared to null.
146105 virtual bool isDereferenceableOrNull (Value *O, const DataLayout &DL);
147106 };
148107
108+ // / Types of use capture kinds, see \p DetermineUseCaptureKind.
109+ enum class UseCaptureKind {
110+ NO_CAPTURE,
111+ MAY_CAPTURE,
112+ PASSTHROUGH,
113+ };
114+
149115 // / Determine what kind of capture behaviour \p U may exhibit.
150116 // /
151- // / The returned UseCaptureInfo contains the components captured directly
152- // / by the use (UseCC) and the components captured through the return value
153- // / of the user (ResultCC).
154- // /
155- // / \p Base is the starting value of the capture analysis, which is
156- // / relevant for address_is_null captures.
117+ // / A use can be no-capture, a use can potentially capture, or a use can be
118+ // / passthrough such that the uses of the user or \p U should be inspected.
157119 // / The \p IsDereferenceableOrNull callback is used to rule out capturing for
158120 // / certain comparisons.
159- UseCaptureInfo
160- DetermineUseCaptureKind (const Use &U, const Value *Base,
121+ UseCaptureKind
122+ DetermineUseCaptureKind (const Use &U,
161123 llvm::function_ref<bool (Value *, const DataLayout &)>
162124 IsDereferenceableOrNull);
163125
0 commit comments