llvm-project
ee2a225a - [mlir] Fix correct memset range in `OwningMemRef` zero-init (#158200)

Commit
54 days ago
[mlir] Fix correct memset range in `OwningMemRef` zero-init (#158200) `OwningMemref` allocates with overprovision + manual alignment. This is fixing the zero-initialization of the data, the existing code was potentially overrunning the allocation: ```cpp memset(descriptor.data, 0, size + desiredAlignment); // ❌ may overrun ``` This is invalid because `descriptor.data` (the aligned pointer) **does not point to the full allocated block** (`size + desiredAlignment`). Zeroing that much from the aligned start can write past the end of the allocation. Instead we only initialize the data from the aligned pointer for the expected buffer size. The padding from [allocatedPtr, alignedDataPtr] is left untouched.
Author
Parents
Loading