Skip to content

Commit 628b373

Browse files
committed
Revert "[mlir][Symbol] Add verification that symbol's parent is a SymbolTable (#80590)"
This reverts commit 7d055af.
1 parent a02ffb3 commit 628b373

File tree

13 files changed

+85
-68
lines changed

13 files changed

+85
-68
lines changed

mlir/include/mlir/IR/SymbolInterfaces.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ def Symbol : OpInterface<"SymbolOpInterface"> {
171171
if (concreteOp.isDeclaration() && concreteOp.isPublic())
172172
return concreteOp.emitOpError("symbol declaration cannot have public "
173173
"visibility");
174-
auto parent = $_op->getParentOp();
175-
if (parent && !parent->hasTrait<OpTrait::SymbolTable>() && parent->isRegistered()) {
176-
return concreteOp.emitOpError("symbol's parent must have the SymbolTable "
177-
"trait");
178-
}
179174
return success();
180175
}];
181176

mlir/test/Dialect/LLVMIR/global.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ llvm.mlir.global internal constant @constant(37.0) : !llvm.label
132132
// -----
133133

134134
func.func @foo() {
135-
// expected-error @+1 {{op symbol's parent must have the SymbolTable trait}}
135+
// expected-error @+1 {{must appear at the module level}}
136136
llvm.mlir.global internal @bar(42) : i32
137137

138138
return

mlir/test/Dialect/Linalg/transform-op-replace.mlir

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ module attributes {transform.with_named_sequence} {
1212
transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
1313
%0 = transform.structured.match ops{["func.func"]} in %arg1 : (!transform.any_op) -> !transform.any_op
1414
transform.structured.replace %0 {
15-
builtin.module {
16-
func.func @foo() {
17-
"dummy_op"() : () -> ()
18-
}
15+
func.func @foo() {
16+
"dummy_op"() : () -> ()
1917
}
2018
} : (!transform.any_op) -> !transform.any_op
2119
transform.yield

mlir/test/Dialect/Transform/ops-invalid.mlir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,10 @@ module {
482482
// -----
483483

484484
module attributes { transform.with_named_sequence} {
485+
// expected-note @below {{ancestor transform op}}
485486
transform.sequence failures(suppress) {
486487
^bb0(%arg0: !transform.any_op):
487-
// expected-error @below {{op symbol's parent must have the SymbolTable trai}}
488+
// expected-error @below {{cannot be defined inside another transform op}}
488489
transform.named_sequence @nested() {
489490
transform.yield
490491
}

mlir/test/IR/invalid-func-op.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func.func @func_op() {
3131
// -----
3232

3333
func.func @func_op() {
34-
// expected-error@+1 {{op symbol's parent must have the SymbolTable trait}}
34+
// expected-error@+1 {{entry block must have 1 arguments to match function signature}}
3535
func.func @mixed_named_arguments(f32) {
3636
^entry:
3737
return
@@ -42,7 +42,7 @@ func.func @func_op() {
4242
// -----
4343

4444
func.func @func_op() {
45-
// expected-error@+1 {{op symbol's parent must have the SymbolTable trait}}
45+
// expected-error@+1 {{type of entry block argument #0('i32') must match the type of the corresponding argument in function signature('f32')}}
4646
func.func @mixed_named_arguments(f32) {
4747
^entry(%arg : i32):
4848
return

mlir/test/IR/region.mlir

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,18 @@ func.func @named_region_has_wrong_number_of_blocks() {
8787
// CHECK: test.single_no_terminator_op
8888
"test.single_no_terminator_op"() (
8989
{
90-
%foo = arith.constant 1 : i32
90+
func.func @foo1() { return }
91+
func.func @foo2() { return }
9192
}
9293
) : () -> ()
9394

9495
// CHECK: test.variadic_no_terminator_op
9596
"test.variadic_no_terminator_op"() (
9697
{
97-
%foo = arith.constant 1 : i32
98+
func.func @foo1() { return }
9899
},
99100
{
100-
%bar = arith.constant 1 : i32
101+
func.func @foo2() { return }
101102
}
102103
) : () -> ()
103104

mlir/test/IR/traits.mlir

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -572,13 +572,15 @@ func.func @failedHasDominanceScopeOutsideDominanceFreeScope() -> () {
572572

573573
// Ensure that SSACFG regions of operations in GRAPH regions are
574574
// checked for dominance
575-
func.func @illegalInsideDominanceFreeScope(%cond: i1) -> () {
575+
func.func @illegalInsideDominanceFreeScope() -> () {
576576
test.graph_region {
577-
scf.if %cond {
577+
func.func @test() -> i1 {
578+
^bb1:
578579
// expected-error @+1 {{operand #0 does not dominate this use}}
579580
%2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
580581
// expected-note @+1 {{operand defined here}}
581-
%1 = "baz"(%2#0) : (i1) -> (i64)
582+
%1 = "baz"(%2#0) : (i1) -> (i64)
583+
return %2#1 : i1
582584
}
583585
"terminator"() : () -> ()
584586
}
@@ -589,21 +591,20 @@ func.func @illegalInsideDominanceFreeScope(%cond: i1) -> () {
589591

590592
// Ensure that SSACFG regions of operations in GRAPH regions are
591593
// checked for dominance
592-
func.func @illegalCFGInsideDominanceFreeScope(%cond: i1) -> () {
594+
func.func @illegalCDFGInsideDominanceFreeScope() -> () {
593595
test.graph_region {
594-
scf.if %cond {
595-
"test.ssacfg_region"() ({
596-
^bb1:
597-
// expected-error @+1 {{operand #0 does not dominate this use}}
598-
%2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
599-
cf.br ^bb4
600-
^bb2:
601-
cf.br ^bb2
602-
^bb4:
603-
%1 = "foo"() : ()->i64 // expected-note {{operand defined here}}
604-
}) : () -> ()
596+
func.func @test() -> i1 {
597+
^bb1:
598+
// expected-error @+1 {{operand #0 does not dominate this use}}
599+
%2:3 = "bar"(%1) : (i64) -> (i1,i1,i1)
600+
cf.br ^bb4
601+
^bb2:
602+
cf.br ^bb2
603+
^bb4:
604+
%1 = "foo"() : ()->i64 // expected-note {{operand defined here}}
605+
return %2#1 : i1
605606
}
606-
"terminator"() : () -> ()
607+
"terminator"() : () -> ()
607608
}
608609
return
609610
}

mlir/test/Transforms/canonicalize-dce.mlir

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ func.func @f(%arg0: f32, %pred: i1) {
7777

7878
// Test case: Recursively DCE into enclosed regions.
7979

80-
// CHECK: func.func @f(%arg0: f32)
81-
// CHECK-NOT: arith.addf
80+
// CHECK: func @f(%arg0: f32)
81+
// CHECK-NEXT: func @g(%arg1: f32)
82+
// CHECK-NEXT: return
8283

8384
func.func @f(%arg0: f32) {
84-
"test.region"() (
85-
{
86-
%0 = "arith.addf"(%arg0, %arg0) : (f32, f32) -> f32
87-
}
88-
) : () -> ()
85+
func.func @g(%arg1: f32) {
86+
%0 = "arith.addf"(%arg1, %arg1) : (f32, f32) -> f32
87+
return
88+
}
8989
return
9090
}
9191

mlir/test/Transforms/canonicalize.mlir

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,16 @@ func.func @write_only_alloca_fold(%v: f32) {
429429
// CHECK-LABEL: func @dead_block_elim
430430
func.func @dead_block_elim() {
431431
// CHECK-NOT: ^bb
432-
builtin.module {
433-
func.func @nested() {
434-
return
432+
func.func @nested() {
433+
return
435434

436-
^bb1:
437-
return
438-
}
435+
^bb1:
436+
return
439437
}
440438
return
439+
440+
^bb1:
441+
return
441442
}
442443

443444
// CHECK-LABEL: func @dyn_shape_fold(%arg0: index, %arg1: index)

mlir/test/Transforms/constant-fold.mlir

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -794,15 +794,12 @@ func.func @cmpf_inf() -> (i1, i1, i1, i1, i1, i1, i1, i1, i1, i1, i1, i1, i1, i1
794794

795795
// CHECK-LABEL: func @nested_isolated_region
796796
func.func @nested_isolated_region() {
797-
// CHECK-NEXT: builtin.module {
798797
// CHECK-NEXT: func @isolated_op
799798
// CHECK-NEXT: arith.constant 2
800-
builtin.module {
801-
func.func @isolated_op() {
802-
%0 = arith.constant 1 : i32
803-
%2 = arith.addi %0, %0 : i32
804-
"foo.yield"(%2) : (i32) -> ()
805-
}
799+
func.func @isolated_op() {
800+
%0 = arith.constant 1 : i32
801+
%2 = arith.addi %0, %0 : i32
802+
"foo.yield"(%2) : (i32) -> ()
806803
}
807804

808805
// CHECK: "foo.unknown_region"

mlir/test/Transforms/cse.mlir

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,11 @@ func.func @nested_isolated() -> i32 {
228228
// CHECK-NEXT: arith.constant 1
229229
%0 = arith.constant 1 : i32
230230

231-
// CHECK-NEXT: builtin.module
232231
// CHECK-NEXT: @nested_func
233-
builtin.module {
234-
func.func @nested_func() {
235-
// CHECK-NEXT: arith.constant 1
236-
%foo = arith.constant 1 : i32
237-
"foo.yield"(%foo) : (i32) -> ()
238-
}
232+
func.func @nested_func() {
233+
// CHECK-NEXT: arith.constant 1
234+
%foo = arith.constant 1 : i32
235+
"foo.yield"(%foo) : (i32) -> ()
239236
}
240237

241238
// CHECK: "foo.region"

mlir/test/Transforms/test-legalizer-full.mlir

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ func.func @recursively_legal_invalid_op() {
3737
}
3838
/// Operation that is dynamically legal, i.e. the function has a pattern
3939
/// applied to legalize the argument type before it becomes recursively legal.
40-
builtin.module {
41-
func.func @dynamic_func(%arg: i64) attributes {test.recursively_legal} {
42-
%ignored = "test.illegal_op_f"() : () -> (i32)
43-
"test.return"() : () -> ()
44-
}
40+
func.func @dynamic_func(%arg: i64) attributes {test.recursively_legal} {
41+
%ignored = "test.illegal_op_f"() : () -> (i32)
42+
"test.return"() : () -> ()
4543
}
4644

4745
"test.return"() : () -> ()

mlir/test/python/ir/value.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,28 @@ def testValuePrintAsOperand():
166166
print(value2)
167167

168168
topFn = func.FuncOp("test", ([i32, i32], []))
169-
entry_block = Block.create_at_start(topFn.operation.regions[0], [i32, i32])
169+
entry_block1 = Block.create_at_start(topFn.operation.regions[0], [i32, i32])
170170

171-
with InsertionPoint(entry_block):
171+
with InsertionPoint(entry_block1):
172172
value3 = Operation.create("custom.op3", results=[i32]).results[0]
173173
# CHECK: Value(%[[VAL3:.*]] = "custom.op3"() : () -> i32)
174174
print(value3)
175175
value4 = Operation.create("custom.op4", results=[i32]).results[0]
176176
# CHECK: Value(%[[VAL4:.*]] = "custom.op4"() : () -> i32)
177177
print(value4)
178+
179+
f = func.FuncOp("test", ([i32, i32], []))
180+
entry_block2 = Block.create_at_start(f.operation.regions[0], [i32, i32])
181+
with InsertionPoint(entry_block2):
182+
value5 = Operation.create("custom.op5", results=[i32]).results[0]
183+
# CHECK: Value(%[[VAL5:.*]] = "custom.op5"() : () -> i32)
184+
print(value5)
185+
value6 = Operation.create("custom.op6", results=[i32]).results[0]
186+
# CHECK: Value(%[[VAL6:.*]] = "custom.op6"() : () -> i32)
187+
print(value6)
188+
189+
func.ReturnOp([])
190+
178191
func.ReturnOp([])
179192

180193
# CHECK: %[[VAL1]]
@@ -201,17 +214,32 @@ def testValuePrintAsOperand():
201214
# CHECK: %1
202215
print(value4.get_name(use_local_scope=True))
203216

217+
# CHECK: %[[VAL5]]
218+
print(value5.get_name())
219+
# CHECK: %[[VAL6]]
220+
print(value6.get_name())
221+
204222
# CHECK: %[[ARG0:.*]]
205-
print(entry_block.arguments[0].get_name())
223+
print(entry_block1.arguments[0].get_name())
206224
# CHECK: %[[ARG1:.*]]
207-
print(entry_block.arguments[1].get_name())
225+
print(entry_block1.arguments[1].get_name())
226+
227+
# CHECK: %[[ARG2:.*]]
228+
print(entry_block2.arguments[0].get_name())
229+
# CHECK: %[[ARG3:.*]]
230+
print(entry_block2.arguments[1].get_name())
208231

209232
# CHECK: module {
210233
# CHECK: %[[VAL1]] = "custom.op1"() : () -> i32
211234
# CHECK: %[[VAL2]] = "custom.op2"() : () -> i32
212235
# CHECK: func.func @test(%[[ARG0]]: i32, %[[ARG1]]: i32) {
213236
# CHECK: %[[VAL3]] = "custom.op3"() : () -> i32
214237
# CHECK: %[[VAL4]] = "custom.op4"() : () -> i32
238+
# CHECK: func @test(%[[ARG2]]: i32, %[[ARG3]]: i32) {
239+
# CHECK: %[[VAL5]] = "custom.op5"() : () -> i32
240+
# CHECK: %[[VAL6]] = "custom.op6"() : () -> i32
241+
# CHECK: return
242+
# CHECK: }
215243
# CHECK: return
216244
# CHECK: }
217245
# CHECK: }

0 commit comments

Comments
 (0)