diff options
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 3e59970..b516590 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -101,17 +101,18 @@ bool BasicAAResult::invalidate(Function &Fn, const PreservedAnalyses &PA, //===----------------------------------------------------------------------===// /// Returns the size of the object specified by V or UnknownSize if unknown. -static uint64_t getObjectSize(const Value *V, const DataLayout &DL, - const TargetLibraryInfo &TLI, - bool NullIsValidLoc, - bool RoundToAlign = false) { +static std::optional<uint64_t> getObjectSize(const Value *V, + const DataLayout &DL, + const TargetLibraryInfo &TLI, + bool NullIsValidLoc, + bool RoundToAlign = false) { uint64_t Size; ObjectSizeOpts Opts; Opts.RoundToAlign = RoundToAlign; Opts.NullIsUnknownSize = NullIsValidLoc; if (getObjectSize(V, Size, DL, &TLI, Opts)) return Size; - return MemoryLocation::UnknownSize; + return std::nullopt; } /// 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, // This function needs to use the aligned object size because we allow // reads a bit past the end given sufficient alignment. - uint64_t ObjectSize = getObjectSize(V, DL, TLI, NullIsValidLoc, - /*RoundToAlign*/ true); + std::optional<uint64_t> ObjectSize = getObjectSize(V, DL, TLI, NullIsValidLoc, + /*RoundToAlign*/ true); - return ObjectSize != MemoryLocation::UnknownSize && ObjectSize < Size; + return ObjectSize && *ObjectSize < Size; } /// 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, /// Returns true if we can prove that the object specified by V has size Size. static bool isObjectSize(const Value *V, uint64_t Size, const DataLayout &DL, const TargetLibraryInfo &TLI, bool NullIsValidLoc) { - uint64_t ObjectSize = getObjectSize(V, DL, TLI, NullIsValidLoc); - return ObjectSize != MemoryLocation::UnknownSize && ObjectSize == Size; + std::optional<uint64_t> ObjectSize = + getObjectSize(V, DL, TLI, NullIsValidLoc); + return ObjectSize && *ObjectSize == Size; } //===----------------------------------------------------------------------===// |