[llvm] [Analysis] Add Scalable field in MemoryLocation.h (PR #69716)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 05:50:45 PDT 2023


================
@@ -151,19 +151,21 @@ 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,
+  TypeSize ObjectSize = getObjectSize(V, DL, TLI, NullIsValidLoc,
                                       /*RoundToAlign*/ true);
 
-  return ObjectSize != MemoryLocation::UnknownSize && ObjectSize < Size;
+  // Bail on comparing V and Size if Size is scalable
+  return ObjectSize != MemoryLocation::UnknownSize && !Size.isScalable() &&
+         (ObjectSize < Size.getValue());
----------------
nikic wrote:

```suggestion
  return ObjectSize != MemoryLocation::UnknownSize &&
         TypeSize::isKnownLT(ObjectSize, Size.getValue());
```

https://github.com/llvm/llvm-project/pull/69716


More information about the llvm-commits mailing list