[Mlir-commits] [mlir] 29fbe60 - [MLIR] Rename the generic LLVM allocation and deallocation functions

Alex Zinenko llvmlistbot at llvm.org
Tue Aug 2 11:23:19 PDT 2022


Author: Michele Scuttari
Date: 2022-08-02T18:23:14Z
New Revision: 29fbe600091d89134cd998d02b0e9d7a4a6115b3

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

LOG: [MLIR] Rename the generic LLVM allocation and deallocation functions

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/mlir/docs/TargetLLVMIR.md b/mlir/docs/TargetLLVMIR.md
index c86ed7a9544b5..bf639b81dd64f 100644
--- a/mlir/docs/TargetLLVMIR.md
+++ b/mlir/docs/TargetLLVMIR.md
@@ -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
 

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp b/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp
index 1a336fe29308b..65e26aaed5672 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp
@@ -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.

diff  --git a/mlir/test/Conversion/MemRefToLLVM/generic-functions.mlir b/mlir/test/Conversion/MemRefToLLVM/generic-functions.mlir
index 624ae76c08061..3d98dbcf8f29d 100644
--- a/mlir/test/Conversion/MemRefToLLVM/generic-functions.mlir
+++ b/mlir/test/Conversion/MemRefToLLVM/generic-functions.mlir
@@ -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
 }


        


More information about the Mlir-commits mailing list