[MLIR] Rename the generic LLVM allocation and deallocation functions
authorMichele Scuttari <michele.scuttari@outlook.com>
Tue, 2 Aug 2022 18:21:05 +0000 (18:21 +0000)
committerAlex Zinenko <zinenko@google.com>
Tue, 2 Aug 2022 18:23:14 +0000 (18:23 +0000)
The generic allocation and deallocation instructions, which are optionally used during the MemRef -> LLVM conversion, should have a name that is specifically bound to their origin, that is the conversion pass itself.

Reviewed By: silvas

Differential Revision: https://reviews.llvm.org/D130588

mlir/docs/TargetLLVMIR.md
mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp
mlir/test/Conversion/MemRefToLLVM/generic-functions.mlir

index c86ed7a..bf639b8 100644 (file)
@@ -560,9 +560,10 @@ into calls to `malloc` (`aligned_alloc` if aligned allocations are requested)
 and `free`. However, it is possible to convert them to more generic functions
 which can be implemented by a runtime library, thus allowing custom allocation
 strategies or runtime profiling. When the conversion pass is  instructed to
-perform such operation, the names of the calles are `_mlir_alloc`,
-`_mlir_aligned_alloc` and `_mlir_free`. Their signatures are the same of
-`malloc`, `aligned_alloc` and `free`.
+perform such operation, the names of the calles are
+`_mlir_memref_to_llvm_alloc`, `_mlir_memref_to_llvm_aligned_alloc` and
+`_mlir_memref_to_llvm_free`. Their signatures are the same of `malloc`,
+`aligned_alloc` and `free`.
 
 ### C-compatible wrapper emission
 
index 1a336fe..65e26aa 100644 (file)
@@ -35,9 +35,10 @@ static constexpr llvm::StringRef kPrintNewline = "printNewline";
 static constexpr llvm::StringRef kMalloc = "malloc";
 static constexpr llvm::StringRef kAlignedAlloc = "aligned_alloc";
 static constexpr llvm::StringRef kFree = "free";
-static constexpr llvm::StringRef kGenericAlloc = "_mlir_alloc";
-static constexpr llvm::StringRef kGenericAlignedAlloc = "_mlir_aligned_alloc";
-static constexpr llvm::StringRef kGenericFree = "_mlir_free";
+static constexpr llvm::StringRef kGenericAlloc = "_mlir_memref_to_llvm_alloc";
+static constexpr llvm::StringRef kGenericAlignedAlloc =
+    "_mlir_memref_to_llvm_aligned_alloc";
+static constexpr llvm::StringRef kGenericFree = "_mlir_memref_to_llvm_free";
 static constexpr llvm::StringRef kMemRefCopy = "memrefCopy";
 
 /// Generic print function lookupOrCreate helper.
index 624ae76..3d98dbc 100644 (file)
@@ -6,8 +6,8 @@
 
 // CHECK-LABEL: func @alloc()
 func.func @zero_d_alloc() -> memref<f32> {
-// CHECK-NOTALIGNED: llvm.call @_mlir_alloc(%{{.*}}) : (i64) -> !llvm.ptr<i8>
-// CHECK-ALIGNED: llvm.call @_mlir_aligned_alloc(%{{.*}}, %{{.*}}) : (i64, i64) -> !llvm.ptr<i8>
+// CHECK-NOTALIGNED: llvm.call @_mlir_memref_to_llvm_alloc(%{{.*}}) : (i64) -> !llvm.ptr<i8>
+// CHECK-ALIGNED: llvm.call @_mlir_memref_to_llvm_aligned_alloc(%{{.*}}, %{{.*}}) : (i64, i64) -> !llvm.ptr<i8>
   %0 = memref.alloc() : memref<f32>
   return %0 : memref<f32>
 }
@@ -16,8 +16,8 @@ func.func @zero_d_alloc() -> memref<f32> {
 
 // CHECK-LABEL: func @dealloc()
 func.func @dealloc(%arg0: memref<f32>) {
-// CHECK-NOTALIGNED: llvm.call @_mlir_free(%{{.*}}) : (!llvm.ptr<i8>) -> ()
-// CHECK-ALIGNED: llvm.call @_mlir_free(%{{.*}}) : (!llvm.ptr<i8>) -> ()
+// CHECK-NOTALIGNED: llvm.call @_mlir_memref_to_llvm_free(%{{.*}}) : (!llvm.ptr<i8>) -> ()
+// CHECK-ALIGNED: llvm.call @_mlir_memref_to_llvm_free(%{{.*}}) : (!llvm.ptr<i8>) -> ()
   memref.dealloc %arg0 : memref<f32>
   return
 }