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<BoolAttr>())
+ !argAttr.second.isa<UnitAttr>())
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<IntegerAttr>())
llvm::Argument &llvmArg = std::get<1>(kvp);
BlockArgument mlirArg = std::get<0>(kvp);
- if (auto attr = func.getArgAttrOfType<BoolAttr>(
+ if (auto attr = func.getArgAttrOfType<UnitAttr>(
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.
if (!argTy.isa<LLVM::LLVMPointerType>())
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<IntegerAttr>(
// 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<f32> {llvm.noalias = true}, %{{.*}}: !llvm.ptr<f32> {llvm.noalias = true}
-func @check_noalias(%static : memref<2xf32> {llvm.noalias = true}, %other : memref<2xf32> {llvm.noalias = true}) {
+// BAREPTR-SAME: %{{.*}}: !llvm.ptr<f32> {llvm.noalias}, %{{.*}}: !llvm.ptr<f32> {llvm.noalias}
+func @check_noalias(%static : memref<2xf32> {llvm.noalias}, %other : memref<2xf32> {llvm.noalias}) {
return
}
// GENERIC-SAME: () -> ()
}) {sym_name = "baz", type = !llvm.func<i64 (i64)>} : () -> ()
- // CHECK: llvm.func @qux(!llvm.ptr<i64> {llvm.noalias = true}, i64)
+ // CHECK: llvm.func @qux(!llvm.ptr<i64> {llvm.noalias}, i64)
// CHECK: attributes {xxx = {yyy = 42 : i64}}
"llvm.func"() ({
}) {sym_name = "qux", type = !llvm.func<void (ptr<i64>, i64)>,
- arg_attrs = [{llvm.noalias = true}, {}], xxx = {yyy = 42}} : () -> ()
+ arg_attrs = [{llvm.noalias}, {}], xxx = {yyy = 42}} : () -> ()
// CHECK: llvm.func @roundtrip1()
llvm.func @roundtrip1()
// CHECK: llvm.func @roundtrip8() -> i32
llvm.func @roundtrip8() -> i32 attributes {}
- // CHECK: llvm.func @roundtrip9(!llvm.ptr<i32> {llvm.noalias = true})
- llvm.func @roundtrip9(!llvm.ptr<i32> {llvm.noalias = true})
+ // CHECK: llvm.func @roundtrip9(!llvm.ptr<i32> {llvm.noalias})
+ llvm.func @roundtrip9(!llvm.ptr<i32> {llvm.noalias})
- // CHECK: llvm.func @roundtrip10(!llvm.ptr<i32> {llvm.noalias = true})
- llvm.func @roundtrip10(%arg0: !llvm.ptr<i32> {llvm.noalias = true})
+ // CHECK: llvm.func @roundtrip10(!llvm.ptr<i32> {llvm.noalias})
+ llvm.func @roundtrip10(%arg0: !llvm.ptr<i32> {llvm.noalias})
- // CHECK: llvm.func @roundtrip11(%{{.*}}: !llvm.ptr<i32> {llvm.noalias = true}) {
- llvm.func @roundtrip11(%arg0: !llvm.ptr<i32> {llvm.noalias = true}) {
+ // CHECK: llvm.func @roundtrip11(%{{.*}}: !llvm.ptr<i32> {llvm.noalias}) {
+ llvm.func @roundtrip11(%arg0: !llvm.ptr<i32> {llvm.noalias}) {
llvm.return
}
- // CHECK: llvm.func @roundtrip12(%{{.*}}: !llvm.ptr<i32> {llvm.noalias = true})
+ // CHECK: llvm.func @roundtrip12(%{{.*}}: !llvm.ptr<i32> {llvm.noalias})
// CHECK: attributes {foo = 42 : i32}
- llvm.func @roundtrip12(%arg0: !llvm.ptr<i32> {llvm.noalias = true})
+ llvm.func @roundtrip12(%arg0: !llvm.ptr<i32> {llvm.noalias})
attributes {foo = 42 : i32} {
llvm.return
}
// 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"() : () -> ()
}
// -----
// 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
}
}
// CHECK-LABEL: define void @llvm_noalias(float* noalias {{%*.}})
-llvm.func @llvm_noalias(%arg0: !llvm.ptr<f32> {llvm.noalias = true}) {
+llvm.func @llvm_noalias(%arg0: !llvm.ptr<f32> {llvm.noalias}) {
llvm.return
}