[Mlir-commits] [mlir] 4f52210 - [mlir][llvm] Fix export of 64-bit integer function attributes

Jeff Niu llvmlistbot at llvm.org
Fri Jul 28 15:37:30 PDT 2023


Author: Mogball
Date: 2023-07-28T15:37:25-07:00
New Revision: 4f52210a563b5780ae447a876e6da446b32f0b07

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

LOG: [mlir][llvm] Fix export of 64-bit integer function attributes

The `allocsize` attribute is weird because it packs two 32-bit values
into a 64-bit value. It also turns out that the passthrough attribute
exporter was using `int`, which is incorrectly handling 64-bit integers.

Reviewed By: rriddle

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

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
    mlir/test/Target/LLVMIR/llvmir.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index c92b85ff3d2991..7ec7e6528571e0 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -825,7 +825,7 @@ static LogicalResult checkedAddLLVMFnAttribute(Location loc,
     if (value.empty())
       return emitError(loc) << "LLVM attribute '" << key << "' expects a value";
 
-    int result;
+    int64_t result;
     if (!value.getAsInteger(/*Radix=*/0, result))
       llvmFunc->addFnAttr(
           llvm::Attribute::get(llvmFunc->getContext(), kind, result));

diff  --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir
index e4ffcb31135f09..f5dcc0192e7fef 100644
--- a/mlir/test/Target/LLVMIR/llvmir.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir.mlir
@@ -1727,6 +1727,15 @@ llvm.func @passthrough() attributes {passthrough = ["noinline", ["alignstack", "
 
 // -----
 
+// CHECK-LABEL: @my_allocator
+// CHECK: #[[ALLOC_ATTRS:[0-9]*]]
+llvm.func @my_allocator(i64) attributes {passthrough = [["allocsize", "4294967295"]]}
+
+// CHECK: attributes #[[ALLOC_ATTRS]] = {
+// CHECK-DAG: allocsize(0)
+
+// -----
+
 // CHECK-LABEL: @functionEntryCount
 // CHECK-SAME: !prof ![[PROF_ID:[0-9]*]]
 llvm.func @functionEntryCount() attributes {function_entry_count = 4242 : i64} {


        


More information about the Mlir-commits mailing list