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
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
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.
// 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>
}
// 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
}