diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -2306,11 +2306,11 @@ unsigned regionIdx, unsigned argIdx, NamedAttribute argAttr) { - // Check that llvm.noalias is a boolean attribute. + // Check that llvm.noalias is a unit attribute. if (argAttr.first == LLVMDialect::getNoAliasAttrName() && - !argAttr.second.isa()) + !argAttr.second.isa()) return op->emitError() - << "llvm.noalias argument attribute of non boolean type"; + << "expected llvm.noalias argument attribute to be a unit attribute"; // Check that llvm.align is an integer attribute. if (argAttr.first == LLVMDialect::getAlignAttrName() && !argAttr.second.isa()) 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 @@ -558,7 +558,7 @@ llvm::Argument &llvmArg = std::get<1>(kvp); BlockArgument mlirArg = std::get<0>(kvp); - if (auto attr = func.getArgAttrOfType( + if (auto attr = func.getArgAttrOfType( argIdx, LLVMDialect::getNoAliasAttrName())) { // NB: Attribute already verified to be boolean, so check if we can indeed // attach the attribute to this argument, based on its type. @@ -566,8 +566,7 @@ if (!argTy.isa()) return func.emitError( "llvm.noalias attribute attached to LLVM non-pointer argument"); - if (attr.getValue()) - llvmArg.addAttr(llvm::Attribute::AttrKind::NoAlias); + llvmArg.addAttr(llvm::Attribute::AttrKind::NoAlias); } if (auto attr = func.getArgAttrOfType( diff --git a/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir b/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir --- a/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir +++ b/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir @@ -2,8 +2,8 @@ // RUN: mlir-opt -convert-std-to-llvm='use-bare-ptr-memref-call-conv=1' -split-input-file %s | FileCheck %s --check-prefix=BAREPTR // BAREPTR-LABEL: func @check_noalias -// BAREPTR-SAME: %{{.*}}: !llvm.ptr {llvm.noalias = true}, %{{.*}}: !llvm.ptr {llvm.noalias = true} -func @check_noalias(%static : memref<2xf32> {llvm.noalias = true}, %other : memref<2xf32> {llvm.noalias = true}) { +// BAREPTR-SAME: %{{.*}}: !llvm.ptr {llvm.noalias}, %{{.*}}: !llvm.ptr {llvm.noalias} +func @check_noalias(%static : memref<2xf32> {llvm.noalias}, %other : memref<2xf32> {llvm.noalias}) { return } diff --git a/mlir/test/Dialect/LLVMIR/func.mlir b/mlir/test/Dialect/LLVMIR/func.mlir --- a/mlir/test/Dialect/LLVMIR/func.mlir +++ b/mlir/test/Dialect/LLVMIR/func.mlir @@ -31,11 +31,11 @@ // GENERIC-SAME: () -> () }) {sym_name = "baz", type = !llvm.func} : () -> () - // CHECK: llvm.func @qux(!llvm.ptr {llvm.noalias = true}, i64) + // CHECK: llvm.func @qux(!llvm.ptr {llvm.noalias}, i64) // CHECK: attributes {xxx = {yyy = 42 : i64}} "llvm.func"() ({ }) {sym_name = "qux", type = !llvm.func, i64)>, - arg_attrs = [{llvm.noalias = true}, {}], xxx = {yyy = 42}} : () -> () + arg_attrs = [{llvm.noalias}, {}], xxx = {yyy = 42}} : () -> () // CHECK: llvm.func @roundtrip1() llvm.func @roundtrip1() @@ -69,20 +69,20 @@ // CHECK: llvm.func @roundtrip8() -> i32 llvm.func @roundtrip8() -> i32 attributes {} - // CHECK: llvm.func @roundtrip9(!llvm.ptr {llvm.noalias = true}) - llvm.func @roundtrip9(!llvm.ptr {llvm.noalias = true}) + // CHECK: llvm.func @roundtrip9(!llvm.ptr {llvm.noalias}) + llvm.func @roundtrip9(!llvm.ptr {llvm.noalias}) - // CHECK: llvm.func @roundtrip10(!llvm.ptr {llvm.noalias = true}) - llvm.func @roundtrip10(%arg0: !llvm.ptr {llvm.noalias = true}) + // CHECK: llvm.func @roundtrip10(!llvm.ptr {llvm.noalias}) + llvm.func @roundtrip10(%arg0: !llvm.ptr {llvm.noalias}) - // CHECK: llvm.func @roundtrip11(%{{.*}}: !llvm.ptr {llvm.noalias = true}) { - llvm.func @roundtrip11(%arg0: !llvm.ptr {llvm.noalias = true}) { + // CHECK: llvm.func @roundtrip11(%{{.*}}: !llvm.ptr {llvm.noalias}) { + llvm.func @roundtrip11(%arg0: !llvm.ptr {llvm.noalias}) { llvm.return } - // CHECK: llvm.func @roundtrip12(%{{.*}}: !llvm.ptr {llvm.noalias = true}) + // CHECK: llvm.func @roundtrip12(%{{.*}}: !llvm.ptr {llvm.noalias}) // CHECK: attributes {foo = 42 : i32} - llvm.func @roundtrip12(%arg0: !llvm.ptr {llvm.noalias = true}) + llvm.func @roundtrip12(%arg0: !llvm.ptr {llvm.noalias}) attributes {foo = 42 : i32} { llvm.return } diff --git a/mlir/test/Dialect/LLVMIR/invalid.mlir b/mlir/test/Dialect/LLVMIR/invalid.mlir --- a/mlir/test/Dialect/LLVMIR/invalid.mlir +++ b/mlir/test/Dialect/LLVMIR/invalid.mlir @@ -1,6 +1,6 @@ // RUN: mlir-opt -allow-unregistered-dialect %s -split-input-file -verify-diagnostics -// expected-error@+1{{llvm.noalias argument attribute of non boolean type}} +// expected-error@+1{{expected llvm.noalias argument attribute to be a unit attribute}} func @invalid_noalias(%arg0: i32 {llvm.noalias = 3}) { "llvm.return"() : () -> () } diff --git a/mlir/test/Target/LLVMIR/llvmir-invalid.mlir b/mlir/test/Target/LLVMIR/llvmir-invalid.mlir --- a/mlir/test/Target/LLVMIR/llvmir-invalid.mlir +++ b/mlir/test/Target/LLVMIR/llvmir-invalid.mlir @@ -8,7 +8,7 @@ // ----- // expected-error @+1 {{llvm.noalias attribute attached to LLVM non-pointer argument}} -llvm.func @invalid_noalias(%arg0 : f32 {llvm.noalias = true}) -> f32 { +llvm.func @invalid_noalias(%arg0 : f32 {llvm.noalias}) -> f32 { llvm.return %arg0 : f32 } 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 @@ -952,7 +952,7 @@ } // CHECK-LABEL: define void @llvm_noalias(float* noalias {{%*.}}) -llvm.func @llvm_noalias(%arg0: !llvm.ptr {llvm.noalias = true}) { +llvm.func @llvm_noalias(%arg0: !llvm.ptr {llvm.noalias}) { llvm.return }