Skip to content

Commit a5b35de

Browse files
committed
[AA] Rename FunctionModRefBehavior to MemoryEffects (NFC)
As part of https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579, the FunctionModRefBehavior class sees a good bit of additional use, and I've found the name to be something of a mouthful. This patch renames it to MemoryEffects, which has a couple of advantages over the old name: * It is more concise. * It decouples it from modelling only functions. * It matches the terminology of the aforementioned RFC. * The meaning should be more obvious to people not familiar with our particular AA lingo. This patch just updates the class definition. Other uses of the name will be updated separately. Differential Revision: https://reviews.llvm.org/D135962
1 parent 82c820b commit a5b35de

File tree

1 file changed

+60
-58
lines changed

1 file changed

+60
-58
lines changed

llvm/include/llvm/IR/ModRef.h

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// Definitions of ModRefInfo and FunctionModRefBehavior, which are used to
9+
// Definitions of ModRefInfo and MemoryEffects, which are used to
1010
// describe the memory effects of instructions.
1111
//
1212
//===----------------------------------------------------------------------===//
@@ -60,7 +60,7 @@ raw_ostream &operator<<(raw_ostream &OS, ModRefInfo MR);
6060
/// Loads from constant globals are not considered memory accesses for this
6161
/// interface. Also, functions may freely modify stack space local to their
6262
/// invocation without having to report it through these interfaces.
63-
class FunctionModRefBehavior {
63+
class MemoryEffects {
6464
public:
6565
/// The locations at which a function might access memory.
6666
enum Location {
@@ -87,61 +87,60 @@ class FunctionModRefBehavior {
8787
force_iteration_on_noniterable_enum);
8888
}
8989

90-
FunctionModRefBehavior(uint32_t Data) : Data(Data) {}
90+
MemoryEffects(uint32_t Data) : Data(Data) {}
9191

9292
void setModRef(Location Loc, ModRefInfo MR) {
9393
Data &= ~(LocMask << getLocationPos(Loc));
9494
Data |= static_cast<uint32_t>(MR) << getLocationPos(Loc);
9595
}
9696

97-
friend raw_ostream &operator<<(raw_ostream &OS, FunctionModRefBehavior RMRB);
97+
friend raw_ostream &operator<<(raw_ostream &OS, MemoryEffects RMRB);
9898

9999
public:
100-
/// Create FunctionModRefBehavior that can access only the given location
101-
/// with the given ModRefInfo.
102-
FunctionModRefBehavior(Location Loc, ModRefInfo MR) { setModRef(Loc, MR); }
103-
104-
/// Create FunctionModRefBehavior that can access any location with the
100+
/// Create MemoryEffects that can access only the given location with the
105101
/// given ModRefInfo.
106-
explicit FunctionModRefBehavior(ModRefInfo MR) {
102+
MemoryEffects(Location Loc, ModRefInfo MR) { setModRef(Loc, MR); }
103+
104+
/// Create MemoryEffects that can access any location with the given
105+
/// ModRefInfo.
106+
explicit MemoryEffects(ModRefInfo MR) {
107107
for (Location Loc : locations())
108108
setModRef(Loc, MR);
109109
}
110110

111-
/// Create FunctionModRefBehavior that can read and write any memory.
112-
static FunctionModRefBehavior unknown() {
113-
return FunctionModRefBehavior(ModRefInfo::ModRef);
111+
/// Create MemoryEffects that can read and write any memory.
112+
static MemoryEffects unknown() {
113+
return MemoryEffects(ModRefInfo::ModRef);
114114
}
115115

116-
/// Create FunctionModRefBehavior that cannot read or write any memory.
117-
static FunctionModRefBehavior none() {
118-
return FunctionModRefBehavior(ModRefInfo::NoModRef);
116+
/// Create MemoryEffects that cannot read or write any memory.
117+
static MemoryEffects none() {
118+
return MemoryEffects(ModRefInfo::NoModRef);
119119
}
120120

121-
/// Create FunctionModRefBehavior that can read any memory.
122-
static FunctionModRefBehavior readOnly() {
123-
return FunctionModRefBehavior(ModRefInfo::Ref);
121+
/// Create MemoryEffects that can read any memory.
122+
static MemoryEffects readOnly() {
123+
return MemoryEffects(ModRefInfo::Ref);
124124
}
125125

126-
/// Create FunctionModRefBehavior that can write any memory.
127-
static FunctionModRefBehavior writeOnly() {
128-
return FunctionModRefBehavior(ModRefInfo::Mod);
126+
/// Create MemoryEffects that can write any memory.
127+
static MemoryEffects writeOnly() {
128+
return MemoryEffects(ModRefInfo::Mod);
129129
}
130130

131-
/// Create FunctionModRefBehavior that can only access argument memory.
132-
static FunctionModRefBehavior argMemOnly(ModRefInfo MR) {
133-
return FunctionModRefBehavior(ArgMem, MR);
131+
/// Create MemoryEffects that can only access argument memory.
132+
static MemoryEffects argMemOnly(ModRefInfo MR) {
133+
return MemoryEffects(ArgMem, MR);
134134
}
135135

136-
/// Create FunctionModRefBehavior that can only access inaccessible memory.
137-
static FunctionModRefBehavior inaccessibleMemOnly(ModRefInfo MR) {
138-
return FunctionModRefBehavior(InaccessibleMem, MR);
136+
/// Create MemoryEffects that can only access inaccessible memory.
137+
static MemoryEffects inaccessibleMemOnly(ModRefInfo MR) {
138+
return MemoryEffects(InaccessibleMem, MR);
139139
}
140140

141-
/// Create FunctionModRefBehavior that can only access inaccessible or
142-
/// argument memory.
143-
static FunctionModRefBehavior inaccessibleOrArgMemOnly(ModRefInfo MR) {
144-
FunctionModRefBehavior FRMB = none();
141+
/// Create MemoryEffects that can only access inaccessible or argument memory.
142+
static MemoryEffects inaccessibleOrArgMemOnly(ModRefInfo MR) {
143+
MemoryEffects FRMB = none();
145144
FRMB.setModRef(ArgMem, MR);
146145
FRMB.setModRef(InaccessibleMem, MR);
147146
return FRMB;
@@ -152,18 +151,18 @@ class FunctionModRefBehavior {
152151
return ModRefInfo((Data >> getLocationPos(Loc)) & LocMask);
153152
}
154153

155-
/// Get new FunctionModRefBehavior with modified ModRefInfo for Loc.
156-
FunctionModRefBehavior getWithModRef(Location Loc, ModRefInfo MR) const {
157-
FunctionModRefBehavior FMRB = *this;
158-
FMRB.setModRef(Loc, MR);
159-
return FMRB;
154+
/// Get new MemoryEffects with modified ModRefInfo for Loc.
155+
MemoryEffects getWithModRef(Location Loc, ModRefInfo MR) const {
156+
MemoryEffects ME = *this;
157+
ME.setModRef(Loc, MR);
158+
return ME;
160159
}
161160

162-
/// Get new FunctionModRefBehavior with NoModRef on the given Loc.
163-
FunctionModRefBehavior getWithoutLoc(Location Loc) const {
164-
FunctionModRefBehavior FMRB = *this;
165-
FMRB.setModRef(Loc, ModRefInfo::NoModRef);
166-
return FMRB;
161+
/// Get new MemoryEffects with NoModRef on the given Loc.
162+
MemoryEffects getWithoutLoc(Location Loc) const {
163+
MemoryEffects ME = *this;
164+
ME.setModRef(Loc, ModRefInfo::NoModRef);
165+
return ME;
167166
}
168167

169168
/// Get ModRefInfo for any location.
@@ -204,41 +203,44 @@ class FunctionModRefBehavior {
204203
return isNoModRef(getModRef(Other));
205204
}
206205

207-
/// Intersect with another FunctionModRefBehavior.
208-
FunctionModRefBehavior operator&(FunctionModRefBehavior Other) const {
209-
return FunctionModRefBehavior(Data & Other.Data);
206+
/// Intersect with other MemoryEffects.
207+
MemoryEffects operator&(MemoryEffects Other) const {
208+
return MemoryEffects(Data & Other.Data);
210209
}
211210

212-
/// Intersect (in-place) with another FunctionModRefBehavior.
213-
FunctionModRefBehavior &operator&=(FunctionModRefBehavior Other) {
211+
/// Intersect (in-place) with other MemoryEffects.
212+
MemoryEffects &operator&=(MemoryEffects Other) {
214213
Data &= Other.Data;
215214
return *this;
216215
}
217216

218-
/// Union with another FunctionModRefBehavior.
219-
FunctionModRefBehavior operator|(FunctionModRefBehavior Other) const {
220-
return FunctionModRefBehavior(Data | Other.Data);
217+
/// Union with other MemoryEffects.
218+
MemoryEffects operator|(MemoryEffects Other) const {
219+
return MemoryEffects(Data | Other.Data);
221220
}
222221

223-
/// Union (in-place) with another FunctionModRefBehavior.
224-
FunctionModRefBehavior &operator|=(FunctionModRefBehavior Other) {
222+
/// Union (in-place) with other MemoryEffects.
223+
MemoryEffects &operator|=(MemoryEffects Other) {
225224
Data |= Other.Data;
226225
return *this;
227226
}
228227

229-
/// Check whether this is the same as another FunctionModRefBehavior.
230-
bool operator==(FunctionModRefBehavior Other) const {
228+
/// Check whether this is the same as other MemoryEffects.
229+
bool operator==(MemoryEffects Other) const {
231230
return Data == Other.Data;
232231
}
233232

234-
/// Check whether this is different from another FunctionModRefBehavior.
235-
bool operator!=(FunctionModRefBehavior Other) const {
233+
/// Check whether this is different from other MemoryEffects.
234+
bool operator!=(MemoryEffects Other) const {
236235
return !operator==(Other);
237236
}
238237
};
239238

240-
/// Debug print FunctionModRefBehavior.
241-
raw_ostream &operator<<(raw_ostream &OS, FunctionModRefBehavior RMRB);
239+
/// Debug print MemoryEffects.
240+
raw_ostream &operator<<(raw_ostream &OS, MemoryEffects RMRB);
241+
242+
// Legacy alias.
243+
using FunctionModRefBehavior = MemoryEffects;
242244

243245
} // namespace llvm
244246

0 commit comments

Comments
 (0)