diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -825,7 +825,7 @@ 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 --- a/mlir/test/Target/LLVMIR/llvmir.mlir +++ b/mlir/test/Target/LLVMIR/llvmir.mlir @@ -1727,6 +1727,15 @@ // ----- +// 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} {