[Mlir-commits] [mlir] [mlir] Fix correct memset range in `OwningMemRef` zero-init (PR #158200)

Ryan Kim llvmlistbot at llvm.org
Fri Sep 12 01:55:04 PDT 2025


================
@@ -174,9 +174,7 @@ class OwningMemRef {
            it != end; ++it)
         init(*it, it.getIndices());
     } else {
-      memset(descriptor.data, 0,
-             nElements * sizeof(T) +
-                 alignment.value_or(detail::nextPowerOf2(sizeof(T))));
+      memset(descriptor.data, 0, nElements * sizeof(T));
----------------
chokobole wrote:

I believe this has nothing to do with that line because this `data` comes from the `descriptor`. In my opinion, the root cause is a misuse of the `descriptor.data`. When you use `descriptor.data`, you need to use the size of your `data`. When you use the `descriptor.basePtr`, you need to use the sum of your data's size and its alignment.



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


More information about the Mlir-commits mailing list