[Mlir-commits] [mlir] 39cb2a8 - [mlir] Fix argument attribute attribute reassignment in ConvertStandardToLLVM

Alex Zinenko llvmlistbot at llvm.org
Fri Feb 14 01:22:40 PST 2020


Author: Alex Zinenko
Date: 2020-02-14T10:22:33+01:00
New Revision: 39cb2a8fc79976171b20369ff756f7fa43232b50

URL: https://github.com/llvm/llvm-project/commit/39cb2a8fc79976171b20369ff756f7fa43232b50
DIFF: https://github.com/llvm/llvm-project/commit/39cb2a8fc79976171b20369ff756f7fa43232b50.diff

LOG: [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.

Added: 
    

Modified: 
    mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
    mlir/test/Conversion/StandardToLLVM/convert-argattrs.mlir
    mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
index 57ebe42ac688..f613a39a9612 100644
--- a/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/ConvertStandardToLLVM.cpp
@@ -921,8 +921,8 @@ struct FuncOpConversionBase : public LLVMLegalizationPattern<FuncOp> {
       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));
       }
     }

diff  --git a/mlir/test/Conversion/StandardToLLVM/convert-argattrs.mlir b/mlir/test/Conversion/StandardToLLVM/convert-argattrs.mlir
index f2cd0f8e694d..2831aefc10f9 100644
--- a/mlir/test/Conversion/StandardToLLVM/convert-argattrs.mlir
+++ b/mlir/test/Conversion/StandardToLLVM/convert-argattrs.mlir
@@ -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
+}

diff  --git a/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir b/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir
index b47d355f77f6..105a80dec7a7 100644
--- a/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir
+++ b/mlir/test/Conversion/StandardToLLVM/convert-static-memref-ops.mlir
@@ -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
 }
 


        


More information about the Mlir-commits mailing list