[llvm] [offload] add handling of memory alignment to MemoryManagerTy (PR #218418)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 7 01:45:53 PDT 2026


================
@@ -264,32 +281,55 @@ class MemoryManagerTy {
       ODBG(OLDT_Alloc) << "Got target pointer " << *TgtPtrOrErr
                        << ". Return directly.";
 
+      if (Alignment > 0 && !isAddrAligned(Align(Alignment), *TgtPtrOrErr)) {
+        auto AlignErr = make_error<StringError>(
+            "Allocated address is misaligned", inconvertibleErrorCode());
----------------
EuphoricThinking wrote:

After another round of thinking, I have come to the conclusion that leaving the condition as it is while changing the requested amount of memory to `Size` is the simplest approach. I can't see many benefits from allocating excess memory with `AllocationSize`, but the memory manager is not supposed to handle such a large request. Correct me if I am wrong, but I assume this concern is relevant only to the path of the aligned allocation and large amounts of the requested memory, which seems to be an uncommon use case. 

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


More information about the llvm-commits mailing list