Skip to content

Commit dbaeb9c

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 3e86395 commit dbaeb9c

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
@@ -6,8 +6,12 @@ module {
66
cir.return
77
}
88

9+
// Should print/parse function aliases.
10+
// CHECK: cir.func @l1() alias(@l0)
911
cir.func @l1() alias(@l0)
1012

13+
// Should print/parse variadic function types.
14+
// CHECK: cir.func private @variadic(!s32i, ...) -> !s32i
1115
cir.func private @variadic(!s32i, ...) -> !s32i
1216

1317
// Should accept call with only the required parameters.
@@ -28,18 +32,25 @@ module {
2832
cir.return
2933
}
3034

31-
// Should parse void return types.
35+
// Should drop void return types.
36+
// CHECK: cir.func @parse_explicit_void_func() {
3237
cir.func @parse_explicit_void_func() -> !cir.void {
3338
cir.return
3439
}
3540

36-
// Should parse omitted void return type.
41+
// Should print/parse omitted void return type.
42+
// CHECK: cir.func @parse_func_type_with_omitted_void() {
3743
cir.func @parse_func_type_with_omitted_void() {
3844
cir.return
3945
}
4046

41-
// Should parse variadic no-proto functions.
47+
// Should print/parse variadic no-proto functions.
48+
// CHECK: cir.func no_proto private @no_proto(...) -> !s32i
4249
cir.func no_proto private @no_proto(...) -> !s32i
43-
}
4450

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

0 commit comments

Comments
 (0)