From: Christian Sigg Date: Thu, 4 Nov 2021 08:05:53 +0000 (+0100) Subject: Fix `insertFunctionArguments()` block argument order. X-Git-Tag: upstream/15.0.7~26656 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fce529fc6e83dc045fab1715734aecdde962ec2e;p=platform%2Fupstream%2Fllvm.git Fix `insertFunctionArguments()` block argument order. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D113171 --- diff --git a/mlir/lib/IR/FunctionSupport.cpp b/mlir/lib/IR/FunctionSupport.cpp index 4f6f76c..d67d277 100644 --- a/mlir/lib/IR/FunctionSupport.cpp +++ b/mlir/lib/IR/FunctionSupport.cpp @@ -164,7 +164,7 @@ void mlir::function_like_impl::insertFunctionArguments( // Update the function type and any entry block arguments. op->setAttr(getTypeAttrName(), TypeAttr::get(newType)); for (unsigned i = 0, e = argIndices.size(); i < e; ++i) - entry.insertArgument(argIndices[i], argTypes[i], + entry.insertArgument(argIndices[i] + i, argTypes[i], argLocs.empty() ? Optional{} : argLocs[i]); } diff --git a/mlir/test/IR/test-func-insert-arg.mlir b/mlir/test/IR/test-func-insert-arg.mlir index 2de6c66..61308a1 100644 --- a/mlir/test/IR/test-func-insert-arg.mlir +++ b/mlir/test/IR/test-func-insert-arg.mlir @@ -1,49 +1,49 @@ // RUN: mlir-opt %s -test-func-insert-arg -split-input-file | FileCheck %s -// CHECK: func @f(%arg0: f32 {test.A}) +// CHECK: func @f(%arg0: i1 {test.A}) func @f() attributes {test.insert_args = [ - [0, f32, {test.A}]]} { + [0, i1, {test.A}]]} { return } // ----- -// CHECK: func @f(%arg0: f32 {test.A}, %arg1: f32 {test.B}) -func @f(%arg0: f32 {test.B}) attributes {test.insert_args = [ - [0, f32, {test.A}]]} { +// CHECK: func @f(%arg0: i1 {test.A}, %arg1: i2 {test.B}) +func @f(%arg0: i2 {test.B}) attributes {test.insert_args = [ + [0, i1, {test.A}]]} { return } // ----- -// CHECK: func @f(%arg0: f32 {test.A}, %arg1: f32 {test.B}) -func @f(%arg0: f32 {test.A}) attributes {test.insert_args = [ - [1, f32, {test.B}]]} { +// CHECK: func @f(%arg0: i1 {test.A}, %arg1: i2 {test.B}) +func @f(%arg0: i1 {test.A}) attributes {test.insert_args = [ + [1, i2, {test.B}]]} { return } // ----- -// CHECK: func @f(%arg0: f32 {test.A}, %arg1: f32 {test.B}, %arg2: f32 {test.C}) -func @f(%arg0: f32 {test.A}, %arg1: f32 {test.C}) attributes {test.insert_args = [ - [1, f32, {test.B}]]} { +// CHECK: func @f(%arg0: i1 {test.A}, %arg1: i2 {test.B}, %arg2: i3 {test.C}) +func @f(%arg0: i1 {test.A}, %arg1: i3 {test.C}) attributes {test.insert_args = [ + [1, i2, {test.B}]]} { return } // ----- -// CHECK: func @f(%arg0: f32 {test.A}, %arg1: f32 {test.B}, %arg2: f32 {test.C}) -func @f(%arg0: f32 {test.B}) attributes {test.insert_args = [ - [0, f32, {test.A}], - [1, f32, {test.C}]]} { +// CHECK: func @f(%arg0: i1 {test.A}, %arg1: i2 {test.B}, %arg2: i3 {test.C}) +func @f(%arg0: i2 {test.B}) attributes {test.insert_args = [ + [0, i1, {test.A}], + [1, i3, {test.C}]]} { return } // ----- -// CHECK: func @f(%arg0: f32 {test.A}, %arg1: f32 {test.B}, %arg2: f32 {test.C}) -func @f(%arg0: f32 {test.C}) attributes {test.insert_args = [ - [0, f32, {test.A}], - [0, f32, {test.B}]]} { +// CHECK: func @f(%arg0: i1 {test.A}, %arg1: i2 {test.B}, %arg2: i3 {test.C}) +func @f(%arg0: i3 {test.C}) attributes {test.insert_args = [ + [0, i1, {test.A}], + [0, i2, {test.B}]]} { return }