14
14
#define LLVM_ANALYSIS_CAPTURETRACKING_H
15
15
16
16
#include " llvm/ADT/DenseMap.h"
17
- #include " llvm/Support/ModRef.h"
18
17
19
18
namespace llvm {
20
19
21
20
class Value ;
22
21
class Use ;
23
- class CaptureInfo ;
24
22
class DataLayout ;
25
23
class Instruction ;
26
24
class DominatorTree ;
@@ -79,47 +77,10 @@ namespace llvm {
79
77
const DominatorTree &DT,
80
78
unsigned MaxUsesToExplore = 0 );
81
79
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
-
104
80
// / This callback is used in conjunction with PointerMayBeCaptured. In
105
81
// / addition to the interface here, you'll need to provide your own getters
106
82
// / to see whether anything was captured.
107
83
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
-
123
84
virtual ~CaptureTracker ();
124
85
125
86
// / tooManyUses - The depth of traversal has breached a limit. There may be
@@ -133,31 +94,32 @@ namespace llvm {
133
94
// / U->getUser() is always an Instruction.
134
95
virtual bool shouldExplore (const Use *U);
135
96
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;
142
101
143
102
// / isDereferenceableOrNull - Overload to allow clients with additional
144
103
// / knowledge about pointer dereferenceability to provide it and thereby
145
104
// / avoid conservative responses when a pointer is compared to null.
146
105
virtual bool isDereferenceableOrNull (Value *O, const DataLayout &DL);
147
106
};
148
107
108
+ // / Types of use capture kinds, see \p DetermineUseCaptureKind.
109
+ enum class UseCaptureKind {
110
+ NO_CAPTURE,
111
+ MAY_CAPTURE,
112
+ PASSTHROUGH,
113
+ };
114
+
149
115
// / Determine what kind of capture behaviour \p U may exhibit.
150
116
// /
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.
157
119
// / The \p IsDereferenceableOrNull callback is used to rule out capturing for
158
120
// / certain comparisons.
159
- UseCaptureInfo
160
- DetermineUseCaptureKind (const Use &U, const Value *Base,
121
+ UseCaptureKind
122
+ DetermineUseCaptureKind (const Use &U,
161
123
llvm::function_ref<bool (Value *, const DataLayout &)>
162
124
IsDereferenceableOrNull);
163
125
0 commit comments