From 5ccee62918eaf0f58a5eb356540461db05459230 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 4 Oct 2023 18:15:53 -0700 Subject: [PATCH] Add `name_reference` SemIR node for references to names. (#3260) Also add `name_reference_untyped` for references to non-first-class names without types, which currently covers namespaces and functions. This improves the fidelity of the SemIR representation, and fixes some issues where we would use the wrong location for nodes and diagnostics downstream of a name reference. We're still missing a representation for dotted name expressions, such as `Namespace.Function`, and we don't use the `untyped` node as an operand of any other node yet. --- toolchain/check/context.cpp | 20 +++++++++++ toolchain/check/context.h | 3 ++ toolchain/check/handle_call_expression.cpp | 3 +- toolchain/check/handle_name.cpp | 25 +++++++++---- .../testdata/array/array_in_place.carbon | 2 ++ .../testdata/array/assign_return_value.carbon | 1 + .../check/testdata/array/assign_var.carbon | 35 ++++++++++--------- .../testdata/array/fail_type_mismatch.carbon | 34 +++++++++--------- .../testdata/array/function_param.carbon | 7 ++-- .../testdata/basics/fail_name_lookup.carbon | 1 + .../basics/fail_qualifier_unsupported.carbon | 1 + .../testdata/basics/raw_and_textual_ir.carbon | 21 ++++++----- toolchain/check/testdata/basics/raw_ir.carbon | 18 +++++----- .../check/testdata/basics/textual_ir.carbon | 3 +- .../check/testdata/const/collapse.carbon | 3 +- .../check/testdata/const/fail_collapse.carbon | 1 + .../in_place_tuple_initialization.carbon | 15 +++++--- .../function/call/empty_struct.carbon | 4 ++- .../testdata/function/call/empty_tuple.carbon | 4 ++- .../function/call/fail_param_count.carbon | 6 ++++ .../function/call/fail_param_type.carbon | 1 + .../call/fail_return_type_mismatch.carbon | 1 + .../check/testdata/function/call/i32.carbon | 4 ++- .../function/call/more_param_ir.carbon | 1 + .../testdata/function/call/params_one.carbon | 1 + .../function/call/params_one_comma.carbon | 2 ++ .../testdata/function/call/params_two.carbon | 1 + .../function/call/params_two_comma.carbon | 2 ++ .../testdata/function/call/params_zero.carbon | 1 + .../function/call/return_implicit.carbon | 1 + .../function/declaration/simple.carbon | 1 + toolchain/check/testdata/if/else.carbon | 6 +++- .../if/fail_reachable_fallthrough.carbon | 9 +++-- toolchain/check/testdata/if/fail_scope.carbon | 13 ++++--- toolchain/check/testdata/if/no_else.carbon | 5 ++- .../if/unreachable_fallthrough.carbon | 3 +- .../check/testdata/if_expression/basic.carbon | 11 ++++-- .../if_expression/constant_condition.carbon | 4 +++ .../if_expression/control_flow.carbon | 5 ++- .../testdata/if_expression/nested.carbon | 9 +++-- .../testdata/if_expression/struct.carbon | 30 +++++++++------- .../index/array_element_access.carbon | 13 ++++--- .../testdata/index/expression_category.carbon | 13 ++++--- .../index/fail_array_large_index.carbon | 3 +- .../index/fail_array_non_int_indexing.carbon | 3 +- .../fail_array_out_of_bound_access.carbon | 3 +- .../index/fail_empty_tuple_access.carbon | 1 + .../index/fail_expression_category.carbon | 8 +++-- .../testdata/index/fail_invalid_base.carbon | 16 +++++---- .../testdata/index/fail_name_not_found.carbon | 1 + .../index/fail_non_deterministic_type.carbon | 4 ++- .../index/fail_tuple_large_index.carbon | 14 ++++---- .../index/fail_tuple_non_int_indexing.carbon | 3 +- .../fail_tuple_out_of_bound_access.carbon | 3 +- .../index/tuple_element_access.carbon | 14 ++++---- .../index/tuple_return_value_access.carbon | 1 + .../check/testdata/namespace/function.carbon | 1 + .../check/testdata/namespace/nested.carbon | 2 ++ toolchain/check/testdata/operators/and.carbon | 2 ++ .../testdata/operators/assignment.carbon | 31 ++++++++++------ .../fail_assigment_to_non_assignable.carbon | 25 +++++++------ .../fail_type_mismatch_assignment.carbon | 3 +- toolchain/check/testdata/operators/or.carbon | 2 ++ .../check/testdata/operators/unary_op.carbon | 3 +- .../testdata/pointer/address_of_deref.carbon | 3 +- .../testdata/pointer/address_of_lvalue.carbon | 15 +++++--- toolchain/check/testdata/pointer/basic.carbon | 8 +++-- .../pointer/fail_address_of_value.carbon | 5 ++- .../fail_dereference_not_pointer.carbon | 3 +- .../pointer/fail_type_mismatch.carbon | 1 + .../testdata/pointer/nested_const.carbon | 3 +- toolchain/check/testdata/pointer/types.carbon | 6 ++-- toolchain/check/testdata/struct/empty.carbon | 7 ++-- .../struct/fail_access_into_invalid.carbon | 1 + .../struct/fail_member_access_type.carbon | 1 + .../struct/fail_non_member_access.carbon | 1 + .../struct/literal_member_access.carbon | 1 + .../testdata/struct/member_access.carbon | 8 +++-- .../struct/nested_struct_in_place.carbon | 2 ++ .../check/testdata/struct/one_entry.carbon | 11 +++--- .../testdata/struct/tuple_as_element.carbon | 25 ++++++------- .../check/testdata/struct/two_entries.carbon | 23 ++++++------ toolchain/check/testdata/tuples/empty.carbon | 7 ++-- .../tuples/nested_tuple_in_place.carbon | 3 ++ .../check/testdata/tuples/one_element.carbon | 11 +++--- .../check/testdata/tuples/two_elements.carbon | 23 ++++++------ .../testdata/var/fail_init_with_self.carbon | 1 + .../var/fail_lookup_outside_scope.carbon | 1 + .../check/testdata/var/global_lookup.carbon | 9 ++--- .../var/global_lookup_in_scope.carbon | 5 +-- toolchain/check/testdata/var/lookup.carbon | 1 + toolchain/lower/handle.cpp | 12 +++++++ toolchain/sem_ir/file.cpp | 17 +++++++-- toolchain/sem_ir/file.h | 2 ++ toolchain/sem_ir/formatter.cpp | 10 ++++++ toolchain/sem_ir/node.h | 7 ++++ toolchain/sem_ir/node_kind.def | 4 +++ 97 files changed, 489 insertions(+), 235 deletions(-) diff --git a/toolchain/check/context.cpp b/toolchain/check/context.cpp index 08b5d057e67c..4f1121e9097b 100644 --- a/toolchain/check/context.cpp +++ b/toolchain/check/context.cpp @@ -144,6 +144,26 @@ auto Context::PopScope() -> void { } } +auto Context::FollowNameReferences(SemIR::NodeId node_id) -> SemIR::NodeId { + while (true) { + auto node = semantics_ir().GetNode(node_id); + switch (node.kind()) { + case SemIR::NodeKind::NameReference: { + auto [name_id, value_id] = node.GetAsNameReference(); + node_id = value_id; + break; + } + case SemIR::NodeKind::NameReferenceUntyped: { + auto [name_id, value_id] = node.GetAsNameReferenceUntyped(); + node_id = value_id; + break; + } + default: + return node_id; + } + } +} + template static auto AddDominatedBlockAndBranchImpl(Context& context, Parse::Node parse_node, Args... args) diff --git a/toolchain/check/context.h b/toolchain/check/context.h index acff030b079e..0b5504e00fd2 100644 --- a/toolchain/check/context.h +++ b/toolchain/check/context.h @@ -64,6 +64,9 @@ class Context { // Pops the top scope from scope_stack_, cleaning up names from name_lookup_. auto PopScope() -> void; + // Follows NameReference nodes to find the value named by a given node. + auto FollowNameReferences(SemIR::NodeId node_id) -> SemIR::NodeId; + // Adds a `Branch` node branching to a new node block, and returns the ID of // the new block. All paths to the branch target must go through the current // block, though not necessarily through this branch. diff --git a/toolchain/check/handle_call_expression.cpp b/toolchain/check/handle_call_expression.cpp index d509eac1612f..d920aabd2f0c 100644 --- a/toolchain/check/handle_call_expression.cpp +++ b/toolchain/check/handle_call_expression.cpp @@ -17,7 +17,8 @@ auto HandleCallExpression(Context& context, Parse::Node parse_node) -> bool { auto [call_expr_parse_node, name_id] = context.node_stack() .PopWithParseNode(); - auto name_node = context.semantics_ir().GetNode(name_id); + auto name_node = + context.semantics_ir().GetNode(context.FollowNameReferences(name_id)); if (name_node.kind() != SemIR::NodeKind::FunctionDeclaration) { // TODO: Work on error. context.TODO(parse_node, "Not a callable name"); diff --git a/toolchain/check/handle_name.cpp b/toolchain/check/handle_name.cpp index 66be7b4d1d58..8b7db384dcf5 100644 --- a/toolchain/check/handle_name.cpp +++ b/toolchain/check/handle_name.cpp @@ -15,7 +15,8 @@ auto HandleMemberAccessExpression(Context& context, Parse::Node parse_node) auto base_id = context.node_stack().PopExpression(); - auto base = context.semantics_ir().GetNode(base_id); + auto base = + context.semantics_ir().GetNode(context.FollowNameReferences(base_id)); if (base.kind() == SemIR::NodeKind::Namespace) { // For a namespace, just resolve the name. auto node_id = @@ -90,10 +91,22 @@ auto HandleName(Context& context, Parse::Node parse_node) -> bool { auto HandleNameExpression(Context& context, Parse::Node parse_node) -> bool { auto name_str = context.parse_tree().GetNodeText(parse_node); auto name_id = context.semantics_ir().AddString(name_str); - context.node_stack().Push( - parse_node, + auto value_id = context.LookupName(parse_node, name_id, SemIR::NameScopeId::Invalid, - /*print_diagnostics=*/true)); + /*print_diagnostics=*/true); + auto value = context.semantics_ir().GetNode(value_id); + if (value.kind().value_kind() == SemIR::NodeValueKind::Typed) { + // This is a reference to a name binding that has a value and a type. + context.AddNodeAndPush(parse_node, + SemIR::Node::NameReference::Make( + parse_node, value.type_id(), name_id, value_id)); + } else { + // This is something like a namespace name, that can be found by name lookup + // but isn't a first-class value with a type. + context.AddNodeAndPush(parse_node, + SemIR::Node::NameReferenceUntyped::Make( + parse_node, value.type_id(), name_id, value_id)); + } return true; } @@ -105,8 +118,8 @@ auto HandleQualifiedDeclaration(Context& context, Parse::Node parse_node) // First QualifiedDeclaration in a chain. auto [parse_node1, node_id1] = context.node_stack().PopExpressionWithParseNode(); - context.declaration_name_stack().ApplyExpressionQualifier(parse_node1, - node_id1); + context.declaration_name_stack().ApplyExpressionQualifier( + parse_node1, context.FollowNameReferences(node_id1)); // Add the QualifiedDeclaration so that it can be used for bracketing. context.node_stack().Push(parse_node); } else { diff --git a/toolchain/check/testdata/array/array_in_place.carbon b/toolchain/check/testdata/array/array_in_place.carbon index be1ce7023b26..b7ec0a6ecec4 100644 --- a/toolchain/check/testdata/array/array_in_place.carbon +++ b/toolchain/check/testdata/array/array_in_place.carbon @@ -23,11 +23,13 @@ fn G() { // CHECK:STDOUT: %.loc10_28: i32 = int_literal 2 // CHECK:STDOUT: %.loc10_29: type = array_type %.loc10_28, (i32, i32, i32) // CHECK:STDOUT: %v: ref [(i32, i32, i32); 2] = var "v" +// CHECK:STDOUT: %F.ref.loc10_34 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc10_42.3: ref (i32, i32, i32) = splice_block %.loc10_42.2 { // CHECK:STDOUT: %.loc10_42.1: i32 = int_literal 0 // CHECK:STDOUT: %.loc10_42.2: ref (i32, i32, i32) = array_index %v, %.loc10_42.1 // CHECK:STDOUT: } // CHECK:STDOUT: %.loc10_35: init (i32, i32, i32) = call @F() to %.loc10_42.3 +// CHECK:STDOUT: %F.ref.loc10_39 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc10_42.6: ref (i32, i32, i32) = splice_block %.loc10_42.5 { // CHECK:STDOUT: %.loc10_42.4: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_42.5: ref (i32, i32, i32) = array_index %v, %.loc10_42.4 diff --git a/toolchain/check/testdata/array/assign_return_value.carbon b/toolchain/check/testdata/array/assign_return_value.carbon index daa2fc6ee5e3..033aa725a447 100644 --- a/toolchain/check/testdata/array/assign_return_value.carbon +++ b/toolchain/check/testdata/array/assign_return_value.carbon @@ -28,6 +28,7 @@ fn Run() { // CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_17: type = array_type %.loc10_16, i32 // CHECK:STDOUT: %t: ref [i32; 1] = var "t" +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc10_22.1: init (i32,) = call @F() // CHECK:STDOUT: %.loc10_22.2: ref (i32,) = temporary_storage // CHECK:STDOUT: %.loc10_22.3: ref (i32,) = temporary %.loc10_22.2, %.loc10_22.1 diff --git a/toolchain/check/testdata/array/assign_var.carbon b/toolchain/check/testdata/array/assign_var.carbon index 90191833f3be..e205b7fd155d 100644 --- a/toolchain/check/testdata/array/assign_var.carbon +++ b/toolchain/check/testdata/array/assign_var.carbon @@ -27,21 +27,22 @@ var b: [i32; 3] = a; // CHECK:STDOUT: %.loc8_14: i32 = int_literal 3 // CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, i32 // CHECK:STDOUT: %b: ref [i32; 3] = var "b" -// CHECK:STDOUT: %.loc7_5.1: ref i32 = tuple_access %a, member0 -// CHECK:STDOUT: %.loc7_5.2: i32 = bind_value %.loc7_5.1 -// CHECK:STDOUT: %.loc7_5.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_5.4: ref i32 = array_index %b, %.loc7_5.3 -// CHECK:STDOUT: %.loc7_5.5: init i32 = initialize_from %.loc7_5.2 to %.loc7_5.4 -// CHECK:STDOUT: %.loc7_5.6: ref i32 = tuple_access %a, member1 -// CHECK:STDOUT: %.loc7_5.7: i32 = bind_value %.loc7_5.6 -// CHECK:STDOUT: %.loc7_5.8: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_5.9: ref i32 = array_index %b, %.loc7_5.8 -// CHECK:STDOUT: %.loc7_5.10: init i32 = initialize_from %.loc7_5.7 to %.loc7_5.9 -// CHECK:STDOUT: %.loc7_5.11: ref i32 = tuple_access %a, member2 -// CHECK:STDOUT: %.loc7_5.12: i32 = bind_value %.loc7_5.11 -// CHECK:STDOUT: %.loc7_5.13: i32 = int_literal 2 -// CHECK:STDOUT: %.loc7_5.14: ref i32 = array_index %b, %.loc7_5.13 -// CHECK:STDOUT: %.loc7_5.15: init i32 = initialize_from %.loc7_5.12 to %.loc7_5.14 -// CHECK:STDOUT: %.loc7_5.16: init [i32; 3] = array_init %a, (%.loc7_5.5, %.loc7_5.10, %.loc7_5.15) to %b -// CHECK:STDOUT: assign %b, %.loc7_5.16 +// CHECK:STDOUT: %a.ref: ref (i32, i32, i32) = name_reference "a", %a +// CHECK:STDOUT: %.loc8_19.1: ref i32 = tuple_access %a.ref, member0 +// CHECK:STDOUT: %.loc8_19.2: i32 = bind_value %.loc8_19.1 +// CHECK:STDOUT: %.loc8_19.3: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_19.4: ref i32 = array_index %b, %.loc8_19.3 +// CHECK:STDOUT: %.loc8_19.5: init i32 = initialize_from %.loc8_19.2 to %.loc8_19.4 +// CHECK:STDOUT: %.loc8_19.6: ref i32 = tuple_access %a.ref, member1 +// CHECK:STDOUT: %.loc8_19.7: i32 = bind_value %.loc8_19.6 +// CHECK:STDOUT: %.loc8_19.8: i32 = int_literal 1 +// CHECK:STDOUT: %.loc8_19.9: ref i32 = array_index %b, %.loc8_19.8 +// CHECK:STDOUT: %.loc8_19.10: init i32 = initialize_from %.loc8_19.7 to %.loc8_19.9 +// CHECK:STDOUT: %.loc8_19.11: ref i32 = tuple_access %a.ref, member2 +// CHECK:STDOUT: %.loc8_19.12: i32 = bind_value %.loc8_19.11 +// CHECK:STDOUT: %.loc8_19.13: i32 = int_literal 2 +// CHECK:STDOUT: %.loc8_19.14: ref i32 = array_index %b, %.loc8_19.13 +// CHECK:STDOUT: %.loc8_19.15: init i32 = initialize_from %.loc8_19.12 to %.loc8_19.14 +// CHECK:STDOUT: %.loc8_19.16: init [i32; 3] = array_init %a.ref, (%.loc8_19.5, %.loc8_19.10, %.loc8_19.15) to %b +// CHECK:STDOUT: assign %b, %.loc8_19.16 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/fail_type_mismatch.carbon b/toolchain/check/testdata/array/fail_type_mismatch.carbon index 4cdf82c38f08..483628d9332b 100644 --- a/toolchain/check/testdata/array/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/array/fail_type_mismatch.carbon @@ -9,10 +9,10 @@ // CHECK:STDERR: ^ var a: [i32; 3] = (1, "Hello", "World"); -// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:5: ERROR: Cannot implicitly convert from `String` to `i32`. -// CHECK:STDERR: var t1: (i32, String, String); -// CHECK:STDERR: ^ var t1: (i32, String, String); +// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:19: ERROR: Cannot implicitly convert from `String` to `i32`. +// CHECK:STDERR: var b: [i32; 3] = t1; +// CHECK:STDERR: ^ var b: [i32; 3] = t1; // CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:24: ERROR: Cannot initialize array of 3 element(s) from 2 initializer(s). @@ -20,10 +20,10 @@ var b: [i32; 3] = t1; // CHECK:STDERR: ^ var c: [i32; 3] = (1, 2); -// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:5: ERROR: Cannot initialize array of 3 element(s) from tuple with 2 element(s). -// CHECK:STDERR: var t2: (i32, i32); -// CHECK:STDERR: ^ var t2: (i32, i32); +// CHECK:STDERR: fail_type_mismatch.carbon:[[@LINE+3]]:19: ERROR: Cannot initialize array of 3 element(s) from tuple with 2 element(s). +// CHECK:STDERR: var d: [i32; 3] = t2; +// CHECK:STDERR: ^ var d: [i32; 3] = t2; // CHECK:STDOUT: file "fail_type_mismatch.carbon" { @@ -39,18 +39,19 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: %.loc10_39.4: ref i32 = array_index %a, %.loc10_39.3 // CHECK:STDOUT: %.loc10_39.5: init i32 = initialize_from %.loc10_20 to %.loc10_39.4 // CHECK:STDOUT: assign %a, -// CHECK:STDOUT: %.loc15_29.1: type = tuple_type (type, type, type) -// CHECK:STDOUT: %.loc15_29.2: (type, type, type) = tuple_literal (i32, String, String) +// CHECK:STDOUT: %.loc12_29.1: type = tuple_type (type, type, type) +// CHECK:STDOUT: %.loc12_29.2: (type, type, type) = tuple_literal (i32, String, String) // CHECK:STDOUT: %t1: ref (i32, String, String) = var "t1" // CHECK:STDOUT: %.loc16_14: i32 = int_literal 3 // CHECK:STDOUT: %.loc16_15: type = array_type %.loc16_14, i32 // CHECK:STDOUT: %b: ref [i32; 3] = var "b" -// CHECK:STDOUT: %.loc15_5.1: ref i32 = tuple_access %t1, member0 -// CHECK:STDOUT: %.loc15_5.2: i32 = bind_value %.loc15_5.1 -// CHECK:STDOUT: %.loc15_5.3: i32 = int_literal 0 -// CHECK:STDOUT: %.loc15_5.4: ref i32 = array_index %b, %.loc15_5.3 -// CHECK:STDOUT: %.loc15_5.5: init i32 = initialize_from %.loc15_5.2 to %.loc15_5.4 -// CHECK:STDOUT: %.loc15_5.6: ref String = tuple_access %t1, member1 +// CHECK:STDOUT: %t1.ref: ref (i32, String, String) = name_reference "t1", %t1 +// CHECK:STDOUT: %.loc16_19.1: ref i32 = tuple_access %t1.ref, member0 +// CHECK:STDOUT: %.loc16_19.2: i32 = bind_value %.loc16_19.1 +// CHECK:STDOUT: %.loc16_19.3: i32 = int_literal 0 +// CHECK:STDOUT: %.loc16_19.4: ref i32 = array_index %b, %.loc16_19.3 +// CHECK:STDOUT: %.loc16_19.5: init i32 = initialize_from %.loc16_19.2 to %.loc16_19.4 +// CHECK:STDOUT: %.loc16_19.6: ref String = tuple_access %t1.ref, member1 // CHECK:STDOUT: assign %b, // CHECK:STDOUT: %.loc21_14: i32 = int_literal 3 // CHECK:STDOUT: %.loc21_15: type = array_type %.loc21_14, i32 @@ -60,11 +61,12 @@ var d: [i32; 3] = t2; // CHECK:STDOUT: %.loc21_24.1: type = tuple_type (i32, i32) // CHECK:STDOUT: %.loc21_24.2: (i32, i32) = tuple_literal (%.loc21_20, %.loc21_23) // CHECK:STDOUT: assign %c, -// CHECK:STDOUT: %.loc26_18.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc26_18.2: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: %.loc23_18.1: type = tuple_type (type, type) +// CHECK:STDOUT: %.loc23_18.2: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %t2: ref (i32, i32) = var "t2" // CHECK:STDOUT: %.loc27_14: i32 = int_literal 3 // CHECK:STDOUT: %.loc27_15: type = array_type %.loc27_14, i32 // CHECK:STDOUT: %d: ref [i32; 3] = var "d" +// CHECK:STDOUT: %t2.ref: ref (i32, i32) = name_reference "t2", %t2 // CHECK:STDOUT: assign %d, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/array/function_param.carbon b/toolchain/check/testdata/array/function_param.carbon index c29e113505b9..4777c82bb7c7 100644 --- a/toolchain/check/testdata/array/function_param.carbon +++ b/toolchain/check/testdata/array/function_param.carbon @@ -19,14 +19,17 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%arr: [i32; 3], %i: i32) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_15.1: ref [i32; 3] = value_as_reference %arr -// CHECK:STDOUT: %.loc8_15.2: ref i32 = array_index %.loc8_15.1, %i +// CHECK:STDOUT: %arr.ref: [i32; 3] = name_reference "arr", %arr +// CHECK:STDOUT: %i.ref: i32 = name_reference "i", %i +// CHECK:STDOUT: %.loc8_15.1: ref [i32; 3] = value_as_reference %arr.ref +// CHECK:STDOUT: %.loc8_15.2: ref i32 = array_index %.loc8_15.1, %i.ref // CHECK:STDOUT: %.loc8_15.3: i32 = bind_value %.loc8_15.2 // CHECK:STDOUT: return %.loc8_15.3 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc12_13: i32 = int_literal 1 // CHECK:STDOUT: %.loc12_16: i32 = int_literal 2 // CHECK:STDOUT: %.loc12_19: i32 = int_literal 3 diff --git a/toolchain/check/testdata/basics/fail_name_lookup.carbon b/toolchain/check/testdata/basics/fail_name_lookup.carbon index d6736265b0e7..c780bac0d462 100644 --- a/toolchain/check/testdata/basics/fail_name_lookup.carbon +++ b/toolchain/check/testdata/basics/fail_name_lookup.carbon @@ -17,5 +17,6 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %x.ref: = name_reference "x", // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon b/toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon index 44dd88151dd8..5a0cf64991a5 100644 --- a/toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon +++ b/toolchain/check/testdata/basics/fail_qualifier_unsupported.carbon @@ -13,5 +13,6 @@ var y: i32 = x.b; // CHECK:STDOUT: file "fail_qualifier_unsupported.carbon" { // CHECK:STDOUT: %x: ref i32 = var "x" // CHECK:STDOUT: %y: ref i32 = var "y" +// CHECK:STDOUT: %x.ref: ref i32 = name_reference "x", %x // CHECK:STDOUT: assign %y, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/basics/raw_and_textual_ir.carbon b/toolchain/check/testdata/basics/raw_and_textual_ir.carbon index ea6ea9aef695..089817b94b6a 100644 --- a/toolchain/check/testdata/basics/raw_and_textual_ir.carbon +++ b/toolchain/check/testdata/basics/raw_and_textual_ir.carbon @@ -52,16 +52,17 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, +// CHECK:STDOUT: {kind: NameReference, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+0, arg1: node+6, type: type0}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+6, arg1: node+7, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type2}, // CHECK:STDOUT: {kind: TupleLiteral, arg0: block5, type: type3}, // CHECK:STDOUT: {kind: TupleAccess, arg0: node+4, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+11, type: type0}, // CHECK:STDOUT: {kind: TupleAccess, arg0: node+4, arg1: member1, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+12, type: type2}, -// CHECK:STDOUT: {kind: TupleInit, arg0: node+9, arg1: block6, type: type3}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: TupleInit, arg0: node+10, arg1: block6, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -91,14 +92,15 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -111,8 +113,9 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Foo(%n: i32) -> %return: (i32, f64) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %n.ref: i32 = name_reference "n", %n // CHECK:STDOUT: %.loc12_15: i32 = int_literal 2 -// CHECK:STDOUT: %.loc12_13: i32 = add %n, %.loc12_15 +// CHECK:STDOUT: %.loc12_13: i32 = add %n.ref, %.loc12_15 // CHECK:STDOUT: %.loc12_18: f64 = real_literal 34e-1 // CHECK:STDOUT: %.loc12_21.1: (i32, f64) = tuple_literal (%.loc12_13, %.loc12_18) // CHECK:STDOUT: %.loc12_21.2: ref i32 = tuple_access %return, member0 diff --git a/toolchain/check/testdata/basics/raw_ir.carbon b/toolchain/check/testdata/basics/raw_ir.carbon index 6ee38a3b65d1..75368e3f87d5 100644 --- a/toolchain/check/testdata/basics/raw_ir.carbon +++ b/toolchain/check/testdata/basics/raw_ir.carbon @@ -52,16 +52,17 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, +// CHECK:STDOUT: {kind: NameReference, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+0, arg1: node+6, type: type0}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+6, arg1: node+7, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type2}, // CHECK:STDOUT: {kind: TupleLiteral, arg0: block5, type: type3}, // CHECK:STDOUT: {kind: TupleAccess, arg0: node+4, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+11, type: type0}, // CHECK:STDOUT: {kind: TupleAccess, arg0: node+4, arg1: member1, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+12, type: type2}, -// CHECK:STDOUT: {kind: TupleInit, arg0: node+9, arg1: block6, type: type3}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: TupleInit, arg0: node+10, arg1: block6, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -91,14 +92,15 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, diff --git a/toolchain/check/testdata/basics/textual_ir.carbon b/toolchain/check/testdata/basics/textual_ir.carbon index bd4fbe0971bd..fef263e94e4e 100644 --- a/toolchain/check/testdata/basics/textual_ir.carbon +++ b/toolchain/check/testdata/basics/textual_ir.carbon @@ -18,8 +18,9 @@ fn Foo(n: i32) -> (i32, f64) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Foo(%n: i32) -> %return: (i32, f64) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %n.ref: i32 = name_reference "n", %n // CHECK:STDOUT: %.loc12_15: i32 = int_literal 2 -// CHECK:STDOUT: %.loc12_13: i32 = add %n, %.loc12_15 +// CHECK:STDOUT: %.loc12_13: i32 = add %n.ref, %.loc12_15 // CHECK:STDOUT: %.loc12_18: f64 = real_literal 34e-1 // CHECK:STDOUT: %.loc12_21.1: (i32, f64) = tuple_literal (%.loc12_13, %.loc12_18) // CHECK:STDOUT: %.loc12_21.2: ref i32 = tuple_access %return, member0 diff --git a/toolchain/check/testdata/const/collapse.carbon b/toolchain/check/testdata/const/collapse.carbon index 418353067b6f..daeb38573faa 100644 --- a/toolchain/check/testdata/const/collapse.carbon +++ b/toolchain/check/testdata/const/collapse.carbon @@ -18,5 +18,6 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const i32**) -> const i32** { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %p +// CHECK:STDOUT: %p.ref: const i32** = name_reference "p", %p +// CHECK:STDOUT: return %p.ref // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/const/fail_collapse.carbon b/toolchain/check/testdata/const/fail_collapse.carbon index d17fcfec4084..8f7c863271e4 100644 --- a/toolchain/check/testdata/const/fail_collapse.carbon +++ b/toolchain/check/testdata/const/fail_collapse.carbon @@ -20,5 +20,6 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%p: const i32**) -> i32** { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %p.ref: const i32** = name_reference "p", %p // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/expression_category/in_place_tuple_initialization.carbon b/toolchain/check/testdata/expression_category/in_place_tuple_initialization.carbon index 3c8bb603f9cd..570cd82c4c7e 100644 --- a/toolchain/check/testdata/expression_category/in_place_tuple_initialization.carbon +++ b/toolchain/check/testdata/expression_category/in_place_tuple_initialization.carbon @@ -28,12 +28,16 @@ fn H() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_19: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %v: ref (i32, i32) = var "v" -// CHECK:STDOUT: %.loc10_7.1: ref (i32, i32) = splice_block %v {} -// CHECK:STDOUT: %.loc10_24: init (i32, i32) = call @F() to %.loc10_7.1 +// CHECK:STDOUT: %F.ref.loc10 = name_reference_untyped "F", package.%F +// CHECK:STDOUT: %.loc10_7: ref (i32, i32) = splice_block %v {} +// CHECK:STDOUT: %.loc10_24: init (i32, i32) = call @F() to %.loc10_7 // CHECK:STDOUT: assign %v, %.loc10_24 -// CHECK:STDOUT: %.loc10_7.2: ref (i32, i32) = splice_block %v {} -// CHECK:STDOUT: %.loc11: init (i32, i32) = call @F() to %.loc10_7.2 -// CHECK:STDOUT: assign %v, %.loc11 +// CHECK:STDOUT: %v.ref: ref (i32, i32) = name_reference "v", %v +// CHECK:STDOUT: %F.ref.loc11 = name_reference_untyped "F", package.%F +// CHECK:STDOUT: %.loc11_3: ref (i32, i32) = splice_block %v.ref {} +// CHECK:STDOUT: %.loc11_8: init (i32, i32) = call @F() to %.loc11_3 +// CHECK:STDOUT: assign %v.ref, %.loc11_8 +// CHECK:STDOUT: %F.ref.loc12 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc9: ref (i32, i32) = splice_block %return {} // CHECK:STDOUT: %.loc12: init (i32, i32) = call @F() to %.loc9 // CHECK:STDOUT: return %.loc12 @@ -41,6 +45,7 @@ fn H() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @H() -> i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %G.ref = name_reference_untyped "G", package.%G // CHECK:STDOUT: %.loc16_11.1: ref (i32, i32) = temporary_storage // CHECK:STDOUT: %.loc16_11.2: init (i32, i32) = call @G() to %.loc16_11.1 // CHECK:STDOUT: %.loc16_14: i32 = int_literal 0 diff --git a/toolchain/check/testdata/function/call/empty_struct.carbon b/toolchain/check/testdata/function/call/empty_struct.carbon index 5c47aa2593d2..6e323e280f6b 100644 --- a/toolchain/check/testdata/function/call/empty_struct.carbon +++ b/toolchain/check/testdata/function/call/empty_struct.carbon @@ -19,11 +19,13 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: {}) -> {} { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %a.ref: {} = name_reference "a", %a +// CHECK:STDOUT: return %a.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Echo.ref = name_reference_untyped "Echo", package.%Echo // CHECK:STDOUT: %.loc12_9.1: {} = struct_literal () // CHECK:STDOUT: %.loc12_9.2: {} = struct_value %.loc12_9.1, () // CHECK:STDOUT: %.loc12_7: init {} = call @Echo(%.loc12_9.2) diff --git a/toolchain/check/testdata/function/call/empty_tuple.carbon b/toolchain/check/testdata/function/call/empty_tuple.carbon index 878e7019e1a5..7393dd462bc4 100644 --- a/toolchain/check/testdata/function/call/empty_tuple.carbon +++ b/toolchain/check/testdata/function/call/empty_tuple.carbon @@ -19,11 +19,13 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: ()) -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %a.ref: () = name_reference "a", %a +// CHECK:STDOUT: return %a.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Echo.ref = name_reference_untyped "Echo", package.%Echo // CHECK:STDOUT: %.loc12_9.1: () = tuple_literal () // CHECK:STDOUT: %.loc12_9.2: () = tuple_value %.loc12_9.1, () // CHECK:STDOUT: %.loc12_7: init () = call @Echo(%.loc12_9.2) diff --git a/toolchain/check/testdata/function/call/fail_param_count.carbon b/toolchain/check/testdata/function/call/fail_param_count.carbon index a3adfcef47b9..4fae95f63b94 100644 --- a/toolchain/check/testdata/function/call/fail_param_count.carbon +++ b/toolchain/check/testdata/function/call/fail_param_count.carbon @@ -79,12 +79,18 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Run0.ref.loc18 = name_reference_untyped "Run0", package.%Run0 // CHECK:STDOUT: %.loc18_8: i32 = int_literal 1 // CHECK:STDOUT: %.loc18_7: type = tuple_type () +// CHECK:STDOUT: %Run0.ref.loc25 = name_reference_untyped "Run0", package.%Run0 // CHECK:STDOUT: %.loc25_8: i32 = int_literal 0 // CHECK:STDOUT: %.loc25_11: i32 = int_literal 1 +// CHECK:STDOUT: %Run1.ref.loc33 = name_reference_untyped "Run1", package.%Run1 +// CHECK:STDOUT: %Run1.ref.loc40 = name_reference_untyped "Run1", package.%Run1 // CHECK:STDOUT: %.loc40_8: i32 = int_literal 0 // CHECK:STDOUT: %.loc40_11: i32 = int_literal 1 +// CHECK:STDOUT: %Run2.ref.loc48 = name_reference_untyped "Run2", package.%Run2 +// CHECK:STDOUT: %Run2.ref.loc55 = name_reference_untyped "Run2", package.%Run2 // CHECK:STDOUT: %.loc55: i32 = int_literal 0 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/function/call/fail_param_type.carbon b/toolchain/check/testdata/function/call/fail_param_type.carbon index 9b12f8a4c9d0..fd18560d02e9 100644 --- a/toolchain/check/testdata/function/call/fail_param_type.carbon +++ b/toolchain/check/testdata/function/call/fail_param_type.carbon @@ -28,6 +28,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Run.ref = name_reference_untyped "Run", package.%Run // CHECK:STDOUT: %.loc16_7: f64 = real_literal 10e-1 // CHECK:STDOUT: %.loc16_6: type = tuple_type () // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon index 3c574c098fca..638b805e752f 100644 --- a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon @@ -27,6 +27,7 @@ fn Run() { // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: ref i32 = var "x" +// CHECK:STDOUT: %Foo.ref = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc13: init f64 = call @Foo() // CHECK:STDOUT: assign %x, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/function/call/i32.carbon b/toolchain/check/testdata/function/call/i32.carbon index 6e23c96eed36..1647f5092dd8 100644 --- a/toolchain/check/testdata/function/call/i32.carbon +++ b/toolchain/check/testdata/function/call/i32.carbon @@ -19,12 +19,14 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: i32) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %a.ref: i32 = name_reference "a", %a +// CHECK:STDOUT: return %a.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %b: ref i32 = var "b" +// CHECK:STDOUT: %Echo.ref = name_reference_untyped "Echo", package.%Echo // CHECK:STDOUT: %.loc12_21: i32 = int_literal 1 // CHECK:STDOUT: %.loc12_20: init i32 = call @Echo(%.loc12_21) // CHECK:STDOUT: assign %b, %.loc12_20 diff --git a/toolchain/check/testdata/function/call/more_param_ir.carbon b/toolchain/check/testdata/function/call/more_param_ir.carbon index 69b47111c95d..a00a89158197 100644 --- a/toolchain/check/testdata/function/call/more_param_ir.carbon +++ b/toolchain/check/testdata/function/call/more_param_ir.carbon @@ -23,6 +23,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Foo.ref = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_11: i32 = int_literal 2 // CHECK:STDOUT: %.loc11_9: i32 = add %.loc11_7, %.loc11_11 diff --git a/toolchain/check/testdata/function/call/params_one.carbon b/toolchain/check/testdata/function/call/params_one.carbon index 49631efdfff8..e28b17e5a1a7 100644 --- a/toolchain/check/testdata/function/call/params_one.carbon +++ b/toolchain/check/testdata/function/call/params_one.carbon @@ -22,6 +22,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Foo.ref = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: init () = call @Foo(%.loc10_7) diff --git a/toolchain/check/testdata/function/call/params_one_comma.carbon b/toolchain/check/testdata/function/call/params_one_comma.carbon index 7329151160a5..aaf2606e0e60 100644 --- a/toolchain/check/testdata/function/call/params_one_comma.carbon +++ b/toolchain/check/testdata/function/call/params_one_comma.carbon @@ -23,9 +23,11 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Foo.ref.loc10 = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: init () = call @Foo(%.loc10_7) +// CHECK:STDOUT: %Foo.ref.loc11 = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_6: init () = call @Foo(%.loc11_7) // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/function/call/params_two.carbon b/toolchain/check/testdata/function/call/params_two.carbon index 72c28c51cac2..9d8a77149c60 100644 --- a/toolchain/check/testdata/function/call/params_two.carbon +++ b/toolchain/check/testdata/function/call/params_two.carbon @@ -22,6 +22,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Foo.ref = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () diff --git a/toolchain/check/testdata/function/call/params_two_comma.carbon b/toolchain/check/testdata/function/call/params_two_comma.carbon index 6099775a8c96..ca1c9e459946 100644 --- a/toolchain/check/testdata/function/call/params_two_comma.carbon +++ b/toolchain/check/testdata/function/call/params_two_comma.carbon @@ -23,10 +23,12 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Foo.ref.loc10 = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc10_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_10: i32 = int_literal 2 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: init () = call @Foo(%.loc10_7, %.loc10_10) +// CHECK:STDOUT: %Foo.ref.loc11 = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc11_7: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_10: i32 = int_literal 2 // CHECK:STDOUT: %.loc11_6: init () = call @Foo(%.loc11_7, %.loc11_10) diff --git a/toolchain/check/testdata/function/call/params_zero.carbon b/toolchain/check/testdata/function/call/params_zero.carbon index fe2f345d0d9a..908de8b21850 100644 --- a/toolchain/check/testdata/function/call/params_zero.carbon +++ b/toolchain/check/testdata/function/call/params_zero.carbon @@ -22,6 +22,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Foo.ref = name_reference_untyped "Foo", package.%Foo // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: init () = call @Foo() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/function/call/return_implicit.carbon b/toolchain/check/testdata/function/call/return_implicit.carbon index 19a5a325d335..b1074eb2943c 100644 --- a/toolchain/check/testdata/function/call/return_implicit.carbon +++ b/toolchain/check/testdata/function/call/return_implicit.carbon @@ -26,6 +26,7 @@ fn Main() { // CHECK:STDOUT: %.loc11_11.1: type = tuple_type () // CHECK:STDOUT: %.loc11_11.2: () = tuple_literal () // CHECK:STDOUT: %b: ref () = var "b" +// CHECK:STDOUT: %MakeImplicitEmptyTuple.ref = name_reference_untyped "MakeImplicitEmptyTuple", package.%MakeImplicitEmptyTuple // CHECK:STDOUT: %.loc11_37: init () = call @MakeImplicitEmptyTuple() // CHECK:STDOUT: assign %b, %.loc11_37 // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/function/declaration/simple.carbon b/toolchain/check/testdata/function/declaration/simple.carbon index e9e52868f4af..d1b3722e1088 100644 --- a/toolchain/check/testdata/function/declaration/simple.carbon +++ b/toolchain/check/testdata/function/declaration/simple.carbon @@ -17,6 +17,7 @@ fn G() { F(); } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc9_11.1: type = tuple_type () // CHECK:STDOUT: %.loc9_11.2: init () = call @F() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/if/else.carbon b/toolchain/check/testdata/if/else.carbon index f778ba2e9231..b9e2676dde3e 100644 --- a/toolchain/check/testdata/if/else.carbon +++ b/toolchain/check/testdata/if/else.carbon @@ -41,18 +41,22 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.then else br !if.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc13_6.1: type = tuple_type () // CHECK:STDOUT: %.loc13_6.2: init () = call @F() // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.else: +// CHECK:STDOUT: %G.ref = name_reference_untyped "G", package.%G // CHECK:STDOUT: %.loc15: init () = call @G() // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.done: +// CHECK:STDOUT: %H.ref = name_reference_untyped "H", package.%H // CHECK:STDOUT: %.loc17: init () = call @H() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon index aece667e690a..7062ac0dada4 100644 --- a/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/check/testdata/if/fail_reachable_fallthrough.carbon @@ -41,7 +41,8 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If1(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.then else br !if.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc9: i32 = int_literal 1 @@ -55,7 +56,8 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If2(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.then else br !if.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: br !if.done @@ -69,7 +71,8 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If3(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.then else br !if.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc29: i32 = int_literal 1 diff --git a/toolchain/check/testdata/if/fail_scope.carbon b/toolchain/check/testdata/if/fail_scope.carbon index 659a6ecee88b..d3edf43162ad 100644 --- a/toolchain/check/testdata/if/fail_scope.carbon +++ b/toolchain/check/testdata/if/fail_scope.carbon @@ -21,15 +21,18 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @VarScope(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.then else br !if.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n: ref i32 = var "n" -// CHECK:STDOUT: %.loc9_18: i32 = int_literal 2 -// CHECK:STDOUT: assign %n, %.loc9_18 -// CHECK:STDOUT: %.loc9_9: i32 = bind_value %n -// CHECK:STDOUT: return %.loc9_9 +// CHECK:STDOUT: %.loc9: i32 = int_literal 2 +// CHECK:STDOUT: assign %n, %.loc9 +// CHECK:STDOUT: %n.ref.loc10: ref i32 = name_reference "n", %n +// CHECK:STDOUT: %.loc10: i32 = bind_value %n.ref.loc10 +// CHECK:STDOUT: return %.loc10 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: +// CHECK:STDOUT: %n.ref.loc15: = name_reference "n", // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/if/no_else.carbon b/toolchain/check/testdata/if/no_else.carbon index f16e6d3a929c..2ef88d2b8aa0 100644 --- a/toolchain/check/testdata/if/no_else.carbon +++ b/toolchain/check/testdata/if/no_else.carbon @@ -32,14 +32,17 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.then else br !if.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc12_6.1: type = tuple_type () // CHECK:STDOUT: %.loc12_6.2: init () = call @F() // CHECK:STDOUT: br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.else: +// CHECK:STDOUT: %G.ref = name_reference_untyped "G", package.%G // CHECK:STDOUT: %.loc14: init () = call @G() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/if/unreachable_fallthrough.carbon b/toolchain/check/testdata/if/unreachable_fallthrough.carbon index cefbc6ff3aef..26ea349943c4 100644 --- a/toolchain/check/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/check/testdata/if/unreachable_fallthrough.carbon @@ -19,7 +19,8 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.then else br !if.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc9: i32 = int_literal 1 diff --git a/toolchain/check/testdata/if_expression/basic.carbon b/toolchain/check/testdata/if_expression/basic.carbon index 7016c33dd41f..7c85884ac002 100644 --- a/toolchain/check/testdata/if_expression/basic.carbon +++ b/toolchain/check/testdata/if_expression/basic.carbon @@ -14,14 +14,19 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%b: bool, %n: i32, %m: i32) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.expr.then else br !if.expr.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc8_22: i32 = add %n, %m +// CHECK:STDOUT: %n.ref.loc8_20: i32 = name_reference "n", %n +// CHECK:STDOUT: %m.ref.loc8_24: i32 = name_reference "m", %m +// CHECK:STDOUT: %.loc8_22: i32 = add %n.ref.loc8_20, %m.ref.loc8_24 // CHECK:STDOUT: br !if.expr.result(%.loc8_22) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc8_33: i32 = add %m, %n +// CHECK:STDOUT: %m.ref.loc8_31: i32 = name_reference "m", %m +// CHECK:STDOUT: %n.ref.loc8_35: i32 = name_reference "n", %n +// CHECK:STDOUT: %.loc8_33: i32 = add %m.ref.loc8_31, %n.ref.loc8_35 // CHECK:STDOUT: br !if.expr.result(%.loc8_33) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: diff --git a/toolchain/check/testdata/if_expression/constant_condition.carbon b/toolchain/check/testdata/if_expression/constant_condition.carbon index 98d61733e776..93a14e792b7a 100644 --- a/toolchain/check/testdata/if_expression/constant_condition.carbon +++ b/toolchain/check/testdata/if_expression/constant_condition.carbon @@ -40,6 +40,7 @@ fn G() -> i32 { // CHECK:STDOUT: if %.loc11_13 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: +// CHECK:STDOUT: %A.ref = name_reference_untyped "A", package.%A // CHECK:STDOUT: %.loc11_24.1: init i32 = call @A() // CHECK:STDOUT: %.loc11_24.2: ref i32 = temporary_storage // CHECK:STDOUT: %.loc11_24.3: ref i32 = temporary %.loc11_24.2, %.loc11_24.1 @@ -47,6 +48,7 @@ fn G() -> i32 { // CHECK:STDOUT: br !if.expr.result(%.loc11_24.4) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: +// CHECK:STDOUT: %B.ref = name_reference_untyped "B", package.%B // CHECK:STDOUT: %.loc11_33.1: init i32 = call @B() // CHECK:STDOUT: %.loc11_33.2: ref i32 = temporary_storage // CHECK:STDOUT: %.loc11_33.3: ref i32 = temporary %.loc11_33.2, %.loc11_33.1 @@ -64,6 +66,7 @@ fn G() -> i32 { // CHECK:STDOUT: if %.loc15_13 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: +// CHECK:STDOUT: %A.ref = name_reference_untyped "A", package.%A // CHECK:STDOUT: %.loc15_25.1: init i32 = call @A() // CHECK:STDOUT: %.loc15_25.2: ref i32 = temporary_storage // CHECK:STDOUT: %.loc15_25.3: ref i32 = temporary %.loc15_25.2, %.loc15_25.1 @@ -71,6 +74,7 @@ fn G() -> i32 { // CHECK:STDOUT: br !if.expr.result(%.loc15_25.4) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: +// CHECK:STDOUT: %B.ref = name_reference_untyped "B", package.%B // CHECK:STDOUT: %.loc15_34.1: init i32 = call @B() // CHECK:STDOUT: %.loc15_34.2: ref i32 = temporary_storage // CHECK:STDOUT: %.loc15_34.3: ref i32 = temporary %.loc15_34.2, %.loc15_34.1 diff --git a/toolchain/check/testdata/if_expression/control_flow.carbon b/toolchain/check/testdata/if_expression/control_flow.carbon index cc6934ffd97f..5528574dc4ea 100644 --- a/toolchain/check/testdata/if_expression/control_flow.carbon +++ b/toolchain/check/testdata/if_expression/control_flow.carbon @@ -31,9 +31,11 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !if.expr.then else br !if.expr.else +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: +// CHECK:STDOUT: %A.ref = name_reference_untyped "A", package.%A // CHECK:STDOUT: %.loc11_21.1: init i32 = call @A() // CHECK:STDOUT: %.loc11_21.2: ref i32 = temporary_storage // CHECK:STDOUT: %.loc11_21.3: ref i32 = temporary %.loc11_21.2, %.loc11_21.1 @@ -41,6 +43,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: br !if.expr.result(%.loc11_21.4) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: +// CHECK:STDOUT: %B.ref = name_reference_untyped "B", package.%B // CHECK:STDOUT: %.loc11_30.1: init i32 = call @B() // CHECK:STDOUT: %.loc11_30.2: ref i32 = temporary_storage // CHECK:STDOUT: %.loc11_30.3: ref i32 = temporary %.loc11_30.2, %.loc11_30.1 diff --git a/toolchain/check/testdata/if_expression/nested.carbon b/toolchain/check/testdata/if_expression/nested.carbon index dc827087d406..16b1d476a634 100644 --- a/toolchain/check/testdata/if_expression/nested.carbon +++ b/toolchain/check/testdata/if_expression/nested.carbon @@ -14,10 +14,12 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%a: bool, %b: bool, %c: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %a br !if.expr.then.loc8_10 else br !if.expr.else.loc8_10 +// CHECK:STDOUT: %a.ref: bool = name_reference "a", %a +// CHECK:STDOUT: if %a.ref br !if.expr.then.loc8_10 else br !if.expr.else.loc8_10 // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc8_10: -// CHECK:STDOUT: if %b br !if.expr.then.loc8_20 else br !if.expr.else.loc8_20 +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: if %b.ref br !if.expr.then.loc8_20 else br !if.expr.else.loc8_20 // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc8_20: // CHECK:STDOUT: %.loc8_30: i32 = int_literal 1 @@ -32,7 +34,8 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: br !if.expr.result.loc8_10(%.loc8_20) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else.loc8_10: -// CHECK:STDOUT: if %c br !if.expr.then.loc8_44 else br !if.expr.else.loc8_44 +// CHECK:STDOUT: %c.ref: bool = name_reference "c", %c +// CHECK:STDOUT: if %c.ref br !if.expr.then.loc8_44 else br !if.expr.else.loc8_44 // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc8_44: // CHECK:STDOUT: %.loc8_54: i32 = int_literal 3 diff --git a/toolchain/check/testdata/if_expression/struct.carbon b/toolchain/check/testdata/if_expression/struct.carbon index 794eb6de8833..5a608e4409de 100644 --- a/toolchain/check/testdata/if_expression/struct.carbon +++ b/toolchain/check/testdata/if_expression/struct.carbon @@ -31,23 +31,27 @@ fn F(cond: bool) { // CHECK:STDOUT: %.loc10_46.5: init i32 = initialize_from %.loc10_45 to %.loc10_46.4 // CHECK:STDOUT: %.loc10_46.6: init {.a: i32, .b: i32} = struct_init %.loc10_46.1, (%.loc10_46.3, %.loc10_46.5) // CHECK:STDOUT: assign %a, %.loc10_46.6 -// CHECK:STDOUT: if %cond br !if.expr.then else br !if.expr.else +// CHECK:STDOUT: %G.ref = name_reference_untyped "G", package.%G +// CHECK:STDOUT: %cond.ref: bool = name_reference "cond", %cond +// CHECK:STDOUT: if %cond.ref br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc10_7.1: ref i32 = struct_access %a, member0 -// CHECK:STDOUT: %.loc10_7.2: i32 = bind_value %.loc10_7.1 -// CHECK:STDOUT: %.loc10_7.3: ref i32 = struct_access %a, member1 -// CHECK:STDOUT: %.loc10_7.4: i32 = bind_value %.loc10_7.3 -// CHECK:STDOUT: %.loc10_7.5: {.a: i32, .b: i32} = struct_value %a, (%.loc10_7.2, %.loc10_7.4) -// CHECK:STDOUT: br !if.expr.result(%.loc10_7.5) +// CHECK:STDOUT: %a.ref.loc11_18: ref {.a: i32, .b: i32} = name_reference "a", %a +// CHECK:STDOUT: %.loc11_18.1: ref i32 = struct_access %a.ref.loc11_18, member0 +// CHECK:STDOUT: %.loc11_18.2: i32 = bind_value %.loc11_18.1 +// CHECK:STDOUT: %.loc11_18.3: ref i32 = struct_access %a.ref.loc11_18, member1 +// CHECK:STDOUT: %.loc11_18.4: i32 = bind_value %.loc11_18.3 +// CHECK:STDOUT: %.loc11_18.5: {.a: i32, .b: i32} = struct_value %a.ref.loc11_18, (%.loc11_18.2, %.loc11_18.4) +// CHECK:STDOUT: br !if.expr.result(%.loc11_18.5) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc10_7.6: ref i32 = struct_access %a, member0 -// CHECK:STDOUT: %.loc10_7.7: i32 = bind_value %.loc10_7.6 -// CHECK:STDOUT: %.loc10_7.8: ref i32 = struct_access %a, member1 -// CHECK:STDOUT: %.loc10_7.9: i32 = bind_value %.loc10_7.8 -// CHECK:STDOUT: %.loc10_7.10: {.a: i32, .b: i32} = struct_value %a, (%.loc10_7.7, %.loc10_7.9) -// CHECK:STDOUT: br !if.expr.result(%.loc10_7.10) +// CHECK:STDOUT: %a.ref.loc11_25: ref {.a: i32, .b: i32} = name_reference "a", %a +// CHECK:STDOUT: %.loc11_25.1: ref i32 = struct_access %a.ref.loc11_25, member0 +// CHECK:STDOUT: %.loc11_25.2: i32 = bind_value %.loc11_25.1 +// CHECK:STDOUT: %.loc11_25.3: ref i32 = struct_access %a.ref.loc11_25, member1 +// CHECK:STDOUT: %.loc11_25.4: i32 = bind_value %.loc11_25.3 +// CHECK:STDOUT: %.loc11_25.5: {.a: i32, .b: i32} = struct_value %a.ref.loc11_25, (%.loc11_25.2, %.loc11_25.4) +// CHECK:STDOUT: br !if.expr.result(%.loc11_25.5) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_5: {.a: i32, .b: i32} = block_arg !if.expr.result diff --git a/toolchain/check/testdata/index/array_element_access.carbon b/toolchain/check/testdata/index/array_element_access.carbon index d330c81f7886..a4c6e08a2ede 100644 --- a/toolchain/check/testdata/index/array_element_access.carbon +++ b/toolchain/check/testdata/index/array_element_access.carbon @@ -26,16 +26,19 @@ var d: i32 = a[b]; // CHECK:STDOUT: %.loc7_26.9: init [i32; 2] = array_init %.loc7_26.2, (%.loc7_26.5, %.loc7_26.8) to %a // CHECK:STDOUT: assign %a, %.loc7_26.9 // CHECK:STDOUT: %b: ref i32 = var "b" -// CHECK:STDOUT: %.loc8_14: i32 = int_literal 1 -// CHECK:STDOUT: assign %b, %.loc8_14 +// CHECK:STDOUT: %.loc8: i32 = int_literal 1 +// CHECK:STDOUT: assign %b, %.loc8 // CHECK:STDOUT: %c: ref i32 = var "c" +// CHECK:STDOUT: %a.ref.loc9: ref [i32; 2] = name_reference "a", %a // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_17.1: ref i32 = array_index %a, %.loc9_16 +// CHECK:STDOUT: %.loc9_17.1: ref i32 = array_index %a.ref.loc9, %.loc9_16 // CHECK:STDOUT: %.loc9_17.2: i32 = bind_value %.loc9_17.1 // CHECK:STDOUT: assign %c, %.loc9_17.2 // CHECK:STDOUT: %d: ref i32 = var "d" -// CHECK:STDOUT: %.loc8_5: i32 = bind_value %b -// CHECK:STDOUT: %.loc10_17.1: ref i32 = array_index %a, %.loc8_5 +// CHECK:STDOUT: %a.ref.loc10: ref [i32; 2] = name_reference "a", %a +// CHECK:STDOUT: %b.ref: ref i32 = name_reference "b", %b +// CHECK:STDOUT: %.loc10_16: i32 = bind_value %b.ref +// CHECK:STDOUT: %.loc10_17.1: ref i32 = array_index %a.ref.loc10, %.loc10_16 // CHECK:STDOUT: %.loc10_17.2: i32 = bind_value %.loc10_17.1 // CHECK:STDOUT: assign %d, %.loc10_17.2 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/expression_category.carbon b/toolchain/check/testdata/index/expression_category.carbon index ba49cae31205..84589409d4fc 100644 --- a/toolchain/check/testdata/index/expression_category.carbon +++ b/toolchain/check/testdata/index/expression_category.carbon @@ -55,12 +55,14 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: assign %a, %.loc10_29.12 // CHECK:STDOUT: %.loc13_14: type = ptr_type i32 // CHECK:STDOUT: %pa: ref i32* = var "pa" +// CHECK:STDOUT: %a.ref.loc13: ref [i32; 3] = name_reference "a", %a // CHECK:STDOUT: %.loc13_21: i32 = int_literal 0 -// CHECK:STDOUT: %.loc13_22: ref i32 = array_index %a, %.loc13_21 +// CHECK:STDOUT: %.loc13_22: ref i32 = array_index %a.ref.loc13, %.loc13_21 // CHECK:STDOUT: %.loc13_18: i32* = address_of %.loc13_22 // CHECK:STDOUT: assign %pa, %.loc13_18 +// CHECK:STDOUT: %a.ref.loc14: ref [i32; 3] = name_reference "a", %a // CHECK:STDOUT: %.loc14_5: i32 = int_literal 0 -// CHECK:STDOUT: %.loc14_6: ref i32 = array_index %a, %.loc14_5 +// CHECK:STDOUT: %.loc14_6: ref i32 = array_index %a.ref.loc14, %.loc14_5 // CHECK:STDOUT: %.loc14_10: i32 = int_literal 4 // CHECK:STDOUT: assign %.loc14_6, %.loc14_10 // CHECK:STDOUT: return @@ -86,12 +88,15 @@ fn ValueBinding(b: [i32; 3]) { // CHECK:STDOUT: %.loc18_29.10: init i32 = initialize_from %.loc18_28 to %.loc18_29.9 // CHECK:STDOUT: %.loc18_29.11: init [i32; 3] = array_init %.loc18_29.1, (%.loc18_29.4, %.loc18_29.7, %.loc18_29.10) to %a // CHECK:STDOUT: assign %a, %.loc18_29.11 +// CHECK:STDOUT: %a.ref: ref [i32; 3] = name_reference "a", %a // CHECK:STDOUT: %.loc22_5: i32 = int_literal 0 -// CHECK:STDOUT: %.loc22_6: ref i32 = array_index %a, %.loc22_5 +// CHECK:STDOUT: %.loc22_6: ref i32 = array_index %a.ref, %.loc22_5 +// CHECK:STDOUT: %b.ref: [i32; 3] = name_reference "b", %b // CHECK:STDOUT: %.loc23_5: i32 = int_literal 0 -// CHECK:STDOUT: %.loc23_6.1: ref [i32; 3] = value_as_reference %b +// CHECK:STDOUT: %.loc23_6.1: ref [i32; 3] = value_as_reference %b.ref // CHECK:STDOUT: %.loc23_6.2: ref i32 = array_index %.loc23_6.1, %.loc23_5 // CHECK:STDOUT: %.loc23_6.3: i32 = bind_value %.loc23_6.2 +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc24_4.1: ref [i32; 3] = temporary_storage // CHECK:STDOUT: %.loc24_4.2: init [i32; 3] = call @F() to %.loc24_4.1 // CHECK:STDOUT: %.loc24_7: i32 = int_literal 0 diff --git a/toolchain/check/testdata/index/fail_array_large_index.carbon b/toolchain/check/testdata/index/fail_array_large_index.carbon index 1242f98d7a93..1b975e54956b 100644 --- a/toolchain/check/testdata/index/fail_array_large_index.carbon +++ b/toolchain/check/testdata/index/fail_array_large_index.carbon @@ -23,8 +23,9 @@ var b: i32 = a[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %.loc7_23.6: init [i32; 1] = array_init %.loc7_23.2, (%.loc7_23.5) to %a // CHECK:STDOUT: assign %a, %.loc7_23.6 // CHECK:STDOUT: %b: ref i32 = var "b" +// CHECK:STDOUT: %a.ref: ref [i32; 1] = name_reference "a", %a // CHECK:STDOUT: %.loc11_16: i32 = int_literal 295147905179352825855 -// CHECK:STDOUT: %.loc11_35.1: ref i32 = array_index %a, +// CHECK:STDOUT: %.loc11_35.1: ref i32 = array_index %a.ref, // CHECK:STDOUT: %.loc11_35.2: i32 = bind_value %.loc11_35.1 // CHECK:STDOUT: assign %b, %.loc11_35.2 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon index 64bbc1534aec..c74b4d79f48d 100644 --- a/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_array_non_int_indexing.carbon @@ -23,8 +23,9 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_23.6: init [i32; 1] = array_init %.loc7_23.2, (%.loc7_23.5) to %a // CHECK:STDOUT: assign %a, %.loc7_23.6 // CHECK:STDOUT: %b: ref i32 = var "b" +// CHECK:STDOUT: %a.ref: ref [i32; 1] = name_reference "a", %a // CHECK:STDOUT: %.loc11_16: f64 = real_literal 26e-1 -// CHECK:STDOUT: %.loc11_19.1: ref i32 = array_index %a, +// CHECK:STDOUT: %.loc11_19.1: ref i32 = array_index %a.ref, // CHECK:STDOUT: %.loc11_19.2: i32 = bind_value %.loc11_19.1 // CHECK:STDOUT: assign %b, %.loc11_19.2 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon index ecfa55f56476..fd0af5a9df71 100644 --- a/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon +++ b/toolchain/check/testdata/index/fail_array_out_of_bound_access.carbon @@ -23,8 +23,9 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_23.6: init [i32; 1] = array_init %.loc7_23.2, (%.loc7_23.5) to %a // CHECK:STDOUT: assign %a, %.loc7_23.6 // CHECK:STDOUT: %b: ref i32 = var "b" +// CHECK:STDOUT: %a.ref: ref [i32; 1] = name_reference "a", %a // CHECK:STDOUT: %.loc11_16: i32 = int_literal 2 -// CHECK:STDOUT: %.loc11_17.1: ref i32 = array_index %a, +// CHECK:STDOUT: %.loc11_17.1: ref i32 = array_index %a.ref, // CHECK:STDOUT: %.loc11_17.2: i32 = bind_value %.loc11_17.1 // CHECK:STDOUT: assign %b, %.loc11_17.2 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_empty_tuple_access.carbon b/toolchain/check/testdata/index/fail_empty_tuple_access.carbon index d5eefe8dfb8b..b6eafaa30a68 100644 --- a/toolchain/check/testdata/index/fail_empty_tuple_access.carbon +++ b/toolchain/check/testdata/index/fail_empty_tuple_access.carbon @@ -25,6 +25,7 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc13_4.1: type = tuple_type () // CHECK:STDOUT: %.loc13_4.2: init () = call @F() // CHECK:STDOUT: %.loc13_7: i32 = int_literal 0 diff --git a/toolchain/check/testdata/index/fail_expression_category.carbon b/toolchain/check/testdata/index/fail_expression_category.carbon index cc959bb2c921..7e5992ede82f 100644 --- a/toolchain/check/testdata/index/fail_expression_category.carbon +++ b/toolchain/check/testdata/index/fail_expression_category.carbon @@ -40,20 +40,23 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc14_14: type = ptr_type i32 // CHECK:STDOUT: %pb: ref i32* = var "pb" +// CHECK:STDOUT: %b.ref.loc14: [i32; 3] = name_reference "b", %b // CHECK:STDOUT: %.loc14_21: i32 = int_literal 0 -// CHECK:STDOUT: %.loc14_22.1: ref [i32; 3] = value_as_reference %b +// CHECK:STDOUT: %.loc14_22.1: ref [i32; 3] = value_as_reference %b.ref.loc14 // CHECK:STDOUT: %.loc14_22.2: ref i32 = array_index %.loc14_22.1, %.loc14_21 // CHECK:STDOUT: %.loc14_22.3: i32 = bind_value %.loc14_22.2 // CHECK:STDOUT: %.loc14_18: i32* = address_of %.loc14_22.3 // CHECK:STDOUT: assign %pb, %.loc14_18 +// CHECK:STDOUT: %b.ref.loc18: [i32; 3] = name_reference "b", %b // CHECK:STDOUT: %.loc18_5: i32 = int_literal 0 -// CHECK:STDOUT: %.loc18_6.1: ref [i32; 3] = value_as_reference %b +// CHECK:STDOUT: %.loc18_6.1: ref [i32; 3] = value_as_reference %b.ref.loc18 // CHECK:STDOUT: %.loc18_6.2: ref i32 = array_index %.loc18_6.1, %.loc18_5 // CHECK:STDOUT: %.loc18_6.3: i32 = bind_value %.loc18_6.2 // CHECK:STDOUT: %.loc18_10: i32 = int_literal 4 // CHECK:STDOUT: assign %.loc18_6.3, %.loc18_10 // CHECK:STDOUT: %.loc25_14: type = ptr_type i32 // CHECK:STDOUT: %pf: ref i32* = var "pf" +// CHECK:STDOUT: %F.ref.loc25 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc25_20.1: ref [i32; 3] = temporary_storage // CHECK:STDOUT: %.loc25_20.2: init [i32; 3] = call @F() to %.loc25_20.1 // CHECK:STDOUT: %.loc25_23: i32 = int_literal 0 @@ -62,6 +65,7 @@ fn G(b: [i32; 3]) { // CHECK:STDOUT: %.loc25_24.2: i32 = bind_value %.loc25_24.1 // CHECK:STDOUT: %.loc25_18: i32* = address_of %.loc25_24.2 // CHECK:STDOUT: assign %pf, %.loc25_18 +// CHECK:STDOUT: %F.ref.loc29 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc29_4.1: ref [i32; 3] = temporary_storage // CHECK:STDOUT: %.loc29_4.2: init [i32; 3] = call @F() to %.loc29_4.1 // CHECK:STDOUT: %.loc29_7: i32 = int_literal 0 diff --git a/toolchain/check/testdata/index/fail_invalid_base.carbon b/toolchain/check/testdata/index/fail_invalid_base.carbon index 0a948802e722..c8337debab2c 100644 --- a/toolchain/check/testdata/index/fail_invalid_base.carbon +++ b/toolchain/check/testdata/index/fail_invalid_base.carbon @@ -8,16 +8,16 @@ // representation for a reference to a name so that we can track the location // properly. -// CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+3]]:12: ERROR: Expression cannot be used as a value. -// CHECK:STDERR: namespace N; -// CHECK:STDERR: ^ namespace N; +// CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+3]]:14: ERROR: Expression cannot be used as a value. +// CHECK:STDERR: var a: i32 = N[0]; +// CHECK:STDERR: ^ var a: i32 = N[0]; -// CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+3]]:1: ERROR: Expression cannot be used as a value. -// CHECK:STDERR: fn F(); -// CHECK:STDERR: ^ fn F(); +// CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+3]]:14: ERROR: Expression cannot be used as a value. +// CHECK:STDERR: var b: i32 = F[1]; +// CHECK:STDERR: ^ var b: i32 = F[1]; // CHECK:STDERR: fail_invalid_base.carbon:[[@LINE+3]]:32: ERROR: `{.a: i32, .b: i32}` does not support indexing. @@ -31,12 +31,14 @@ var c: i32 = {.a = 1, .b = 2}[0]; var d: i32 = {.a: i32, .b: i32}[0]; // CHECK:STDOUT: file "fail_invalid_base.carbon" { -// CHECK:STDOUT: %.loc14 = namespace {} +// CHECK:STDOUT: %.loc11 = namespace {} // CHECK:STDOUT: %a: ref i32 = var "a" +// CHECK:STDOUT: %N.ref = name_reference_untyped "N", %.loc11 // CHECK:STDOUT: %.loc15: i32 = int_literal 0 // CHECK:STDOUT: assign %a, // CHECK:STDOUT: %F = fn_decl @F // CHECK:STDOUT: %b: ref i32 = var "b" +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", %F // CHECK:STDOUT: %.loc21: i32 = int_literal 1 // CHECK:STDOUT: assign %b, // CHECK:STDOUT: %c: ref i32 = var "c" diff --git a/toolchain/check/testdata/index/fail_name_not_found.carbon b/toolchain/check/testdata/index/fail_name_not_found.carbon index eb2a24e7cc42..5a54c0ae3666 100644 --- a/toolchain/check/testdata/index/fail_name_not_found.carbon +++ b/toolchain/check/testdata/index/fail_name_not_found.carbon @@ -18,6 +18,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %b: ref i32 = var "b" +// CHECK:STDOUT: %a.ref: = name_reference "a", // CHECK:STDOUT: %.loc11: i32 = int_literal 0 // CHECK:STDOUT: assign %b, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/index/fail_non_deterministic_type.carbon b/toolchain/check/testdata/index/fail_non_deterministic_type.carbon index e336f97ba748..b1ca51f3040c 100644 --- a/toolchain/check/testdata/index/fail_non_deterministic_type.carbon +++ b/toolchain/check/testdata/index/fail_non_deterministic_type.carbon @@ -29,6 +29,8 @@ var c: i32 = a[b]; // CHECK:STDOUT: %.loc8: i32 = int_literal 0 // CHECK:STDOUT: assign %b, %.loc8 // CHECK:STDOUT: %c: ref i32 = var "c" -// CHECK:STDOUT: %.loc12: ref = tuple_index %a, +// CHECK:STDOUT: %a.ref: ref (i32, i32) = name_reference "a", %a +// CHECK:STDOUT: %b.ref: ref i32 = name_reference "b", %b +// CHECK:STDOUT: %.loc12: ref = tuple_index %a.ref, // CHECK:STDOUT: assign %c, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_tuple_large_index.carbon b/toolchain/check/testdata/index/fail_tuple_large_index.carbon index 5a18ae06c9ed..55004b1a95b6 100644 --- a/toolchain/check/testdata/index/fail_tuple_large_index.carbon +++ b/toolchain/check/testdata/index/fail_tuple_large_index.carbon @@ -20,14 +20,16 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_literal (%.loc7_18) // CHECK:STDOUT: %.loc7_21.2: init (i32,) = tuple_init %.loc7_21.1, (%.loc7_18) // CHECK:STDOUT: assign %a, %.loc7_21.2 -// CHECK:STDOUT: %.loc8: (type,) = tuple_literal (i32) +// CHECK:STDOUT: %.loc8_13: (type,) = tuple_literal (i32) // CHECK:STDOUT: %b: ref (i32,) = var "b" -// CHECK:STDOUT: %.loc7_5.1: ref i32 = tuple_access %a, member0 -// CHECK:STDOUT: %.loc7_5.2: i32 = bind_value %.loc7_5.1 -// CHECK:STDOUT: %.loc7_5.3: init (i32,) = tuple_init %a, (%.loc7_5.2) -// CHECK:STDOUT: assign %b, %.loc7_5.3 +// CHECK:STDOUT: %a.ref: ref (i32,) = name_reference "a", %a +// CHECK:STDOUT: %.loc8_17.1: ref i32 = tuple_access %a.ref, member0 +// CHECK:STDOUT: %.loc8_17.2: i32 = bind_value %.loc8_17.1 +// CHECK:STDOUT: %.loc8_17.3: init (i32,) = tuple_init %a.ref, (%.loc8_17.2) +// CHECK:STDOUT: assign %b, %.loc8_17.3 // CHECK:STDOUT: %c: ref i32 = var "c" +// CHECK:STDOUT: %b.ref: ref (i32,) = name_reference "b", %b // CHECK:STDOUT: %.loc12_16: i32 = int_literal 295147905179352825855 -// CHECK:STDOUT: %.loc12_35: ref = tuple_index %b, +// CHECK:STDOUT: %.loc12_35: ref = tuple_index %b.ref, // CHECK:STDOUT: assign %c, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon b/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon index 8ef4feff1d47..4241cffed3b1 100644 --- a/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon +++ b/toolchain/check/testdata/index/fail_tuple_non_int_indexing.carbon @@ -25,7 +25,8 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_27.6: init (i32, i32) = tuple_init %.loc7_27.1, (%.loc7_27.3, %.loc7_27.5) // CHECK:STDOUT: assign %a, %.loc7_27.6 // CHECK:STDOUT: %b: ref i32 = var "b" +// CHECK:STDOUT: %a.ref: ref (i32, i32) = name_reference "a", %a // CHECK:STDOUT: %.loc11_16: f64 = real_literal 26e-1 -// CHECK:STDOUT: %.loc11_19: ref = tuple_index %a, +// CHECK:STDOUT: %.loc11_19: ref = tuple_index %a.ref, // CHECK:STDOUT: assign %b, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon b/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon index 961b22cc192f..8e106fd160bc 100644 --- a/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon +++ b/toolchain/check/testdata/index/fail_tuple_out_of_bound_access.carbon @@ -25,7 +25,8 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_27.6: init (i32, i32) = tuple_init %.loc7_27.1, (%.loc7_27.3, %.loc7_27.5) // CHECK:STDOUT: assign %a, %.loc7_27.6 // CHECK:STDOUT: %b: ref i32 = var "b" +// CHECK:STDOUT: %a.ref: ref (i32, i32) = name_reference "a", %a // CHECK:STDOUT: %.loc11_16: i32 = int_literal 2 -// CHECK:STDOUT: %.loc11_17: ref = tuple_index %a, +// CHECK:STDOUT: %.loc11_17: ref = tuple_index %a.ref, // CHECK:STDOUT: assign %b, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/tuple_element_access.carbon b/toolchain/check/testdata/index/tuple_element_access.carbon index b962730df0a8..b750536dad62 100644 --- a/toolchain/check/testdata/index/tuple_element_access.carbon +++ b/toolchain/check/testdata/index/tuple_element_access.carbon @@ -17,15 +17,17 @@ var c: i32 = b[0]; // CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_literal (%.loc7_18) // CHECK:STDOUT: %.loc7_21.2: init (i32,) = tuple_init %.loc7_21.1, (%.loc7_18) // CHECK:STDOUT: assign %a, %.loc7_21.2 -// CHECK:STDOUT: %.loc8: (type,) = tuple_literal (i32) +// CHECK:STDOUT: %.loc8_13: (type,) = tuple_literal (i32) // CHECK:STDOUT: %b: ref (i32,) = var "b" -// CHECK:STDOUT: %.loc7_5.1: ref i32 = tuple_access %a, member0 -// CHECK:STDOUT: %.loc7_5.2: i32 = bind_value %.loc7_5.1 -// CHECK:STDOUT: %.loc7_5.3: init (i32,) = tuple_init %a, (%.loc7_5.2) -// CHECK:STDOUT: assign %b, %.loc7_5.3 +// CHECK:STDOUT: %a.ref: ref (i32,) = name_reference "a", %a +// CHECK:STDOUT: %.loc8_17.1: ref i32 = tuple_access %a.ref, member0 +// CHECK:STDOUT: %.loc8_17.2: i32 = bind_value %.loc8_17.1 +// CHECK:STDOUT: %.loc8_17.3: init (i32,) = tuple_init %a.ref, (%.loc8_17.2) +// CHECK:STDOUT: assign %b, %.loc8_17.3 // CHECK:STDOUT: %c: ref i32 = var "c" +// CHECK:STDOUT: %b.ref: ref (i32,) = name_reference "b", %b // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_17.1: ref i32 = tuple_index %b, %.loc9_16 +// CHECK:STDOUT: %.loc9_17.1: ref i32 = tuple_index %b.ref, %.loc9_16 // CHECK:STDOUT: %.loc9_17.2: i32 = bind_value %.loc9_17.1 // CHECK:STDOUT: assign %c, %.loc9_17.2 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/index/tuple_return_value_access.carbon b/toolchain/check/testdata/index/tuple_return_value_access.carbon index 87753cf64aaa..a07c11c16d12 100644 --- a/toolchain/check/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/check/testdata/index/tuple_return_value_access.carbon @@ -25,6 +25,7 @@ fn Run() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> i32 { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc10_11.1: init (i32,) = call @F() // CHECK:STDOUT: %.loc10_14: i32 = int_literal 0 // CHECK:STDOUT: %.loc10_11.2: ref (i32,) = temporary_storage diff --git a/toolchain/check/testdata/namespace/function.carbon b/toolchain/check/testdata/namespace/function.carbon index deb9e9d196c1..7eced5753b6f 100644 --- a/toolchain/check/testdata/namespace/function.carbon +++ b/toolchain/check/testdata/namespace/function.carbon @@ -36,6 +36,7 @@ fn Bar() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Bar() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Foo.ref = name_reference_untyped "Foo", package.%.loc7 // CHECK:STDOUT: %.loc17_10.1: type = tuple_type () // CHECK:STDOUT: %.loc17_10.2: init () = call @Baz.2() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/namespace/nested.carbon b/toolchain/check/testdata/namespace/nested.carbon index 26c3d8a0c88d..0eb4341a2c66 100644 --- a/toolchain/check/testdata/namespace/nested.carbon +++ b/toolchain/check/testdata/namespace/nested.carbon @@ -16,6 +16,7 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: file "nested.carbon" { // CHECK:STDOUT: %.loc7 = namespace {.Bar = %.loc8} +// CHECK:STDOUT: %Foo.ref = name_reference_untyped "Foo", %.loc7 // CHECK:STDOUT: %.loc8 = namespace {.Wiz = %Wiz, .Baz = %Baz} // CHECK:STDOUT: %Wiz = fn_decl @Wiz // CHECK:STDOUT: %Baz = fn_decl @Baz @@ -28,6 +29,7 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Baz() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %Foo.ref = name_reference_untyped "Foo", package.%.loc7 // CHECK:STDOUT: %.loc14_14.1: type = tuple_type () // CHECK:STDOUT: %.loc14_14.2: init () = call @Wiz() // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/operators/and.carbon b/toolchain/check/testdata/operators/and.carbon index 7bebfd9275b6..bb381db9966c 100644 --- a/toolchain/check/testdata/operators/and.carbon +++ b/toolchain/check/testdata/operators/and.carbon @@ -31,6 +31,7 @@ fn And() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @And() -> bool { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc11_11.1: init bool = call @F() // CHECK:STDOUT: %.loc11_11.2: ref bool = temporary_storage // CHECK:STDOUT: %.loc11_11.3: ref bool = temporary %.loc11_11.2, %.loc11_11.1 @@ -39,6 +40,7 @@ fn And() -> bool { // CHECK:STDOUT: if %.loc11_11.4 br !and.rhs else br !and.result(%.loc11_14.1) // CHECK:STDOUT: // CHECK:STDOUT: !and.rhs: +// CHECK:STDOUT: %G.ref = name_reference_untyped "G", package.%G // CHECK:STDOUT: %.loc11_19.1: init bool = call @G() // CHECK:STDOUT: %.loc11_19.2: ref bool = temporary_storage // CHECK:STDOUT: %.loc11_19.3: ref bool = temporary %.loc11_19.2, %.loc11_19.1 diff --git a/toolchain/check/testdata/operators/assignment.carbon b/toolchain/check/testdata/operators/assignment.carbon index 43ccaad0fc72..115519b4a6c3 100644 --- a/toolchain/check/testdata/operators/assignment.carbon +++ b/toolchain/check/testdata/operators/assignment.carbon @@ -31,8 +31,9 @@ fn Main() { // CHECK:STDOUT: %a: ref i32 = var "a" // CHECK:STDOUT: %.loc8: i32 = int_literal 12 // CHECK:STDOUT: assign %a, %.loc8 +// CHECK:STDOUT: %a.ref.loc9: ref i32 = name_reference "a", %a // CHECK:STDOUT: %.loc9: i32 = int_literal 9 -// CHECK:STDOUT: assign %a, %.loc9 +// CHECK:STDOUT: assign %a.ref.loc9, %.loc9 // CHECK:STDOUT: %.loc11_19.1: type = tuple_type (type, type) // CHECK:STDOUT: %.loc11_19.2: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %.loc11_19.3: type = tuple_type (i32, i32) @@ -46,12 +47,14 @@ fn Main() { // CHECK:STDOUT: %.loc11_28.5: init i32 = initialize_from %.loc11_27 to %.loc11_28.4 // CHECK:STDOUT: %.loc11_28.6: init (i32, i32) = tuple_init %.loc11_28.1, (%.loc11_28.3, %.loc11_28.5) // CHECK:STDOUT: assign %b, %.loc11_28.6 +// CHECK:STDOUT: %b.ref.loc12: ref (i32, i32) = name_reference "b", %b // CHECK:STDOUT: %.loc12_5: i32 = int_literal 0 -// CHECK:STDOUT: %.loc12_6: ref i32 = tuple_index %b, %.loc12_5 +// CHECK:STDOUT: %.loc12_6: ref i32 = tuple_index %b.ref.loc12, %.loc12_5 // CHECK:STDOUT: %.loc12_10: i32 = int_literal 3 // CHECK:STDOUT: assign %.loc12_6, %.loc12_10 +// CHECK:STDOUT: %b.ref.loc13: ref (i32, i32) = name_reference "b", %b // CHECK:STDOUT: %.loc13_5: i32 = int_literal 1 -// CHECK:STDOUT: %.loc13_6: ref i32 = tuple_index %b, %.loc13_5 +// CHECK:STDOUT: %.loc13_6: ref i32 = tuple_index %b.ref.loc13, %.loc13_5 // CHECK:STDOUT: %.loc13_10: i32 = int_literal 4 // CHECK:STDOUT: assign %.loc13_6, %.loc13_10 // CHECK:STDOUT: %.loc15_27: type = struct_type {.a: i32, .b: i32} @@ -65,29 +68,35 @@ fn Main() { // CHECK:STDOUT: %.loc15_46.5: init i32 = initialize_from %.loc15_45 to %.loc15_46.4 // CHECK:STDOUT: %.loc15_46.6: init {.a: i32, .b: i32} = struct_init %.loc15_46.1, (%.loc15_46.3, %.loc15_46.5) // CHECK:STDOUT: assign %c, %.loc15_46.6 -// CHECK:STDOUT: %.loc16_4: ref i32 = struct_access %c, member0 +// CHECK:STDOUT: %c.ref.loc16: ref {.a: i32, .b: i32} = name_reference "c", %c +// CHECK:STDOUT: %.loc16_4: ref i32 = struct_access %c.ref.loc16, member0 // CHECK:STDOUT: %.loc16_9: i32 = int_literal 3 // CHECK:STDOUT: assign %.loc16_4, %.loc16_9 -// CHECK:STDOUT: %.loc17_4: ref i32 = struct_access %c, member1 +// CHECK:STDOUT: %c.ref.loc17: ref {.a: i32, .b: i32} = name_reference "c", %c +// CHECK:STDOUT: %.loc17_4: ref i32 = struct_access %c.ref.loc17, member1 // CHECK:STDOUT: %.loc17_9: i32 = int_literal 4 // CHECK:STDOUT: assign %.loc17_4, %.loc17_9 // CHECK:STDOUT: %.loc19_13: type = ptr_type i32 // CHECK:STDOUT: %p: ref i32* = var "p" -// CHECK:STDOUT: %.loc19_17: i32* = address_of %a +// CHECK:STDOUT: %a.ref.loc19: ref i32 = name_reference "a", %a +// CHECK:STDOUT: %.loc19_17: i32* = address_of %a.ref.loc19 // CHECK:STDOUT: assign %p, %.loc19_17 -// CHECK:STDOUT: %.loc19_7.1: i32* = bind_value %p -// CHECK:STDOUT: %.loc20_3: ref i32 = dereference %.loc19_7.1 +// CHECK:STDOUT: %p.ref.loc20: ref i32* = name_reference "p", %p +// CHECK:STDOUT: %.loc20_4: i32* = bind_value %p.ref.loc20 +// CHECK:STDOUT: %.loc20_3: ref i32 = dereference %.loc20_4 // CHECK:STDOUT: %.loc20_8: i32 = int_literal 5 // CHECK:STDOUT: assign %.loc20_3, %.loc20_8 // CHECK:STDOUT: %.loc22_8: bool = bool_literal true // CHECK:STDOUT: if %.loc22_8 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc19_7.2: i32* = bind_value %p -// CHECK:STDOUT: br !if.expr.result(%.loc19_7.2) +// CHECK:STDOUT: %p.ref.loc22: ref i32* = name_reference "p", %p +// CHECK:STDOUT: %.loc22_18: i32* = bind_value %p.ref.loc22 +// CHECK:STDOUT: br !if.expr.result(%.loc22_18) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc22_25: i32* = address_of %a +// CHECK:STDOUT: %a.ref.loc22: ref i32 = name_reference "a", %a +// CHECK:STDOUT: %.loc22_25: i32* = address_of %a.ref.loc22 // CHECK:STDOUT: br !if.expr.result(%.loc22_25) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: diff --git a/toolchain/check/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/check/testdata/operators/fail_assigment_to_non_assignable.carbon index 25b6a9515a86..9736c807e9b4 100644 --- a/toolchain/check/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/check/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -57,6 +57,7 @@ fn Main() { // CHECK:STDOUT: %.loc13_3: i32 = int_literal 1 // CHECK:STDOUT: %.loc13_7: i32 = int_literal 2 // CHECK:STDOUT: assign %.loc13_3, %.loc13_7 +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc17_4: init i32 = call @F() // CHECK:STDOUT: %.loc17_9: i32 = int_literal 1 // CHECK:STDOUT: assign %.loc17_4, %.loc17_9 @@ -75,9 +76,11 @@ fn Main() { // CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17.6 // CHECK:STDOUT: %.loc21_8.3: (i32, i32) = tuple_value %.loc21_8.2, (%.loc21_4, %.loc21_7) // CHECK:STDOUT: %n: ref i32 = var "n" -// CHECK:STDOUT: %.loc22_16: i32 = int_literal 0 -// CHECK:STDOUT: assign %n, %.loc22_16 -// CHECK:STDOUT: %.loc26_8.1: (i32, i32) = tuple_literal (%n, %n) +// CHECK:STDOUT: %.loc22: i32 = int_literal 0 +// CHECK:STDOUT: assign %n, %.loc22 +// CHECK:STDOUT: %n.ref.loc26_4: ref i32 = name_reference "n", %n +// CHECK:STDOUT: %n.ref.loc26_7: ref i32 = name_reference "n", %n +// CHECK:STDOUT: %.loc26_8.1: (i32, i32) = tuple_literal (%n.ref.loc26_4, %n.ref.loc26_7) // CHECK:STDOUT: %.loc26_13: i32 = int_literal 1 // CHECK:STDOUT: %.loc26_16: i32 = int_literal 2 // CHECK:STDOUT: %.loc26_17.1: (i32, i32) = tuple_literal (%.loc26_13, %.loc26_16) @@ -87,9 +90,9 @@ fn Main() { // CHECK:STDOUT: %.loc26_17.5: init i32 = initialize_from %.loc26_16 to %.loc26_17.4 // CHECK:STDOUT: %.loc26_17.6: init (i32, i32) = tuple_init %.loc26_17.1, (%.loc26_17.3, %.loc26_17.5) // CHECK:STDOUT: assign %.loc26_8.1, %.loc26_17.6 -// CHECK:STDOUT: %.loc22_7.1: i32 = bind_value %n -// CHECK:STDOUT: %.loc22_7.2: i32 = bind_value %n -// CHECK:STDOUT: %.loc26_8.2: (i32, i32) = tuple_value %.loc26_8.1, (%.loc22_7.1, %.loc22_7.2) +// CHECK:STDOUT: %.loc26_4: i32 = bind_value %n.ref.loc26_4 +// CHECK:STDOUT: %.loc26_7: i32 = bind_value %n.ref.loc26_7 +// CHECK:STDOUT: %.loc26_8.2: (i32, i32) = tuple_value %.loc26_8.1, (%.loc26_4, %.loc26_7) // CHECK:STDOUT: %.loc30: type = ptr_type i32 // CHECK:STDOUT: assign i32, %.loc30 // CHECK:STDOUT: %.loc34_9: i32 = int_literal 1 @@ -126,12 +129,14 @@ fn Main() { // CHECK:STDOUT: if %.loc45_7 br !if.expr.then.loc45 else br !if.expr.else.loc45 // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc45: -// CHECK:STDOUT: %.loc41_7.1: i32 = bind_value %a -// CHECK:STDOUT: br !if.expr.result.loc45(%.loc41_7.1) +// CHECK:STDOUT: %a.ref.loc45_17: ref i32 = name_reference "a", %a +// CHECK:STDOUT: %.loc45_17: i32 = bind_value %a.ref.loc45_17 +// CHECK:STDOUT: br !if.expr.result.loc45(%.loc45_17) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else.loc45: -// CHECK:STDOUT: %.loc41_7.2: i32 = bind_value %a -// CHECK:STDOUT: br !if.expr.result.loc45(%.loc41_7.2) +// CHECK:STDOUT: %a.ref.loc45_24: ref i32 = name_reference "a", %a +// CHECK:STDOUT: %.loc45_24: i32 = bind_value %a.ref.loc45_24 +// CHECK:STDOUT: br !if.expr.result.loc45(%.loc45_24) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc45: // CHECK:STDOUT: %.loc45_4: i32 = block_arg !if.expr.result.loc45 diff --git a/toolchain/check/testdata/operators/fail_type_mismatch_assignment.carbon b/toolchain/check/testdata/operators/fail_type_mismatch_assignment.carbon index 57a309c08215..4b0922a360fd 100644 --- a/toolchain/check/testdata/operators/fail_type_mismatch_assignment.carbon +++ b/toolchain/check/testdata/operators/fail_type_mismatch_assignment.carbon @@ -21,7 +21,8 @@ fn Main() { // CHECK:STDOUT: %a: ref i32 = var "a" // CHECK:STDOUT: %.loc8: i32 = int_literal 3 // CHECK:STDOUT: assign %a, %.loc8 +// CHECK:STDOUT: %a.ref: ref i32 = name_reference "a", %a // CHECK:STDOUT: %.loc12: f64 = real_literal 56e-1 -// CHECK:STDOUT: assign %a, +// CHECK:STDOUT: assign %a.ref, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/operators/or.carbon b/toolchain/check/testdata/operators/or.carbon index 99586a18a97a..5e05ebd764dd 100644 --- a/toolchain/check/testdata/operators/or.carbon +++ b/toolchain/check/testdata/operators/or.carbon @@ -31,6 +31,7 @@ fn Or() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @Or() -> bool { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc11_11.1: init bool = call @F() // CHECK:STDOUT: %.loc11_11.2: ref bool = temporary_storage // CHECK:STDOUT: %.loc11_11.3: ref bool = temporary %.loc11_11.2, %.loc11_11.1 @@ -40,6 +41,7 @@ fn Or() -> bool { // CHECK:STDOUT: if %.loc11_14.1 br !or.rhs else br !or.result(%.loc11_14.2) // CHECK:STDOUT: // CHECK:STDOUT: !or.rhs: +// CHECK:STDOUT: %G.ref = name_reference_untyped "G", package.%G // CHECK:STDOUT: %.loc11_18.1: init bool = call @G() // CHECK:STDOUT: %.loc11_18.2: ref bool = temporary_storage // CHECK:STDOUT: %.loc11_18.3: ref bool = temporary %.loc11_18.2, %.loc11_18.1 diff --git a/toolchain/check/testdata/operators/unary_op.carbon b/toolchain/check/testdata/operators/unary_op.carbon index f1be86e63b07..5a3ff826e551 100644 --- a/toolchain/check/testdata/operators/unary_op.carbon +++ b/toolchain/check/testdata/operators/unary_op.carbon @@ -14,6 +14,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @Not(%b: bool) -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: bool = not %b +// CHECK:STDOUT: %b.ref: bool = name_reference "b", %b +// CHECK:STDOUT: %.loc8: bool = not %b.ref // CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/address_of_deref.carbon b/toolchain/check/testdata/pointer/address_of_deref.carbon index b15e20bd79cd..b45644a8b53f 100644 --- a/toolchain/check/testdata/pointer/address_of_deref.carbon +++ b/toolchain/check/testdata/pointer/address_of_deref.carbon @@ -18,8 +18,9 @@ fn F() -> i32 { // CHECK:STDOUT: %n: ref i32 = var "n" // CHECK:STDOUT: %.loc8: i32 = int_literal 0 // CHECK:STDOUT: assign %n, %.loc8 +// CHECK:STDOUT: %n.ref: ref i32 = name_reference "n", %n // CHECK:STDOUT: %.loc9_13.1: type = ptr_type i32 -// CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n +// CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n.ref // CHECK:STDOUT: %.loc9_12: ref i32 = dereference %.loc9_13.2 // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 // CHECK:STDOUT: %.loc9_10.1: ref i32 = dereference %.loc9_11 diff --git a/toolchain/check/testdata/pointer/address_of_lvalue.carbon b/toolchain/check/testdata/pointer/address_of_lvalue.carbon index 628747d3726d..b02e325ae607 100644 --- a/toolchain/check/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/check/testdata/pointer/address_of_lvalue.carbon @@ -36,16 +36,19 @@ fn F() { // CHECK:STDOUT: %.loc10_27: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %.loc10_28: type = ptr_type {.a: i32, .b: i32} // CHECK:STDOUT: %p: ref {.a: i32, .b: i32}* = var "p" -// CHECK:STDOUT: %.loc10_32: {.a: i32, .b: i32}* = address_of %s +// CHECK:STDOUT: %s.ref.loc10: ref {.a: i32, .b: i32} = name_reference "s", %s +// CHECK:STDOUT: %.loc10_32: {.a: i32, .b: i32}* = address_of %s.ref.loc10 // CHECK:STDOUT: assign %p, %.loc10_32 // CHECK:STDOUT: %.loc11_13: type = ptr_type i32 // CHECK:STDOUT: %q: ref i32* = var "q" -// CHECK:STDOUT: %.loc11_19: ref i32 = struct_access %s, member0 +// CHECK:STDOUT: %s.ref.loc11: ref {.a: i32, .b: i32} = name_reference "s", %s +// CHECK:STDOUT: %.loc11_19: ref i32 = struct_access %s.ref.loc11, member0 // CHECK:STDOUT: %.loc11_17: i32* = address_of %.loc11_19 // CHECK:STDOUT: assign %q, %.loc11_17 // CHECK:STDOUT: %.loc12_13: type = ptr_type i32 // CHECK:STDOUT: %r: ref i32* = var "r" -// CHECK:STDOUT: %.loc12_19: ref i32 = struct_access %s, member1 +// CHECK:STDOUT: %s.ref.loc12: ref {.a: i32, .b: i32} = name_reference "s", %s +// CHECK:STDOUT: %.loc12_19: ref i32 = struct_access %s.ref.loc12, member1 // CHECK:STDOUT: %.loc12_17: i32* = address_of %.loc12_19 // CHECK:STDOUT: assign %r, %.loc12_17 // CHECK:STDOUT: %.loc14_19.1: type = tuple_type (type, type) @@ -63,14 +66,16 @@ fn F() { // CHECK:STDOUT: assign %t, %.loc14_28.6 // CHECK:STDOUT: %.loc15_14: type = ptr_type i32 // CHECK:STDOUT: %t0: ref i32* = var "t0" +// CHECK:STDOUT: %t.ref.loc15: ref (i32, i32) = name_reference "t", %t // CHECK:STDOUT: %.loc15_21: i32 = int_literal 0 -// CHECK:STDOUT: %.loc15_22: ref i32 = tuple_index %t, %.loc15_21 +// CHECK:STDOUT: %.loc15_22: ref i32 = tuple_index %t.ref.loc15, %.loc15_21 // CHECK:STDOUT: %.loc15_18: i32* = address_of %.loc15_22 // CHECK:STDOUT: assign %t0, %.loc15_18 // CHECK:STDOUT: %.loc16_14: type = ptr_type i32 // CHECK:STDOUT: %t1: ref i32* = var "t1" +// CHECK:STDOUT: %t.ref.loc16: ref (i32, i32) = name_reference "t", %t // CHECK:STDOUT: %.loc16_21: i32 = int_literal 1 -// CHECK:STDOUT: %.loc16_22: ref i32 = tuple_index %t, %.loc16_21 +// CHECK:STDOUT: %.loc16_22: ref i32 = tuple_index %t.ref.loc16, %.loc16_21 // CHECK:STDOUT: %.loc16_18: i32* = address_of %.loc16_22 // CHECK:STDOUT: assign %t1, %.loc16_18 // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/pointer/basic.carbon b/toolchain/check/testdata/pointer/basic.carbon index 021f5435707f..6724d4d107d4 100644 --- a/toolchain/check/testdata/pointer/basic.carbon +++ b/toolchain/check/testdata/pointer/basic.carbon @@ -22,10 +22,12 @@ fn F() -> i32 { // CHECK:STDOUT: assign %n, %.loc8 // CHECK:STDOUT: %.loc9_13: type = ptr_type i32 // CHECK:STDOUT: %p: ref i32* = var "p" -// CHECK:STDOUT: %.loc9_17: i32* = address_of %n +// CHECK:STDOUT: %n.ref: ref i32 = name_reference "n", %n +// CHECK:STDOUT: %.loc9_17: i32* = address_of %n.ref // CHECK:STDOUT: assign %p, %.loc9_17 -// CHECK:STDOUT: %.loc9_7: i32* = bind_value %p -// CHECK:STDOUT: %.loc11_10.1: ref i32 = dereference %.loc9_7 +// CHECK:STDOUT: %p.ref: ref i32* = name_reference "p", %p +// CHECK:STDOUT: %.loc11_11: i32* = bind_value %p.ref +// CHECK:STDOUT: %.loc11_10.1: ref i32 = dereference %.loc11_11 // CHECK:STDOUT: %.loc11_10.2: i32 = bind_value %.loc11_10.1 // CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/fail_address_of_value.carbon b/toolchain/check/testdata/pointer/fail_address_of_value.carbon index b67f6c3d063f..4379f4110e73 100644 --- a/toolchain/check/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/check/testdata/pointer/fail_address_of_value.carbon @@ -130,6 +130,7 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: %.loc42_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc42_7: i32 = add %.loc42_5, %.loc42_9 // CHECK:STDOUT: %.loc42_3: i32* = address_of %.loc42_7 +// CHECK:STDOUT: %H.ref = name_reference_untyped "H", package.%H // CHECK:STDOUT: %.loc46_5.1: init {.a: i32} = call @H() // CHECK:STDOUT: %.loc46_5.2: ref {.a: i32} = temporary_storage // CHECK:STDOUT: %.loc46_5.3: ref {.a: i32} = temporary %.loc46_5.2, %.loc46_5.1 @@ -143,6 +144,7 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @AddressOfCall() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %G.ref = name_reference_untyped "G", package.%G // CHECK:STDOUT: %.loc57_5: init i32 = call @G() // CHECK:STDOUT: %.loc57_3: i32* = address_of %.loc57_5 // CHECK:STDOUT: return @@ -174,7 +176,8 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc82_22: type = ptr_type i32 // CHECK:STDOUT: %param_addr: ref i32* = var "param_addr" -// CHECK:STDOUT: %.loc82_26: i32* = address_of %param +// CHECK:STDOUT: %param.ref: i32 = name_reference "param", %param +// CHECK:STDOUT: %.loc82_26: i32* = address_of %param.ref // CHECK:STDOUT: assign %param_addr, %.loc82_26 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/fail_dereference_not_pointer.carbon b/toolchain/check/testdata/pointer/fail_dereference_not_pointer.carbon index d67c8550d2a0..992384c5cec9 100644 --- a/toolchain/check/testdata/pointer/fail_dereference_not_pointer.carbon +++ b/toolchain/check/testdata/pointer/fail_dereference_not_pointer.carbon @@ -25,7 +25,8 @@ fn Deref(n: i32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Deref(%n: i32) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: ref = dereference %n +// CHECK:STDOUT: %n.ref: i32 = name_reference "n", %n +// CHECK:STDOUT: %.loc11: ref = dereference %n.ref // CHECK:STDOUT: %.loc15_5.1: type = tuple_type () // CHECK:STDOUT: %.loc15_5.2: () = tuple_literal () // CHECK:STDOUT: %.loc15_5.3: () = tuple_value %.loc15_5.2, () diff --git a/toolchain/check/testdata/pointer/fail_type_mismatch.carbon b/toolchain/check/testdata/pointer/fail_type_mismatch.carbon index 9af0ebe2f4dc..7d29f3f1635a 100644 --- a/toolchain/check/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/check/testdata/pointer/fail_type_mismatch.carbon @@ -17,5 +17,6 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> const ({}*) { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %p.ref: const {}* = name_reference "p", %p // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/pointer/nested_const.carbon b/toolchain/check/testdata/pointer/nested_const.carbon index 626e3fa234f0..590a2cc3ba9d 100644 --- a/toolchain/check/testdata/pointer/nested_const.carbon +++ b/toolchain/check/testdata/pointer/nested_const.carbon @@ -15,7 +15,8 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc9_11.1: ref const (const i32*) = dereference %p +// CHECK:STDOUT: %p.ref: const (const (const i32*)*) = name_reference "p", %p +// CHECK:STDOUT: %.loc9_11.1: ref const (const i32*) = dereference %p.ref // CHECK:STDOUT: %.loc9_11.2: const (const i32*) = bind_value %.loc9_11.1 // CHECK:STDOUT: %.loc9_10.1: ref const i32 = dereference %.loc9_11.2 // CHECK:STDOUT: %.loc9_10.2: const i32 = bind_value %.loc9_10.1 diff --git a/toolchain/check/testdata/pointer/types.carbon b/toolchain/check/testdata/pointer/types.carbon index 5988cff41a76..87675f59571c 100644 --- a/toolchain/check/testdata/pointer/types.carbon +++ b/toolchain/check/testdata/pointer/types.carbon @@ -19,10 +19,12 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: // CHECK:STDOUT: fn @Ptr(%p: i32*) -> i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %p +// CHECK:STDOUT: %p.ref: i32* = name_reference "p", %p +// CHECK:STDOUT: return %p.ref // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> const i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %p +// CHECK:STDOUT: %p.ref: const i32* = name_reference "p", %p +// CHECK:STDOUT: return %p.ref // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/empty.carbon b/toolchain/check/testdata/struct/empty.carbon index 26af89b07982..9c4134360813 100644 --- a/toolchain/check/testdata/struct/empty.carbon +++ b/toolchain/check/testdata/struct/empty.carbon @@ -14,8 +14,9 @@ var y: {} = x; // CHECK:STDOUT: %.loc7_14.1: {} = struct_literal () // CHECK:STDOUT: %.loc7_14.2: init {} = struct_init %.loc7_14.1, () // CHECK:STDOUT: assign %x, %.loc7_14.2 -// CHECK:STDOUT: %.loc8: {} = struct_literal () +// CHECK:STDOUT: %.loc8_9: {} = struct_literal () // CHECK:STDOUT: %y: ref {} = var "y" -// CHECK:STDOUT: %.loc7_5: init {} = struct_init %x, () -// CHECK:STDOUT: assign %y, %.loc7_5 +// CHECK:STDOUT: %x.ref: ref {} = name_reference "x", %x +// CHECK:STDOUT: %.loc8_13: init {} = struct_init %x.ref, () +// CHECK:STDOUT: assign %y, %.loc8_13 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_access_into_invalid.carbon b/toolchain/check/testdata/struct/fail_access_into_invalid.carbon index c42ffff794e0..570d13fc4b8b 100644 --- a/toolchain/check/testdata/struct/fail_access_into_invalid.carbon +++ b/toolchain/check/testdata/struct/fail_access_into_invalid.carbon @@ -16,5 +16,6 @@ fn F() { a.b; } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() { // CHECK:STDOUT: !entry: +// CHECK:STDOUT: %a.ref: = name_reference "a", // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_member_access_type.carbon b/toolchain/check/testdata/struct/fail_member_access_type.carbon index 3381eb011fec..eed156857abf 100644 --- a/toolchain/check/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/check/testdata/struct/fail_member_access_type.carbon @@ -18,5 +18,6 @@ var y: i32 = x.b; // CHECK:STDOUT: %.loc7_29.2: init {.a: f64} = struct_init %.loc7_29.1, (%.loc7_26) // CHECK:STDOUT: assign %x, %.loc7_29.2 // CHECK:STDOUT: %y: ref i32 = var "y" +// CHECK:STDOUT: %x.ref: ref {.a: f64} = name_reference "x", %x // CHECK:STDOUT: assign %y, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/fail_non_member_access.carbon b/toolchain/check/testdata/struct/fail_non_member_access.carbon index f8069f584c2f..1fd2ffde846f 100644 --- a/toolchain/check/testdata/struct/fail_non_member_access.carbon +++ b/toolchain/check/testdata/struct/fail_non_member_access.carbon @@ -18,5 +18,6 @@ var y: i32 = x.b; // CHECK:STDOUT: %.loc7_27.2: init {.a: i32} = struct_init %.loc7_27.1, (%.loc7_26) // CHECK:STDOUT: assign %x, %.loc7_27.2 // CHECK:STDOUT: %y: ref i32 = var "y" +// CHECK:STDOUT: %x.ref: ref {.a: i32} = name_reference "x", %x // CHECK:STDOUT: assign %y, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/literal_member_access.carbon b/toolchain/check/testdata/struct/literal_member_access.carbon index c1c89c9dbac3..07c8ffd410c5 100644 --- a/toolchain/check/testdata/struct/literal_member_access.carbon +++ b/toolchain/check/testdata/struct/literal_member_access.carbon @@ -20,6 +20,7 @@ fn F() -> i32 { // CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 +// CHECK:STDOUT: %G.ref = name_reference_untyped "G", package.%G // CHECK:STDOUT: %.loc10_25.1: ref {.x: i32, .y: i32, .z: i32} = temporary_storage // CHECK:STDOUT: %.loc10_25.2: init {.x: i32, .y: i32, .z: i32} = call @G() to %.loc10_25.1 // CHECK:STDOUT: %.loc10_34: i32 = int_literal 3 diff --git a/toolchain/check/testdata/struct/member_access.carbon b/toolchain/check/testdata/struct/member_access.carbon index 395008f3036c..b06a5e36915b 100644 --- a/toolchain/check/testdata/struct/member_access.carbon +++ b/toolchain/check/testdata/struct/member_access.carbon @@ -21,10 +21,12 @@ var z: i32 = y; // CHECK:STDOUT: %.loc7_46.6: init {.a: f64, .b: i32} = struct_init %.loc7_46.1, (%.loc7_46.3, %.loc7_46.5) // CHECK:STDOUT: assign %x, %.loc7_46.6 // CHECK:STDOUT: %y: ref i32 = var "y" -// CHECK:STDOUT: %.loc8_15.1: ref i32 = struct_access %x, member1 +// CHECK:STDOUT: %x.ref: ref {.a: f64, .b: i32} = name_reference "x", %x +// CHECK:STDOUT: %.loc8_15.1: ref i32 = struct_access %x.ref, member1 // CHECK:STDOUT: %.loc8_15.2: i32 = bind_value %.loc8_15.1 // CHECK:STDOUT: assign %y, %.loc8_15.2 // CHECK:STDOUT: %z: ref i32 = var "z" -// CHECK:STDOUT: %.loc8_5: i32 = bind_value %y -// CHECK:STDOUT: assign %z, %.loc8_5 +// CHECK:STDOUT: %y.ref: ref i32 = name_reference "y", %y +// CHECK:STDOUT: %.loc9: i32 = bind_value %y.ref +// CHECK:STDOUT: assign %z, %.loc9 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/nested_struct_in_place.carbon b/toolchain/check/testdata/struct/nested_struct_in_place.carbon index 90dc8d1d9c0e..713a09ca4c3d 100644 --- a/toolchain/check/testdata/struct/nested_struct_in_place.carbon +++ b/toolchain/check/testdata/struct/nested_struct_in_place.carbon @@ -23,8 +23,10 @@ fn G() { // CHECK:STDOUT: %.loc10_50: (type, type, type) = tuple_literal (i32, i32, i32) // CHECK:STDOUT: %.loc10_51: type = struct_type {.a: (i32, i32, i32), .b: (i32, i32, i32)} // CHECK:STDOUT: %v: ref {.a: (i32, i32, i32), .b: (i32, i32, i32)} = var "v" +// CHECK:STDOUT: %F.ref.loc10_61 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc10_74.1: ref (i32, i32, i32) = struct_access %v, member0 // CHECK:STDOUT: %.loc10_62: init (i32, i32, i32) = call @F() to %.loc10_74.1 +// CHECK:STDOUT: %F.ref.loc10_71 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc10_74.2: ref (i32, i32, i32) = struct_access %v, member1 // CHECK:STDOUT: %.loc10_72: init (i32, i32, i32) = call @F() to %.loc10_74.2 // CHECK:STDOUT: %.loc10_74.3: {.a: (i32, i32, i32), .b: (i32, i32, i32)} = struct_literal (%.loc10_62, %.loc10_72) diff --git a/toolchain/check/testdata/struct/one_entry.carbon b/toolchain/check/testdata/struct/one_entry.carbon index f532e6c384c9..65e114bb1042 100644 --- a/toolchain/check/testdata/struct/one_entry.carbon +++ b/toolchain/check/testdata/struct/one_entry.carbon @@ -14,10 +14,11 @@ var y: {.a: i32} = x; // CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_literal (%.loc7_26) // CHECK:STDOUT: %.loc7_27.2: init {.a: i32} = struct_init %.loc7_27.1, (%.loc7_26) // CHECK:STDOUT: assign %x, %.loc7_27.2 -// CHECK:STDOUT: %.loc8: type = struct_type {.a: i32} +// CHECK:STDOUT: %.loc8_16: type = struct_type {.a: i32} // CHECK:STDOUT: %y: ref {.a: i32} = var "y" -// CHECK:STDOUT: %.loc7_5.1: ref i32 = struct_access %x, member0 -// CHECK:STDOUT: %.loc7_5.2: i32 = bind_value %.loc7_5.1 -// CHECK:STDOUT: %.loc7_5.3: init {.a: i32} = struct_init %x, (%.loc7_5.2) -// CHECK:STDOUT: assign %y, %.loc7_5.3 +// CHECK:STDOUT: %x.ref: ref {.a: i32} = name_reference "x", %x +// CHECK:STDOUT: %.loc8_20.1: ref i32 = struct_access %x.ref, member0 +// CHECK:STDOUT: %.loc8_20.2: i32 = bind_value %.loc8_20.1 +// CHECK:STDOUT: %.loc8_20.3: init {.a: i32} = struct_init %x.ref, (%.loc8_20.2) +// CHECK:STDOUT: assign %y, %.loc8_20.3 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/tuple_as_element.carbon b/toolchain/check/testdata/struct/tuple_as_element.carbon index 486efe82c5b3..41b12abafc10 100644 --- a/toolchain/check/testdata/struct/tuple_as_element.carbon +++ b/toolchain/check/testdata/struct/tuple_as_element.carbon @@ -27,16 +27,17 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc8_27: (type,) = tuple_literal (i32) // CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} // CHECK:STDOUT: %y: ref {.a: i32, .b: (i32,)} = var "y" -// CHECK:STDOUT: %.loc7_5.1: ref i32 = struct_access %x, member0 -// CHECK:STDOUT: %.loc7_5.2: i32 = bind_value %.loc7_5.1 -// CHECK:STDOUT: %.loc7_5.3: ref i32 = struct_access %y, member0 -// CHECK:STDOUT: %.loc7_5.4: init i32 = initialize_from %.loc7_5.2 to %.loc7_5.3 -// CHECK:STDOUT: %.loc7_5.5: ref (i32,) = struct_access %x, member1 -// CHECK:STDOUT: %.loc7_5.6: ref i32 = tuple_access %.loc7_5.5, member0 -// CHECK:STDOUT: %.loc7_5.7: i32 = bind_value %.loc7_5.6 -// CHECK:STDOUT: %.loc7_5.8: init (i32,) = tuple_init %.loc7_5.5, (%.loc7_5.7) -// CHECK:STDOUT: %.loc7_5.9: ref (i32,) = struct_access %y, member1 -// CHECK:STDOUT: %.loc7_5.10: init (i32,) = initialize_from %.loc7_5.8 to %.loc7_5.9 -// CHECK:STDOUT: %.loc7_5.11: init {.a: i32, .b: (i32,)} = struct_init %x, (%.loc7_5.4, %.loc7_5.10) -// CHECK:STDOUT: assign %y, %.loc7_5.11 +// CHECK:STDOUT: %x.ref: ref {.a: i32, .b: (i32,)} = name_reference "x", %x +// CHECK:STDOUT: %.loc8_32.1: ref i32 = struct_access %x.ref, member0 +// CHECK:STDOUT: %.loc8_32.2: i32 = bind_value %.loc8_32.1 +// CHECK:STDOUT: %.loc8_32.3: ref i32 = struct_access %y, member0 +// CHECK:STDOUT: %.loc8_32.4: init i32 = initialize_from %.loc8_32.2 to %.loc8_32.3 +// CHECK:STDOUT: %.loc8_32.5: ref (i32,) = struct_access %x.ref, member1 +// CHECK:STDOUT: %.loc8_32.6: ref i32 = tuple_access %.loc8_32.5, member0 +// CHECK:STDOUT: %.loc8_32.7: i32 = bind_value %.loc8_32.6 +// CHECK:STDOUT: %.loc8_32.8: init (i32,) = tuple_init %.loc8_32.5, (%.loc8_32.7) +// CHECK:STDOUT: %.loc8_32.9: ref (i32,) = struct_access %y, member1 +// CHECK:STDOUT: %.loc8_32.10: init (i32,) = initialize_from %.loc8_32.8 to %.loc8_32.9 +// CHECK:STDOUT: %.loc8_32.11: init {.a: i32, .b: (i32,)} = struct_init %x.ref, (%.loc8_32.4, %.loc8_32.10) +// CHECK:STDOUT: assign %y, %.loc8_32.11 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/two_entries.carbon b/toolchain/check/testdata/struct/two_entries.carbon index 9450426f24c2..8c2995a52da5 100644 --- a/toolchain/check/testdata/struct/two_entries.carbon +++ b/toolchain/check/testdata/struct/two_entries.carbon @@ -19,16 +19,17 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: %.loc7_44.5: init i32 = initialize_from %.loc7_43 to %.loc7_44.4 // CHECK:STDOUT: %.loc7_44.6: init {.a: i32, .b: i32} = struct_init %.loc7_44.1, (%.loc7_44.3, %.loc7_44.5) // CHECK:STDOUT: assign %x, %.loc7_44.6 -// CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} +// CHECK:STDOUT: %.loc8_25: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %y: ref {.a: i32, .b: i32} = var "y" -// CHECK:STDOUT: %.loc7_5.1: ref i32 = struct_access %x, member0 -// CHECK:STDOUT: %.loc7_5.2: i32 = bind_value %.loc7_5.1 -// CHECK:STDOUT: %.loc7_5.3: ref i32 = struct_access %y, member0 -// CHECK:STDOUT: %.loc7_5.4: init i32 = initialize_from %.loc7_5.2 to %.loc7_5.3 -// CHECK:STDOUT: %.loc7_5.5: ref i32 = struct_access %x, member1 -// CHECK:STDOUT: %.loc7_5.6: i32 = bind_value %.loc7_5.5 -// CHECK:STDOUT: %.loc7_5.7: ref i32 = struct_access %y, member1 -// CHECK:STDOUT: %.loc7_5.8: init i32 = initialize_from %.loc7_5.6 to %.loc7_5.7 -// CHECK:STDOUT: %.loc7_5.9: init {.a: i32, .b: i32} = struct_init %x, (%.loc7_5.4, %.loc7_5.8) -// CHECK:STDOUT: assign %y, %.loc7_5.9 +// CHECK:STDOUT: %x.ref: ref {.a: i32, .b: i32} = name_reference "x", %x +// CHECK:STDOUT: %.loc8_29.1: ref i32 = struct_access %x.ref, member0 +// CHECK:STDOUT: %.loc8_29.2: i32 = bind_value %.loc8_29.1 +// CHECK:STDOUT: %.loc8_29.3: ref i32 = struct_access %y, member0 +// CHECK:STDOUT: %.loc8_29.4: init i32 = initialize_from %.loc8_29.2 to %.loc8_29.3 +// CHECK:STDOUT: %.loc8_29.5: ref i32 = struct_access %x.ref, member1 +// CHECK:STDOUT: %.loc8_29.6: i32 = bind_value %.loc8_29.5 +// CHECK:STDOUT: %.loc8_29.7: ref i32 = struct_access %y, member1 +// CHECK:STDOUT: %.loc8_29.8: init i32 = initialize_from %.loc8_29.6 to %.loc8_29.7 +// CHECK:STDOUT: %.loc8_29.9: init {.a: i32, .b: i32} = struct_init %x.ref, (%.loc8_29.4, %.loc8_29.8) +// CHECK:STDOUT: assign %y, %.loc8_29.9 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuples/empty.carbon b/toolchain/check/testdata/tuples/empty.carbon index 96c1cd280e1a..dfc83024954c 100644 --- a/toolchain/check/testdata/tuples/empty.carbon +++ b/toolchain/check/testdata/tuples/empty.carbon @@ -14,8 +14,9 @@ var y: () = x; // CHECK:STDOUT: %.loc7_14.1: () = tuple_literal () // CHECK:STDOUT: %.loc7_14.2: init () = tuple_init %.loc7_14.1, () // CHECK:STDOUT: assign %x, %.loc7_14.2 -// CHECK:STDOUT: %.loc8: () = tuple_literal () +// CHECK:STDOUT: %.loc8_9: () = tuple_literal () // CHECK:STDOUT: %y: ref () = var "y" -// CHECK:STDOUT: %.loc7_5: init () = tuple_init %x, () -// CHECK:STDOUT: assign %y, %.loc7_5 +// CHECK:STDOUT: %x.ref: ref () = name_reference "x", %x +// CHECK:STDOUT: %.loc8_13: init () = tuple_init %x.ref, () +// CHECK:STDOUT: assign %y, %.loc8_13 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon b/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon index 91be9259bf59..dfd8c998379f 100644 --- a/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon +++ b/toolchain/check/testdata/tuples/nested_tuple_in_place.carbon @@ -30,8 +30,10 @@ fn H() { // CHECK:STDOUT: %.loc10_43.2: ((type, type, type), (type, type, type)) = tuple_literal (%.loc10_25, %.loc10_42) // CHECK:STDOUT: %.loc10_43.3: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) // CHECK:STDOUT: %v: ref ((i32, i32, i32), (i32, i32, i32)) = var "v" +// CHECK:STDOUT: %F.ref.loc10_48 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc10_56.1: ref (i32, i32, i32) = tuple_access %v, member0 // CHECK:STDOUT: %.loc10_49: init (i32, i32, i32) = call @F() to %.loc10_56.1 +// CHECK:STDOUT: %F.ref.loc10_53 = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc10_56.2: ref (i32, i32, i32) = tuple_access %v, member1 // CHECK:STDOUT: %.loc10_54: init (i32, i32, i32) = call @F() to %.loc10_56.2 // CHECK:STDOUT: %.loc10_56.3: ((i32, i32, i32), (i32, i32, i32)) = tuple_literal (%.loc10_49, %.loc10_54) @@ -48,6 +50,7 @@ fn H() { // CHECK:STDOUT: %.loc14_36.3: type = tuple_type (i32, (i32, i32, i32), i32) // CHECK:STDOUT: %v: ref (i32, (i32, i32, i32), i32) = var "v" // CHECK:STDOUT: %.loc14_41: i32 = int_literal 1 +// CHECK:STDOUT: %F.ref = name_reference_untyped "F", package.%F // CHECK:STDOUT: %.loc14_50.1: ref (i32, i32, i32) = tuple_access %v, member1 // CHECK:STDOUT: %.loc14_45: init (i32, i32, i32) = call @F() to %.loc14_50.1 // CHECK:STDOUT: %.loc14_49: i32 = int_literal 2 diff --git a/toolchain/check/testdata/tuples/one_element.carbon b/toolchain/check/testdata/tuples/one_element.carbon index b12479b1e290..a07944f8cc00 100644 --- a/toolchain/check/testdata/tuples/one_element.carbon +++ b/toolchain/check/testdata/tuples/one_element.carbon @@ -16,10 +16,11 @@ var y: (i32,) = x; // CHECK:STDOUT: %.loc7_20.1: (i32,) = tuple_literal (%.loc7_18) // CHECK:STDOUT: %.loc7_20.2: init (i32,) = tuple_init %.loc7_20.1, (%.loc7_18) // CHECK:STDOUT: assign %x, %.loc7_20.2 -// CHECK:STDOUT: %.loc8: (type,) = tuple_literal (i32) +// CHECK:STDOUT: %.loc8_13: (type,) = tuple_literal (i32) // CHECK:STDOUT: %y: ref (i32,) = var "y" -// CHECK:STDOUT: %.loc7_5.1: ref i32 = tuple_access %x, member0 -// CHECK:STDOUT: %.loc7_5.2: i32 = bind_value %.loc7_5.1 -// CHECK:STDOUT: %.loc7_5.3: init (i32,) = tuple_init %x, (%.loc7_5.2) -// CHECK:STDOUT: assign %y, %.loc7_5.3 +// CHECK:STDOUT: %x.ref: ref (i32,) = name_reference "x", %x +// CHECK:STDOUT: %.loc8_17.1: ref i32 = tuple_access %x.ref, member0 +// CHECK:STDOUT: %.loc8_17.2: i32 = bind_value %.loc8_17.1 +// CHECK:STDOUT: %.loc8_17.3: init (i32,) = tuple_init %x.ref, (%.loc8_17.2) +// CHECK:STDOUT: assign %y, %.loc8_17.3 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/tuples/two_elements.carbon b/toolchain/check/testdata/tuples/two_elements.carbon index 82fd2f594c88..ea92de611cf8 100644 --- a/toolchain/check/testdata/tuples/two_elements.carbon +++ b/toolchain/check/testdata/tuples/two_elements.carbon @@ -21,16 +21,17 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %.loc7_28.5: init i32 = initialize_from %.loc7_25 to %.loc7_28.4 // CHECK:STDOUT: %.loc7_28.6: init (i32, i32) = tuple_init %.loc7_28.1, (%.loc7_28.3, %.loc7_28.5) // CHECK:STDOUT: assign %x, %.loc7_28.6 -// CHECK:STDOUT: %.loc8: (type, type) = tuple_literal (i32, i32) +// CHECK:STDOUT: %.loc8_17: (type, type) = tuple_literal (i32, i32) // CHECK:STDOUT: %y: ref (i32, i32) = var "y" -// CHECK:STDOUT: %.loc7_5.1: ref i32 = tuple_access %x, member0 -// CHECK:STDOUT: %.loc7_5.2: i32 = bind_value %.loc7_5.1 -// CHECK:STDOUT: %.loc7_5.3: ref i32 = tuple_access %y, member0 -// CHECK:STDOUT: %.loc7_5.4: init i32 = initialize_from %.loc7_5.2 to %.loc7_5.3 -// CHECK:STDOUT: %.loc7_5.5: ref i32 = tuple_access %x, member1 -// CHECK:STDOUT: %.loc7_5.6: i32 = bind_value %.loc7_5.5 -// CHECK:STDOUT: %.loc7_5.7: ref i32 = tuple_access %y, member1 -// CHECK:STDOUT: %.loc7_5.8: init i32 = initialize_from %.loc7_5.6 to %.loc7_5.7 -// CHECK:STDOUT: %.loc7_5.9: init (i32, i32) = tuple_init %x, (%.loc7_5.4, %.loc7_5.8) -// CHECK:STDOUT: assign %y, %.loc7_5.9 +// CHECK:STDOUT: %x.ref: ref (i32, i32) = name_reference "x", %x +// CHECK:STDOUT: %.loc8_21.1: ref i32 = tuple_access %x.ref, member0 +// CHECK:STDOUT: %.loc8_21.2: i32 = bind_value %.loc8_21.1 +// CHECK:STDOUT: %.loc8_21.3: ref i32 = tuple_access %y, member0 +// CHECK:STDOUT: %.loc8_21.4: init i32 = initialize_from %.loc8_21.2 to %.loc8_21.3 +// CHECK:STDOUT: %.loc8_21.5: ref i32 = tuple_access %x.ref, member1 +// CHECK:STDOUT: %.loc8_21.6: i32 = bind_value %.loc8_21.5 +// CHECK:STDOUT: %.loc8_21.7: ref i32 = tuple_access %y, member1 +// CHECK:STDOUT: %.loc8_21.8: init i32 = initialize_from %.loc8_21.6 to %.loc8_21.7 +// CHECK:STDOUT: %.loc8_21.9: init (i32, i32) = tuple_init %x.ref, (%.loc8_21.4, %.loc8_21.8) +// CHECK:STDOUT: assign %y, %.loc8_21.9 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/fail_init_with_self.carbon b/toolchain/check/testdata/var/fail_init_with_self.carbon index 5ca47124b9c4..943226152e63 100644 --- a/toolchain/check/testdata/var/fail_init_with_self.carbon +++ b/toolchain/check/testdata/var/fail_init_with_self.carbon @@ -18,6 +18,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: ref i32 = var "x" +// CHECK:STDOUT: %x.ref: = name_reference "x", // CHECK:STDOUT: assign %x, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/fail_lookup_outside_scope.carbon b/toolchain/check/testdata/var/fail_lookup_outside_scope.carbon index 8fd29871f794..9dcb6fe408c6 100644 --- a/toolchain/check/testdata/var/fail_lookup_outside_scope.carbon +++ b/toolchain/check/testdata/var/fail_lookup_outside_scope.carbon @@ -16,6 +16,7 @@ var y: i32 = x; // CHECK:STDOUT: file "fail_lookup_outside_scope.carbon" { // CHECK:STDOUT: %Main = fn_decl @Main // CHECK:STDOUT: %y: ref i32 = var "y" +// CHECK:STDOUT: %x.ref: = name_reference "x", // CHECK:STDOUT: assign %y, // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/var/global_lookup.carbon b/toolchain/check/testdata/var/global_lookup.carbon index 255933d1ce9f..ce29fe6daa5e 100644 --- a/toolchain/check/testdata/var/global_lookup.carbon +++ b/toolchain/check/testdata/var/global_lookup.carbon @@ -9,9 +9,10 @@ var y: i32 = x; // CHECK:STDOUT: file "global_lookup.carbon" { // CHECK:STDOUT: %x: ref i32 = var "x" -// CHECK:STDOUT: %.loc7_14: i32 = int_literal 0 -// CHECK:STDOUT: assign %x, %.loc7_14 +// CHECK:STDOUT: %.loc7: i32 = int_literal 0 +// CHECK:STDOUT: assign %x, %.loc7 // CHECK:STDOUT: %y: ref i32 = var "y" -// CHECK:STDOUT: %.loc7_5: i32 = bind_value %x -// CHECK:STDOUT: assign %y, %.loc7_5 +// CHECK:STDOUT: %x.ref: ref i32 = name_reference "x", %x +// CHECK:STDOUT: %.loc8: i32 = bind_value %x.ref +// CHECK:STDOUT: assign %y, %.loc8 // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/global_lookup_in_scope.carbon b/toolchain/check/testdata/var/global_lookup_in_scope.carbon index 0007b865467c..29010c197f2e 100644 --- a/toolchain/check/testdata/var/global_lookup_in_scope.carbon +++ b/toolchain/check/testdata/var/global_lookup_in_scope.carbon @@ -20,7 +20,8 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %y: ref i32 = var "y" -// CHECK:STDOUT: %.loc7: i32 = bind_value package.%x -// CHECK:STDOUT: assign %y, %.loc7 +// CHECK:STDOUT: %x.ref: ref i32 = name_reference "x", package.%x +// CHECK:STDOUT: %.loc10: i32 = bind_value %x.ref +// CHECK:STDOUT: assign %y, %.loc10 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/var/lookup.carbon b/toolchain/check/testdata/var/lookup.carbon index 8905e2e12d6d..126a4434069f 100644 --- a/toolchain/check/testdata/var/lookup.carbon +++ b/toolchain/check/testdata/var/lookup.carbon @@ -18,5 +18,6 @@ fn Main() { // CHECK:STDOUT: %x: ref i32 = var "x" // CHECK:STDOUT: %.loc8: i32 = int_literal 0 // CHECK:STDOUT: assign %x, %.loc8 +// CHECK:STDOUT: %x.ref: ref i32 = name_reference "x", %x // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/lower/handle.cpp b/toolchain/lower/handle.cpp index 9ef4dc2f6bcc..3464caed15aa 100644 --- a/toolchain/lower/handle.cpp +++ b/toolchain/lower/handle.cpp @@ -203,6 +203,18 @@ auto HandleIntegerLiteral(FunctionContext& context, SemIR::NodeId node_id, context.SetLocal(node_id, v); } +auto HandleNameReference(FunctionContext& context, SemIR::NodeId node_id, + SemIR::Node node) -> void { + auto [name_id, value_id] = node.GetAsNameReference(); + context.SetLocal(node_id, context.GetLocal(value_id)); +} + +auto HandleNameReferenceUntyped(FunctionContext& /*context*/, + SemIR::NodeId /*node_id*/, SemIR::Node /*node*/) + -> void { + // No action to take: untyped name references don't hold a value. +} + auto HandleNamespace(FunctionContext& /*context*/, SemIR::NodeId /*node_id*/, SemIR::Node /*node*/) -> void { // No action to take. diff --git a/toolchain/sem_ir/file.cpp b/toolchain/sem_ir/file.cpp index c0d79b921a99..a4b6c7ebcd43 100644 --- a/toolchain/sem_ir/file.cpp +++ b/toolchain/sem_ir/file.cpp @@ -210,6 +210,8 @@ static auto GetTypePrecedence(NodeKind kind) -> int { case NodeKind::InitializeFrom: case NodeKind::IntegerLiteral: case NodeKind::Invalid: + case NodeKind::NameReference: + case NodeKind::NameReferenceUntyped: case NodeKind::Namespace: case NodeKind::NoOp: case NodeKind::Parameter: @@ -257,10 +259,8 @@ auto File::StringifyType(TypeId type_id, bool in_type_context) const while (!steps.empty()) { auto step = steps.pop_back_val(); - - // Invalid node IDs will use the default invalid printing. if (!step.node_id.is_valid()) { - out << step.node_id; + out << ""; continue; } @@ -379,6 +379,8 @@ auto File::StringifyType(TypeId type_id, bool in_type_context) const case NodeKind::FunctionDeclaration: case NodeKind::InitializeFrom: case NodeKind::IntegerLiteral: + case NodeKind::NameReference: + case NodeKind::NameReferenceUntyped: case NodeKind::Namespace: case NodeKind::NoOp: case NodeKind::Parameter: @@ -439,6 +441,7 @@ auto GetExpressionCategory(const File& file, NodeId node_id) case NodeKind::BranchIf: case NodeKind::BranchWithArg: case NodeKind::FunctionDeclaration: + case NodeKind::NameReferenceUntyped: case NodeKind::Namespace: case NodeKind::NoOp: case NodeKind::Return: @@ -453,6 +456,12 @@ auto GetExpressionCategory(const File& file, NodeId node_id) continue; } + case NodeKind::NameReference: { + auto [name_id, value_id] = node.GetAsNameReference(); + node_id = value_id; + continue; + } + case NodeKind::AddressOf: case NodeKind::ArrayType: case NodeKind::BinaryOperatorAdd: @@ -552,6 +561,8 @@ auto GetValueRepresentation(const File& file, TypeId type_id) case NodeKind::InitializeFrom: case NodeKind::IntegerLiteral: case NodeKind::Invalid: + case NodeKind::NameReference: + case NodeKind::NameReferenceUntyped: case NodeKind::Namespace: case NodeKind::NoOp: case NodeKind::Parameter: diff --git a/toolchain/sem_ir/file.h b/toolchain/sem_ir/file.h index b758cd52e11b..b39abbfe2f38 100644 --- a/toolchain/sem_ir/file.h +++ b/toolchain/sem_ir/file.h @@ -285,6 +285,8 @@ class File : public Printable { return NodeId::BuiltinTypeType; } else if (type_id == TypeId::Error) { return NodeId::BuiltinError; + } else if (type_id == TypeId::Invalid) { + return NodeId::Invalid; } else { return GetType(type_id); } diff --git a/toolchain/sem_ir/formatter.cpp b/toolchain/sem_ir/formatter.cpp index fb950dcfccd0..f325443a5d3d 100644 --- a/toolchain/sem_ir/formatter.cpp +++ b/toolchain/sem_ir/formatter.cpp @@ -375,6 +375,16 @@ class NodeNamer { .name_id); continue; } + case NodeKind::NameReference: { + auto [name_id, value_id] = node.GetAsNameReference(); + add_node_name(semantics_ir_.GetString(name_id).str() + ".ref"); + continue; + } + case NodeKind::NameReferenceUntyped: { + auto [name_id, value_id] = node.GetAsNameReferenceUntyped(); + add_node_name(semantics_ir_.GetString(name_id).str() + ".ref"); + continue; + } case NodeKind::Parameter: { add_node_name_id(node.GetAsParameter()); continue; diff --git a/toolchain/sem_ir/node.h b/toolchain/sem_ir/node.h index 749009326333..8d95e0c413e4 100644 --- a/toolchain/sem_ir/node.h +++ b/toolchain/sem_ir/node.h @@ -385,6 +385,13 @@ class Node : public Printable { using IntegerLiteral = Factory; + using NameReference = Factory; + + using NameReferenceUntyped = + Factory; + using Namespace = FactoryNoType; diff --git a/toolchain/sem_ir/node_kind.def b/toolchain/sem_ir/node_kind.def index 779036893009..e2ab0cb2d847 100644 --- a/toolchain/sem_ir/node_kind.def +++ b/toolchain/sem_ir/node_kind.def @@ -69,6 +69,10 @@ CARBON_SEMANTICS_NODE_KIND_IMPL(InitializeFrom, "initialize_from", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(IntegerLiteral, "int_literal", Typed, NotTerminator) +CARBON_SEMANTICS_NODE_KIND_IMPL(NameReference, "name_reference", Typed, + NotTerminator) +CARBON_SEMANTICS_NODE_KIND_IMPL(NameReferenceUntyped, "name_reference_untyped", + Untyped, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(Namespace, "namespace", Untyped, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(NoOp, "no_op", None, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(Parameter, "parameter", Typed, NotTerminator)