From b3cf9066de9386857fcadcd62fe4cc2f38bfd044 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Mon, 28 Nov 2022 18:48:12 -0800 Subject: [PATCH] [mlir] Update HeapAsmResourceBlob::allocate API to make alignment explicit This effectively matches the same API changes that were made to UnmanagedAsmResourceBlob. --- mlir/include/mlir/IR/AsmState.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mlir/include/mlir/IR/AsmState.h b/mlir/include/mlir/IR/AsmState.h index 0b00f1f..adec4b7 100644 --- a/mlir/include/mlir/IR/AsmState.h +++ b/mlir/include/mlir/IR/AsmState.h @@ -192,18 +192,19 @@ public: llvm::deallocate_buffer, dataIsMutable); } /// Create a new heap allocated blob and copy the provided data into it. - static AsmResourceBlob allocateAndCopy(ArrayRef data, size_t align, - bool dataIsMutable = true) { + static AsmResourceBlob allocateAndCopyWithAlign(ArrayRef data, + size_t align, + bool dataIsMutable = true) { AsmResourceBlob blob = allocate(data.size(), align, dataIsMutable); std::memcpy(blob.getMutableData().data(), data.data(), data.size()); return blob; } template - static std::enable_if_t::value, AsmResourceBlob> - allocateAndCopy(ArrayRef data, bool dataIsMutable = true) { - return allocateAndCopy( + static AsmResourceBlob allocateAndCopyInferAlign(ArrayRef data, + bool dataIsMutable = true) { + return allocateAndCopyWithAlign( ArrayRef((const char *)data.data(), data.size() * sizeof(T)), - alignof(T)); + alignof(T), dataIsMutable); } }; /// This class provides a simple utility wrapper for creating "unmanaged" -- 2.7.4