[Mlir-commits] [mlir] b3cf906 - [mlir] Update HeapAsmResourceBlob::allocate API to make alignment explicit

River Riddle llvmlistbot at llvm.org
Wed Nov 30 17:03:19 PST 2022


Author: River Riddle
Date: 2022-11-30T17:02:54-08:00
New Revision: b3cf9066de9386857fcadcd62fe4cc2f38bfd044

URL: https://github.com/llvm/llvm-project/commit/b3cf9066de9386857fcadcd62fe4cc2f38bfd044
DIFF: https://github.com/llvm/llvm-project/commit/b3cf9066de9386857fcadcd62fe4cc2f38bfd044.diff

LOG: [mlir] Update HeapAsmResourceBlob::allocate API to make alignment explicit

This effectively matches the same API changes that were made to
UnmanagedAsmResourceBlob.

Added: 
    

Modified: 
    mlir/include/mlir/IR/AsmState.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/AsmState.h b/mlir/include/mlir/IR/AsmState.h
index 0b00f1fb46dc..adec4b721b90 100644
--- a/mlir/include/mlir/IR/AsmState.h
+++ b/mlir/include/mlir/IR/AsmState.h
@@ -192,18 +192,19 @@ class HeapAsmResourceBlob {
         llvm::deallocate_buffer, dataIsMutable);
   }
   /// Create a new heap allocated blob and copy the provided data into it.
-  static AsmResourceBlob allocateAndCopy(ArrayRef<char> data, size_t align,
-                                         bool dataIsMutable = true) {
+  static AsmResourceBlob allocateAndCopyWithAlign(ArrayRef<char> 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 <typename T>
-  static std::enable_if_t<!std::is_same<T, char>::value, AsmResourceBlob>
-  allocateAndCopy(ArrayRef<T> data, bool dataIsMutable = true) {
-    return allocateAndCopy(
+  static AsmResourceBlob allocateAndCopyInferAlign(ArrayRef<T> data,
+                                                   bool dataIsMutable = true) {
+    return allocateAndCopyWithAlign(
         ArrayRef<char>((const char *)data.data(), data.size() * sizeof(T)),
-        alignof(T));
+        alignof(T), dataIsMutable);
   }
 };
 /// This class provides a simple utility wrapper for creating "unmanaged"


        


More information about the Mlir-commits mailing list