[llvm] [Attributor] Check range size before constant fold load (PR #151359)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 15 17:56:26 PDT 2025


================
@@ -272,6 +272,9 @@ AA::getInitialValueForObj(Attributor &A, const AbstractAttribute &QueryingAA,
   }
 
   if (RangePtr && !RangePtr->offsetOrSizeAreUnknown()) {
+    int64_t StorageSize = DL.getTypeStoreSize(&Ty);
+    if (StorageSize != RangePtr->Size)
+      return nullptr;
----------------
shiltian wrote:

It is truncated but the start position of the load is wrong here, because the range itself is a combination of multiple small sections. The range here says, some accesses are within the range of `[0, N)`, but if we load a value of size `M`, where `M < N`, before this change it will just say it reads from memory `[0, M)`.

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


More information about the llvm-commits mailing list