forked from OSchip/llvm-project
[mlir] Fix argument attribute attribute reassignment in ConvertStandardToLLVM
The commit switching the calling convention for memrefs (5a1778057
)
inadvertently introduced a bug in the function argument attribute conversion:
due to incorrect indexing of function arguments it was not assigning the
attributes to the arguments beyond those generated from the first original
argument. This was not caught in the commit since the test suite does have a
test for converting multi-argument functions with argument attributes. Fix the
bug and add relevant tests.
This commit is contained in:
parent
189c701332
commit
39cb2a8fc7
|
@ -921,8 +921,8 @@ protected:
|
|||
assert(mapping.hasValue() && "unexpected deletion of function argument");
|
||||
|
||||
SmallString<8> name;
|
||||
for (size_t j = mapping->inputNo; j < mapping->size; ++j) {
|
||||
impl::getArgAttrName(j, name);
|
||||
for (size_t j = 0; j < mapping->size; ++j) {
|
||||
impl::getArgAttrName(mapping->inputNo + j, name);
|
||||
attributes.push_back(rewriter.getNamedAttr(name, attr));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,3 +9,11 @@ func @check_attributes(%static: memref<10x20xf32> {dialect.a = true, dialect.b =
|
|||
return
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @check_multiple
|
||||
// Make sure arguments attributes are attached to the right argument. We match
|
||||
// commas in the argument list for this purpose.
|
||||
// CHECK: %{{.*}}: !llvm{{.*}} {first.arg = true}, %{{.*}}: !llvm{{.*}} {first.arg = true}, %{{.*}}: !llvm{{.*}} {first.arg = true},
|
||||
// CHECK-SAME: %{{.*}}: !llvm{{.*}} {second.arg = 42 : i32}, %{{.*}}: !llvm{{.*}} {second.arg = 42 : i32}, %{{.*}}: !llvm{{.*}} {second.arg = 42 : i32})
|
||||
func @check_multiple(%first: memref<f32> {first.arg = true}, %second: memref<f32> {second.arg = 42 : i32}) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -3,8 +3,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<"float*"> {llvm.noalias = true}
|
||||
func @check_noalias(%static : memref<2xf32> {llvm.noalias = true}) {
|
||||
// BAREPTR-SAME: %{{.*}}: !llvm<"float*"> {llvm.noalias = true}, %{{.*}}: !llvm<"float*"> {llvm.noalias = true}
|
||||
func @check_noalias(%static : memref<2xf32> {llvm.noalias = true}, %other : memref<2xf32> {llvm.noalias = true}) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue