[llvm] [Analysis] Add Scalable field in MemoryLocation.h (PR #69716)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 20 07:38:10 PDT 2023
================
@@ -101,22 +101,23 @@ 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) {
+/// getObjectSize does not support scalable Value
+static LocationSize 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 LocationSize(Size);
+ return LocationSize(MemoryLocation::UnknownSize);
----------------
nikic wrote:
What do we gain by returning LocationSize from this function? I think this code mostly only works by accident (MemoryLocation::UnknownSize gets converted to LocationSize::afterPointer() by being out of range, and then the comparison below also does this conversion via the non-explicit ctor).
If this should be something other than uint64_t, then it should probably be TypeSize, not LocationSize.
https://github.com/llvm/llvm-project/pull/69716
More information about the llvm-commits
mailing list