From 0ff5e42b1299c184f3eab55d37feffb06c5caee5 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 23 Aug 2023 16:38:17 -0700 Subject: [PATCH] Put the IR for the return type in the same block as the IR for the parameters. (#3145) Previously, IR generated for the computation of the return type ended up in the package's node block. Put it with the IR for the parameters for consistency and cleanliness. --- .../semantics/semantics_handle_function.cpp | 12 ++++++++ .../semantics_handle_parameter_list.cpp | 9 ------ .../testdata/array/assign_return_value.carbon | 18 +++++------- .../semantics/testdata/const/collapse.carbon | 14 ++++----- .../testdata/const/fail_collapse.carbon | 8 ++--- .../function/call/empty_struct.carbon | 5 ++-- .../testdata/function/call/empty_tuple.carbon | 5 ++-- .../index/tuple_return_value_access.carbon | 18 +++++------- .../pointer/fail_address_of_value.carbon | 29 ++++++++++--------- .../pointer/fail_type_mismatch.carbon | 11 +++---- .../testdata/pointer/nested_const.carbon | 5 ++-- .../semantics/testdata/pointer/types.carbon | 13 ++++----- .../fail_missing_return_empty_tuple.carbon | 8 ++--- .../semantics/testdata/return/struct.carbon | 11 +++---- .../semantics/testdata/return/tuple.carbon | 15 ++++------ 15 files changed, 82 insertions(+), 99 deletions(-) diff --git a/toolchain/semantics/semantics_handle_function.cpp b/toolchain/semantics/semantics_handle_function.cpp index 13ff7e2c0678..84d3a78571bb 100644 --- a/toolchain/semantics/semantics_handle_function.cpp +++ b/toolchain/semantics/semantics_handle_function.cpp @@ -11,6 +11,15 @@ namespace Carbon::Check { // definition syntax. static auto BuildFunctionDeclaration(Context& context) -> std::pair { + // TODO: This contains the IR block for the parameters and return type. At + // present, it's just loose, but it's not strictly required for parameter + // refs; we should either stop constructing it completely or, if it turns out + // to be needed, store it. Note, the underlying issue is that the LLVM IR has + // nowhere clear to emit, so changing storage would require addressing that + // problem. For comparison with function calls, the IR needs to be emitted + // prior to the call. + context.node_block_stack().Pop(); + SemIR::TypeId return_type_id = SemIR::TypeId::Invalid; if (context.parse_tree().node_kind(context.node_stack().PeekParseNode()) == ParseNodeKind::ReturnType) { @@ -98,6 +107,9 @@ auto HandleFunctionDefinitionStart(Context& context, ParseTree::Node parse_node) auto HandleFunctionIntroducer(Context& context, ParseTree::Node parse_node) -> bool { + // Create a node block to hold the nodes created as part of the function + // signature, such as parameter and return types. + context.node_block_stack().Push(); // Push the bracketing node. context.node_stack().Push(parse_node); // A name should always follow. diff --git a/toolchain/semantics/semantics_handle_parameter_list.cpp b/toolchain/semantics/semantics_handle_parameter_list.cpp index 9141188a6488..345669435761 100644 --- a/toolchain/semantics/semantics_handle_parameter_list.cpp +++ b/toolchain/semantics/semantics_handle_parameter_list.cpp @@ -19,14 +19,6 @@ auto HandleDeducedParameterListStart(Context& context, auto HandleParameterList(Context& context, ParseTree::Node parse_node) -> bool { auto refs_id = context.ParamOrArgEnd( /*for_args=*/false, ParseNodeKind::ParameterListStart); - // TODO: This contains the IR block for parameters. At present, it's just - // loose, but it's not strictly required for parameter refs; we should either - // stop constructing it completely or, if it turns out to be needed, store it. - // Note, the underlying issue is that the LLVM IR has nowhere clear to emit, - // so changing storage would require addressing that problem. For comparison - // with function calls, the IR needs to be emitted prior to the call. - context.node_block_stack().Pop(); - context.PopScope(); context.node_stack() .PopAndDiscardSoloParseNode(); @@ -44,7 +36,6 @@ auto HandleParameterListStart(Context& context, ParseTree::Node parse_node) -> bool { context.PushScope(); context.node_stack().Push(parse_node); - context.node_block_stack().Push(); context.ParamOrArgStart(); return true; } diff --git a/toolchain/semantics/testdata/array/assign_return_value.carbon b/toolchain/semantics/testdata/array/assign_return_value.carbon index 04ce03c41ed4..83d7f543623b 100644 --- a/toolchain/semantics/testdata/array/assign_return_value.carbon +++ b/toolchain/semantics/testdata/array/assign_return_value.carbon @@ -12,8 +12,8 @@ fn Run() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block3]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: [block5]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block4]}, +// CHECK:STDOUT: {name: str1, param_refs: block0, body: [block6]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -48,7 +48,7 @@ fn Run() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, @@ -67,13 +67,15 @@ fn Run() { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, @@ -94,11 +96,7 @@ fn Run() { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12: type = stub_reference i32 -// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_16.2: (type,) = tuple_value (%.loc7_12) -// CHECK:STDOUT: %.loc7_16.3: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index 005e26b60a15..c87f434b8794 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -52,15 +52,15 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -69,11 +69,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc11_32: type = const_type i32 -// CHECK:STDOUT: %.loc11_25: type = const_type const i32 -// CHECK:STDOUT: %.loc11_42: type = ptr_type const i32 -// CHECK:STDOUT: %.loc11_43: type = ptr_type const i32* -// CHECK:STDOUT: %.loc11_1 = fn_decl @F +// CHECK:STDOUT: %.loc11 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const i32**) -> const i32** { diff --git a/toolchain/semantics/testdata/const/fail_collapse.carbon b/toolchain/semantics/testdata/const/fail_collapse.carbon index 802e935f7cfd..ebcf622624c0 100644 --- a/toolchain/semantics/testdata/const/fail_collapse.carbon +++ b/toolchain/semantics/testdata/const/fail_collapse.carbon @@ -56,13 +56,13 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -71,9 +71,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc10_36: type = ptr_type i32 -// CHECK:STDOUT: %.loc10_37: type = ptr_type i32* -// CHECK:STDOUT: %.loc10_1 = fn_decl @G +// CHECK:STDOUT: %.loc10 = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%p: const i32**) -> i32** { diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index 475e48cf9b66..5e47dd46e59c 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -51,12 +51,12 @@ fn Main() { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], @@ -75,8 +75,7 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_20: {} = struct_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @Echo +// CHECK:STDOUT: %.loc7 = fn_decl @Echo // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index 79c38cb82fc1..c545555321d1 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -53,12 +53,12 @@ fn Main() { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], @@ -77,8 +77,7 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_20: () = tuple_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @Echo +// CHECK:STDOUT: %.loc7 = fn_decl @Echo // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/index/tuple_return_value_access.carbon b/toolchain/semantics/testdata/index/tuple_return_value_access.carbon index 158b7314bf90..db9e4ebd0a39 100644 --- a/toolchain/semantics/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/semantics/testdata/index/tuple_return_value_access.carbon @@ -12,8 +12,8 @@ fn Run() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block3]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, body: [block5]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block4]}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, body: [block6]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -46,7 +46,7 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, @@ -62,13 +62,15 @@ fn Run() -> i32 { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, @@ -86,11 +88,7 @@ fn Run() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12: type = stub_reference i32 -// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_16.2: (type,) = tuple_value (%.loc7_12) -// CHECK:STDOUT: %.loc7_16.3: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon index 576ade41cbe9..5aa598fef41f 100644 --- a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon @@ -86,12 +86,12 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0}, // CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1}, -// CHECK:STDOUT: {name: str3, param_refs: block0, body: [block3]}, -// CHECK:STDOUT: {name: str5, param_refs: block0, body: [block7]}, -// CHECK:STDOUT: {name: str6, param_refs: block0, body: [block8]}, -// CHECK:STDOUT: {name: str7, param_refs: block0, body: [block9]}, -// CHECK:STDOUT: {name: str8, param_refs: block0, body: [block10]}, -// CHECK:STDOUT: {name: str9, param_refs: block13, body: [block14]}, +// CHECK:STDOUT: {name: str3, param_refs: block0, body: [block4]}, +// CHECK:STDOUT: {name: str5, param_refs: block0, body: [block8]}, +// CHECK:STDOUT: {name: str6, param_refs: block0, body: [block9]}, +// CHECK:STDOUT: {name: str7, param_refs: block0, body: [block10]}, +// CHECK:STDOUT: {name: str8, param_refs: block0, body: [block11]}, +// CHECK:STDOUT: {name: str9, param_refs: block14, body: [block15]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -146,7 +146,7 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, @@ -166,13 +166,13 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type9}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type9}, // CHECK:STDOUT: {kind: PointerType, arg0: type9, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+22, type: type10}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+25, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block6, type: type1}, +// CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type1}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+28, type: type11}, // CHECK:STDOUT: {kind: Return}, @@ -204,7 +204,7 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: {kind: StubReference, arg0: node+56, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+58, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block11, type: type9}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block12, type: type9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, // CHECK:STDOUT: {kind: TupleIndex, arg0: node+60, arg1: node+61, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+62, type: type2}, @@ -222,8 +222,6 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+32, @@ -234,6 +232,10 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -331,8 +333,7 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @G -// CHECK:STDOUT: %.loc9_19: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc9_1 = fn_decl @H +// CHECK:STDOUT: %.loc9 = fn_decl @H // CHECK:STDOUT: %.loc11 = fn_decl @AddressOfLiteral // CHECK:STDOUT: %.loc38 = fn_decl @AddressOfOperator // CHECK:STDOUT: %.loc53 = fn_decl @AddressOfCall diff --git a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon index 5accd43b38e4..ed0016b207d8 100644 --- a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon @@ -53,14 +53,14 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -69,10 +69,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_43: {} = struct_value () -// CHECK:STDOUT: %.loc7_44: type = ptr_type {} -// CHECK:STDOUT: %.loc7_35: type = const_type {}* -// CHECK:STDOUT: %.loc7_1 = fn_decl @ConstMismatch +// CHECK:STDOUT: %.loc7 = fn_decl @ConstMismatch // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> const ({}*) { diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index b282e549945b..1c61a7adb3d4 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -54,12 +54,12 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -70,8 +70,7 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc8_41: type = const_type i32 -// CHECK:STDOUT: %.loc8_1 = fn_decl @F +// CHECK:STDOUT: %.loc8 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> const i32 { diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index 5f34f9a360e8..d1abebc677fd 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -54,15 +54,13 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -72,6 +70,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, @@ -82,11 +82,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_23: type = ptr_type i32 -// CHECK:STDOUT: %.loc7_1 = fn_decl @Ptr -// CHECK:STDOUT: %.loc11_32: type = const_type i32 -// CHECK:STDOUT: %.loc11_42: type = ptr_type const i32 -// CHECK:STDOUT: %.loc11_1 = fn_decl @ConstPtr +// CHECK:STDOUT: %.loc7 = fn_decl @Ptr +// CHECK:STDOUT: %.loc11 = fn_decl @ConstPtr // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Ptr(%p: i32*) -> i32* { diff --git a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon index a8f73e128e0c..dc60288c3ebf 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon @@ -12,7 +12,7 @@ fn F() -> () { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -39,6 +39,8 @@ fn F() -> () { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -46,9 +48,7 @@ fn F() -> () { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12.1: type = tuple_type () -// CHECK:STDOUT: %.loc7_12.2: () = tuple_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> () { diff --git a/toolchain/semantics/testdata/return/struct.carbon b/toolchain/semantics/testdata/return/struct.carbon index 2d575afe1d61..5f73b3f98e16 100644 --- a/toolchain/semantics/testdata/return/struct.carbon +++ b/toolchain/semantics/testdata/return/struct.carbon @@ -10,7 +10,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type1, body: [block3]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type1, body: [block4]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 3, @@ -34,7 +34,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block5, type: type1}, +// CHECK:STDOUT: {kind: StructValue, arg0: block6, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -43,12 +43,14 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, @@ -63,8 +65,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_22: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc7_1 = fn_decl @Main +// CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() -> {.a: i32} { diff --git a/toolchain/semantics/testdata/return/tuple.carbon b/toolchain/semantics/testdata/return/tuple.carbon index 507c43449be2..7e757f747064 100644 --- a/toolchain/semantics/testdata/return/tuple.carbon +++ b/toolchain/semantics/testdata/return/tuple.carbon @@ -11,7 +11,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block3]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block4]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 15, @@ -48,7 +48,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -60,13 +60,15 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, @@ -81,12 +83,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc8_15: type = stub_reference i32 -// CHECK:STDOUT: %.loc8_20: type = stub_reference i32 -// CHECK:STDOUT: %.loc8_23.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc8_23.2: (type, type) = tuple_value (%.loc8_15, %.loc8_20) -// CHECK:STDOUT: %.loc8_23.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc8_1 = fn_decl @Main +// CHECK:STDOUT: %.loc8 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() -> (i32, i32) {