diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index 06ec1c85fb4d5..2d5381d43f863 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -884,6 +884,8 @@ int OperationName::UnregisteredOpModel::getOpPropertyByteSize() { void OperationName::UnregisteredOpModel::initProperties( OperationName opName, OpaqueProperties storage, OpaqueProperties init) { new (storage.as()) Attribute(); + if (init) + *storage.as() = *init.as(); } void OperationName::UnregisteredOpModel::deleteProperties( OpaqueProperties prop) { diff --git a/mlir/test/IR/test-clone.mlir b/mlir/test/IR/test-clone.mlir index 0c07593aef32d..f723efc1a2c53 100644 --- a/mlir/test/IR/test-clone.mlir +++ b/mlir/test/IR/test-clone.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="builtin.module(func.func(test-clone))" | FileCheck %s +// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline="builtin.module(func.func(test-clone))" --split-input-file | FileCheck %s module { func.func @fixpoint(%arg1 : i32) -> i32 { @@ -18,7 +18,8 @@ module { // CHECK-NEXT: notifyOperationInserted: test.yield // CHECK-NEXT: notifyOperationInserted: func.return -// CHECK: func @fixpoint(%[[arg0:.+]]: i32) -> i32 { +// CHECK-LABEL: func @fixpoint +// CHECK-SAME: (%[[arg0:.+]]: i32) -> i32 { // CHECK-NEXT: %[[i0:.+]] = "test.use"(%[[arg0]]) ({ // CHECK-NEXT: %[[r2:.+]] = "test.use2"(%[[arg0]]) ({ // CHECK-NEXT: "test.yield2"(%[[arg0]]) : (i32) -> () @@ -33,3 +34,33 @@ module { // CHECK-NEXT: }) : (i32) -> i32 // CHECK-NEXT: return %[[i1]] : i32 // CHECK-NEXT: } + +// ----- + +func.func @clone_unregistered_with_attrs() { + "unregistered.foo"() <{bar = 1 : i64, flag = true, name = "test", value = 3.14 : f32}> : () -> () + "unregistered.bar"() : () -> () + "unregistered.empty_dict"() <{}> : () -> () + "unregistered.complex"() <{ + array = [1, 2, 3], + dict = {key1 = 42 : i32, key2 = "value"}, + nested = {inner = {deep = 100 : i64}} + }> : () -> () + return +} + +// CHECK: notifyOperationInserted: unregistered.foo +// CHECK-NEXT: notifyOperationInserted: unregistered.bar +// CHECK-NEXT: notifyOperationInserted: unregistered.empty_dict +// CHECK-NEXT: notifyOperationInserted: unregistered.complex +// CHECK-NEXT: notifyOperationInserted: func.return + +// CHECK-LABEL: func @clone_unregistered_with_attrs() { +// CHECK-NEXT: "unregistered.foo"() <{bar = 1 : i64, flag = true, name = "test", value = [[PI:.+]] : f32}> : () -> () +// CHECK-NEXT: "unregistered.bar"() : () -> () +// CHECK-NEXT: "unregistered.empty_dict"() <{}> : () -> () +// CHECK-NEXT: "unregistered.complex"() <{array = [1, 2, 3], dict = {key1 = 42 : i32, key2 = "value"}, nested = {inner = {deep = 100 : i64}}}> : () -> () +// CHECK-NEXT: "unregistered.foo"() <{bar = 1 : i64, flag = true, name = "test", value = [[PI]] : f32}> : () -> () +// CHECK-NEXT: "unregistered.bar"() : () -> () +// CHECK-NEXT: "unregistered.empty_dict"() <{}> : () -> () +// CHECK-NEXT: "unregistered.complex"() <{array = [1, 2, 3], dict = {key1 = 42 : i32, key2 = "value"}, nested = {inner = {deep = 100 : i64}}}> : () -> ()