@@ -80,11 +80,7 @@ class LocationSize {
8080
8181 uint64_t Value;
8282
83- // Hack to support implicit construction. This should disappear when the
84- // public LocationSize ctor goes away.
85- enum DirectConstruction { Direct };
86-
87- constexpr LocationSize (uint64_t Raw, DirectConstruction) : Value(Raw) {}
83+ constexpr LocationSize (uint64_t Raw) : Value(Raw) {}
8884 constexpr LocationSize (uint64_t Raw, bool Scalable)
8985 : Value(Raw > MaxValue ? AfterPointer
9086 : Raw | (Scalable ? ScalableBit : uint64_t (0 ))) {}
@@ -96,14 +92,6 @@ class LocationSize {
9692 static_assert (~(MaxValue & ScalableBit), " Max value don't have bit 62 set" );
9793
9894public:
99- // FIXME: Migrate all users to construct via either `precise` or `upperBound`,
100- // to make it more obvious at the callsite the kind of size that they're
101- // providing.
102- //
103- // Since the overwhelming majority of users of this provide precise values,
104- // this assumes the provided value is precise.
105- constexpr LocationSize (uint64_t Raw)
106- : Value(Raw > MaxValue ? AfterPointer : Raw) {}
10795 // Create non-scalable LocationSize
10896 static LocationSize precise (uint64_t Value) {
10997 return LocationSize (Value, false /* Scalable*/ );
@@ -118,7 +106,7 @@ class LocationSize {
118106 return precise (0 );
119107 if (LLVM_UNLIKELY (Value > MaxValue))
120108 return afterPointer ();
121- return LocationSize (Value | ImpreciseBit, Direct );
109+ return LocationSize (Value | ImpreciseBit);
122110 }
123111 static LocationSize upperBound (TypeSize Value) {
124112 if (Value.isScalable ())
@@ -129,21 +117,21 @@ class LocationSize {
129117 // / Any location after the base pointer (but still within the underlying
130118 // / object).
131119 constexpr static LocationSize afterPointer () {
132- return LocationSize (AfterPointer, Direct );
120+ return LocationSize (AfterPointer);
133121 }
134122
135123 // / Any location before or after the base pointer (but still within the
136124 // / underlying object).
137125 constexpr static LocationSize beforeOrAfterPointer () {
138- return LocationSize (BeforeOrAfterPointer, Direct );
126+ return LocationSize (BeforeOrAfterPointer);
139127 }
140128
141129 // Sentinel values, generally used for maps.
142130 constexpr static LocationSize mapTombstone () {
143- return LocationSize (MapTombstone, Direct );
131+ return LocationSize (MapTombstone);
144132 }
145133 constexpr static LocationSize mapEmpty () {
146- return LocationSize (MapEmpty, Direct );
134+ return LocationSize (MapEmpty);
147135 }
148136
149137 // Returns a LocationSize that can correctly represent either `*this` or
@@ -189,14 +177,16 @@ class LocationSize {
189177 bool operator ==(const LocationSize &Other) const {
190178 return Value == Other.Value ;
191179 }
192-
193180 bool operator ==(const TypeSize &Other) const {
194- return hasValue () && getValue () == Other;
181+ return (*this == LocationSize::precise (Other));
182+ }
183+ bool operator ==(uint64_t Other) const {
184+ return (*this == LocationSize::precise (Other));
195185 }
196186
197187 bool operator !=(const LocationSize &Other) const { return !(*this == Other); }
198-
199188 bool operator !=(const TypeSize &Other) const { return !(*this == Other); }
189+ bool operator !=(uint64_t Other) const { return !(*this == Other); }
200190
201191 // Ordering operators are not provided, since it's unclear if there's only one
202192 // reasonable way to compare:
@@ -301,6 +291,12 @@ class MemoryLocation {
301291 explicit MemoryLocation (const Value *Ptr, LocationSize Size,
302292 const AAMDNodes &AATags = AAMDNodes())
303293 : Ptr(Ptr), Size(Size), AATags(AATags) {}
294+ explicit MemoryLocation (const Value *Ptr, TypeSize Size,
295+ const AAMDNodes &AATags = AAMDNodes())
296+ : Ptr(Ptr), Size(LocationSize::precise(Size)), AATags(AATags) {}
297+ explicit MemoryLocation (const Value *Ptr, uint64_t Size,
298+ const AAMDNodes &AATags = AAMDNodes())
299+ : Ptr(Ptr), Size(LocationSize::precise(Size)), AATags(AATags) {}
304300
305301 MemoryLocation getWithNewPtr (const Value *NewPtr) const {
306302 MemoryLocation Copy (*this );
@@ -313,6 +309,12 @@ class MemoryLocation {
313309 Copy.Size = NewSize;
314310 return Copy;
315311 }
312+ MemoryLocation getWithNewSize (uint64_t NewSize) const {
313+ return getWithNewSize (LocationSize::precise (NewSize));
314+ }
315+ MemoryLocation getWithNewSize (TypeSize NewSize) const {
316+ return getWithNewSize (LocationSize::precise (NewSize));
317+ }
316318
317319 MemoryLocation getWithoutAATags () const {
318320 MemoryLocation Copy (*this );
0 commit comments