Skip to content

Commit b6f2fb6

Browse files
sitio-coutolanza
authored andcommitted
[CIR][IR] Fix FuncOp duplicate attr printing (#609)
This patch ensures that only the pretty-print version of function param and result attributes is printed. The tailing dictionary attributes are no longer printed. It also ensures some FuncOp tests are properly validating both parsing and printing.
1 parent 2da5665 commit b6f2fb6

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2089,6 +2089,8 @@ void cir::FuncOp::print(OpAsmPrinter &p) {
20892089
getLinkageAttrName(),
20902090
getNoProtoAttrName(),
20912091
getSymVisibilityAttrName(),
2092+
getArgAttrsAttrName(),
2093+
getResAttrsAttrName(),
20922094
});
20932095

20942096
if (auto aliaseeName = getAliasee()) {

clang/test/CIR/IR/func.cir

+16-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ module {
88
cir.return
99
}
1010

11+
// Should print/parse function aliases.
12+
// CHECK: cir.func @l1() alias(@l0)
1113
cir.func @l1() alias(@l0)
1214

15+
// Should print/parse variadic function types.
16+
// CHECK: cir.func private @variadic(!s32i, ...) -> !s32i
1317
cir.func private @variadic(!s32i, ...) -> !s32i
1418

1519
// Should accept call with only the required parameters.
@@ -30,18 +34,25 @@ module {
3034
cir.return
3135
}
3236

33-
// Should parse void return types.
37+
// Should drop void return types.
38+
// CHECK: cir.func @parse_explicit_void_func() {
3439
cir.func @parse_explicit_void_func() -> !cir.void {
3540
cir.return
3641
}
3742

38-
// Should parse omitted void return type.
43+
// Should print/parse omitted void return type.
44+
// CHECK: cir.func @parse_func_type_with_omitted_void() {
3945
cir.func @parse_func_type_with_omitted_void() {
4046
cir.return
4147
}
4248

43-
// Should parse variadic no-proto functions.
49+
// Should print/parse variadic no-proto functions.
50+
// CHECK: cir.func no_proto private @no_proto(...) -> !s32i
4451
cir.func no_proto private @no_proto(...) -> !s32i
45-
}
4652

47-
// CHECK: cir.func @l0()
53+
// Should print/parse argument and result attributes.
54+
// CHECK: cir.func @parse_arg_res_attrs(%arg0: !u8i {cir.zeroext}) -> (!u8i {cir.zeroext}) {
55+
cir.func @parse_arg_res_attrs(%0: !u8i {cir.zeroext}) -> (!u8i {cir.zeroext}) {
56+
cir.return %0 : !u8i
57+
}
58+
}

0 commit comments

Comments
 (0)