@@ -101,17 +101,18 @@ bool BasicAAResult::invalidate(Function &Fn, const PreservedAnalyses &PA,
101
101
// ===----------------------------------------------------------------------===//
102
102
103
103
// / Returns the size of the object specified by V or UnknownSize if unknown.
104
- static uint64_t getObjectSize (const Value *V, const DataLayout &DL,
105
- const TargetLibraryInfo &TLI,
106
- bool NullIsValidLoc,
107
- bool RoundToAlign = false ) {
104
+ static std::optional<uint64_t > getObjectSize (const Value *V,
105
+ const DataLayout &DL,
106
+ const TargetLibraryInfo &TLI,
107
+ bool NullIsValidLoc,
108
+ bool RoundToAlign = false ) {
108
109
uint64_t Size;
109
110
ObjectSizeOpts Opts;
110
111
Opts.RoundToAlign = RoundToAlign;
111
112
Opts.NullIsUnknownSize = NullIsValidLoc;
112
113
if (getObjectSize (V, Size, DL, &TLI, Opts))
113
114
return Size;
114
- return MemoryLocation::UnknownSize ;
115
+ return std::nullopt ;
115
116
}
116
117
117
118
// / Returns true if we can prove that the object specified by V is smaller than
@@ -151,10 +152,10 @@ static bool isObjectSmallerThan(const Value *V, uint64_t Size,
151
152
152
153
// This function needs to use the aligned object size because we allow
153
154
// reads a bit past the end given sufficient alignment.
154
- uint64_t ObjectSize = getObjectSize (V, DL, TLI, NullIsValidLoc,
155
- /* RoundToAlign*/ true );
155
+ std::optional< uint64_t > ObjectSize = getObjectSize (V, DL, TLI, NullIsValidLoc,
156
+ /* RoundToAlign*/ true );
156
157
157
- return ObjectSize != MemoryLocation::UnknownSize && ObjectSize < Size;
158
+ return ObjectSize && * ObjectSize < Size;
158
159
}
159
160
160
161
// / Return the minimal extent from \p V to the end of the underlying object,
@@ -182,8 +183,9 @@ static uint64_t getMinimalExtentFrom(const Value &V,
182
183
// / Returns true if we can prove that the object specified by V has size Size.
183
184
static bool isObjectSize (const Value *V, uint64_t Size, const DataLayout &DL,
184
185
const TargetLibraryInfo &TLI, bool NullIsValidLoc) {
185
- uint64_t ObjectSize = getObjectSize (V, DL, TLI, NullIsValidLoc);
186
- return ObjectSize != MemoryLocation::UnknownSize && ObjectSize == Size;
186
+ std::optional<uint64_t > ObjectSize =
187
+ getObjectSize (V, DL, TLI, NullIsValidLoc);
188
+ return ObjectSize && *ObjectSize == Size;
187
189
}
188
190
189
191
// ===----------------------------------------------------------------------===//
0 commit comments