From 0400cdf6013eb413501cad54b32a579da6f50655 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 10 Aug 2023 17:30:27 -0700 Subject: [PATCH 01/21] Rough semantic support for expression category conversions. Value bindings, temporary materializations, and initialization steps are created where necessary to transition between expression categories. --- .../testdata/function/call/var_param.carbon | 3 +- toolchain/semantics/semantics_context.cpp | 70 +++++- toolchain/semantics/semantics_context.h | 38 +++- .../semantics_handle_if_expression.cpp | 10 +- .../semantics_handle_if_statement.cpp | 2 +- toolchain/semantics/semantics_handle_name.cpp | 7 + .../semantics/semantics_handle_operator.cpp | 12 +- .../semantics/semantics_handle_paren.cpp | 16 ++ .../semantics/semantics_handle_statement.cpp | 4 +- .../semantics/semantics_handle_struct.cpp | 5 + .../semantics/semantics_handle_variable.cpp | 2 +- toolchain/semantics/semantics_ir.cpp | 15 +- toolchain/semantics/semantics_node.h | 9 + toolchain/semantics/semantics_node_kind.def | 6 + .../testdata/basics/builtin_types.carbon | 40 ++-- .../basics/fail_non_type_as_type.carbon | 7 +- .../basics/fail_qualifier_unsupported.carbon | 7 +- .../semantics/testdata/basics/parens.carbon | 9 +- .../semantics/testdata/const/collapse.carbon | 10 +- .../testdata/const/fail_collapse.carbon | 7 +- .../function/call/empty_struct.carbon | 20 +- .../testdata/function/call/empty_tuple.carbon | 20 +- .../call/fail_return_type_mismatch.carbon | 22 +- .../testdata/function/call/i32.carbon | 31 ++- .../function/call/return_implicit.carbon | 9 +- toolchain/semantics/testdata/if/else.carbon | 17 +- .../if/fail_reachable_fallthrough.carbon | 80 ++++--- .../semantics/testdata/if/fail_scope.carbon | 41 ++-- .../semantics/testdata/if/no_else.carbon | 13 +- .../if/unreachable_fallthrough.carbon | 31 ++- .../testdata/if_expression/basic.carbon | 56 +++-- .../if_expression/constant_condition.carbon | 76 ++++--- .../if_expression/control_flow.carbon | 58 +++-- .../testdata/if_expression/nested.carbon | 88 ++++---- .../testdata/index/element_access.carbon | 39 +++- .../testdata/index/fail_large_index.carbon | 32 ++- .../testdata/index/fail_name_not_found.carbon | 7 +- .../index/fail_negative_indexing.carbon | 6 +- .../index/fail_non_deterministic_type.carbon | 29 ++- .../index/fail_non_int_indexing.carbon | 18 +- .../index/fail_out_of_bound_access.carbon | 18 +- .../testdata/index/return_value_access.carbon | 24 +- .../ir/duplicate_name_same_line.carbon | 26 ++- .../semantics/testdata/operators/and.carbon | 45 ++-- .../testdata/operators/assignment.carbon | 195 ++++++++++------- .../testdata/operators/binary_op.carbon | 9 +- .../fail_assigment_to_non_assignable.carbon | 207 +++++++++++------- .../operators/fail_type_mismatch.carbon | 7 +- .../fail_type_mismatch_assignment.carbon | 16 +- .../operators/fail_type_mismatch_once.carbon | 7 +- .../semantics/testdata/operators/or.carbon | 47 ++-- .../testdata/operators/unary_op.carbon | 14 +- .../testdata/pointer/address_of_deref.carbon | 29 ++- .../testdata/pointer/address_of_lvalue.carbon | 120 ++++++---- .../semantics/testdata/pointer/basic.carbon | 39 +++- .../fail_dereference_not_pointer.carbon | 15 +- .../pointer/fail_type_mismatch.carbon | 7 +- .../testdata/pointer/nested_const.carbon | 24 +- .../semantics/testdata/pointer/types.carbon | 38 ++-- .../testdata/return/code_after_return.carbon | 3 +- .../return/code_after_return_value.carbon | 25 ++- .../testdata/return/fail_type_mismatch.carbon | 7 +- .../semantics/testdata/return/struct.carbon | 9 +- .../semantics/testdata/return/tuple.carbon | 9 +- .../semantics/testdata/return/value.carbon | 9 +- .../semantics/testdata/struct/empty.carbon | 21 +- .../testdata/struct/fail_assign_empty.carbon | 7 +- .../testdata/struct/fail_assign_nested.carbon | 7 +- .../struct/fail_assign_to_empty.carbon | 7 +- .../struct/fail_field_name_mismatch.carbon | 7 +- .../struct/fail_field_type_mismatch.carbon | 7 +- .../struct/fail_member_access_type.carbon | 18 +- .../struct/fail_non_member_access.carbon | 18 +- .../struct/fail_too_few_values.carbon | 7 +- .../testdata/struct/fail_type_assign.carbon | 7 +- .../testdata/struct/member_access.carbon | 35 ++- .../testdata/struct/one_entry.carbon | 23 +- .../testdata/struct/tuple_as_element.carbon | 27 ++- .../testdata/struct/two_entries.carbon | 23 +- .../semantics/testdata/tuples/empty.carbon | 21 +- .../testdata/tuples/fail_assign_empty.carbon | 7 +- .../testdata/tuples/fail_assign_nested.carbon | 7 +- .../tuples/fail_assign_to_empty.carbon | 7 +- .../tuples/fail_element_type_mismatch.carbon | 7 +- .../tuples/fail_too_few_element.carbon | 7 +- .../testdata/tuples/fail_type_assign.carbon | 7 +- .../testdata/tuples/nested_tuple.carbon | 9 +- .../testdata/tuples/one_element.carbon | 23 +- .../testdata/tuples/two_elements.carbon | 23 +- .../testdata/var/decl_with_init.carbon | 9 +- .../testdata/var/fail_duplicate_decl.carbon | 20 +- .../var/fail_init_type_mismatch.carbon | 7 +- .../testdata/var/fail_init_with_self.carbon | 7 +- .../var/fail_lookup_outside_scope.carbon | 7 +- .../var/fail_storage_is_literal.carbon | 7 +- .../testdata/var/global_decl_with_init.carbon | 9 +- .../testdata/var/global_lookup.carbon | 21 +- .../var/global_lookup_in_scope.carbon | 23 +- .../semantics/testdata/var/lookup.carbon | 9 +- 99 files changed, 1571 insertions(+), 801 deletions(-) diff --git a/toolchain/lowering/testdata/function/call/var_param.carbon b/toolchain/lowering/testdata/function/call/var_param.carbon index ef42b8a12e81a..61947f8561eba 100644 --- a/toolchain/lowering/testdata/function/call/var_param.carbon +++ b/toolchain/lowering/testdata/function/call/var_param.carbon @@ -22,7 +22,8 @@ fn Main() { // CHECK:STDOUT: %var = alloca i32, align 4 // CHECK:STDOUT: store i32 0, ptr %var, align 4 // CHECK:STDOUT: %1 = load i32, ptr %var, align 4 -// CHECK:STDOUT: call void @DoNothing(i32 %1) +// CHECK:STDOUT: %2 = load i32, ptr %var, align 4 +// CHECK:STDOUT: call void @DoNothing(i32 %2) // CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 1779d0696c47e..3546c2dbfc94a 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -268,6 +268,62 @@ auto SemanticsContext::is_current_position_reachable() -> bool { } } +auto SemanticsContext::ConvertToInitializingExpression(SemanticsNodeId expr_id) + -> SemanticsNodeId { + SemanticsNode expr = semantics_ir().GetNode(expr_id); + switch (GetSemanticsExpressionCategory(semantics_ir(), expr_id)) { + case SemanticsExpressionCategory::NotExpression: + CARBON_FATAL() << "Converting non-expression node " << expr + << " to initializing expression"; + + case SemanticsExpressionCategory::DurableReference: + case SemanticsExpressionCategory::EphemeralReference: + // The design uses a custom "copy initialization" process here. We model + // that as value binding followed by direct initialization. + // + // TODO: Determine whether this is observably different from the design, + // and change either the toolchain or the design so they match. + expr_id = AddNode(SemanticsNode::ValueBinding::Make( + expr.parse_node(), expr.type_id(), expr_id)); + [[fallthrough]]; + + case SemanticsExpressionCategory::Value: + // TODO: For class types, use an interface to determine how to perform + // this operation. + return AddNode(SemanticsNode::InitializeFrom::Make( + expr.parse_node(), expr.type_id(), expr_id)); + + case SemanticsExpressionCategory::Initializing: + return expr_id; + } +} + +auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) + -> SemanticsNodeId { + SemanticsNode expr = semantics_ir().GetNode(expr_id); + switch (GetSemanticsExpressionCategory(semantics_ir(), expr_id)) { + case SemanticsExpressionCategory::NotExpression: + CARBON_FATAL() << "Converting non-expression node " << expr + << " to value expression"; + + case SemanticsExpressionCategory::Initializing: + // TODO: For class types, use an interface to determine how to perform + // this operation. + expr_id = AddNode(SemanticsNode::MaterializeTemporary::Make( + expr.parse_node(), expr.type_id(), expr_id)); + [[fallthrough]]; + + case SemanticsExpressionCategory::DurableReference: + case SemanticsExpressionCategory::EphemeralReference: + // TODO: Support types with custom value representations. + return AddNode(SemanticsNode::ValueBinding::Make( + expr.parse_node(), expr.type_id(), expr_id)); + + case SemanticsExpressionCategory::Value: + return expr_id; + } +} + auto SemanticsContext::ImplicitAsForArgs( SemanticsNodeBlockId arg_refs_id, ParseTree::Node param_parse_node, SemanticsNodeBlockId param_refs_id, @@ -314,6 +370,13 @@ auto SemanticsContext::ImplicitAsForArgs( semantics_ir_->StringifyType(as_type_id)); return false; } + + // TODO: Convert to the proper expression category. For now, we assume + // parameters are all `let` bindings. + if (!diagnostic) { + // TODO: Insert the conversion in the proper place in the node block. + arg_refs[i] = ConvertToValueExpression(value_id); + } } return true; @@ -340,13 +403,6 @@ auto SemanticsContext::ImplicitAsRequired(ParseTree::Node parse_node, return output_value_id; } -auto SemanticsContext::ImplicitAsBool(ParseTree::Node parse_node, - SemanticsNodeId value_id) - -> SemanticsNodeId { - return ImplicitAsRequired(parse_node, value_id, - CanonicalizeType(SemanticsNodeId::BuiltinBoolType)); -} - auto SemanticsContext::ImplicitAsImpl(SemanticsNodeId value_id, SemanticsTypeId as_type_id, SemanticsNodeId* output_value_id) diff --git a/toolchain/semantics/semantics_context.h b/toolchain/semantics/semantics_context.h index 5146542286c8c..76f4e364fcdfd 100644 --- a/toolchain/semantics/semantics_context.h +++ b/toolchain/semantics/semantics_context.h @@ -110,6 +110,38 @@ class SemanticsContext { // Returns whether the current position in the current block is reachable. auto is_current_position_reachable() -> bool; + // Convert the given expression to an initializing expression of the same + // type. + auto ConvertToInitializingExpression(SemanticsNodeId expr_id) + -> SemanticsNodeId; + + // Convert the given expression to a value expression of the same type. + auto ConvertToValueExpression(SemanticsNodeId expr_id) -> SemanticsNodeId; + + // Converts `value_id` to an initializing expression of type `type_id`. + auto ConvertToInitializerOfType(ParseTree::Node parse_node, + SemanticsNodeId value_id, + SemanticsTypeId type_id) -> SemanticsNodeId { + return ConvertToInitializingExpression( + ImplicitAsRequired(parse_node, value_id, type_id)); + } + + // Converts `value_id` to a value expression of type `type_id`. + auto ConvertToValueOfType(ParseTree::Node parse_node, + SemanticsNodeId value_id, SemanticsTypeId type_id) + -> SemanticsNodeId { + return ConvertToValueExpression( + ImplicitAsRequired(parse_node, value_id, type_id)); + } + + // Converts `value_id` to a value expression of type `bool`. + auto ConvertToBoolValue(ParseTree::Node parse_node, SemanticsNodeId value_id) + -> SemanticsNodeId { + return ConvertToValueOfType( + parse_node, value_id, + CanonicalizeType(SemanticsNodeId::BuiltinBoolType)); + } + // Runs ImplicitAsImpl for a set of arguments and parameters. // // This will eventually need to support checking against multiple possible @@ -129,10 +161,6 @@ class SemanticsContext { auto ImplicitAsRequired(ParseTree::Node parse_node, SemanticsNodeId value_id, SemanticsTypeId as_type_id) -> SemanticsNodeId; - // Runs ImplicitAsRequired for a conversion to `bool`. - auto ImplicitAsBool(ParseTree::Node parse_node, SemanticsNodeId value_id) - -> SemanticsNodeId; - // Canonicalizes a type which is tracked as a single node. // TODO: This should eventually return a type ID. auto CanonicalizeType(SemanticsNodeId node_id) -> SemanticsTypeId; @@ -170,7 +198,7 @@ class SemanticsContext { } return CanonicalizeType( - ImplicitAsRequired(parse_node, value_id, SemanticsTypeId::TypeType)); + ConvertToValueOfType(parse_node, value_id, SemanticsTypeId::TypeType)); } // Removes any top-level `const` qualifiers from a type. diff --git a/toolchain/semantics/semantics_handle_if_expression.cpp b/toolchain/semantics/semantics_handle_if_expression.cpp index 5c9ae5cbd928d..b3c1168fafaf4 100644 --- a/toolchain/semantics/semantics_handle_if_expression.cpp +++ b/toolchain/semantics/semantics_handle_if_expression.cpp @@ -13,7 +13,7 @@ auto SemanticsHandleIfExpressionIf(SemanticsContext& context, context.node_stack().Push(if_node); // Convert the condition to `bool`, and branch on it. - cond_value_id = context.ImplicitAsBool(if_node, cond_value_id); + cond_value_id = context.ConvertToBoolValue(if_node, cond_value_id); auto then_block_id = context.AddDominatedBlockAndBranchIf(if_node, cond_value_id); auto else_block_id = context.AddDominatedBlockAndBranch(if_node); @@ -28,6 +28,12 @@ auto SemanticsHandleIfExpressionIf(SemanticsContext& context, auto SemanticsHandleIfExpressionThen(SemanticsContext& context, ParseTree::Node then_node) -> bool { + // Convert the first operand to a value. + auto [then_value_node, then_value_id] = + context.node_stack().PopExpressionWithParseNode(); + context.node_stack().Push(then_value_node, + context.ConvertToValueExpression(then_value_id)); + context.node_stack().Push(then_node, context.node_block_stack().Pop()); context.AddCurrentCodeBlockToFunction(); return true; @@ -47,7 +53,7 @@ auto SemanticsHandleIfExpressionElse(SemanticsContext& context, // TODO: Find a common type, and convert both operands to it instead. auto result_type_id = context.semantics_ir().GetNode(then_value_id).type_id(); else_value_id = - context.ImplicitAsRequired(else_node, else_value_id, result_type_id); + context.ConvertToValueOfType(else_node, else_value_id, result_type_id); auto else_end_block_id = context.node_block_stack().Pop(); // Create a resumption block and branches to it. diff --git a/toolchain/semantics/semantics_handle_if_statement.cpp b/toolchain/semantics/semantics_handle_if_statement.cpp index a144d0e6ca1ec..58ad380f2bb58 100644 --- a/toolchain/semantics/semantics_handle_if_statement.cpp +++ b/toolchain/semantics/semantics_handle_if_statement.cpp @@ -16,7 +16,7 @@ auto SemanticsHandleIfCondition(SemanticsContext& context, ParseTree::Node parse_node) -> bool { // Convert the condition to `bool`. auto cond_value_id = context.node_stack().PopExpression(); - cond_value_id = context.ImplicitAsBool(parse_node, cond_value_id); + cond_value_id = context.ConvertToBoolValue(parse_node, cond_value_id); // Create the then block and the else block, and branch to the right one. If // there is no `else`, the then block will terminate with a branch to the diff --git a/toolchain/semantics/semantics_handle_name.cpp b/toolchain/semantics/semantics_handle_name.cpp index 1cdf613345833..e70ace34c9d1b 100644 --- a/toolchain/semantics/semantics_handle_name.cpp +++ b/toolchain/semantics/semantics_handle_name.cpp @@ -12,6 +12,13 @@ auto SemanticsHandleMemberAccessExpression(SemanticsContext& context, SemanticsStringId name_id = context.node_stack().Pop(); auto base_id = context.node_stack().PopExpression(); + + // Materialize a temporary for the base expression if necessary. + if (GetSemanticsExpressionCategory(context.semantics_ir(), base_id) == + SemanticsExpressionCategory::Initializing) { + base_id = context.ConvertToValueExpression(base_id); + } + auto base = context.semantics_ir().GetNode(base_id); if (base.kind() == SemanticsNodeKind::Namespace) { // For a namespace, just resolve the name. diff --git a/toolchain/semantics/semantics_handle_operator.cpp b/toolchain/semantics/semantics_handle_operator.cpp index 33f42fa6c7769..1e0abb0dc9300 100644 --- a/toolchain/semantics/semantics_handle_operator.cpp +++ b/toolchain/semantics/semantics_handle_operator.cpp @@ -17,8 +17,9 @@ auto SemanticsHandleInfixOperator(SemanticsContext& context, case TokenKind::Plus: // TODO: This should search for a compatible interface. For now, it's a // very trivial check of validity on the operation. - lhs_id = context.ImplicitAsRequired( + lhs_id = context.ConvertToValueOfType( parse_node, lhs_id, context.semantics_ir().GetNode(rhs_id).type_id()); + rhs_id = context.ConvertToValueExpression(rhs_id); context.AddNodeAndPush( parse_node, @@ -32,7 +33,7 @@ auto SemanticsHandleInfixOperator(SemanticsContext& context, // The first operand is wrapped in a ShortCircuitOperand, which we // already handled by creating a RHS block and a resumption block, which // are the current block and its enclosing block. - rhs_id = context.ImplicitAsBool(parse_node, rhs_id); + rhs_id = context.ConvertToBoolValue(parse_node, rhs_id); // When the second operand is evaluated, the result of `and` and `or` is // its value. @@ -59,7 +60,7 @@ auto SemanticsHandleInfixOperator(SemanticsContext& context, "Expression is not assignable."); context.emitter().Emit(lhs_node, AssignmentToNonAssignable); } - context.ImplicitAsRequired( + rhs_id = context.ConvertToInitializerOfType( parse_node, rhs_id, context.semantics_ir().GetNode(lhs_id).type_id()); context.AddNodeAndPush( parse_node, SemanticsNode::Assign::Make(parse_node, lhs_id, rhs_id)); @@ -147,7 +148,7 @@ auto SemanticsHandlePrefixOperator(SemanticsContext& context, } case TokenKind::Not: - value_id = context.ImplicitAsBool(parse_node, value_id); + value_id = context.ConvertToBoolValue(parse_node, value_id); context.AddNodeAndPush( parse_node, SemanticsNode::UnaryOperatorNot::Make( @@ -180,6 +181,7 @@ auto SemanticsHandlePrefixOperator(SemanticsContext& context, } builder.Emit(); } + value_id = context.ConvertToValueExpression(value_id); context.AddNodeAndPush(parse_node, SemanticsNode::Dereference::Make( parse_node, result_type_id, value_id)); @@ -195,7 +197,7 @@ auto SemanticsHandleShortCircuitOperand(SemanticsContext& context, ParseTree::Node parse_node) -> bool { // Convert the condition to `bool`. auto cond_value_id = context.node_stack().PopExpression(); - cond_value_id = context.ImplicitAsBool(parse_node, cond_value_id); + cond_value_id = context.ConvertToBoolValue(parse_node, cond_value_id); auto bool_type_id = context.semantics_ir().GetNode(cond_value_id).type_id(); // Compute the branch value: the condition for `and`, inverted for `or`. diff --git a/toolchain/semantics/semantics_handle_paren.cpp b/toolchain/semantics/semantics_handle_paren.cpp index 6cec1fc0108a7..2f2d54e5b0d4f 100644 --- a/toolchain/semantics/semantics_handle_paren.cpp +++ b/toolchain/semantics/semantics_handle_paren.cpp @@ -29,14 +29,30 @@ auto SemanticsHandleParenExpressionOrTupleLiteralStart( return true; } +static auto HandleTupleLiteralElement(SemanticsContext& context) -> void { + // Convert the operand to a value. + // TODO: We need to decide how tuple literals interact with expression + // categories. + auto [value_node, value_id] = + context.node_stack().PopExpressionWithParseNode(); + value_id = context.ConvertToValueExpression(value_id); + context.node_stack().Push(value_node, value_id); +} + auto SemanticsHandleTupleLiteralComma(SemanticsContext& context, ParseTree::Node /*parse_node*/) -> bool { + HandleTupleLiteralElement(context); context.ParamOrArgComma(/*for_args=*/true); return true; } auto SemanticsHandleTupleLiteral(SemanticsContext& context, ParseTree::Node parse_node) -> bool { + if (context.parse_tree().node_kind(context.node_stack().PeekParseNode()) != + ParseNodeKind::ParenExpressionOrTupleLiteralStart) { + HandleTupleLiteralElement(context); + } + auto refs_id = context.ParamOrArgEnd( /*for_args=*/true, ParseNodeKind::ParenExpressionOrTupleLiteralStart); diff --git a/toolchain/semantics/semantics_handle_statement.cpp b/toolchain/semantics/semantics_handle_statement.cpp index a8e9dc87f3e12..29eb14a88b717 100644 --- a/toolchain/semantics/semantics_handle_statement.cpp +++ b/toolchain/semantics/semantics_handle_statement.cpp @@ -57,8 +57,8 @@ auto SemanticsHandleReturnStatement(SemanticsContext& context, .Note(fn_node.parse_node(), ReturnStatementImplicitNote) .Emit(); } else { - arg = - context.ImplicitAsRequired(parse_node, arg, callable.return_type_id); + arg = context.ConvertToInitializerOfType(parse_node, arg, + callable.return_type_id); } context.AddNode(SemanticsNode::ReturnExpression::Make(parse_node, arg)); diff --git a/toolchain/semantics/semantics_handle_struct.cpp b/toolchain/semantics/semantics_handle_struct.cpp index 68741f030f50f..eeb6185cd79ff 100644 --- a/toolchain/semantics/semantics_handle_struct.cpp +++ b/toolchain/semantics/semantics_handle_struct.cpp @@ -49,6 +49,11 @@ auto SemanticsHandleStructFieldValue(SemanticsContext& context, context.node_stack().PopExpressionWithParseNode(); SemanticsStringId name_id = context.node_stack().Pop(); + // Convert the operand to a value. + // TODO: We need to decide how struct literals interact with expression + // categories. + value_node_id = context.ConvertToValueExpression(value_node_id); + // Store the name for the type. auto type_block_id = context.args_type_info_stack().PeekForAdd(); context.semantics_ir().AddNode( diff --git a/toolchain/semantics/semantics_handle_variable.cpp b/toolchain/semantics/semantics_handle_variable.cpp index e8f54bcf6e19a..79baa1fe40a1f 100644 --- a/toolchain/semantics/semantics_handle_variable.cpp +++ b/toolchain/semantics/semantics_handle_variable.cpp @@ -28,7 +28,7 @@ auto SemanticsHandleVariableDeclaration(SemanticsContext& context, context.AddNameToLookup(binding.parse_node(), name_id, storage_id); // If there was an initializer, assign it to storage. if (has_init) { - auto cast_value_id = context.ImplicitAsRequired( + auto cast_value_id = context.ConvertToInitializerOfType( parse_node, expr_node_id, context.semantics_ir().GetNode(storage_id).type_id()); context.AddNode( diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index 42b6aaeb86d5d..fac127ea89baf 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -233,8 +233,10 @@ static auto GetTypePrecedence(SemanticsNodeKind kind) -> int { case SemanticsNodeKind::Dereference: case SemanticsNodeKind::FunctionDeclaration: case SemanticsNodeKind::Index: + case SemanticsNodeKind::InitializeFrom: case SemanticsNodeKind::IntegerLiteral: case SemanticsNodeKind::Invalid: + case SemanticsNodeKind::MaterializeTemporary: case SemanticsNodeKind::Namespace: case SemanticsNodeKind::RealLiteral: case SemanticsNodeKind::Return: @@ -246,6 +248,7 @@ static auto GetTypePrecedence(SemanticsNodeKind kind) -> int { case SemanticsNodeKind::StubReference: case SemanticsNodeKind::TupleValue: case SemanticsNodeKind::UnaryOperatorNot: + case SemanticsNodeKind::ValueBinding: case SemanticsNodeKind::VarStorage: CARBON_FATAL() << "GetTypePrecedence for non-type node kind " << kind; } @@ -373,11 +376,13 @@ auto SemanticsIR::StringifyType(SemanticsTypeId type_id, case SemanticsNodeKind::BranchWithArg: case SemanticsNodeKind::Builtin: case SemanticsNodeKind::Call: - case SemanticsNodeKind::Dereference: case SemanticsNodeKind::CrossReference: + case SemanticsNodeKind::Dereference: case SemanticsNodeKind::FunctionDeclaration: case SemanticsNodeKind::Index: + case SemanticsNodeKind::InitializeFrom: case SemanticsNodeKind::IntegerLiteral: + case SemanticsNodeKind::MaterializeTemporary: case SemanticsNodeKind::Namespace: case SemanticsNodeKind::RealLiteral: case SemanticsNodeKind::Return: @@ -388,6 +393,7 @@ auto SemanticsIR::StringifyType(SemanticsTypeId type_id, case SemanticsNodeKind::StubReference: case SemanticsNodeKind::TupleValue: case SemanticsNodeKind::UnaryOperatorNot: + case SemanticsNodeKind::ValueBinding: case SemanticsNodeKind::VarStorage: // We don't need to handle stringification for nodes that don't show up // in errors, but make it clear what's going on so that it's clearer @@ -462,6 +468,7 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, case SemanticsNodeKind::StructType: case SemanticsNodeKind::TupleType: case SemanticsNodeKind::UnaryOperatorNot: + case SemanticsNodeKind::ValueBinding: return SemanticsExpressionCategory::Value; case SemanticsNodeKind::StructMemberAccess: { @@ -489,9 +496,15 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, // struct/tuple value construction. return SemanticsExpressionCategory::Value; + case SemanticsNodeKind::InitializeFrom: + return SemanticsExpressionCategory::Initializing; + case SemanticsNodeKind::Dereference: case SemanticsNodeKind::VarStorage: return SemanticsExpressionCategory::DurableReference; + + case SemanticsNodeKind::MaterializeTemporary: + return SemanticsExpressionCategory::EphemeralReference; } } } diff --git a/toolchain/semantics/semantics_node.h b/toolchain/semantics/semantics_node.h index a21305920a268..45fb478fffde7 100644 --- a/toolchain/semantics/semantics_node.h +++ b/toolchain/semantics/semantics_node.h @@ -389,9 +389,15 @@ class SemanticsNode { using Index = Factory; + using InitializeFrom = + Factory; + using IntegerLiteral = Factory; + using MaterializeTemporary = Factory; + using Namespace = FactoryNoType; @@ -435,6 +441,9 @@ class SemanticsNode { using UnaryOperatorNot = Factory; + using ValueBinding = + Factory; + using VarStorage = Factory; SemanticsNode() : SemanticsNode(ParseTree::Node::Invalid, SemanticsNodeKind::Invalid, diff --git a/toolchain/semantics/semantics_node_kind.def b/toolchain/semantics/semantics_node_kind.def index bd1d0294e25b0..d4f2b65604cc6 100644 --- a/toolchain/semantics/semantics_node_kind.def +++ b/toolchain/semantics/semantics_node_kind.def @@ -62,8 +62,12 @@ CARBON_SEMANTICS_NODE_KIND_IMPL(Dereference, "dereference", Typed, CARBON_SEMANTICS_NODE_KIND_IMPL(FunctionDeclaration, "fn_decl", Untyped, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(Index, "tuple_index", Typed, NotTerminator) +CARBON_SEMANTICS_NODE_KIND_IMPL(InitializeFrom, "initialize_from", Typed, + NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(IntegerLiteral, "int_value", Typed, NotTerminator) +CARBON_SEMANTICS_NODE_KIND_IMPL(MaterializeTemporary, "materialize_temporary", + Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(Namespace, "namespace", Untyped, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(PointerType, "ptr_type", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(RealLiteral, "real_value", Typed, NotTerminator) @@ -83,6 +87,8 @@ CARBON_SEMANTICS_NODE_KIND_IMPL(StubReference, "stub_reference", Typed, CARBON_SEMANTICS_NODE_KIND_IMPL(TupleType, "tuple_type", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(TupleValue, "tuple_value", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(UnaryOperatorNot, "not", Typed, NotTerminator) +CARBON_SEMANTICS_NODE_KIND_IMPL(ValueBinding, "value_binding", Typed, + NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(VarStorage, "var", Typed, NotTerminator) #undef CARBON_SEMANTICS_NODE_KIND diff --git a/toolchain/semantics/testdata/basics/builtin_types.carbon b/toolchain/semantics/testdata/basics/builtin_types.carbon index df3a4b1650bc5..d6e1d175fecd1 100644 --- a/toolchain/semantics/testdata/basics/builtin_types.carbon +++ b/toolchain/semantics/testdata/basics/builtin_types.carbon @@ -36,18 +36,22 @@ var test_type: type = i32; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+4, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type1}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+8, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type2}, // CHECK:STDOUT: {kind: StringLiteral, arg0: str3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+13}, // CHECK:STDOUT: {kind: VarStorage, type: typeTypeType}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+12, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: nodeIntegerType}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+15, type: typeTypeType}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeIntegerType, type: typeTypeType}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,19 +72,27 @@ var test_type: type = i32; // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %test_i32: i32 = var -// CHECK:STDOUT: %.loc7: i32 = int_value 0 -// CHECK:STDOUT: assign %test_i32, %.loc7 +// CHECK:STDOUT: %.loc7_21.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc7_21.2: i32 = initialize_from %.loc7_21.1 +// CHECK:STDOUT: assign %test_i32, %.loc7_21.2 // CHECK:STDOUT: %test_f64: f64 = var -// CHECK:STDOUT: %.loc8: f64 = real_value 1e-1 -// CHECK:STDOUT: assign %test_f64, %.loc8 +// CHECK:STDOUT: %.loc8_21.1: f64 = real_value 1e-1 +// CHECK:STDOUT: %.loc8_21.2: f64 = initialize_from %.loc8_21.1 +// CHECK:STDOUT: assign %test_f64, %.loc8_21.2 // CHECK:STDOUT: %test_str: String = var -// CHECK:STDOUT: %.loc9: String = string_value "Test" -// CHECK:STDOUT: assign %test_str, %.loc9 +// CHECK:STDOUT: %.loc9_24.1: String = string_value "Test" +// CHECK:STDOUT: %.loc9_24.2: String = initialize_from %.loc9_24.1 +// CHECK:STDOUT: assign %test_str, %.loc9_24.2 // CHECK:STDOUT: %test_type: type = var -// CHECK:STDOUT: assign %test_type, i32 +// CHECK:STDOUT: %.1: type = initialize_from i32 +// CHECK:STDOUT: assign %test_type, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon index 8a9dd9c6d5dd8..065e546f1230c 100644 --- a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon +++ b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon @@ -29,7 +29,8 @@ var x: type = 42; // CHECK:STDOUT: {kind: VarStorage, type: typeTypeType}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: typeTypeType}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -39,11 +40,13 @@ var x: type = 42; // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: type = var // CHECK:STDOUT: %.loc10: i32 = int_value 42 -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon index 781ad17a96160..d6463d4d9e1c7 100644 --- a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon +++ b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon @@ -32,7 +32,8 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -43,11 +44,13 @@ var y: i32 = x.b; // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: assign %y, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/parens.carbon b/toolchain/semantics/testdata/basics/parens.carbon index c79a037de837f..18647abc4bc75 100644 --- a/toolchain/semantics/testdata/basics/parens.carbon +++ b/toolchain/semantics/testdata/basics/parens.carbon @@ -29,7 +29,8 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+3, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -41,6 +42,7 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -48,6 +50,7 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: %test_i32: i32 = var // CHECK:STDOUT: %.loc7_23: i32 = int_value 1 // CHECK:STDOUT: %.loc7_29: i32 = int_value 2 -// CHECK:STDOUT: %.loc7_26: i32 = add %.loc7_23, %.loc7_29 -// CHECK:STDOUT: assign %test_i32, %.loc7_26 +// CHECK:STDOUT: %.loc7_26.1: i32 = add %.loc7_23, %.loc7_29 +// CHECK:STDOUT: %.loc7_26.2: i32 = initialize_from %.loc7_26.1 +// CHECK:STDOUT: assign %test_i32, %.loc7_26.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index 7df8e3619694b..99254517f0955 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -43,7 +43,9 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -67,6 +69,8 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,5 +84,7 @@ 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: %.loc11_6.1: const i32** = value_binding %p +// CHECK:STDOUT: %.loc11_6.2: const i32** = initialize_from %.loc11_6.1 +// CHECK:STDOUT: return %.loc11_6.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/fail_collapse.carbon b/toolchain/semantics/testdata/const/fail_collapse.carbon index ef1b627b542a9..a2ad5e8cde7c9 100644 --- a/toolchain/semantics/testdata/const/fail_collapse.carbon +++ b/toolchain/semantics/testdata/const/fail_collapse.carbon @@ -46,7 +46,8 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type4, type: typeTypeType}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -69,6 +70,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,5 +82,6 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%p: const i32**) -> i32** { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index 6533c2ce21cc0..9eead8b54beb7 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -38,10 +38,12 @@ fn Main() { // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -60,19 +62,21 @@ fn Main() { // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,7 +88,9 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: {}) -> {} { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %.loc7_9.1: {} = value_binding %a +// CHECK:STDOUT: %.loc7_9.2: {} = initialize_from %.loc7_9.1 +// CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index 166590da46e5a..9c30a04914655 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -40,10 +40,12 @@ fn Main() { // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -62,19 +64,21 @@ fn Main() { // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -86,7 +90,9 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: ()) -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %.loc7_9.1: () = value_binding %a +// CHECK:STDOUT: %.loc7_9.2: () = initialize_from %.loc7_9.1 +// CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { diff --git a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon index f4ef4a1cdce79..44f135cb177cd 100644 --- a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon @@ -37,12 +37,14 @@ fn Run() { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+4, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,18 +52,20 @@ fn Run() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -72,14 +76,16 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Foo() -> f64 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: f64 = real_value 10e-1 -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_26.1: f64 = real_value 10e-1 +// CHECK:STDOUT: %.loc7_26.2: f64 = initialize_from %.loc7_26.1 +// CHECK:STDOUT: return %.loc7_26.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc13: f64 = call @Foo() -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index 23e652e3d81b5..d2b6e89b865f1 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -37,14 +37,17 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+7, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+9}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -59,22 +62,25 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -85,7 +91,9 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: i32) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %.loc7_9.1: i32 = value_binding %a +// CHECK:STDOUT: %.loc7_9.2: i32 = initialize_from %.loc7_9.1 +// CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { @@ -93,7 +101,8 @@ fn Main() { // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc12_21.1: i32 = int_value 1 // CHECK:STDOUT: %.loc12_21.2: i32 = stub_reference %.loc12_21.1 -// CHECK:STDOUT: %.loc12_20: i32 = call @Echo(%.loc12_21.2) -// CHECK:STDOUT: assign %b, %.loc12_20 +// CHECK:STDOUT: %.loc12_20.1: i32 = call @Echo(%.loc12_21.2) +// CHECK:STDOUT: %.loc12_20.2: i32 = initialize_from %.loc12_20.1 +// CHECK:STDOUT: assign %b, %.loc12_20.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/return_implicit.carbon b/toolchain/semantics/testdata/function/call/return_implicit.carbon index 46c8f4c53af8a..db09cef4fd2ce 100644 --- a/toolchain/semantics/testdata/function/call/return_implicit.carbon +++ b/toolchain/semantics/testdata/function/call/return_implicit.carbon @@ -41,7 +41,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -62,6 +63,7 @@ fn Main() { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,7 +82,8 @@ fn Main() { // CHECK:STDOUT: %.loc11_11.1: type = tuple_type () // CHECK:STDOUT: %.loc11_11.2: () = tuple_value () // CHECK:STDOUT: %b: () = var -// CHECK:STDOUT: %.loc11_37: () = call @MakeImplicitEmptyTuple() -// CHECK:STDOUT: assign %b, %.loc11_37 +// CHECK:STDOUT: %.loc11_37.1: () = call @MakeImplicitEmptyTuple() +// CHECK:STDOUT: %.loc11_37.2: () = initialize_from %.loc11_37.1 +// CHECK:STDOUT: assign %b, %.loc11_37.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/else.carbon b/toolchain/semantics/testdata/if/else.carbon index 8a8d5627ba130..aff52fd963fc3 100644 --- a/toolchain/semantics/testdata/if/else.carbon +++ b/toolchain/semantics/testdata/if/else.carbon @@ -37,7 +37,7 @@ fn If(b: bool) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -53,7 +53,8 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+6, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+6}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+9}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, @@ -91,19 +92,20 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+14, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -131,7 +133,8 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !.loc13 else br !.loc15 +// CHECK:STDOUT: %.loc11: bool = value_binding %b +// CHECK:STDOUT: if %.loc11 br !.loc13 else br !.loc15 // CHECK:STDOUT: // CHECK:STDOUT: !.loc13: // CHECK:STDOUT: %.loc13_6.1: type = tuple_type () diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index 77fdfb2741788..ce9973dcfcbd5 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -62,26 +62,32 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+8}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+13}, // CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+16, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+20, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+16}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+23}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+21}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+26, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+27}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -96,56 +102,62 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: ], @@ -159,11 +171,13 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If1(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !.loc9 else br !.loc8 +// CHECK:STDOUT: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !.loc9 else br !.loc8 // CHECK:STDOUT: // CHECK:STDOUT: !.loc9: -// CHECK:STDOUT: %.loc9: i32 = int_value 1 -// CHECK:STDOUT: return %.loc9 +// CHECK:STDOUT: %.loc9_12.1: i32 = int_value 1 +// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 +// CHECK:STDOUT: return %.loc9_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !.loc8: // CHECK:STDOUT: br !.1 @@ -173,25 +187,29 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If2(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !.loc18 else br !.loc20 +// CHECK:STDOUT: %.loc17: bool = value_binding %b +// CHECK:STDOUT: if %.loc17 br !.loc18 else br !.loc20 // CHECK:STDOUT: // CHECK:STDOUT: !.loc18: // CHECK:STDOUT: br !.1 // CHECK:STDOUT: // CHECK:STDOUT: !.loc20: -// CHECK:STDOUT: %.loc20: i32 = int_value 2 -// CHECK:STDOUT: return %.loc20 +// CHECK:STDOUT: %.loc20_12.1: i32 = int_value 2 +// CHECK:STDOUT: %.loc20_12.2: i32 = initialize_from %.loc20_12.1 +// CHECK:STDOUT: return %.loc20_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !.1: // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @If3(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !.loc29 else br !.1 +// CHECK:STDOUT: %.loc27: bool = value_binding %b +// CHECK:STDOUT: if %.loc27 br !.loc29 else br !.1 // CHECK:STDOUT: // CHECK:STDOUT: !.loc29: -// CHECK:STDOUT: %.loc29: i32 = int_value 1 -// CHECK:STDOUT: return %.loc29 +// CHECK:STDOUT: %.loc29_12.1: i32 = int_value 1 +// CHECK:STDOUT: %.loc29_12.2: i32 = initialize_from %.loc29_12.1 +// CHECK:STDOUT: return %.loc29_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !.1: // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index d7a594b2c1b18..f6a131d2dba27 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -39,15 +39,20 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -65,16 +70,21 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,14 +94,19 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @VarScope(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !.loc9 else br !.loc15 +// CHECK:STDOUT: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !.loc9 else br !.1 // CHECK:STDOUT: // CHECK:STDOUT: !.loc9: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc9: i32 = int_value 2 -// CHECK:STDOUT: assign %n, %.loc9 -// CHECK:STDOUT: return %n +// CHECK:STDOUT: %.loc9_18.1: i32 = int_value 2 +// CHECK:STDOUT: %.loc9_18.2: i32 = initialize_from %.loc9_18.1 +// CHECK:STDOUT: assign %n, %.loc9_18.2 +// CHECK:STDOUT: %.loc9_9.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc9_9.2: i32 = initialize_from %.loc9_9.1 +// CHECK:STDOUT: return %.loc9_9.2 // CHECK:STDOUT: -// CHECK:STDOUT: !.loc15: -// CHECK:STDOUT: return +// CHECK:STDOUT: !.1: +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/no_else.carbon b/toolchain/semantics/testdata/if/no_else.carbon index 3f17beebaadfd..19e8320a843a0 100644 --- a/toolchain/semantics/testdata/if/no_else.carbon +++ b/toolchain/semantics/testdata/if/no_else.carbon @@ -32,7 +32,7 @@ fn If(b: bool) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -46,7 +46,8 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+4, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, @@ -78,15 +79,16 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -108,7 +110,8 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !.loc12 else br !.loc14 +// CHECK:STDOUT: %.loc10: bool = value_binding %b +// CHECK:STDOUT: if %.loc10 br !.loc12 else br !.loc14 // CHECK:STDOUT: // CHECK:STDOUT: !.loc12: // CHECK:STDOUT: %.loc12_6.1: type = tuple_type () diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index e88bbb2f0ef40..0c73ff20c4720 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -37,12 +37,15 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -60,15 +63,18 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -77,13 +83,16 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !.loc9 else br !.loc11 +// CHECK:STDOUT: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !.loc9 else br !.loc11 // CHECK:STDOUT: // CHECK:STDOUT: !.loc9: -// CHECK:STDOUT: %.loc9: i32 = int_value 1 -// CHECK:STDOUT: return %.loc9 +// CHECK:STDOUT: %.loc9_12.1: i32 = int_value 1 +// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 +// CHECK:STDOUT: return %.loc9_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !.loc11: -// CHECK:STDOUT: %.loc11: i32 = int_value 2 -// CHECK:STDOUT: return %.loc11 +// CHECK:STDOUT: %.loc11_12.1: i32 = int_value 2 +// CHECK:STDOUT: %.loc11_12.2: i32 = initialize_from %.loc11_12.1 +// CHECK:STDOUT: return %.loc11_12.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index bef7a2f3ef894..cfa12b1e8d196 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -36,14 +36,20 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+4, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+4, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+4, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+9}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type1}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+10, arg1: node+11, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+13, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+15}, // CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -67,18 +73,24 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -88,17 +100,23 @@ 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 !.loc8_22 else br !.loc8_33 +// CHECK:STDOUT: %.loc7_6: bool = value_binding %b +// CHECK:STDOUT: if %.loc7_6 br !.loc7_15 else br !.loc7_23 // CHECK:STDOUT: -// CHECK:STDOUT: !.loc8_22: -// CHECK:STDOUT: %.loc8_22: i32 = add %n, %m -// CHECK:STDOUT: br !.loc8_10(%.loc8_22) +// CHECK:STDOUT: !.loc7_15: +// CHECK:STDOUT: %.loc7_15.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc7_23.1: i32 = value_binding %m +// CHECK:STDOUT: %.loc8_22: i32 = add %.loc7_15.1, %.loc7_23.1 +// CHECK:STDOUT: br !.loc8(%.loc8_22) // CHECK:STDOUT: -// CHECK:STDOUT: !.loc8_33: -// CHECK:STDOUT: %.loc8_33: i32 = add %m, %n -// CHECK:STDOUT: br !.loc8_10(%.loc8_33) +// CHECK:STDOUT: !.loc7_23: +// CHECK:STDOUT: %.loc7_23.2: i32 = value_binding %m +// CHECK:STDOUT: %.loc7_15.2: i32 = value_binding %n +// CHECK:STDOUT: %.loc8_33: i32 = add %.loc7_23.2, %.loc7_15.2 +// CHECK:STDOUT: br !.loc8(%.loc8_33) // CHECK:STDOUT: -// CHECK:STDOUT: !.loc8_10: -// CHECK:STDOUT: %.loc8_10: i32 = block_arg !.loc8_10 -// CHECK:STDOUT: return %.loc8_10 +// CHECK:STDOUT: !.loc8: +// CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !.loc8 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/constant_condition.carbon b/toolchain/semantics/testdata/if_expression/constant_condition.carbon index ebcdcfec1f6e3..3efa14e001fc6 100644 --- a/toolchain/semantics/testdata/if_expression/constant_condition.carbon +++ b/toolchain/semantics/testdata/if_expression/constant_condition.carbon @@ -43,81 +43,89 @@ fn G() -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+9}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+10}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+11}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+13}, // CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+17}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+20}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+20}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+21}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+23}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+24}, // CHECK:STDOUT: {kind: BlockArg, arg0: block11, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+28}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+21, // CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+25, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -130,14 +138,16 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @A() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = int_value 1 -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_24.1: i32 = int_value 1 +// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 +// CHECK:STDOUT: return %.loc7_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @B() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_value 2 -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_24.1: i32 = int_value 2 +// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 +// CHECK:STDOUT: return %.loc8_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> i32 { @@ -154,8 +164,9 @@ fn G() -> i32 { // CHECK:STDOUT: br !.loc11_10(%.loc11_33) // CHECK:STDOUT: // CHECK:STDOUT: !.loc11_10: -// CHECK:STDOUT: %.loc11_10: i32 = block_arg !.loc11_10 -// CHECK:STDOUT: return %.loc11_10 +// CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !.loc11_10 +// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 +// CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> i32 { @@ -172,6 +183,7 @@ fn G() -> i32 { // CHECK:STDOUT: br !.loc15_10(%.loc15_34) // CHECK:STDOUT: // CHECK:STDOUT: !.loc15_10: -// CHECK:STDOUT: %.loc15_10: i32 = block_arg !.loc15_10 -// CHECK:STDOUT: return %.loc15_10 +// CHECK:STDOUT: %.loc15_10.1: i32 = block_arg !.loc15_10 +// CHECK:STDOUT: %.loc15_10.2: i32 = initialize_from %.loc15_10.1 +// CHECK:STDOUT: return %.loc15_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index b1e73412d38de..7badac3dd271f 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -38,60 +38,68 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+8, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+6}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+11}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+11}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+15}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -103,19 +111,22 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @A() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = int_value 1 -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_24.1: i32 = int_value 1 +// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 +// CHECK:STDOUT: return %.loc7_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @B() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_value 2 -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_24.1: i32 = int_value 2 +// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 +// CHECK:STDOUT: return %.loc8_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: if %b br !.loc11_21 else br !.loc11_30 +// CHECK:STDOUT: %.loc10: bool = value_binding %b +// CHECK:STDOUT: if %.loc10 br !.loc11_21 else br !.loc11_30 // CHECK:STDOUT: // CHECK:STDOUT: !.loc11_21: // CHECK:STDOUT: %.loc11_21: i32 = call @A() @@ -126,6 +137,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: br !.loc11_10(%.loc11_30) // CHECK:STDOUT: // CHECK:STDOUT: !.loc11_10: -// CHECK:STDOUT: %.loc11_10: i32 = block_arg !.loc11_10 -// CHECK:STDOUT: return %.loc11_10 +// CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !.loc11_10 +// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 +// CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index 87ca9994b7200..dbbd9a8db3fe2 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -40,26 +40,30 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+4, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+10}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+11}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+18}, // CHECK:STDOUT: {kind: Branch, arg0: block11}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+18}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+21}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+22}, // CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+22}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+17}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+25}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+25}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+28, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+29}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -83,34 +87,33 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+22, @@ -118,7 +121,12 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+30, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -128,39 +136,43 @@ 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 !.loc8_20.1 else br !.loc8_44.1 +// CHECK:STDOUT: %.loc7_6: bool = value_binding %a +// CHECK:STDOUT: if %.loc7_6 br !.loc7_15 else br !.loc7_24 // CHECK:STDOUT: -// CHECK:STDOUT: !.loc8_20.1: -// CHECK:STDOUT: if %b br !.loc8_30 else br !.loc8_37 +// CHECK:STDOUT: !.loc7_15: +// CHECK:STDOUT: %.loc7_15: bool = value_binding %b +// CHECK:STDOUT: if %.loc7_15 br !.loc8_30 else br !.loc8_37 // CHECK:STDOUT: // CHECK:STDOUT: !.loc8_30: // CHECK:STDOUT: %.loc8_30: i32 = int_value 1 -// CHECK:STDOUT: br !.loc8_20.2(%.loc8_30) +// CHECK:STDOUT: br !.loc8_20(%.loc8_30) // CHECK:STDOUT: // CHECK:STDOUT: !.loc8_37: // CHECK:STDOUT: %.loc8_37: i32 = int_value 2 -// CHECK:STDOUT: br !.loc8_20.2(%.loc8_37) +// CHECK:STDOUT: br !.loc8_20(%.loc8_37) // CHECK:STDOUT: -// CHECK:STDOUT: !.loc8_20.2: -// CHECK:STDOUT: %.loc8_20: i32 = block_arg !.loc8_20.2 +// CHECK:STDOUT: !.loc8_20: +// CHECK:STDOUT: %.loc8_20: i32 = block_arg !.loc8_20 // CHECK:STDOUT: br !.loc8_10(%.loc8_20) // CHECK:STDOUT: -// CHECK:STDOUT: !.loc8_44.1: -// CHECK:STDOUT: if %c br !.loc8_54 else br !.loc8_61 +// CHECK:STDOUT: !.loc7_24: +// CHECK:STDOUT: %.loc7_24: bool = value_binding %c +// CHECK:STDOUT: if %.loc7_24 br !.loc8_54 else br !.loc8_61 // CHECK:STDOUT: // CHECK:STDOUT: !.loc8_54: // CHECK:STDOUT: %.loc8_54: i32 = int_value 3 -// CHECK:STDOUT: br !.loc8_44.2(%.loc8_54) +// CHECK:STDOUT: br !.loc8_44(%.loc8_54) // CHECK:STDOUT: // CHECK:STDOUT: !.loc8_61: // CHECK:STDOUT: %.loc8_61: i32 = int_value 4 -// CHECK:STDOUT: br !.loc8_44.2(%.loc8_61) +// CHECK:STDOUT: br !.loc8_44(%.loc8_61) // CHECK:STDOUT: -// CHECK:STDOUT: !.loc8_44.2: -// CHECK:STDOUT: %.loc8_44: i32 = block_arg !.loc8_44.2 +// CHECK:STDOUT: !.loc8_44: +// CHECK:STDOUT: %.loc8_44: i32 = block_arg !.loc8_44 // CHECK:STDOUT: br !.loc8_10(%.loc8_44) // CHECK:STDOUT: // CHECK:STDOUT: !.loc8_10: -// CHECK:STDOUT: %.loc8_10: i32 = block_arg !.loc8_10 -// CHECK:STDOUT: return %.loc8_10 +// CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !.loc8_10 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/element_access.carbon b/toolchain/semantics/testdata/index/element_access.carbon index 1920052024fcd..369fd2695ae24 100644 --- a/toolchain/semantics/testdata/index/element_access.carbon +++ b/toolchain/semantics/testdata/index/element_access.carbon @@ -45,17 +45,22 @@ var c: i32 = b[0]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+4}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+15, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: Index, arg0: node+12, arg1: node+17, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+18}, +// CHECK:STDOUT: {kind: Index, arg0: node+13, arg1: node+20, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -81,6 +86,11 @@ var c: i32 = b[0]; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -89,7 +99,7 @@ var c: i32 = b[0]; // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -101,14 +111,19 @@ var c: i32 = b[0]; // CHECK:STDOUT: %a: (i32,) = var // CHECK:STDOUT: %.loc7_18.1: i32 = int_value 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 -// CHECK:STDOUT: %.loc7_21: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: assign %a, %.loc7_21 +// CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) +// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 +// CHECK:STDOUT: assign %a, %.loc7_21.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var -// CHECK:STDOUT: assign %b, %a +// CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc9_16: i32 = int_value 0 -// CHECK:STDOUT: %.loc9_17: i32 = tuple_index %b, %.loc9_16 -// CHECK:STDOUT: assign %c, %.loc9_17 +// CHECK:STDOUT: %.loc9_17.1: i32 = tuple_index %b, %.loc9_16 +// CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 +// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2 +// CHECK:STDOUT: assign %c, %.loc9_17.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_large_index.carbon b/toolchain/semantics/testdata/index/fail_large_index.carbon index cc3e028267eda..ce791d229686d 100644 --- a/toolchain/semantics/testdata/index/fail_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_large_index.carbon @@ -48,16 +48,20 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+4}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+15, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -82,6 +86,10 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -90,7 +98,7 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -102,13 +110,17 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %a: (i32,) = var // CHECK:STDOUT: %.loc7_18.1: i32 = int_value 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 -// CHECK:STDOUT: %.loc7_21: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: assign %a, %.loc7_21 +// CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) +// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 +// CHECK:STDOUT: assign %a, %.loc7_21.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var -// CHECK:STDOUT: assign %b, %a +// CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc12: i32 = int_value -1 -// CHECK:STDOUT: assign %c, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %c, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_name_not_found.carbon b/toolchain/semantics/testdata/index/fail_name_not_found.carbon index 6b070bba4fc2a..666688ca973bb 100644 --- a/toolchain/semantics/testdata/index/fail_name_not_found.carbon +++ b/toolchain/semantics/testdata/index/fail_name_not_found.carbon @@ -35,7 +35,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,6 +51,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -61,6 +63,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_value 0 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_negative_indexing.carbon b/toolchain/semantics/testdata/index/fail_negative_indexing.carbon index fab912197d3f3..985bc80194f9b 100644 --- a/toolchain/semantics/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_negative_indexing.carbon @@ -52,9 +52,10 @@ var b: i32 = a[-10]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -77,6 +78,7 @@ var b: i32 = a[-10]; // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, diff --git a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon index aeb4b43a272f8..104852c58dfdf 100644 --- a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon +++ b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon @@ -54,14 +54,17 @@ var c: i32 = a[b]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+15}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+17, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: nodeError}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+19, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -87,6 +90,9 @@ var c: i32 = a[b]; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -109,11 +115,14 @@ var c: i32 = a[b]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_25.1: i32 = int_value 3 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 -// CHECK:STDOUT: %.loc7_26: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: assign %a, %.loc7_26 +// CHECK:STDOUT: %.loc7_26.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) +// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = initialize_from %.loc7_26.1 +// CHECK:STDOUT: assign %a, %.loc7_26.2 // CHECK:STDOUT: %b: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_value 0 -// CHECK:STDOUT: assign %b, %.loc8 +// CHECK:STDOUT: %.loc8_14.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1 +// CHECK:STDOUT: assign %b, %.loc8_14.2 // CHECK:STDOUT: %c: i32 = var -// CHECK:STDOUT: assign %c, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %c, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon b/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon index e3c4400e6974f..8d431fe37af82 100644 --- a/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon @@ -53,11 +53,13 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -80,6 +82,8 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -102,9 +106,11 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_26.1: i32 = int_value 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 -// CHECK:STDOUT: %.loc7_27: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: assign %a, %.loc7_27 +// CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) +// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 +// CHECK:STDOUT: assign %a, %.loc7_27.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_value 26e-1 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon b/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon index b2afc0fb89e86..fd65c7b2798f4 100644 --- a/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon +++ b/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon @@ -52,11 +52,13 @@ var b: i32 = a[2]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -79,6 +81,8 @@ var b: i32 = a[2]; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -101,9 +105,11 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_26.1: i32 = int_value 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 -// CHECK:STDOUT: %.loc7_27: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: assign %a, %.loc7_27 +// CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) +// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 +// CHECK:STDOUT: assign %a, %.loc7_27.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_value 2 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/return_value_access.carbon b/toolchain/semantics/testdata/index/return_value_access.carbon index 9e0c54b506830..68ea01102a5ab 100644 --- a/toolchain/semantics/testdata/index/return_value_access.carbon +++ b/toolchain/semantics/testdata/index/return_value_access.carbon @@ -47,12 +47,14 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: Index, arg0: node+10, arg1: node+11, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, +// CHECK:STDOUT: {kind: Index, arg0: node+11, arg1: node+12, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+13, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -63,7 +65,7 @@ fn Run() -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -73,15 +75,17 @@ fn Run() -> i32 { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -98,14 +102,16 @@ fn Run() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_28.1: i32 = int_value 0 // CHECK:STDOUT: %.loc7_28.2: i32 = stub_reference %.loc7_28.1 -// CHECK:STDOUT: %.loc7_30: (i32,) = tuple_value (%.loc7_28.2) -// CHECK:STDOUT: return %.loc7_30 +// CHECK:STDOUT: %.loc7_30.1: (i32,) = tuple_value (%.loc7_28.2) +// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1 +// CHECK:STDOUT: return %.loc7_30.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_11: (i32,) = call @F() // CHECK:STDOUT: %.loc10_14: i32 = int_value 0 -// CHECK:STDOUT: %.loc10_15: i32 = tuple_index %.loc10_11, %.loc10_14 -// CHECK:STDOUT: return %.loc10_15 +// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11, %.loc10_14 +// CHECK:STDOUT: %.loc10_15.2: i32 = initialize_from %.loc10_15.1 +// CHECK:STDOUT: return %.loc10_15.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon index 110bee298d2cf..71f04248a9978 100644 --- a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon +++ b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon @@ -31,14 +31,16 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block3, arg1: node+5}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block3, arg1: node+6}, // CHECK:STDOUT: {kind: Branch, arg0: block4}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+9, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+9, arg1: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -56,16 +58,18 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -76,15 +80,17 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: fn @A() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n.loc7_14: i32 = var -// CHECK:STDOUT: %.loc7_23: i32 = int_value 1 -// CHECK:STDOUT: assign %n.loc7_14, %.loc7_23 +// CHECK:STDOUT: %.loc7_23.1: i32 = int_value 1 +// CHECK:STDOUT: %.loc7_23.2: i32 = initialize_from %.loc7_23.1 +// CHECK:STDOUT: assign %n.loc7_14, %.loc7_23.2 // CHECK:STDOUT: %.loc7_30: bool = bool_value true // CHECK:STDOUT: if %.loc7_30 br !.loc7_42 else br !.loc7_56 // CHECK:STDOUT: // CHECK:STDOUT: !.loc7_42: // CHECK:STDOUT: %n.loc7_42: i32 = var -// CHECK:STDOUT: %.loc7_51: i32 = int_value 2 -// CHECK:STDOUT: assign %n.loc7_42, %.loc7_51 +// CHECK:STDOUT: %.loc7_51.1: i32 = int_value 2 +// CHECK:STDOUT: %.loc7_51.2: i32 = initialize_from %.loc7_51.1 +// CHECK:STDOUT: assign %n.loc7_42, %.loc7_51.2 // CHECK:STDOUT: br !.loc7_56 // CHECK:STDOUT: // CHECK:STDOUT: !.loc7_56: diff --git a/toolchain/semantics/testdata/operators/and.carbon b/toolchain/semantics/testdata/operators/and.carbon index 19c4686d49688..78979dbfb0b5c 100644 --- a/toolchain/semantics/testdata/operators/and.carbon +++ b/toolchain/semantics/testdata/operators/and.carbon @@ -34,43 +34,44 @@ fn And() -> bool { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+8}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+9}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+11}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+13}, // CHECK:STDOUT: {kind: BlockArg, arg0: block6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: ], @@ -78,6 +79,11 @@ fn And() -> bool { // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -88,14 +94,16 @@ fn And() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: bool = bool_value true -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_25.1: bool = bool_value true +// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 +// CHECK:STDOUT: return %.loc7_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: bool = bool_value true -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_25.1: bool = bool_value true +// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 +// CHECK:STDOUT: return %.loc8_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @And() -> bool { @@ -110,5 +118,6 @@ fn And() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: !.loc11_14: // CHECK:STDOUT: %.loc11_14.2: bool = block_arg !.loc11_14 -// CHECK:STDOUT: return %.loc11_14.2 +// CHECK:STDOUT: %.loc11_14.3: bool = initialize_from %.loc11_14.2 +// CHECK:STDOUT: return %.loc11_14.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/assignment.carbon b/toolchain/semantics/testdata/operators/assignment.carbon index 473f961ebcd20..12eb443b057c8 100644 --- a/toolchain/semantics/testdata/operators/assignment.carbon +++ b/toolchain/semantics/testdata/operators/assignment.carbon @@ -53,10 +53,10 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+30, -// CHECK:STDOUT: node+47, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -74,67 +74,80 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+7}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+12, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+14, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+18}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+21}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: Index, arg0: node+12, arg1: node+20, type: type0}, +// CHECK:STDOUT: {kind: Index, arg0: node+14, arg1: node+23, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+22}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+24, arg1: node+26}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: Index, arg0: node+12, arg1: node+24, type: type0}, +// CHECK:STDOUT: {kind: Index, arg0: node+14, arg1: node+28, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+26}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+29, arg1: node+31}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+31, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+36, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+33, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+38, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+41, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+39}, -// CHECK:STDOUT: {kind: StructMemberAccess, arg0: node+31, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+44, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+36, arg1: node+45}, +// CHECK:STDOUT: {kind: StructMemberAccess, arg0: node+36, arg1: member0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+41, arg1: node+42}, -// CHECK:STDOUT: {kind: StructMemberAccess, arg0: node+31, arg1: member1, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+48, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+47, arg1: node+49}, +// CHECK:STDOUT: {kind: StructMemberAccess, arg0: node+36, arg1: member1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+44, arg1: node+45}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+52, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+51, arg1: node+53}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type4}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+48, type: type4}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+56, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, -// CHECK:STDOUT: {kind: Assign, arg0: node+48, arg1: node+50}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+48, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+58, type: type4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+56, arg1: node+59}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+56, type: type4}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+61, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+52, arg1: node+53}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+63, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+62, arg1: node+64}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type5}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+55}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+66}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+56, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+48}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+58}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+69}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+70}, // CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type4}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+61, type: type0}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+73, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+62, arg1: node+63}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+75, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+74, arg1: node+76}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -177,13 +190,13 @@ fn Main() { // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+32, // CHECK:STDOUT: node+33, +// CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, +// CHECK:STDOUT: node+37, // CHECK:STDOUT: node+38, -// CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, // CHECK:STDOUT: node+41, -// CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, // CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, @@ -199,40 +212,53 @@ fn Main() { // CHECK:STDOUT: node+55, // CHECK:STDOUT: node+56, // CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+58, +// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+62, +// CHECK:STDOUT: node+63, +// CHECK:STDOUT: node+64, +// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+66, +// CHECK:STDOUT: node+67, +// CHECK:STDOUT: node+68, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+28, -// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+33, +// CHECK:STDOUT: node+34, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+34, -// CHECK:STDOUT: node+37, +// CHECK:STDOUT: node+39, +// CHECK:STDOUT: node+42, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+35, -// CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+43, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+69, +// CHECK:STDOUT: node+71, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+70, +// CHECK:STDOUT: node+72, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+61, -// CHECK:STDOUT: node+62, -// CHECK:STDOUT: node+63, -// CHECK:STDOUT: node+64, -// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+73, +// CHECK:STDOUT: node+74, +// CHECK:STDOUT: node+75, +// CHECK:STDOUT: node+76, +// CHECK:STDOUT: node+77, +// CHECK:STDOUT: node+78, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -243,10 +269,12 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_value 12 -// CHECK:STDOUT: assign %a, %.loc8 -// CHECK:STDOUT: %.loc9: i32 = int_value -7 -// CHECK:STDOUT: assign %a, %.loc9 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_value 12 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %a, %.loc8_16.2 +// CHECK:STDOUT: %.loc9_7.1: i32 = int_value -7 +// CHECK:STDOUT: %.loc9_7.2: i32 = initialize_from %.loc9_7.1 +// CHECK:STDOUT: assign %a, %.loc9_7.2 // CHECK:STDOUT: %.loc11_11: type = stub_reference i32 // CHECK:STDOUT: %.loc11_16: type = stub_reference i32 // CHECK:STDOUT: %.loc11_19.1: type = tuple_type (type, type) @@ -257,51 +285,62 @@ fn Main() { // CHECK:STDOUT: %.loc11_24.2: i32 = stub_reference %.loc11_24.1 // CHECK:STDOUT: %.loc11_27.1: i32 = int_value 2 // CHECK:STDOUT: %.loc11_27.2: i32 = stub_reference %.loc11_27.1 -// CHECK:STDOUT: %.loc11_28: (i32, i32) = tuple_value (%.loc11_24.2, %.loc11_27.2) -// CHECK:STDOUT: assign %b, %.loc11_28 +// CHECK:STDOUT: %.loc11_28.1: (i32, i32) = tuple_value (%.loc11_24.2, %.loc11_27.2) +// CHECK:STDOUT: %.loc11_28.2: (i32, i32) = initialize_from %.loc11_28.1 +// CHECK:STDOUT: assign %b, %.loc11_28.2 // CHECK:STDOUT: %.loc12_5: i32 = int_value 0 // CHECK:STDOUT: %.loc12_6: i32 = tuple_index %b, %.loc12_5 -// CHECK:STDOUT: %.loc12_10: i32 = int_value 3 -// CHECK:STDOUT: assign %.loc12_6, %.loc12_10 +// CHECK:STDOUT: %.loc12_10.1: i32 = int_value 3 +// CHECK:STDOUT: %.loc12_10.2: i32 = initialize_from %.loc12_10.1 +// CHECK:STDOUT: assign %.loc12_6, %.loc12_10.2 // CHECK:STDOUT: %.loc13_5: i32 = int_value 1 // CHECK:STDOUT: %.loc13_6: i32 = tuple_index %b, %.loc13_5 -// CHECK:STDOUT: %.loc13_10: i32 = int_value 4 -// CHECK:STDOUT: assign %.loc13_6, %.loc13_10 +// CHECK:STDOUT: %.loc13_10.1: i32 = int_value 4 +// CHECK:STDOUT: %.loc13_10.2: i32 = initialize_from %.loc13_10.1 +// CHECK:STDOUT: assign %.loc13_6, %.loc13_10.2 // CHECK:STDOUT: %.loc15_27: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %c: {.a: i32, .b: i32} = var // CHECK:STDOUT: %.loc15_37: i32 = int_value 1 // CHECK:STDOUT: %.loc15_35: i32 = stub_reference %.loc15_37 // CHECK:STDOUT: %.loc15_45: i32 = int_value 2 // CHECK:STDOUT: %.loc15_43: i32 = stub_reference %.loc15_45 -// CHECK:STDOUT: %.loc15_46: {.a: i32, .b: i32} = struct_value (%.loc15_35, %.loc15_43) -// CHECK:STDOUT: assign %c, %.loc15_46 +// CHECK:STDOUT: %.loc15_46.1: {.a: i32, .b: i32} = struct_value (%.loc15_35, %.loc15_43) +// CHECK:STDOUT: %.loc15_46.2: {.a: i32, .b: i32} = initialize_from %.loc15_46.1 +// CHECK:STDOUT: assign %c, %.loc15_46.2 // CHECK:STDOUT: %.loc16_4: i32 = struct_access %c, member0 -// CHECK:STDOUT: %.loc16_9: i32 = int_value 3 -// CHECK:STDOUT: assign %.loc16_4, %.loc16_9 +// CHECK:STDOUT: %.loc16_9.1: i32 = int_value 3 +// CHECK:STDOUT: %.loc16_9.2: i32 = initialize_from %.loc16_9.1 +// CHECK:STDOUT: assign %.loc16_4, %.loc16_9.2 // CHECK:STDOUT: %.loc17_4: i32 = struct_access %c, member1 -// CHECK:STDOUT: %.loc17_9: i32 = int_value 4 -// CHECK:STDOUT: assign %.loc17_4, %.loc17_9 +// CHECK:STDOUT: %.loc17_9.1: i32 = int_value 4 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 +// CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 // CHECK:STDOUT: %.loc19_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var -// CHECK:STDOUT: %.loc19_17: i32* = address_of %a -// CHECK:STDOUT: assign %p, %.loc19_17 -// CHECK:STDOUT: %.loc20_3: i32 = dereference %p -// CHECK:STDOUT: %.loc20_8: i32 = int_value 5 -// CHECK:STDOUT: assign %.loc20_3, %.loc20_8 +// CHECK:STDOUT: %.loc19_17.1: i32* = address_of %a +// CHECK:STDOUT: %.loc19_17.2: i32* = initialize_from %.loc19_17.1 +// CHECK:STDOUT: assign %p, %.loc19_17.2 +// CHECK:STDOUT: %.loc19_7.1: i32* = value_binding %p +// CHECK:STDOUT: %.loc20_3: i32 = dereference %.loc19_7.1 +// CHECK:STDOUT: %.loc20_8.1: i32 = int_value 5 +// CHECK:STDOUT: %.loc20_8.2: i32 = initialize_from %.loc20_8.1 +// CHECK:STDOUT: assign %.loc20_3, %.loc20_8.2 // CHECK:STDOUT: %.loc22_8: bool = bool_value true -// CHECK:STDOUT: if %.loc22_8 br !.loc22_5.1 else br !.loc22_25 +// CHECK:STDOUT: if %.loc22_8 br !.loc19 else br !.loc22_25 // CHECK:STDOUT: -// CHECK:STDOUT: !.loc22_5.1: -// CHECK:STDOUT: br !.loc22_5.2(%p) +// CHECK:STDOUT: !.loc19: +// CHECK:STDOUT: %.loc19_7.2: i32* = value_binding %p +// CHECK:STDOUT: br !.loc22_5(%.loc19_7.2) // CHECK:STDOUT: // CHECK:STDOUT: !.loc22_25: // CHECK:STDOUT: %.loc22_25: i32* = address_of %a -// CHECK:STDOUT: br !.loc22_5.2(%.loc22_25) +// CHECK:STDOUT: br !.loc22_5(%.loc22_25) // CHECK:STDOUT: -// CHECK:STDOUT: !.loc22_5.2: -// CHECK:STDOUT: %.loc22_5: i32* = block_arg !.loc22_5.2 +// CHECK:STDOUT: !.loc22_5: +// CHECK:STDOUT: %.loc22_5: i32* = block_arg !.loc22_5 // CHECK:STDOUT: %.loc22_3: i32 = dereference %.loc22_5 -// CHECK:STDOUT: %.loc22_31: i32 = int_value 10 -// CHECK:STDOUT: assign %.loc22_3, %.loc22_31 +// CHECK:STDOUT: %.loc22_31.1: i32 = int_value 10 +// CHECK:STDOUT: %.loc22_31.2: i32 = initialize_from %.loc22_31.1 +// CHECK:STDOUT: assign %.loc22_3, %.loc22_31.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/binary_op.carbon b/toolchain/semantics/testdata/operators/binary_op.carbon index 9b3caa65a228c..d75184b39aca9 100644 --- a/toolchain/semantics/testdata/operators/binary_op.carbon +++ b/toolchain/semantics/testdata/operators/binary_op.carbon @@ -31,7 +31,8 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+1, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -44,6 +45,7 @@ fn Main() -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -55,6 +57,7 @@ fn Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_10: i32 = int_value 12 // CHECK:STDOUT: %.loc8_15: i32 = int_value 34 -// CHECK:STDOUT: %.loc8_13: i32 = add %.loc8_10, %.loc8_15 -// CHECK:STDOUT: return %.loc8_13 +// CHECK:STDOUT: %.loc8_13.1: i32 = add %.loc8_10, %.loc8_15 +// CHECK:STDOUT: %.loc8_13.2: i32 = initialize_from %.loc8_13.1 +// CHECK:STDOUT: return %.loc8_13.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon index dff50409dceef..53e2eefade9d9 100644 --- a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -82,8 +82,8 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+41, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+49, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -97,73 +97,86 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+12, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+18}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+21}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+20, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+23, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+22}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+20, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+23, arg1: node+26}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+23, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+28, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+23, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+33, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+29, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+35, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+26, arg1: node+31}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+37, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+32, arg1: node+38}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+33}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+40, type: typeTypeType}, +// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+41}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+35, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+43, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+38, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+46, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block7, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block8, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+43, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+51, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+46, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+54, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block10, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+42, arg1: node+49}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+57, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+50, arg1: node+58}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+51}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+60}, // CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int15, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+54}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+55}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+63}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+64}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int16, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+58, arg1: node+59}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+68, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+67, arg1: node+69}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+61, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+71, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block14, arg1: node+63}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block14, arg1: node+73}, // CHECK:STDOUT: {kind: Branch, arg0: block15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+61}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+61}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+71, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+71, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+76}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+77}, // CHECK:STDOUT: {kind: BlockArg, arg0: block16, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int17, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+68, arg1: node+69}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+81, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+80, arg1: node+82}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -208,8 +221,10 @@ fn Main() { // CHECK:STDOUT: node+33, // CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+36, // CHECK:STDOUT: node+37, // CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, // CHECK:STDOUT: node+41, // CHECK:STDOUT: node+42, @@ -220,32 +235,31 @@ fn Main() { // CHECK:STDOUT: node+49, // CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, -// CHECK:STDOUT: node+52, // CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+58, +// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+62, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+25, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+28, -// CHECK:STDOUT: node+30, +// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+31, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+34, // CHECK:STDOUT: node+36, -// CHECK:STDOUT: node+39, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+37, -// CHECK:STDOUT: node+40, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+44, @@ -256,34 +270,46 @@ fn Main() { // CHECK:STDOUT: node+48, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+54, -// CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+52, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+55, -// CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+56, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+59, -// CHECK:STDOUT: node+60, -// CHECK:STDOUT: node+61, -// CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, -// CHECK:STDOUT: node+64, // CHECK:STDOUT: node+65, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+64, // CHECK:STDOUT: node+66, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+67, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+68, // CHECK:STDOUT: node+69, // CHECK:STDOUT: node+70, // CHECK:STDOUT: node+71, +// CHECK:STDOUT: node+72, +// CHECK:STDOUT: node+73, +// CHECK:STDOUT: node+74, +// CHECK:STDOUT: node+75, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+76, +// CHECK:STDOUT: node+78, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+77, +// CHECK:STDOUT: node+79, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+80, +// CHECK:STDOUT: node+81, +// CHECK:STDOUT: node+82, +// CHECK:STDOUT: node+83, +// CHECK:STDOUT: node+84, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -297,11 +323,13 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc13_3: i32 = int_value 1 -// CHECK:STDOUT: %.loc13_7: i32 = int_value 2 -// CHECK:STDOUT: assign %.loc13_3, %.loc13_7 +// CHECK:STDOUT: %.loc13_7.1: i32 = int_value 2 +// CHECK:STDOUT: %.loc13_7.2: i32 = initialize_from %.loc13_7.1 +// CHECK:STDOUT: assign %.loc13_3, %.loc13_7.2 // CHECK:STDOUT: %.loc17_4: i32 = call @F() -// CHECK:STDOUT: %.loc17_9: i32 = int_value 1 -// CHECK:STDOUT: assign %.loc17_4, %.loc17_9 +// CHECK:STDOUT: %.loc17_9.1: i32 = int_value 1 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 +// CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 // CHECK:STDOUT: %.loc21_4.1: i32 = int_value 1 // CHECK:STDOUT: %.loc21_4.2: i32 = stub_reference %.loc21_4.1 // CHECK:STDOUT: %.loc21_7.1: i32 = int_value 2 @@ -312,22 +340,28 @@ fn Main() { // CHECK:STDOUT: %.loc21_13.2: i32 = stub_reference %.loc21_13.1 // CHECK:STDOUT: %.loc21_16.1: i32 = int_value 4 // CHECK:STDOUT: %.loc21_16.2: i32 = stub_reference %.loc21_16.1 -// CHECK:STDOUT: %.loc21_17: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) -// CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17 +// CHECK:STDOUT: %.loc21_17.1: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) +// CHECK:STDOUT: %.loc21_17.2: (i32, i32) = initialize_from %.loc21_17.1 +// CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17.2 // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc22: i32 = int_value 0 -// CHECK:STDOUT: assign %n, %.loc22 -// CHECK:STDOUT: %.loc26_4: i32 = stub_reference %n -// CHECK:STDOUT: %.loc26_7: i32 = stub_reference %n +// CHECK:STDOUT: %.loc22_16.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc22_16.2: i32 = initialize_from %.loc22_16.1 +// CHECK:STDOUT: assign %n, %.loc22_16.2 +// CHECK:STDOUT: %.loc22_7.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc26_4: i32 = stub_reference %.loc22_7.1 +// CHECK:STDOUT: %.loc22_7.2: i32 = value_binding %n +// CHECK:STDOUT: %.loc26_7: i32 = stub_reference %.loc22_7.2 // CHECK:STDOUT: %.loc26_8: (i32, i32) = tuple_value (%.loc26_4, %.loc26_7) // CHECK:STDOUT: %.loc26_13.1: i32 = int_value 1 // CHECK:STDOUT: %.loc26_13.2: i32 = stub_reference %.loc26_13.1 // CHECK:STDOUT: %.loc26_16.1: i32 = int_value 2 // CHECK:STDOUT: %.loc26_16.2: i32 = stub_reference %.loc26_16.1 -// CHECK:STDOUT: %.loc26_17: (i32, i32) = tuple_value (%.loc26_13.2, %.loc26_16.2) -// CHECK:STDOUT: assign %.loc26_8, %.loc26_17 -// CHECK:STDOUT: %.loc30: type = ptr_type i32 -// CHECK:STDOUT: assign i32, %.loc30 +// CHECK:STDOUT: %.loc26_17.1: (i32, i32) = tuple_value (%.loc26_13.2, %.loc26_16.2) +// CHECK:STDOUT: %.loc26_17.2: (i32, i32) = initialize_from %.loc26_17.1 +// CHECK:STDOUT: assign %.loc26_8, %.loc26_17.2 +// CHECK:STDOUT: %.loc30_12.1: type = ptr_type i32 +// CHECK:STDOUT: %.loc30_12.2: type = initialize_from %.loc30_12.1 +// CHECK:STDOUT: assign i32, %.loc30_12.2 // CHECK:STDOUT: %.loc34_9: i32 = int_value 1 // CHECK:STDOUT: %.loc34_7: i32 = stub_reference %.loc34_9 // CHECK:STDOUT: %.loc34_17: i32 = int_value 2 @@ -338,8 +372,9 @@ fn Main() { // CHECK:STDOUT: %.loc34_26: i32 = stub_reference %.loc34_28 // CHECK:STDOUT: %.loc34_36: i32 = int_value 4 // CHECK:STDOUT: %.loc34_34: i32 = stub_reference %.loc34_36 -// CHECK:STDOUT: %.loc34_37: {.x: i32, .y: i32} = struct_value (%.loc34_26, %.loc34_34) -// CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37 +// CHECK:STDOUT: %.loc34_37.1: {.x: i32, .y: i32} = struct_value (%.loc34_26, %.loc34_34) +// CHECK:STDOUT: %.loc34_37.2: {.x: i32, .y: i32} = initialize_from %.loc34_37.1 +// CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37.2 // CHECK:STDOUT: %.loc38_7: bool = bool_value true // CHECK:STDOUT: if %.loc38_7 br !.loc38_17 else br !.loc38_24 // CHECK:STDOUT: @@ -353,21 +388,25 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: !.loc38_4: // CHECK:STDOUT: %.loc38_4: i32 = block_arg !.loc38_4 -// CHECK:STDOUT: %.loc38_29: i32 = int_value 3 -// CHECK:STDOUT: assign %.loc38_4, %.loc38_29 +// CHECK:STDOUT: %.loc38_29.1: i32 = int_value 3 +// CHECK:STDOUT: %.loc38_29.2: i32 = initialize_from %.loc38_29.1 +// CHECK:STDOUT: assign %.loc38_4, %.loc38_29.2 // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc45_7: bool = bool_value true -// CHECK:STDOUT: if %.loc45_7 br !.loc45_4.1 else br !.loc45_4.2 +// CHECK:STDOUT: if %.loc45_7 br !.loc41_7.1 else br !.loc41_7.2 // CHECK:STDOUT: -// CHECK:STDOUT: !.loc45_4.1: -// CHECK:STDOUT: br !.loc45_4.3(%a) +// CHECK:STDOUT: !.loc41_7.1: +// CHECK:STDOUT: %.loc41_7.1: i32 = value_binding %a +// CHECK:STDOUT: br !.loc45(%.loc41_7.1) // CHECK:STDOUT: -// CHECK:STDOUT: !.loc45_4.2: -// CHECK:STDOUT: br !.loc45_4.3(%a) +// CHECK:STDOUT: !.loc41_7.2: +// CHECK:STDOUT: %.loc41_7.2: i32 = value_binding %a +// CHECK:STDOUT: br !.loc45(%.loc41_7.2) // CHECK:STDOUT: -// CHECK:STDOUT: !.loc45_4.3: -// CHECK:STDOUT: %.loc45_4: i32 = block_arg !.loc45_4.3 -// CHECK:STDOUT: %.loc45_29: i32 = int_value 10 -// CHECK:STDOUT: assign %.loc45_4, %.loc45_29 +// CHECK:STDOUT: !.loc45: +// CHECK:STDOUT: %.loc45_4: i32 = block_arg !.loc45 +// CHECK:STDOUT: %.loc45_29.1: i32 = int_value 10 +// CHECK:STDOUT: %.loc45_29.2: i32 = initialize_from %.loc45_29.1 +// CHECK:STDOUT: assign %.loc45_4, %.loc45_29.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon index 7549495fa0dbe..dc8cbe1c02de6 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon @@ -35,7 +35,8 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -48,6 +49,7 @@ fn Main() -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -60,5 +62,6 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc11_10: i32 = int_value 12 // CHECK:STDOUT: %.loc11_15: f64 = real_value 34e-1 // CHECK:STDOUT: %.loc11_13: = add , %.loc11_15 -// CHECK:STDOUT: return +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon index 1d9942f4d7305..ecbe75afeb3af 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon @@ -37,9 +37,11 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+7}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -56,6 +58,8 @@ fn Main() { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -66,9 +70,11 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_value 3 -// CHECK:STDOUT: assign %a, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_value 3 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %a, %.loc8_16.2 // CHECK:STDOUT: %.loc12: f64 = real_value 56e-1 -// CHECK:STDOUT: assign %a, %.loc12 +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %a, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon index 5de659b8f323b..5081726480efd 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon @@ -40,7 +40,8 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+4, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -55,6 +56,7 @@ fn Main() -> i32 { // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -69,5 +71,6 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc13_13: = add , %.loc13_15 // CHECK:STDOUT: %.loc13_21: i32 = int_value 12 // CHECK:STDOUT: %.loc13_19: = add , %.loc13_21 -// CHECK:STDOUT: return +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/or.carbon b/toolchain/semantics/testdata/operators/or.carbon index 44a92ec5b7303..acd092cbb956b 100644 --- a/toolchain/semantics/testdata/operators/or.carbon +++ b/toolchain/semantics/testdata/operators/or.carbon @@ -34,45 +34,46 @@ fn Or() -> bool { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+8}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+9}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+10}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+11}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+14}, // CHECK:STDOUT: {kind: BlockArg, arg0: block6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], @@ -80,6 +81,11 @@ fn Or() -> bool { // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -90,14 +96,16 @@ fn Or() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: bool = bool_value true -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_25.1: bool = bool_value true +// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 +// CHECK:STDOUT: return %.loc7_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: bool = bool_value true -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_25.1: bool = bool_value true +// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 +// CHECK:STDOUT: return %.loc8_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Or() -> bool { @@ -113,5 +121,6 @@ fn Or() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: !.loc11_14: // CHECK:STDOUT: %.loc11_14.3: bool = block_arg !.loc11_14 -// CHECK:STDOUT: return %.loc11_14.3 +// CHECK:STDOUT: %.loc11_14.4: bool = initialize_from %.loc11_14.3 +// CHECK:STDOUT: return %.loc11_14.4 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/unary_op.carbon b/toolchain/semantics/testdata/operators/unary_op.carbon index e5f8796cae8ff..0fc83b1fb0810 100644 --- a/toolchain/semantics/testdata/operators/unary_op.carbon +++ b/toolchain/semantics/testdata/operators/unary_op.carbon @@ -29,8 +29,10 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -48,6 +50,8 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -57,6 +61,8 @@ 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: return %.loc8 +// CHECK:STDOUT: %.loc7: bool = value_binding %b +// CHECK:STDOUT: %.loc8_10.1: bool = not %.loc7 +// CHECK:STDOUT: %.loc8_10.2: bool = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_deref.carbon b/toolchain/semantics/testdata/pointer/address_of_deref.carbon index 0a9799d23b7fd..b11607102653f 100644 --- a/toolchain/semantics/testdata/pointer/address_of_deref.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_deref.carbon @@ -24,7 +24,7 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -33,13 +33,16 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+6, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -58,6 +61,9 @@ fn F() -> i32 { // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -68,12 +74,15 @@ fn F() -> i32 { // CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_value 0 -// CHECK:STDOUT: assign %n, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %n, %.loc8_16.2 // CHECK:STDOUT: %.loc9_13.1: type = ptr_type i32 // CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n // CHECK:STDOUT: %.loc9_12: i32 = dereference %.loc9_13.2 // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 -// CHECK:STDOUT: %.loc9_10: i32 = dereference %.loc9_11 -// CHECK:STDOUT: return %.loc9_10 +// CHECK:STDOUT: %.loc9_10.1: i32 = dereference %.loc9_11 +// CHECK:STDOUT: %.loc9_10.2: i32 = value_binding %.loc9_10.1 +// CHECK:STDOUT: %.loc9_10.3: i32 = initialize_from %.loc9_10.2 +// CHECK:STDOUT: return %.loc9_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon index 7bde977e46c64..613962ab20e8d 100644 --- a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon @@ -51,10 +51,10 @@ fn F(param: i32) { // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+38, -// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+42, +// CHECK:STDOUT: node+44, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -82,59 +82,67 @@ fn F(param: i32) { // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+15}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block8, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+20, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+21, type: type2}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+6, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+22}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+24}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str6, arg1: node+25, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str6, arg1: node+27, type: type3}, // CHECK:STDOUT: {kind: StructMemberAccess, arg0: node+6, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+27, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+28}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+29, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+27, arg1: node+31}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str7, arg1: node+31, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str7, arg1: node+34, type: type3}, // CHECK:STDOUT: {kind: StructMemberAccess, arg0: node+6, arg1: member1, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+33, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+34}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+36, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+37, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+34, arg1: node+38}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block9, type: type4}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type5}, -// CHECK:STDOUT: {kind: BindName, arg0: str8, arg1: node+41, type: type5}, +// CHECK:STDOUT: {kind: BindName, arg0: str8, arg1: node+45, type: type5}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+43, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+47, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+45, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+49, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block10, type: type5}, -// CHECK:STDOUT: {kind: Assign, arg0: node+41, arg1: node+47}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+51, type: type5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+45, arg1: node+52}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str9, arg1: node+50, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str9, arg1: node+55, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: Index, arg0: node+41, arg1: node+52, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+53, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+50, arg1: node+54}, +// CHECK:STDOUT: {kind: Index, arg0: node+45, arg1: node+57, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+58, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+59, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+55, arg1: node+60}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str10, arg1: node+57, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str10, arg1: node+63, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: Index, arg0: node+41, arg1: node+59, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+60, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+57, arg1: node+61}, +// CHECK:STDOUT: {kind: Index, arg0: node+45, arg1: node+65, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+66, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+67, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+63, arg1: node+68}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str11, arg1: node+64, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str11, arg1: node+71, type: type3}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+0, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+64, arg1: node+66}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+73, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+71, arg1: node+74}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -215,6 +223,14 @@ fn F(param: i32) { // CHECK:STDOUT: node+66, // CHECK:STDOUT: node+67, // CHECK:STDOUT: node+68, +// CHECK:STDOUT: node+69, +// CHECK:STDOUT: node+70, +// CHECK:STDOUT: node+71, +// CHECK:STDOUT: node+72, +// CHECK:STDOUT: node+73, +// CHECK:STDOUT: node+74, +// CHECK:STDOUT: node+75, +// CHECK:STDOUT: node+76, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, @@ -229,16 +245,16 @@ fn F(param: i32) { // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+36, -// CHECK:STDOUT: node+37, +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+41, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+44, -// CHECK:STDOUT: node+46, +// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+50, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -254,23 +270,27 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc8_35: i32 = stub_reference %.loc8_37 // CHECK:STDOUT: %.loc8_45: i32 = int_value 2 // CHECK:STDOUT: %.loc8_43: i32 = stub_reference %.loc8_45 -// CHECK:STDOUT: %.loc8_46: {.a: i32, .b: i32} = struct_value (%.loc8_35, %.loc8_43) -// CHECK:STDOUT: assign %s, %.loc8_46 +// CHECK:STDOUT: %.loc8_46.1: {.a: i32, .b: i32} = struct_value (%.loc8_35, %.loc8_43) +// CHECK:STDOUT: %.loc8_46.2: {.a: i32, .b: i32} = initialize_from %.loc8_46.1 +// CHECK:STDOUT: assign %s, %.loc8_46.2 // 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: {.a: i32, .b: i32}* = var -// CHECK:STDOUT: %.loc10_32: {.a: i32, .b: i32}* = address_of %s -// CHECK:STDOUT: assign %p, %.loc10_32 +// CHECK:STDOUT: %.loc10_32.1: {.a: i32, .b: i32}* = address_of %s +// CHECK:STDOUT: %.loc10_32.2: {.a: i32, .b: i32}* = initialize_from %.loc10_32.1 +// CHECK:STDOUT: assign %p, %.loc10_32.2 // CHECK:STDOUT: %.loc11_13: type = ptr_type i32 // CHECK:STDOUT: %q: i32* = var // CHECK:STDOUT: %.loc11_19: i32 = struct_access %s, member0 -// CHECK:STDOUT: %.loc11_17: i32* = address_of %.loc11_19 -// CHECK:STDOUT: assign %q, %.loc11_17 +// CHECK:STDOUT: %.loc11_17.1: i32* = address_of %.loc11_19 +// CHECK:STDOUT: %.loc11_17.2: i32* = initialize_from %.loc11_17.1 +// CHECK:STDOUT: assign %q, %.loc11_17.2 // CHECK:STDOUT: %.loc12_13: type = ptr_type i32 // CHECK:STDOUT: %r: i32* = var // CHECK:STDOUT: %.loc12_19: i32 = struct_access %s, member1 -// CHECK:STDOUT: %.loc12_17: i32* = address_of %.loc12_19 -// CHECK:STDOUT: assign %r, %.loc12_17 +// CHECK:STDOUT: %.loc12_17.1: i32* = address_of %.loc12_19 +// CHECK:STDOUT: %.loc12_17.2: i32* = initialize_from %.loc12_17.1 +// CHECK:STDOUT: assign %r, %.loc12_17.2 // CHECK:STDOUT: %.loc14_11: type = stub_reference i32 // CHECK:STDOUT: %.loc14_16: type = stub_reference i32 // CHECK:STDOUT: %.loc14_19.1: type = tuple_type (type, type) @@ -281,23 +301,27 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc14_24.2: i32 = stub_reference %.loc14_24.1 // CHECK:STDOUT: %.loc14_27.1: i32 = int_value 2 // CHECK:STDOUT: %.loc14_27.2: i32 = stub_reference %.loc14_27.1 -// CHECK:STDOUT: %.loc14_28: (i32, i32) = tuple_value (%.loc14_24.2, %.loc14_27.2) -// CHECK:STDOUT: assign %t, %.loc14_28 +// CHECK:STDOUT: %.loc14_28.1: (i32, i32) = tuple_value (%.loc14_24.2, %.loc14_27.2) +// CHECK:STDOUT: %.loc14_28.2: (i32, i32) = initialize_from %.loc14_28.1 +// CHECK:STDOUT: assign %t, %.loc14_28.2 // CHECK:STDOUT: %.loc15_14: type = ptr_type i32 // CHECK:STDOUT: %t0: i32* = var // CHECK:STDOUT: %.loc15_21: i32 = int_value 0 // CHECK:STDOUT: %.loc15_22: i32 = tuple_index %t, %.loc15_21 -// CHECK:STDOUT: %.loc15_18: i32* = address_of %.loc15_22 -// CHECK:STDOUT: assign %t0, %.loc15_18 +// CHECK:STDOUT: %.loc15_18.1: i32* = address_of %.loc15_22 +// CHECK:STDOUT: %.loc15_18.2: i32* = initialize_from %.loc15_18.1 +// CHECK:STDOUT: assign %t0, %.loc15_18.2 // CHECK:STDOUT: %.loc16_14: type = ptr_type i32 // CHECK:STDOUT: %t1: i32* = var // CHECK:STDOUT: %.loc16_21: i32 = int_value 1 // CHECK:STDOUT: %.loc16_22: i32 = tuple_index %t, %.loc16_21 -// CHECK:STDOUT: %.loc16_18: i32* = address_of %.loc16_22 -// CHECK:STDOUT: assign %t1, %.loc16_18 +// CHECK:STDOUT: %.loc16_18.1: i32* = address_of %.loc16_22 +// CHECK:STDOUT: %.loc16_18.2: i32* = initialize_from %.loc16_18.1 +// CHECK:STDOUT: assign %t1, %.loc16_18.2 // CHECK:STDOUT: %.loc20_22: type = ptr_type i32 // CHECK:STDOUT: %param_addr: i32* = var -// CHECK:STDOUT: %.loc20_26: i32* = address_of %param -// CHECK:STDOUT: assign %param_addr, %.loc20_26 +// CHECK:STDOUT: %.loc20_26.1: i32* = address_of %param +// CHECK:STDOUT: %.loc20_26.2: i32* = initialize_from %.loc20_26.1 +// CHECK:STDOUT: assign %param_addr, %.loc20_26.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/basic.carbon b/toolchain/semantics/testdata/pointer/basic.carbon index 8ca0c16fb4493..0c899ec8f58b5 100644 --- a/toolchain/semantics/testdata/pointer/basic.carbon +++ b/toolchain/semantics/testdata/pointer/basic.carbon @@ -27,7 +27,7 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -36,14 +36,19 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+8}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -63,6 +68,11 @@ fn F() -> i32 { // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -73,12 +83,17 @@ fn F() -> i32 { // CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_value 0 -// CHECK:STDOUT: assign %n, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %n, %.loc8_16.2 // CHECK:STDOUT: %.loc9_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var -// CHECK:STDOUT: %.loc9_17: i32* = address_of %n -// CHECK:STDOUT: assign %p, %.loc9_17 -// CHECK:STDOUT: %.loc11: i32 = dereference %p -// CHECK:STDOUT: return %.loc11 +// CHECK:STDOUT: %.loc9_17.1: i32* = address_of %n +// CHECK:STDOUT: %.loc9_17.2: i32* = initialize_from %.loc9_17.1 +// CHECK:STDOUT: assign %p, %.loc9_17.2 +// CHECK:STDOUT: %.loc9_7: i32* = value_binding %p +// CHECK:STDOUT: %.loc11_10.1: i32 = dereference %.loc9_7 +// CHECK:STDOUT: %.loc11_10.2: i32 = value_binding %.loc11_10.1 +// CHECK:STDOUT: %.loc11_10.3: i32 = initialize_from %.loc11_10.2 +// CHECK:STDOUT: return %.loc11_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon b/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon index 0c5f7d5ac4617..f487810e91ddd 100644 --- a/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon +++ b/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon @@ -33,8 +33,8 @@ fn Deref(n: i32) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -44,13 +44,14 @@ fn Deref(n: i32) { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+0, type: typeError}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+3, type: typeError}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+5, type: typeError}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+6, type: typeError}, // CHECK:STDOUT: {kind: StructType, arg0: block0, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type2}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: typeError}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: typeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -75,6 +76,7 @@ fn Deref(n: i32) { // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,7 +86,8 @@ fn Deref(n: i32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Deref(%n: i32) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: = dereference %n +// CHECK:STDOUT: %.loc7: i32 = value_binding %n +// CHECK:STDOUT: %.loc11: = dereference %.loc7 // CHECK:STDOUT: %.loc15_5.1: type = tuple_type () // CHECK:STDOUT: %.loc15_5.2: () = tuple_value () // CHECK:STDOUT: %.loc15_3: = dereference %.loc15_5.2 diff --git a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon index 0ac95bf2aacd6..4a151579287bf 100644 --- a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon @@ -43,7 +43,8 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: ConstType, arg0: type3, type: typeTypeType}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -67,6 +68,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -79,5 +81,6 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> const ({}*) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index ac7b941a79cbd..c4f83d2e6de6c 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -41,9 +41,13 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type5}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+5, type: type3}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type5}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type3}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type3}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+13, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,6 +72,10 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -78,7 +86,11 @@ 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: const (const i32*) = dereference %p -// CHECK:STDOUT: %.loc9_10: const i32 = dereference %.loc9_11 -// CHECK:STDOUT: return %.loc9_10 +// CHECK:STDOUT: %.loc8: const (const (const i32*)*) = value_binding %p +// CHECK:STDOUT: %.loc9_11.1: const (const i32*) = dereference %.loc8 +// CHECK:STDOUT: %.loc9_11.2: const (const i32*) = value_binding %.loc9_11.1 +// CHECK:STDOUT: %.loc9_10.1: const i32 = dereference %.loc9_11.2 +// CHECK:STDOUT: %.loc9_10.2: const i32 = value_binding %.loc9_10.1 +// CHECK:STDOUT: %.loc9_10.3: const i32 = initialize_from %.loc9_10.2 +// CHECK:STDOUT: return %.loc9_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index 23d19e82b8ec9..342f43dc072c3 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -29,8 +29,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -40,15 +40,19 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type1}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type3}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -64,24 +68,28 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -95,10 +103,14 @@ 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: %.loc7_8.1: i32* = value_binding %p +// CHECK:STDOUT: %.loc7_8.2: i32* = initialize_from %.loc7_8.1 +// CHECK:STDOUT: return %.loc7_8.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> const i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %p +// CHECK:STDOUT: %.loc11_13.1: const i32* = value_binding %p +// CHECK:STDOUT: %.loc11_13.2: const i32* = initialize_from %.loc11_13.1 +// CHECK:STDOUT: return %.loc11_13.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/code_after_return.carbon b/toolchain/semantics/testdata/return/code_after_return.carbon index 8f41406739118..02a670390dcd7 100644 --- a/toolchain/semantics/testdata/return/code_after_return.carbon +++ b/toolchain/semantics/testdata/return/code_after_return.carbon @@ -36,7 +36,8 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+4, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index c761ed713fb19..d55f184e00cc4 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -43,21 +43,28 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+9}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+12}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+16, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+19}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+15}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+21}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, // CHECK:STDOUT: {kind: Branch, arg0: unreachable}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -75,6 +82,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,6 +92,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_value 0 -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_10.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon index 63c546a009fe4..431a5487b74c1 100644 --- a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon @@ -32,7 +32,8 @@ fn Main() -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -43,6 +44,7 @@ fn Main() -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -53,5 +55,6 @@ fn Main() -> i32 { // CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11: f64 = real_value 10e-1 -// CHECK:STDOUT: return +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/struct.carbon b/toolchain/semantics/testdata/return/struct.carbon index 948535f90aed5..90db8a57506fd 100644 --- a/toolchain/semantics/testdata/return/struct.carbon +++ b/toolchain/semantics/testdata/return/struct.carbon @@ -35,7 +35,8 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+3, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block5, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -53,6 +54,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, @@ -71,6 +73,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_16: i32 = int_value 3 // CHECK:STDOUT: %.loc8_14: i32 = stub_reference %.loc8_16 -// CHECK:STDOUT: %.loc8_17: {.a: i32} = struct_value (%.loc8_14) -// CHECK:STDOUT: return %.loc8_17 +// CHECK:STDOUT: %.loc8_17.1: {.a: i32} = struct_value (%.loc8_14) +// CHECK:STDOUT: %.loc8_17.2: {.a: i32} = initialize_from %.loc8_17.1 +// CHECK:STDOUT: return %.loc8_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/tuple.carbon b/toolchain/semantics/testdata/return/tuple.carbon index cb52ebbc25e8d..ef87770e510d6 100644 --- a/toolchain/semantics/testdata/return/tuple.carbon +++ b/toolchain/semantics/testdata/return/tuple.carbon @@ -49,7 +49,8 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, type: type2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -73,6 +74,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, @@ -95,6 +97,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: %.loc9_11.2: i32 = stub_reference %.loc9_11.1 // CHECK:STDOUT: %.loc9_15.1: i32 = int_value 35 // CHECK:STDOUT: %.loc9_15.2: i32 = stub_reference %.loc9_15.1 -// CHECK:STDOUT: %.loc9_17: (i32, i32) = tuple_value (%.loc9_11.2, %.loc9_15.2) -// CHECK:STDOUT: return %.loc9_17 +// CHECK:STDOUT: %.loc9_17.1: (i32, i32) = tuple_value (%.loc9_11.2, %.loc9_15.2) +// CHECK:STDOUT: %.loc9_17.2: (i32, i32) = initialize_from %.loc9_17.1 +// CHECK:STDOUT: return %.loc9_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/value.carbon b/toolchain/semantics/testdata/return/value.carbon index 1a6b4933ca3ab..07d12ea85af2b 100644 --- a/toolchain/semantics/testdata/return/value.carbon +++ b/toolchain/semantics/testdata/return/value.carbon @@ -28,7 +28,8 @@ fn Main() -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -39,6 +40,7 @@ fn Main() -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -48,6 +50,7 @@ fn Main() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_value 0 -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_10.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/empty.carbon b/toolchain/semantics/testdata/struct/empty.carbon index 844de18680840..f5ba458d3d8d9 100644 --- a/toolchain/semantics/testdata/struct/empty.carbon +++ b/toolchain/semantics/testdata/struct/empty.carbon @@ -29,11 +29,14 @@ var y: {} = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+2}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -49,6 +52,9 @@ var y: {} = x; // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -56,9 +62,12 @@ var y: {} = x; // CHECK:STDOUT: %.loc7_9.1: type = struct_type {} // CHECK:STDOUT: %.loc7_9.2: {} = struct_value () // CHECK:STDOUT: %x: {} = var -// CHECK:STDOUT: %.loc7_14: {} = struct_value () -// CHECK:STDOUT: assign %x, %.loc7_14 +// CHECK:STDOUT: %.loc7_14.1: {} = struct_value () +// CHECK:STDOUT: %.loc7_14.2: {} = initialize_from %.loc7_14.1 +// CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc8: {} = struct_value () // CHECK:STDOUT: %y: {} = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: {} = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: {} = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon index 281bfd86a5b46..a0032bd3d9c1f 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon @@ -34,7 +34,8 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: StructType, arg0: block0, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -47,6 +48,7 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -58,5 +60,6 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc10_21.1: type = struct_type {} // CHECK:STDOUT: %.loc10_21.2: {} = struct_value () -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_nested.carbon b/toolchain/semantics/testdata/struct/fail_assign_nested.carbon index dc1d228861fc2..804d99573aaa8 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_nested.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_nested.carbon @@ -40,7 +40,8 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -57,6 +58,7 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, @@ -78,5 +80,6 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: %.loc10_23: {} = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: {}} // CHECK:STDOUT: %.loc10_27.2: {.b: {}} = struct_value (%.loc10_23) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon index 8916d3f829f5b..2c79c245938a0 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon @@ -38,7 +38,8 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type1}, // CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -53,6 +54,7 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -70,5 +72,6 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: %.loc10_17: i32 = stub_reference %.loc10_19 // CHECK:STDOUT: %.loc10_20.1: type = struct_type {.a: i32} // CHECK:STDOUT: %.loc10_20.2: {.a: i32} = struct_value (%.loc10_17) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon index 3892f3b782363..e1a59076a85e4 100644 --- a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon @@ -39,7 +39,8 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -54,6 +55,7 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -73,5 +75,6 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: %.loc10_24: i32 = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: i32} // CHECK:STDOUT: %.loc10_27.2: {.b: i32} = struct_value (%.loc10_24) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon index 4ccebdd409170..83f16c8f5a425 100644 --- a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon @@ -40,7 +40,8 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type2}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -55,6 +56,7 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -74,5 +76,6 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: %.loc10_24: f64 = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_29.1: type = struct_type {.b: f64} // CHECK:STDOUT: %.loc10_29.2: {.b: f64} = struct_value (%.loc10_24) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon index 6cdbbe70ec394..6e916ee301603 100644 --- a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon @@ -40,10 +40,12 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+9, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+9, arg1: nodeError}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -60,6 +62,8 @@ var y: i32 = x.b; // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -77,8 +81,10 @@ var y: i32 = x.b; // CHECK:STDOUT: %x: {.a: f64} = var // CHECK:STDOUT: %.loc7_26: f64 = real_value 40e-1 // CHECK:STDOUT: %.loc7_24: f64 = stub_reference %.loc7_26 -// CHECK:STDOUT: %.loc7_29: {.a: f64} = struct_value (%.loc7_24) -// CHECK:STDOUT: assign %x, %.loc7_29 +// CHECK:STDOUT: %.loc7_29.1: {.a: f64} = struct_value (%.loc7_24) +// CHECK:STDOUT: %.loc7_29.2: {.a: f64} = initialize_from %.loc7_29.1 +// CHECK:STDOUT: assign %x, %.loc7_29.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: assign %y, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon index 4e7bc1d86d46b..05f60c35a97cd 100644 --- a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon +++ b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon @@ -39,10 +39,12 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+9, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+9, arg1: nodeError}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -59,6 +61,8 @@ var y: i32 = x.b; // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -76,8 +80,10 @@ var y: i32 = x.b; // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc7_26: i32 = int_value 4 // CHECK:STDOUT: %.loc7_24: i32 = stub_reference %.loc7_26 -// CHECK:STDOUT: %.loc7_27: {.a: i32} = struct_value (%.loc7_24) -// CHECK:STDOUT: assign %x, %.loc7_27 +// CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_value (%.loc7_24) +// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1 +// CHECK:STDOUT: assign %x, %.loc7_27.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: assign %y, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon index 8ba1773fce4fe..23ce0c9ca94b8 100644 --- a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon +++ b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon @@ -40,7 +40,8 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -56,6 +57,7 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -76,5 +78,6 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: %.loc10_33: i32 = stub_reference %.loc10_35 // CHECK:STDOUT: %.loc10_36.1: type = struct_type {.a: i32} // CHECK:STDOUT: %.loc10_36.2: {.a: i32} = struct_value (%.loc10_33) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_type_assign.carbon b/toolchain/semantics/testdata/struct/fail_type_assign.carbon index 63d7e1f661af6..d3d1662825a11 100644 --- a/toolchain/semantics/testdata/struct/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/struct/fail_type_assign.carbon @@ -33,7 +33,8 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -46,6 +47,7 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -59,5 +61,6 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc10_28: type = struct_type {.a: i32} -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/member_access.carbon b/toolchain/semantics/testdata/struct/member_access.carbon index 26ac8253cf261..9c968bb7cb4e8 100644 --- a/toolchain/semantics/testdata/struct/member_access.carbon +++ b/toolchain/semantics/testdata/struct/member_access.carbon @@ -44,14 +44,19 @@ var z: i32 = y; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: StructMemberAccess, arg0: node+3, arg1: member1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+15}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+18}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+17, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+13}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+20, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -75,6 +80,11 @@ var z: i32 = y; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -97,11 +107,16 @@ var z: i32 = y; // CHECK:STDOUT: %.loc7_33: f64 = stub_reference %.loc7_35 // CHECK:STDOUT: %.loc7_45: i32 = int_value 1 // CHECK:STDOUT: %.loc7_43: i32 = stub_reference %.loc7_45 -// CHECK:STDOUT: %.loc7_46: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) -// CHECK:STDOUT: assign %x, %.loc7_46 +// CHECK:STDOUT: %.loc7_46.1: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) +// CHECK:STDOUT: %.loc7_46.2: {.a: f64, .b: i32} = initialize_from %.loc7_46.1 +// CHECK:STDOUT: assign %x, %.loc7_46.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.loc8: i32 = struct_access %x, member1 -// CHECK:STDOUT: assign %y, %.loc8 +// CHECK:STDOUT: %.loc8_15.1: i32 = struct_access %x, member1 +// CHECK:STDOUT: %.loc8_15.2: i32 = value_binding %.loc8_15.1 +// CHECK:STDOUT: %.loc8_15.3: i32 = initialize_from %.loc8_15.2 +// CHECK:STDOUT: assign %y, %.loc8_15.3 // CHECK:STDOUT: %z: i32 = var -// CHECK:STDOUT: assign %z, %y +// CHECK:STDOUT: %.loc8_5.1: i32 = value_binding %y +// CHECK:STDOUT: %.loc8_5.2: i32 = initialize_from %.loc8_5.1 +// CHECK:STDOUT: assign %z, %.loc8_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/one_entry.carbon b/toolchain/semantics/testdata/struct/one_entry.carbon index d48dea4022dcf..cad5aa42593d2 100644 --- a/toolchain/semantics/testdata/struct/one_entry.carbon +++ b/toolchain/semantics/testdata/struct/one_entry.carbon @@ -35,12 +35,15 @@ var y: {.a: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+11, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+2}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+12, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -59,6 +62,9 @@ var y: {.a: i32} = x; // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -70,7 +76,7 @@ var y: {.a: i32} = x; // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -79,9 +85,12 @@ var y: {.a: i32} = x; // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc7_26: i32 = int_value 4 // CHECK:STDOUT: %.loc7_24: i32 = stub_reference %.loc7_26 -// CHECK:STDOUT: %.loc7_27: {.a: i32} = struct_value (%.loc7_24) -// CHECK:STDOUT: assign %x, %.loc7_27 +// CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_value (%.loc7_24) +// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1 +// CHECK:STDOUT: assign %x, %.loc7_27.2 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32} // CHECK:STDOUT: %y: {.a: i32} = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: {.a: i32} = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: {.a: i32} = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/tuple_as_element.carbon b/toolchain/semantics/testdata/struct/tuple_as_element.carbon index ffb45bf365458..77265e1cacbab 100644 --- a/toolchain/semantics/testdata/struct/tuple_as_element.carbon +++ b/toolchain/semantics/testdata/struct/tuple_as_element.carbon @@ -55,15 +55,18 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type2}, // CHECK:STDOUT: {kind: StructValue, arg0: block5, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+17}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+18}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block8, type: type1}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type2}, // CHECK:STDOUT: {kind: StructType, arg0: block7, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+24, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+24, arg1: node+7}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+25, type: type3}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+28}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -94,6 +97,9 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: node+24, // CHECK:STDOUT: node+25, // CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -114,11 +120,11 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -135,11 +141,14 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc7_47.2: i32 = stub_reference %.loc7_47.1 // CHECK:STDOUT: %.loc7_49: (i32,) = tuple_value (%.loc7_47.2) // CHECK:STDOUT: %.loc7_44: (i32,) = stub_reference %.loc7_49 -// CHECK:STDOUT: %.loc7_50: {.a: i32, .b: (i32,)} = struct_value (%.loc7_36, %.loc7_44) -// CHECK:STDOUT: assign %x, %.loc7_50 +// CHECK:STDOUT: %.loc7_50.1: {.a: i32, .b: (i32,)} = struct_value (%.loc7_36, %.loc7_44) +// CHECK:STDOUT: %.loc7_50.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_50.1 +// CHECK:STDOUT: assign %x, %.loc7_50.2 // CHECK:STDOUT: %.loc8_23: type = stub_reference i32 // CHECK:STDOUT: %.loc8_27: (type,) = tuple_value (%.loc8_23) // CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} // CHECK:STDOUT: %y: {.a: i32, .b: (i32,)} = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: {.a: i32, .b: (i32,)} = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/two_entries.carbon b/toolchain/semantics/testdata/struct/two_entries.carbon index e164afbff6342..d8dffa5d65664 100644 --- a/toolchain/semantics/testdata/struct/two_entries.carbon +++ b/toolchain/semantics/testdata/struct/two_entries.carbon @@ -41,13 +41,16 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+12}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+16, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+3}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+17, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -70,6 +73,9 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -84,8 +90,8 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -96,9 +102,12 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: %.loc7_33: i32 = stub_reference %.loc7_35 // CHECK:STDOUT: %.loc7_43: i32 = int_value 2 // CHECK:STDOUT: %.loc7_41: i32 = stub_reference %.loc7_43 -// CHECK:STDOUT: %.loc7_44: {.a: i32, .b: i32} = struct_value (%.loc7_33, %.loc7_41) -// CHECK:STDOUT: assign %x, %.loc7_44 +// CHECK:STDOUT: %.loc7_44.1: {.a: i32, .b: i32} = struct_value (%.loc7_33, %.loc7_41) +// CHECK:STDOUT: %.loc7_44.2: {.a: i32, .b: i32} = initialize_from %.loc7_44.1 +// CHECK:STDOUT: assign %x, %.loc7_44.2 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %y: {.a: i32, .b: i32} = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: {.a: i32, .b: i32} = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: i32} = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/empty.carbon b/toolchain/semantics/testdata/tuples/empty.carbon index 18ee2c5bf282d..a4eb083ccfcbc 100644 --- a/toolchain/semantics/testdata/tuples/empty.carbon +++ b/toolchain/semantics/testdata/tuples/empty.carbon @@ -31,11 +31,14 @@ var y: () = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+2}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -51,6 +54,9 @@ var y: () = x; // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -58,9 +64,12 @@ var y: () = x; // CHECK:STDOUT: %.loc7_9.1: type = tuple_type () // CHECK:STDOUT: %.loc7_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var -// CHECK:STDOUT: %.loc7_14: () = tuple_value () -// CHECK:STDOUT: assign %x, %.loc7_14 +// CHECK:STDOUT: %.loc7_14.1: () = tuple_value () +// CHECK:STDOUT: %.loc7_14.2: () = initialize_from %.loc7_14.1 +// CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc8: () = tuple_value () // CHECK:STDOUT: %y: () = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: () = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: () = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon index 897bc026bb458..03e4b6db3d6d6 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon @@ -44,7 +44,8 @@ var x: (i32,) = (); // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -59,6 +60,7 @@ var x: (i32,) = (); // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -73,5 +75,6 @@ var x: (i32,) = (); // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc10_18.1: type = tuple_type () // CHECK:STDOUT: %.loc10_18.2: () = tuple_value () -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon b/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon index 5ef58a413bf15..b728ffeba7879 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon @@ -96,7 +96,8 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type5}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock5, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type6}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+34}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -137,6 +138,7 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: node+32, // CHECK:STDOUT: node+33, // CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+35, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -200,5 +202,6 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: %.loc10_55.2: (i32, i32, i32) = stub_reference %.loc10_55.1 // CHECK:STDOUT: %.loc10_56.1: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) // CHECK:STDOUT: %.loc10_56.2: ((i32, i32, i32), (i32, i32, i32)) = tuple_value (%.loc10_44.3, %.loc10_55.2) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon index 82c81fdf4cdef..e5f227e0beb0b 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon @@ -34,7 +34,8 @@ var x: () = (66); // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -46,6 +47,7 @@ var x: () = (66); // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -54,5 +56,6 @@ var x: () = (66); // CHECK:STDOUT: %.loc10_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var // CHECK:STDOUT: %.loc10_14: i32 = int_value 66 -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon index 9743a2dd1c08f..6cc6ecf4239dc 100644 --- a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon +++ b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon @@ -56,7 +56,8 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type3}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type4}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+13}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -76,6 +77,7 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -100,5 +102,6 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: %.loc10_25.2: f64 = stub_reference %.loc10_25.1 // CHECK:STDOUT: %.loc10_30.1: type = tuple_type (i32, f64) // CHECK:STDOUT: %.loc10_30.2: (i32, f64) = tuple_value (%.loc10_22.2, %.loc10_25.2) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon index adc63ffd1dc5d..e37afd096003a 100644 --- a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon +++ b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon @@ -51,7 +51,8 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -69,6 +70,7 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -90,5 +92,6 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: %.loc10_22.2: i32 = stub_reference %.loc10_22.1 // CHECK:STDOUT: %.loc10_25.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc10_25.2: (i32,) = tuple_value (%.loc10_22.2) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon index 1ae3ac42ad377..456a446aae384 100644 --- a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon @@ -41,7 +41,8 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -56,6 +57,7 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -73,5 +75,6 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc10_19: type = stub_reference i32 // CHECK:STDOUT: %.loc10_24: (type,) = tuple_value (%.loc10_19) -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/nested_tuple.carbon b/toolchain/semantics/testdata/tuples/nested_tuple.carbon index 7d3a016c98549..e785f872c6b56 100644 --- a/toolchain/semantics/testdata/tuples/nested_tuple.carbon +++ b/toolchain/semantics/testdata/tuples/nested_tuple.carbon @@ -66,7 +66,8 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type2}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type4}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+20}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, type: type4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -94,6 +95,7 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -133,6 +135,7 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: %.loc7_36.2: (i32, i32) = stub_reference %.loc7_36.1 // CHECK:STDOUT: %.loc7_39.1: i32 = int_value 6 // CHECK:STDOUT: %.loc7_39.2: i32 = stub_reference %.loc7_39.1 -// CHECK:STDOUT: %.loc7_40: ((i32, i32), i32) = tuple_value (%.loc7_36.2, %.loc7_39.2) -// CHECK:STDOUT: assign %x, %.loc7_40 +// CHECK:STDOUT: %.loc7_40.1: ((i32, i32), i32) = tuple_value (%.loc7_36.2, %.loc7_39.2) +// CHECK:STDOUT: %.loc7_40.2: ((i32, i32), i32) = initialize_from %.loc7_40.1 +// CHECK:STDOUT: assign %x, %.loc7_40.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/one_element.carbon b/toolchain/semantics/testdata/tuples/one_element.carbon index 6c9deac243fd5..8d6f6d69ecd52 100644 --- a/toolchain/semantics/testdata/tuples/one_element.carbon +++ b/toolchain/semantics/testdata/tuples/one_element.carbon @@ -42,12 +42,15 @@ var y: (i32,) = x; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+4}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,6 +71,9 @@ var y: (i32,) = x; // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -76,7 +82,7 @@ var y: (i32,) = x; // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -88,10 +94,13 @@ var y: (i32,) = x; // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc7_18.1: i32 = int_value 4 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 -// CHECK:STDOUT: %.loc7_20: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: assign %x, %.loc7_20 +// CHECK:STDOUT: %.loc7_20.1: (i32,) = tuple_value (%.loc7_18.2) +// CHECK:STDOUT: %.loc7_20.2: (i32,) = initialize_from %.loc7_20.1 +// CHECK:STDOUT: assign %x, %.loc7_20.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %y: (i32,) = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/two_elements.carbon b/toolchain/semantics/testdata/tuples/two_elements.carbon index 34210600e934d..04193df8f64d4 100644 --- a/toolchain/semantics/testdata/tuples/two_elements.carbon +++ b/toolchain/semantics/testdata/tuples/two_elements.carbon @@ -48,13 +48,16 @@ var y: (i32, i32) = x; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+16, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+5}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+17, type: type2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -79,6 +82,9 @@ var y: (i32, i32) = x; // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -89,8 +95,8 @@ var y: (i32, i32) = x; // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -105,11 +111,14 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_25.1: i32 = int_value 102 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 -// CHECK:STDOUT: %.loc7_28: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: assign %x, %.loc7_28 +// CHECK:STDOUT: %.loc7_28.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) +// CHECK:STDOUT: %.loc7_28.2: (i32, i32) = initialize_from %.loc7_28.1 +// CHECK:STDOUT: assign %x, %.loc7_28.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_14: type = stub_reference i32 // CHECK:STDOUT: %.loc8_17: (type, type) = tuple_value (%.loc8_9, %.loc8_14) // CHECK:STDOUT: %y: (i32, i32) = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: (i32, i32) = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: (i32, i32) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/decl_with_init.carbon b/toolchain/semantics/testdata/var/decl_with_init.carbon index a98f55e643c69..26ad23aced334 100644 --- a/toolchain/semantics/testdata/var/decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/decl_with_init.carbon @@ -31,7 +31,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -46,6 +47,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -56,7 +58,8 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_value 0 -// CHECK:STDOUT: assign %x, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %x, %.loc8_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon index 4c74c09f8ae49..6f8665ab7a6ac 100644 --- a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon +++ b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon @@ -40,11 +40,13 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+6, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -63,6 +65,8 @@ fn Main() { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -73,10 +77,12 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.loc9: i32 = var -// CHECK:STDOUT: %.loc9: i32 = int_value 0 -// CHECK:STDOUT: assign %x.loc9, %.loc9 +// CHECK:STDOUT: %.loc9_16.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc9_16.2: i32 = initialize_from %.loc9_16.1 +// CHECK:STDOUT: assign %x.loc9, %.loc9_16.2 // CHECK:STDOUT: %x.loc16: i32 = var -// CHECK:STDOUT: %.loc16: i32 = int_value 0 -// CHECK:STDOUT: assign %x.loc16, %.loc16 +// CHECK:STDOUT: %.loc16_16.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc16_16.2: i32 = initialize_from %.loc16_16.1 +// CHECK:STDOUT: assign %x.loc16, %.loc16_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon index e13537c534cc1..f9af380639050 100644 --- a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon +++ b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon @@ -35,7 +35,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,6 +51,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -61,6 +63,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_value 10e-1 -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_with_self.carbon b/toolchain/semantics/testdata/var/fail_init_with_self.carbon index 71b38ba05f23f..42d270f427a6d 100644 --- a/toolchain/semantics/testdata/var/fail_init_with_self.carbon +++ b/toolchain/semantics/testdata/var/fail_init_with_self.carbon @@ -32,7 +32,8 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -46,6 +47,7 @@ fn Main() { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -56,6 +58,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon index 5d4630c3eb40f..92d9d73834e40 100644 --- a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon +++ b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon @@ -38,7 +38,8 @@ var y: i32 = x; // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+4, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -48,6 +49,7 @@ var y: i32 = x; // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, @@ -59,7 +61,8 @@ var y: i32 = x; // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: assign %y, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { diff --git a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon index c2e264d973fb8..cb43a409fa52a 100644 --- a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon +++ b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon @@ -36,7 +36,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: typeError}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -52,6 +53,7 @@ fn Main() { // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -64,6 +66,7 @@ fn Main() { // CHECK:STDOUT: %.loc11_10: i32 = int_value 1 // CHECK:STDOUT: %x: = var // CHECK:STDOUT: %.loc11_14: i32 = int_value 1 -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_decl_with_init.carbon b/toolchain/semantics/testdata/var/global_decl_with_init.carbon index e7d33c34a6979..08c53e48fac03 100644 --- a/toolchain/semantics/testdata/var/global_decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/global_decl_with_init.carbon @@ -26,7 +26,8 @@ var x: i32 = 0; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -36,11 +37,13 @@ var x: i32 = 0; // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7: i32 = int_value 0 -// CHECK:STDOUT: assign %x, %.loc7 +// CHECK:STDOUT: %.loc7_14.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup.carbon b/toolchain/semantics/testdata/var/global_lookup.carbon index f4fb61a57239b..5114058d47a0b 100644 --- a/toolchain/semantics/testdata/var/global_lookup.carbon +++ b/toolchain/semantics/testdata/var/global_lookup.carbon @@ -28,10 +28,13 @@ var y: i32 = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+4, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -44,13 +47,19 @@ var y: i32 = x; // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7: i32 = int_value 0 -// CHECK:STDOUT: assign %x, %.loc7 +// CHECK:STDOUT: %.loc7_14.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: i32 = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon index d6f7b82770e53..62d9f2d31a4d2 100644 --- a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon +++ b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon @@ -33,11 +33,14 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -49,25 +52,31 @@ fn Main() { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7: i32 = int_value 0 -// CHECK:STDOUT: assign %x, %.loc7 +// CHECK:STDOUT: %.loc7_14.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc9 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: assign %y, package.%x +// CHECK:STDOUT: %.loc7_5.1: i32 = value_binding package.%x +// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/lookup.carbon b/toolchain/semantics/testdata/var/lookup.carbon index 179a45cef43eb..724b309cfd9e7 100644 --- a/toolchain/semantics/testdata/var/lookup.carbon +++ b/toolchain/semantics/testdata/var/lookup.carbon @@ -32,7 +32,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -47,6 +48,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -57,7 +59,8 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_value 0 -// CHECK:STDOUT: assign %x, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_value 0 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %x, %.loc8_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } From c99bec7b49f5447b93c051ccb4230af2d009f456 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 10 Aug 2023 17:55:04 -0700 Subject: [PATCH 02/21] Add forgotten file. --- .../lowering_handle_expression_category.cpp | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 toolchain/lowering/lowering_handle_expression_category.cpp diff --git a/toolchain/lowering/lowering_handle_expression_category.cpp b/toolchain/lowering/lowering_handle_expression_category.cpp new file mode 100644 index 0000000000000..533ae80161eea --- /dev/null +++ b/toolchain/lowering/lowering_handle_expression_category.cpp @@ -0,0 +1,27 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +#include "toolchain/lowering/lowering_function_context.h" + +namespace Carbon { + +auto LoweringHandleInitializeFrom(LoweringFunctionContext& context, + SemanticsNodeId node_id, SemanticsNode node) + -> void { + context.SetLocal(node_id, context.GetLocal(node.GetAsInitializeFrom())); +} + +auto LoweringHandleMaterializeTemporary(LoweringFunctionContext& context, + SemanticsNodeId node_id, + SemanticsNode node) -> void { + context.SetLocal(node_id, context.GetLocal(node.GetAsMaterializeTemporary())); +} + +auto LoweringHandleValueBinding(LoweringFunctionContext& context, + SemanticsNodeId node_id, SemanticsNode node) + -> void { + context.SetLocal(node_id, context.GetLocalLoaded(node.GetAsValueBinding())); +} + +} // namespace Carbon From 1fa8ffb2a526cc2f223cc559c5977643d9dfb9ff Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 11 Aug 2023 14:55:53 -0700 Subject: [PATCH 03/21] Update tests. --- .../testdata/basics/builtin_types.carbon | 40 ++-- .../basics/fail_non_type_as_type.carbon | 7 +- .../semantics/testdata/basics/parens.carbon | 9 +- .../call/fail_return_type_mismatch.carbon | 22 +- toolchain/semantics/testdata/if/else.carbon | 17 +- .../if/fail_reachable_fallthrough.carbon | 80 ++++--- .../semantics/testdata/if/fail_scope.carbon | 39 ++-- .../semantics/testdata/if/no_else.carbon | 13 +- .../if/unreachable_fallthrough.carbon | 31 ++- .../testdata/if_expression/basic.carbon | 46 ++-- .../if_expression/constant_condition.carbon | 76 ++++--- .../if_expression/control_flow.carbon | 58 ++++-- .../testdata/if_expression/nested.carbon | 68 +++--- .../testdata/index/element_access.carbon | 39 ++-- .../testdata/index/fail_large_index.carbon | 32 ++- .../testdata/index/fail_name_not_found.carbon | 7 +- .../index/fail_non_deterministic_type.carbon | 29 ++- .../index/fail_non_int_indexing.carbon | 18 +- .../index/fail_out_of_bound_access.carbon | 18 +- .../testdata/index/return_value_access.carbon | 24 ++- .../ir/duplicate_name_same_line.carbon | 26 ++- .../semantics/testdata/operators/and.carbon | 45 ++-- .../testdata/operators/assignment.carbon | 185 +++++++++------- .../testdata/operators/binary_op.carbon | 9 +- .../fail_assigment_to_non_assignable.carbon | 197 +++++++++++------- .../fail_type_mismatch_assignment.carbon | 16 +- .../semantics/testdata/operators/or.carbon | 47 +++-- .../testdata/pointer/address_of_deref.carbon | 29 ++- .../testdata/pointer/address_of_lvalue.carbon | 120 ++++++----- .../semantics/testdata/pointer/basic.carbon | 39 ++-- .../return/code_after_return_value.carbon | 25 ++- .../testdata/return/fail_type_mismatch.carbon | 7 +- .../semantics/testdata/return/value.carbon | 9 +- .../testdata/struct/member_access.carbon | 35 +++- .../tuples/fail_assign_to_empty.carbon | 7 +- .../testdata/var/decl_with_init.carbon | 9 +- .../testdata/var/fail_duplicate_decl.carbon | 20 +- .../var/fail_init_type_mismatch.carbon | 7 +- .../var/fail_storage_is_literal.carbon | 7 +- .../testdata/var/global_decl_with_init.carbon | 9 +- .../testdata/var/global_lookup.carbon | 21 +- .../var/global_lookup_in_scope.carbon | 23 +- .../semantics/testdata/var/lookup.carbon | 9 +- 43 files changed, 994 insertions(+), 580 deletions(-) diff --git a/toolchain/semantics/testdata/basics/builtin_types.carbon b/toolchain/semantics/testdata/basics/builtin_types.carbon index b9da04af87076..713edd99348c4 100644 --- a/toolchain/semantics/testdata/basics/builtin_types.carbon +++ b/toolchain/semantics/testdata/basics/builtin_types.carbon @@ -36,18 +36,22 @@ var test_type: type = i32; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+4, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type1}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+8, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type2}, // CHECK:STDOUT: {kind: StringLiteral, arg0: str3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+13}, // CHECK:STDOUT: {kind: VarStorage, type: typeTypeType}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+12, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: nodeIntegerType}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+15, type: typeTypeType}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeIntegerType, type: typeTypeType}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,19 +72,27 @@ var test_type: type = i32; // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %test_i32: i32 = var -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 -// CHECK:STDOUT: assign %test_i32, %.loc7 +// CHECK:STDOUT: %.loc7_21.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_21.2: i32 = initialize_from %.loc7_21.1 +// CHECK:STDOUT: assign %test_i32, %.loc7_21.2 // CHECK:STDOUT: %test_f64: f64 = var -// CHECK:STDOUT: %.loc8: f64 = real_literal 1e-1 -// CHECK:STDOUT: assign %test_f64, %.loc8 +// CHECK:STDOUT: %.loc8_21.1: f64 = real_literal 1e-1 +// CHECK:STDOUT: %.loc8_21.2: f64 = initialize_from %.loc8_21.1 +// CHECK:STDOUT: assign %test_f64, %.loc8_21.2 // CHECK:STDOUT: %test_str: String = var -// CHECK:STDOUT: %.loc9: String = string_literal "Test" -// CHECK:STDOUT: assign %test_str, %.loc9 +// CHECK:STDOUT: %.loc9_24.1: String = string_literal "Test" +// CHECK:STDOUT: %.loc9_24.2: String = initialize_from %.loc9_24.1 +// CHECK:STDOUT: assign %test_str, %.loc9_24.2 // CHECK:STDOUT: %test_type: type = var -// CHECK:STDOUT: assign %test_type, i32 +// CHECK:STDOUT: %.1: type = initialize_from i32 +// CHECK:STDOUT: assign %test_type, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon index 28a3523a0fd77..366e2da6dde8e 100644 --- a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon +++ b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon @@ -29,7 +29,8 @@ var x: type = 42; // CHECK:STDOUT: {kind: VarStorage, type: typeTypeType}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: typeTypeType}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -39,11 +40,13 @@ var x: type = 42; // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: type = var // CHECK:STDOUT: %.loc10: i32 = int_literal 42 -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/parens.carbon b/toolchain/semantics/testdata/basics/parens.carbon index a4aed23c15d5a..a706d0600f992 100644 --- a/toolchain/semantics/testdata/basics/parens.carbon +++ b/toolchain/semantics/testdata/basics/parens.carbon @@ -29,7 +29,8 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+3, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -41,6 +42,7 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -48,6 +50,7 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: %test_i32: i32 = var // CHECK:STDOUT: %.loc7_23: i32 = int_literal 1 // CHECK:STDOUT: %.loc7_29: i32 = int_literal 2 -// CHECK:STDOUT: %.loc7_26: i32 = add %.loc7_23, %.loc7_29 -// CHECK:STDOUT: assign %test_i32, %.loc7_26 +// CHECK:STDOUT: %.loc7_26.1: i32 = add %.loc7_23, %.loc7_29 +// CHECK:STDOUT: %.loc7_26.2: i32 = initialize_from %.loc7_26.1 +// CHECK:STDOUT: assign %test_i32, %.loc7_26.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon index ab04dc2892f44..f03c27d9d0c6f 100644 --- a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon @@ -37,12 +37,14 @@ fn Run() { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+4, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,18 +52,20 @@ fn Run() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -72,14 +76,16 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Foo() -> f64 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: f64 = real_literal 10e-1 -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_26.1: f64 = real_literal 10e-1 +// CHECK:STDOUT: %.loc7_26.2: f64 = initialize_from %.loc7_26.1 +// CHECK:STDOUT: return %.loc7_26.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc13: f64 = call @Foo() -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/else.carbon b/toolchain/semantics/testdata/if/else.carbon index c751f6679d41c..9f0e067b64237 100644 --- a/toolchain/semantics/testdata/if/else.carbon +++ b/toolchain/semantics/testdata/if/else.carbon @@ -37,7 +37,7 @@ fn If(b: bool) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -53,7 +53,8 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+6, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+6}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+9}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, @@ -91,19 +92,20 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+14, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -131,7 +133,8 @@ 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: %.loc11: bool = value_binding %b +// CHECK:STDOUT: if %.loc11 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc13_6.1: type = tuple_type () diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index 7a1f89c3ce2f0..b1f5452ddb65a 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -62,26 +62,32 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+8}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+13}, // CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+16, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+20, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+16}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+23}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+21}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+26, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+27}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -96,56 +102,62 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: ], @@ -159,11 +171,13 @@ 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: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: -// CHECK:STDOUT: %.loc9: i32 = int_literal 1 -// CHECK:STDOUT: return %.loc9 +// CHECK:STDOUT: %.loc9_12.1: i32 = int_literal 1 +// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 +// CHECK:STDOUT: return %.loc9_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: br !if.done @@ -173,25 +187,29 @@ 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: %.loc17: bool = value_binding %b +// CHECK:STDOUT: if %.loc17 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.loc20: i32 = int_literal 2 -// CHECK:STDOUT: return %.loc20 +// CHECK:STDOUT: %.loc20_12.1: i32 = int_literal 2 +// CHECK:STDOUT: %.loc20_12.2: i32 = initialize_from %.loc20_12.1 +// CHECK:STDOUT: return %.loc20_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.done: // CHECK:STDOUT: } // 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: %.loc27: bool = value_binding %b +// CHECK:STDOUT: if %.loc27 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: -// CHECK:STDOUT: %.loc29: i32 = int_literal 1 -// CHECK:STDOUT: return %.loc29 +// CHECK:STDOUT: %.loc29_12.1: i32 = int_literal 1 +// CHECK:STDOUT: %.loc29_12.2: i32 = initialize_from %.loc29_12.1 +// CHECK:STDOUT: return %.loc29_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index 4330b88698e5f..a2ff16ea3dc33 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -39,15 +39,20 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -65,16 +70,21 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,14 +94,19 @@ 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: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc9: i32 = int_literal 2 -// CHECK:STDOUT: assign %n, %.loc9 -// CHECK:STDOUT: return %n +// CHECK:STDOUT: %.loc9_18.1: i32 = int_literal 2 +// CHECK:STDOUT: %.loc9_18.2: i32 = initialize_from %.loc9_18.1 +// CHECK:STDOUT: assign %n, %.loc9_18.2 +// CHECK:STDOUT: %.loc9_9.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc9_9.2: i32 = initialize_from %.loc9_9.1 +// CHECK:STDOUT: return %.loc9_9.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: return +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/no_else.carbon b/toolchain/semantics/testdata/if/no_else.carbon index 1d9ada405f9de..347ada443c0d1 100644 --- a/toolchain/semantics/testdata/if/no_else.carbon +++ b/toolchain/semantics/testdata/if/no_else.carbon @@ -32,7 +32,7 @@ fn If(b: bool) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -46,7 +46,8 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+4, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, @@ -78,15 +79,16 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -108,7 +110,8 @@ 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: %.loc10: bool = value_binding %b +// CHECK:STDOUT: if %.loc10 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc12_6.1: type = tuple_type () diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index 3081fc8801f39..a6a55cbbe14ce 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -37,12 +37,15 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -60,15 +63,18 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -77,13 +83,16 @@ 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: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: -// CHECK:STDOUT: %.loc9: i32 = int_literal 1 -// CHECK:STDOUT: return %.loc9 +// CHECK:STDOUT: %.loc9_12.1: i32 = int_literal 1 +// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 +// CHECK:STDOUT: return %.loc9_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.loc11: i32 = int_literal 2 -// CHECK:STDOUT: return %.loc11 +// CHECK:STDOUT: %.loc11_12.1: i32 = int_literal 2 +// CHECK:STDOUT: %.loc11_12.2: i32 = initialize_from %.loc11_12.1 +// CHECK:STDOUT: return %.loc11_12.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index 2efedfc864e57..be988e63ce51f 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -36,14 +36,20 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+4, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+4, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+4, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+9}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type1}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+10, arg1: node+11, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+13, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+15}, // CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -67,18 +73,24 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -88,17 +100,23 @@ 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: %.loc7_6: bool = value_binding %b +// CHECK:STDOUT: if %.loc7_6 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: %.loc7_15.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc7_23.1: i32 = value_binding %m +// CHECK:STDOUT: %.loc8_22: i32 = add %.loc7_15.1, %.loc7_23.1 // 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: %.loc7_23.2: i32 = value_binding %m +// CHECK:STDOUT: %.loc7_15.2: i32 = value_binding %n +// CHECK:STDOUT: %.loc8_33: i32 = add %.loc7_23.2, %.loc7_15.2 // CHECK:STDOUT: br !if.expr.result(%.loc8_33) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: -// CHECK:STDOUT: %.loc8_10: i32 = block_arg !if.expr.result -// CHECK:STDOUT: return %.loc8_10 +// CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !if.expr.result +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/constant_condition.carbon b/toolchain/semantics/testdata/if_expression/constant_condition.carbon index 3d1cbaa975c27..ab35232e494da 100644 --- a/toolchain/semantics/testdata/if_expression/constant_condition.carbon +++ b/toolchain/semantics/testdata/if_expression/constant_condition.carbon @@ -43,81 +43,89 @@ fn G() -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+9}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+10}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+11}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+13}, // CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+17}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+20}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+20}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+21}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+23}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+24}, // CHECK:STDOUT: {kind: BlockArg, arg0: block11, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+28}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+21, // CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+25, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -130,14 +138,16 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @A() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = int_literal 1 -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 1 +// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 +// CHECK:STDOUT: return %.loc7_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @B() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_literal 2 -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_24.1: i32 = int_literal 2 +// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 +// CHECK:STDOUT: return %.loc8_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> i32 { @@ -154,8 +164,9 @@ fn G() -> i32 { // CHECK:STDOUT: br !if.expr.result(%.loc11_33) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: -// CHECK:STDOUT: %.loc11_10: i32 = block_arg !if.expr.result -// CHECK:STDOUT: return %.loc11_10 +// CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !if.expr.result +// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 +// CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> i32 { @@ -172,6 +183,7 @@ fn G() -> i32 { // CHECK:STDOUT: br !if.expr.result(%.loc15_34) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: -// CHECK:STDOUT: %.loc15_10: i32 = block_arg !if.expr.result -// CHECK:STDOUT: return %.loc15_10 +// CHECK:STDOUT: %.loc15_10.1: i32 = block_arg !if.expr.result +// CHECK:STDOUT: %.loc15_10.2: i32 = initialize_from %.loc15_10.1 +// CHECK:STDOUT: return %.loc15_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index 34715c757e613..4798c7cbfb6f9 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -38,60 +38,68 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+8, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+6}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+11}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+11}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+15}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -103,19 +111,22 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @A() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = int_literal 1 -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 1 +// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 +// CHECK:STDOUT: return %.loc7_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @B() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_literal 2 -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_24.1: i32 = int_literal 2 +// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 +// CHECK:STDOUT: return %.loc8_24.2 // CHECK:STDOUT: } // 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: %.loc10: bool = value_binding %b +// CHECK:STDOUT: if %.loc10 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: // CHECK:STDOUT: %.loc11_21: i32 = call @A() @@ -126,6 +137,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: br !if.expr.result(%.loc11_30) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: -// CHECK:STDOUT: %.loc11_10: i32 = block_arg !if.expr.result -// CHECK:STDOUT: return %.loc11_10 +// CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !if.expr.result +// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 +// CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index 6fd2f2d408bc2..eecfbfd5017b3 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -40,26 +40,30 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+4, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+10}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+11}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+18}, // CHECK:STDOUT: {kind: Branch, arg0: block11}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+18}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+21}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+22}, // CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+22}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+17}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+25}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+25}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+28, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+29}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -83,34 +87,33 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+22, @@ -118,7 +121,12 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+30, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -128,10 +136,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: %.loc7_6: bool = value_binding %a +// CHECK:STDOUT: if %.loc7_6 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: %.loc7_15: bool = value_binding %b +// CHECK:STDOUT: if %.loc7_15 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 @@ -146,7 +156,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: %.loc7_24: bool = value_binding %c +// CHECK:STDOUT: if %.loc7_24 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 @@ -161,6 +172,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: br !if.expr.result.loc8_10(%.loc8_44) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc8_10: -// CHECK:STDOUT: %.loc8_10: i32 = block_arg !if.expr.result.loc8_10 -// CHECK:STDOUT: return %.loc8_10 +// CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !if.expr.result.loc8_10 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/element_access.carbon b/toolchain/semantics/testdata/index/element_access.carbon index 8445c90b845d1..ae63d1b09dcfd 100644 --- a/toolchain/semantics/testdata/index/element_access.carbon +++ b/toolchain/semantics/testdata/index/element_access.carbon @@ -45,17 +45,22 @@ var c: i32 = b[0]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+4}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+15, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+12, arg1: node+17, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+18}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+13, arg1: node+20, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -81,6 +86,11 @@ var c: i32 = b[0]; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -89,7 +99,7 @@ var c: i32 = b[0]; // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -101,14 +111,19 @@ var c: i32 = b[0]; // CHECK:STDOUT: %a: (i32,) = var // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 -// CHECK:STDOUT: %.loc7_21: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: assign %a, %.loc7_21 +// CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) +// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 +// CHECK:STDOUT: assign %a, %.loc7_21.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var -// CHECK:STDOUT: assign %b, %a +// CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_17: i32 = tuple_index %b, %.loc9_16 -// CHECK:STDOUT: assign %c, %.loc9_17 +// CHECK:STDOUT: %.loc9_17.1: i32 = tuple_index %b, %.loc9_16 +// CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 +// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2 +// CHECK:STDOUT: assign %c, %.loc9_17.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_large_index.carbon b/toolchain/semantics/testdata/index/fail_large_index.carbon index 786ce8e90e846..8065fe86e34c8 100644 --- a/toolchain/semantics/testdata/index/fail_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_large_index.carbon @@ -48,16 +48,20 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+4}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+15, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -82,6 +86,10 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -90,7 +98,7 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -102,13 +110,17 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %a: (i32,) = var // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 -// CHECK:STDOUT: %.loc7_21: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: assign %a, %.loc7_21 +// CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) +// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 +// CHECK:STDOUT: assign %a, %.loc7_21.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var -// CHECK:STDOUT: assign %b, %a +// CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc12: i32 = int_literal -1 -// CHECK:STDOUT: assign %c, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %c, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_name_not_found.carbon b/toolchain/semantics/testdata/index/fail_name_not_found.carbon index f437b5147cc85..cb3bc19aa17cf 100644 --- a/toolchain/semantics/testdata/index/fail_name_not_found.carbon +++ b/toolchain/semantics/testdata/index/fail_name_not_found.carbon @@ -35,7 +35,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,6 +51,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -61,6 +63,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 0 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon index d5c13fc308c8b..9505a16f25481 100644 --- a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon +++ b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon @@ -54,14 +54,17 @@ var c: i32 = a[b]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+15}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+17, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: nodeError}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+19, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -87,6 +90,9 @@ var c: i32 = a[b]; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -109,11 +115,14 @@ var c: i32 = a[b]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_25.1: i32 = int_literal 3 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 -// CHECK:STDOUT: %.loc7_26: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: assign %a, %.loc7_26 +// CHECK:STDOUT: %.loc7_26.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) +// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = initialize_from %.loc7_26.1 +// CHECK:STDOUT: assign %a, %.loc7_26.2 // CHECK:STDOUT: %b: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 -// CHECK:STDOUT: assign %b, %.loc8 +// CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1 +// CHECK:STDOUT: assign %b, %.loc8_14.2 // CHECK:STDOUT: %c: i32 = var -// CHECK:STDOUT: assign %c, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %c, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon b/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon index e3d2fc94f554c..57db4c342b2b2 100644 --- a/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon @@ -53,11 +53,13 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -80,6 +82,8 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -102,9 +106,11 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_26.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 -// CHECK:STDOUT: %.loc7_27: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: assign %a, %.loc7_27 +// CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) +// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 +// CHECK:STDOUT: assign %a, %.loc7_27.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 26e-1 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon b/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon index ef0e1eb62af74..d2c1deb909dd2 100644 --- a/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon +++ b/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon @@ -52,11 +52,13 @@ var b: i32 = a[2]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -79,6 +81,8 @@ var b: i32 = a[2]; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -101,9 +105,11 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_26.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 -// CHECK:STDOUT: %.loc7_27: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: assign %a, %.loc7_27 +// CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) +// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 +// CHECK:STDOUT: assign %a, %.loc7_27.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 2 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/return_value_access.carbon b/toolchain/semantics/testdata/index/return_value_access.carbon index 3972bc0e00d4e..682dac745f30f 100644 --- a/toolchain/semantics/testdata/index/return_value_access.carbon +++ b/toolchain/semantics/testdata/index/return_value_access.carbon @@ -47,12 +47,14 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+10, arg1: node+11, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+11, arg1: node+12, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+13, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -63,7 +65,7 @@ fn Run() -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -73,15 +75,17 @@ fn Run() -> i32 { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -98,14 +102,16 @@ fn Run() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_28.1: i32 = int_literal 0 // CHECK:STDOUT: %.loc7_28.2: i32 = stub_reference %.loc7_28.1 -// CHECK:STDOUT: %.loc7_30: (i32,) = tuple_value (%.loc7_28.2) -// CHECK:STDOUT: return %.loc7_30 +// CHECK:STDOUT: %.loc7_30.1: (i32,) = tuple_value (%.loc7_28.2) +// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1 +// CHECK:STDOUT: return %.loc7_30.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_11: (i32,) = call @F() // CHECK:STDOUT: %.loc10_14: i32 = int_literal 0 -// CHECK:STDOUT: %.loc10_15: i32 = tuple_index %.loc10_11, %.loc10_14 -// CHECK:STDOUT: return %.loc10_15 +// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11, %.loc10_14 +// CHECK:STDOUT: %.loc10_15.2: i32 = initialize_from %.loc10_15.1 +// CHECK:STDOUT: return %.loc10_15.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon index 9be8431ffe94c..2d72bc8b1b7f1 100644 --- a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon +++ b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon @@ -31,14 +31,16 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block3, arg1: node+5}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block3, arg1: node+6}, // CHECK:STDOUT: {kind: Branch, arg0: block4}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+9, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+9, arg1: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -56,16 +58,18 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -76,15 +80,17 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: fn @A() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n.loc7_14: i32 = var -// CHECK:STDOUT: %.loc7_23: i32 = int_literal 1 -// CHECK:STDOUT: assign %n.loc7_14, %.loc7_23 +// CHECK:STDOUT: %.loc7_23.1: i32 = int_literal 1 +// CHECK:STDOUT: %.loc7_23.2: i32 = initialize_from %.loc7_23.1 +// CHECK:STDOUT: assign %n.loc7_14, %.loc7_23.2 // CHECK:STDOUT: %.loc7_30: bool = bool_literal true // CHECK:STDOUT: if %.loc7_30 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n.loc7_42: i32 = var -// CHECK:STDOUT: %.loc7_51: i32 = int_literal 2 -// CHECK:STDOUT: assign %n.loc7_42, %.loc7_51 +// CHECK:STDOUT: %.loc7_51.1: i32 = int_literal 2 +// CHECK:STDOUT: %.loc7_51.2: i32 = initialize_from %.loc7_51.1 +// CHECK:STDOUT: assign %n.loc7_42, %.loc7_51.2 // CHECK:STDOUT: br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.else: diff --git a/toolchain/semantics/testdata/operators/and.carbon b/toolchain/semantics/testdata/operators/and.carbon index fc9a4f9a9bd5d..f78bf140ceea9 100644 --- a/toolchain/semantics/testdata/operators/and.carbon +++ b/toolchain/semantics/testdata/operators/and.carbon @@ -34,43 +34,44 @@ fn And() -> bool { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+8}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+9}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+11}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+13}, // CHECK:STDOUT: {kind: BlockArg, arg0: block6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: ], @@ -78,6 +79,11 @@ fn And() -> bool { // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -88,14 +94,16 @@ fn And() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: bool = bool_literal true -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_25.1: bool = bool_literal true +// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 +// CHECK:STDOUT: return %.loc7_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: bool = bool_literal true -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_25.1: bool = bool_literal true +// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 +// CHECK:STDOUT: return %.loc8_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @And() -> bool { @@ -110,5 +118,6 @@ fn And() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: !and.result: // CHECK:STDOUT: %.loc11_14.2: bool = block_arg !and.result -// CHECK:STDOUT: return %.loc11_14.2 +// CHECK:STDOUT: %.loc11_14.3: bool = initialize_from %.loc11_14.2 +// CHECK:STDOUT: return %.loc11_14.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/assignment.carbon b/toolchain/semantics/testdata/operators/assignment.carbon index 15772b63ee65c..43fa0469b7ba1 100644 --- a/toolchain/semantics/testdata/operators/assignment.carbon +++ b/toolchain/semantics/testdata/operators/assignment.carbon @@ -53,10 +53,10 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+30, -// CHECK:STDOUT: node+47, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -74,67 +74,80 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+7}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+12, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+14, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+18}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+21}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+12, arg1: node+20, type: type0}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+23, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+22}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+24, arg1: node+26}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+12, arg1: node+24, type: type0}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+28, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+26}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+29, arg1: node+31}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+31, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+36, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+33, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+38, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+41, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+39}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+31, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+44, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+36, arg1: node+45}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+36, arg1: member0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+41, arg1: node+42}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+31, arg1: member1, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+48, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+47, arg1: node+49}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+36, arg1: member1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+44, arg1: node+45}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+52, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+51, arg1: node+53}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type4}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+48, type: type4}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+56, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, -// CHECK:STDOUT: {kind: Assign, arg0: node+48, arg1: node+50}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+48, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+58, type: type4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+56, arg1: node+59}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+56, type: type4}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+61, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+52, arg1: node+53}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+63, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+62, arg1: node+64}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type5}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+55}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+66}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+56, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+48}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+58}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+69}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+70}, // CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type4}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+61, type: type0}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+73, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+62, arg1: node+63}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+75, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+74, arg1: node+76}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -177,13 +190,13 @@ fn Main() { // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+32, // CHECK:STDOUT: node+33, +// CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, +// CHECK:STDOUT: node+37, // CHECK:STDOUT: node+38, -// CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, // CHECK:STDOUT: node+41, -// CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, // CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, @@ -199,40 +212,53 @@ fn Main() { // CHECK:STDOUT: node+55, // CHECK:STDOUT: node+56, // CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+58, +// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+62, +// CHECK:STDOUT: node+63, +// CHECK:STDOUT: node+64, +// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+66, +// CHECK:STDOUT: node+67, +// CHECK:STDOUT: node+68, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+28, -// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+33, +// CHECK:STDOUT: node+34, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+34, -// CHECK:STDOUT: node+37, +// CHECK:STDOUT: node+39, +// CHECK:STDOUT: node+42, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+35, -// CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+43, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+69, +// CHECK:STDOUT: node+71, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+70, +// CHECK:STDOUT: node+72, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+61, -// CHECK:STDOUT: node+62, -// CHECK:STDOUT: node+63, -// CHECK:STDOUT: node+64, -// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+73, +// CHECK:STDOUT: node+74, +// CHECK:STDOUT: node+75, +// CHECK:STDOUT: node+76, +// CHECK:STDOUT: node+77, +// CHECK:STDOUT: node+78, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -243,10 +269,12 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_literal 12 -// CHECK:STDOUT: assign %a, %.loc8 -// CHECK:STDOUT: %.loc9: i32 = int_literal -7 -// CHECK:STDOUT: assign %a, %.loc9 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 12 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %a, %.loc8_16.2 +// CHECK:STDOUT: %.loc9_7.1: i32 = int_literal -7 +// CHECK:STDOUT: %.loc9_7.2: i32 = initialize_from %.loc9_7.1 +// CHECK:STDOUT: assign %a, %.loc9_7.2 // CHECK:STDOUT: %.loc11_11: type = stub_reference i32 // CHECK:STDOUT: %.loc11_16: type = stub_reference i32 // CHECK:STDOUT: %.loc11_19.1: type = tuple_type (type, type) @@ -257,42 +285,52 @@ fn Main() { // CHECK:STDOUT: %.loc11_24.2: i32 = stub_reference %.loc11_24.1 // CHECK:STDOUT: %.loc11_27.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc11_27.2: i32 = stub_reference %.loc11_27.1 -// CHECK:STDOUT: %.loc11_28: (i32, i32) = tuple_value (%.loc11_24.2, %.loc11_27.2) -// CHECK:STDOUT: assign %b, %.loc11_28 +// CHECK:STDOUT: %.loc11_28.1: (i32, i32) = tuple_value (%.loc11_24.2, %.loc11_27.2) +// CHECK:STDOUT: %.loc11_28.2: (i32, i32) = initialize_from %.loc11_28.1 +// CHECK:STDOUT: assign %b, %.loc11_28.2 // CHECK:STDOUT: %.loc12_5: i32 = int_literal 0 // CHECK:STDOUT: %.loc12_6: i32 = tuple_index %b, %.loc12_5 -// CHECK:STDOUT: %.loc12_10: i32 = int_literal 3 -// CHECK:STDOUT: assign %.loc12_6, %.loc12_10 +// CHECK:STDOUT: %.loc12_10.1: i32 = int_literal 3 +// CHECK:STDOUT: %.loc12_10.2: i32 = initialize_from %.loc12_10.1 +// CHECK:STDOUT: assign %.loc12_6, %.loc12_10.2 // CHECK:STDOUT: %.loc13_5: i32 = int_literal 1 // CHECK:STDOUT: %.loc13_6: i32 = tuple_index %b, %.loc13_5 -// CHECK:STDOUT: %.loc13_10: i32 = int_literal 4 -// CHECK:STDOUT: assign %.loc13_6, %.loc13_10 +// CHECK:STDOUT: %.loc13_10.1: i32 = int_literal 4 +// CHECK:STDOUT: %.loc13_10.2: i32 = initialize_from %.loc13_10.1 +// CHECK:STDOUT: assign %.loc13_6, %.loc13_10.2 // CHECK:STDOUT: %.loc15_27: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %c: {.a: i32, .b: i32} = var // CHECK:STDOUT: %.loc15_37: i32 = int_literal 1 // CHECK:STDOUT: %.loc15_35: i32 = stub_reference %.loc15_37 // CHECK:STDOUT: %.loc15_45: i32 = int_literal 2 // CHECK:STDOUT: %.loc15_43: i32 = stub_reference %.loc15_45 -// CHECK:STDOUT: %.loc15_46: {.a: i32, .b: i32} = struct_value (%.loc15_35, %.loc15_43) -// CHECK:STDOUT: assign %c, %.loc15_46 +// CHECK:STDOUT: %.loc15_46.1: {.a: i32, .b: i32} = struct_value (%.loc15_35, %.loc15_43) +// CHECK:STDOUT: %.loc15_46.2: {.a: i32, .b: i32} = initialize_from %.loc15_46.1 +// CHECK:STDOUT: assign %c, %.loc15_46.2 // CHECK:STDOUT: %.loc16_4: i32 = struct_access %c, member0 -// CHECK:STDOUT: %.loc16_9: i32 = int_literal 3 -// CHECK:STDOUT: assign %.loc16_4, %.loc16_9 +// CHECK:STDOUT: %.loc16_9.1: i32 = int_literal 3 +// CHECK:STDOUT: %.loc16_9.2: i32 = initialize_from %.loc16_9.1 +// CHECK:STDOUT: assign %.loc16_4, %.loc16_9.2 // CHECK:STDOUT: %.loc17_4: i32 = struct_access %c, member1 -// CHECK:STDOUT: %.loc17_9: i32 = int_literal 4 -// CHECK:STDOUT: assign %.loc17_4, %.loc17_9 +// CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 4 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 +// CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 // CHECK:STDOUT: %.loc19_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var -// CHECK:STDOUT: %.loc19_17: i32* = address_of %a -// CHECK:STDOUT: assign %p, %.loc19_17 -// CHECK:STDOUT: %.loc20_3: i32 = dereference %p -// CHECK:STDOUT: %.loc20_8: i32 = int_literal 5 -// CHECK:STDOUT: assign %.loc20_3, %.loc20_8 +// CHECK:STDOUT: %.loc19_17.1: i32* = address_of %a +// CHECK:STDOUT: %.loc19_17.2: i32* = initialize_from %.loc19_17.1 +// CHECK:STDOUT: assign %p, %.loc19_17.2 +// CHECK:STDOUT: %.loc19_7.1: i32* = value_binding %p +// CHECK:STDOUT: %.loc20_3: i32 = dereference %.loc19_7.1 +// CHECK:STDOUT: %.loc20_8.1: i32 = int_literal 5 +// CHECK:STDOUT: %.loc20_8.2: i32 = initialize_from %.loc20_8.1 +// CHECK:STDOUT: assign %.loc20_3, %.loc20_8.2 // 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: br !if.expr.result(%p) +// CHECK:STDOUT: %.loc19_7.2: i32* = value_binding %p +// CHECK:STDOUT: br !if.expr.result(%.loc19_7.2) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: // CHECK:STDOUT: %.loc22_25: i32* = address_of %a @@ -301,7 +339,8 @@ fn Main() { // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc22_5: i32* = block_arg !if.expr.result // CHECK:STDOUT: %.loc22_3: i32 = dereference %.loc22_5 -// CHECK:STDOUT: %.loc22_31: i32 = int_literal 10 -// CHECK:STDOUT: assign %.loc22_3, %.loc22_31 +// CHECK:STDOUT: %.loc22_31.1: i32 = int_literal 10 +// CHECK:STDOUT: %.loc22_31.2: i32 = initialize_from %.loc22_31.1 +// CHECK:STDOUT: assign %.loc22_3, %.loc22_31.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/binary_op.carbon b/toolchain/semantics/testdata/operators/binary_op.carbon index c668ee876684e..e5f77260db2ef 100644 --- a/toolchain/semantics/testdata/operators/binary_op.carbon +++ b/toolchain/semantics/testdata/operators/binary_op.carbon @@ -31,7 +31,8 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+1, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -44,6 +45,7 @@ fn Main() -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -55,6 +57,7 @@ fn Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc8_15: i32 = int_literal 34 -// CHECK:STDOUT: %.loc8_13: i32 = add %.loc8_10, %.loc8_15 -// CHECK:STDOUT: return %.loc8_13 +// CHECK:STDOUT: %.loc8_13.1: i32 = add %.loc8_10, %.loc8_15 +// CHECK:STDOUT: %.loc8_13.2: i32 = initialize_from %.loc8_13.1 +// CHECK:STDOUT: return %.loc8_13.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon index 16eb95739a3ae..a15a460250d72 100644 --- a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -82,8 +82,8 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+41, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+49, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -97,73 +97,86 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+12, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+18}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+21}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+20, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+23, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+22}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+20, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+23, arg1: node+26}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+23, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+28, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+23, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+33, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+29, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+35, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+26, arg1: node+31}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+37, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+32, arg1: node+38}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+33}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+40, type: typeTypeType}, +// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+41}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+35, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+43, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+38, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+46, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block7, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block8, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+43, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+51, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+46, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+54, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block10, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+42, arg1: node+49}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+57, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+50, arg1: node+58}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+51}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+60}, // CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int15, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+54}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+55}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+63}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+64}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int16, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+58, arg1: node+59}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+68, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+67, arg1: node+69}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+61, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+71, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block14, arg1: node+63}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block14, arg1: node+73}, // CHECK:STDOUT: {kind: Branch, arg0: block15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+61}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+61}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+71, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+71, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+76}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+77}, // CHECK:STDOUT: {kind: BlockArg, arg0: block16, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int17, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+68, arg1: node+69}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+81, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+80, arg1: node+82}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -208,8 +221,10 @@ fn Main() { // CHECK:STDOUT: node+33, // CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+36, // CHECK:STDOUT: node+37, // CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, // CHECK:STDOUT: node+41, // CHECK:STDOUT: node+42, @@ -220,32 +235,31 @@ fn Main() { // CHECK:STDOUT: node+49, // CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, -// CHECK:STDOUT: node+52, // CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+58, +// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+62, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+25, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+28, -// CHECK:STDOUT: node+30, +// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+31, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+34, // CHECK:STDOUT: node+36, -// CHECK:STDOUT: node+39, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+37, -// CHECK:STDOUT: node+40, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+44, @@ -256,34 +270,46 @@ fn Main() { // CHECK:STDOUT: node+48, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+54, -// CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+52, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+55, -// CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+56, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+59, -// CHECK:STDOUT: node+60, -// CHECK:STDOUT: node+61, -// CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, -// CHECK:STDOUT: node+64, // CHECK:STDOUT: node+65, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+64, // CHECK:STDOUT: node+66, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+67, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+68, // CHECK:STDOUT: node+69, // CHECK:STDOUT: node+70, // CHECK:STDOUT: node+71, +// CHECK:STDOUT: node+72, +// CHECK:STDOUT: node+73, +// CHECK:STDOUT: node+74, +// CHECK:STDOUT: node+75, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+76, +// CHECK:STDOUT: node+78, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+77, +// CHECK:STDOUT: node+79, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+80, +// CHECK:STDOUT: node+81, +// CHECK:STDOUT: node+82, +// CHECK:STDOUT: node+83, +// CHECK:STDOUT: node+84, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -297,11 +323,13 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // 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: %.loc13_7.1: i32 = int_literal 2 +// CHECK:STDOUT: %.loc13_7.2: i32 = initialize_from %.loc13_7.1 +// CHECK:STDOUT: assign %.loc13_3, %.loc13_7.2 // CHECK:STDOUT: %.loc17_4: i32 = call @F() -// CHECK:STDOUT: %.loc17_9: i32 = int_literal 1 -// CHECK:STDOUT: assign %.loc17_4, %.loc17_9 +// CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 1 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 +// CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 // CHECK:STDOUT: %.loc21_4.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc21_4.2: i32 = stub_reference %.loc21_4.1 // CHECK:STDOUT: %.loc21_7.1: i32 = int_literal 2 @@ -312,22 +340,28 @@ fn Main() { // CHECK:STDOUT: %.loc21_13.2: i32 = stub_reference %.loc21_13.1 // CHECK:STDOUT: %.loc21_16.1: i32 = int_literal 4 // CHECK:STDOUT: %.loc21_16.2: i32 = stub_reference %.loc21_16.1 -// CHECK:STDOUT: %.loc21_17: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) -// CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17 +// CHECK:STDOUT: %.loc21_17.1: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) +// CHECK:STDOUT: %.loc21_17.2: (i32, i32) = initialize_from %.loc21_17.1 +// CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17.2 // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc22: i32 = int_literal 0 -// CHECK:STDOUT: assign %n, %.loc22 -// CHECK:STDOUT: %.loc26_4: i32 = stub_reference %n -// CHECK:STDOUT: %.loc26_7: i32 = stub_reference %n +// CHECK:STDOUT: %.loc22_16.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc22_16.2: i32 = initialize_from %.loc22_16.1 +// CHECK:STDOUT: assign %n, %.loc22_16.2 +// CHECK:STDOUT: %.loc22_7.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc26_4: i32 = stub_reference %.loc22_7.1 +// CHECK:STDOUT: %.loc22_7.2: i32 = value_binding %n +// CHECK:STDOUT: %.loc26_7: i32 = stub_reference %.loc22_7.2 // CHECK:STDOUT: %.loc26_8: (i32, i32) = tuple_value (%.loc26_4, %.loc26_7) // CHECK:STDOUT: %.loc26_13.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc26_13.2: i32 = stub_reference %.loc26_13.1 // CHECK:STDOUT: %.loc26_16.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc26_16.2: i32 = stub_reference %.loc26_16.1 -// CHECK:STDOUT: %.loc26_17: (i32, i32) = tuple_value (%.loc26_13.2, %.loc26_16.2) -// CHECK:STDOUT: assign %.loc26_8, %.loc26_17 -// CHECK:STDOUT: %.loc30: type = ptr_type i32 -// CHECK:STDOUT: assign i32, %.loc30 +// CHECK:STDOUT: %.loc26_17.1: (i32, i32) = tuple_value (%.loc26_13.2, %.loc26_16.2) +// CHECK:STDOUT: %.loc26_17.2: (i32, i32) = initialize_from %.loc26_17.1 +// CHECK:STDOUT: assign %.loc26_8, %.loc26_17.2 +// CHECK:STDOUT: %.loc30_12.1: type = ptr_type i32 +// CHECK:STDOUT: %.loc30_12.2: type = initialize_from %.loc30_12.1 +// CHECK:STDOUT: assign i32, %.loc30_12.2 // CHECK:STDOUT: %.loc34_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc34_7: i32 = stub_reference %.loc34_9 // CHECK:STDOUT: %.loc34_17: i32 = int_literal 2 @@ -338,8 +372,9 @@ fn Main() { // CHECK:STDOUT: %.loc34_26: i32 = stub_reference %.loc34_28 // CHECK:STDOUT: %.loc34_36: i32 = int_literal 4 // CHECK:STDOUT: %.loc34_34: i32 = stub_reference %.loc34_36 -// CHECK:STDOUT: %.loc34_37: {.x: i32, .y: i32} = struct_value (%.loc34_26, %.loc34_34) -// CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37 +// CHECK:STDOUT: %.loc34_37.1: {.x: i32, .y: i32} = struct_value (%.loc34_26, %.loc34_34) +// CHECK:STDOUT: %.loc34_37.2: {.x: i32, .y: i32} = initialize_from %.loc34_37.1 +// CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37.2 // CHECK:STDOUT: %.loc38_7: bool = bool_literal true // CHECK:STDOUT: if %.loc38_7 br !if.expr.then.loc38 else br !if.expr.else.loc38 // CHECK:STDOUT: @@ -353,21 +388,25 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc38: // CHECK:STDOUT: %.loc38_4: i32 = block_arg !if.expr.result.loc38 -// CHECK:STDOUT: %.loc38_29: i32 = int_literal 3 -// CHECK:STDOUT: assign %.loc38_4, %.loc38_29 +// CHECK:STDOUT: %.loc38_29.1: i32 = int_literal 3 +// CHECK:STDOUT: %.loc38_29.2: i32 = initialize_from %.loc38_29.1 +// CHECK:STDOUT: assign %.loc38_4, %.loc38_29.2 // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc45_7: bool = bool_literal true // 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: br !if.expr.result.loc45(%a) +// CHECK:STDOUT: %.loc41_7.1: i32 = value_binding %a +// CHECK:STDOUT: br !if.expr.result.loc45(%.loc41_7.1) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else.loc45: -// CHECK:STDOUT: br !if.expr.result.loc45(%a) +// CHECK:STDOUT: %.loc41_7.2: i32 = value_binding %a +// CHECK:STDOUT: br !if.expr.result.loc45(%.loc41_7.2) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc45: // CHECK:STDOUT: %.loc45_4: i32 = block_arg !if.expr.result.loc45 -// CHECK:STDOUT: %.loc45_29: i32 = int_literal 10 -// CHECK:STDOUT: assign %.loc45_4, %.loc45_29 +// CHECK:STDOUT: %.loc45_29.1: i32 = int_literal 10 +// CHECK:STDOUT: %.loc45_29.2: i32 = initialize_from %.loc45_29.1 +// CHECK:STDOUT: assign %.loc45_4, %.loc45_29.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon index 49099af61debd..4a4765946ae27 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon @@ -37,9 +37,11 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+7}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -56,6 +58,8 @@ fn Main() { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -66,9 +70,11 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_literal 3 -// CHECK:STDOUT: assign %a, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 3 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %a, %.loc8_16.2 // CHECK:STDOUT: %.loc12: f64 = real_literal 56e-1 -// CHECK:STDOUT: assign %a, %.loc12 +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %a, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/or.carbon b/toolchain/semantics/testdata/operators/or.carbon index 826f79a7be9b1..bdb0c10338a9c 100644 --- a/toolchain/semantics/testdata/operators/or.carbon +++ b/toolchain/semantics/testdata/operators/or.carbon @@ -34,45 +34,46 @@ fn Or() -> bool { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+8}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+9}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+10}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+11}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+14}, // CHECK:STDOUT: {kind: BlockArg, arg0: block6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], @@ -80,6 +81,11 @@ fn Or() -> bool { // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -90,14 +96,16 @@ fn Or() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: bool = bool_literal true -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: %.loc7_25.1: bool = bool_literal true +// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 +// CHECK:STDOUT: return %.loc7_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: bool = bool_literal true -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_25.1: bool = bool_literal true +// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 +// CHECK:STDOUT: return %.loc8_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Or() -> bool { @@ -113,5 +121,6 @@ fn Or() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: !or.result: // CHECK:STDOUT: %.loc11_14.3: bool = block_arg !or.result -// CHECK:STDOUT: return %.loc11_14.3 +// CHECK:STDOUT: %.loc11_14.4: bool = initialize_from %.loc11_14.3 +// CHECK:STDOUT: return %.loc11_14.4 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_deref.carbon b/toolchain/semantics/testdata/pointer/address_of_deref.carbon index 84e6ab35adf2f..8c249836b11ff 100644 --- a/toolchain/semantics/testdata/pointer/address_of_deref.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_deref.carbon @@ -24,7 +24,7 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -33,13 +33,16 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+6, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -58,6 +61,9 @@ fn F() -> i32 { // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -68,12 +74,15 @@ fn F() -> i32 { // CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 -// CHECK:STDOUT: assign %n, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %n, %.loc8_16.2 // CHECK:STDOUT: %.loc9_13.1: type = ptr_type i32 // CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n // CHECK:STDOUT: %.loc9_12: i32 = dereference %.loc9_13.2 // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 -// CHECK:STDOUT: %.loc9_10: i32 = dereference %.loc9_11 -// CHECK:STDOUT: return %.loc9_10 +// CHECK:STDOUT: %.loc9_10.1: i32 = dereference %.loc9_11 +// CHECK:STDOUT: %.loc9_10.2: i32 = value_binding %.loc9_10.1 +// CHECK:STDOUT: %.loc9_10.3: i32 = initialize_from %.loc9_10.2 +// CHECK:STDOUT: return %.loc9_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon index 2b19bf04dfba2..5b55384cf3c6c 100644 --- a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon @@ -51,10 +51,10 @@ fn F(param: i32) { // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+38, -// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+42, +// CHECK:STDOUT: node+44, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -82,59 +82,67 @@ fn F(param: i32) { // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+15}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block8, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+20, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+21, type: type2}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+6, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+22}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+24}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str6, arg1: node+25, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str6, arg1: node+27, type: type3}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+6, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+27, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+28}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+29, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+27, arg1: node+31}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str7, arg1: node+31, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str7, arg1: node+34, type: type3}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+6, arg1: member1, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+33, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+34}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+36, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+37, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+34, arg1: node+38}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block9, type: type4}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type5}, -// CHECK:STDOUT: {kind: BindName, arg0: str8, arg1: node+41, type: type5}, +// CHECK:STDOUT: {kind: BindName, arg0: str8, arg1: node+45, type: type5}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+43, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+47, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+45, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+49, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block10, type: type5}, -// CHECK:STDOUT: {kind: Assign, arg0: node+41, arg1: node+47}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+51, type: type5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+45, arg1: node+52}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str9, arg1: node+50, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str9, arg1: node+55, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+41, arg1: node+52, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+53, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+50, arg1: node+54}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+45, arg1: node+57, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+58, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+59, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+55, arg1: node+60}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str10, arg1: node+57, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str10, arg1: node+63, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+41, arg1: node+59, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+60, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+57, arg1: node+61}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+45, arg1: node+65, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+66, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+67, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+63, arg1: node+68}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str11, arg1: node+64, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str11, arg1: node+71, type: type3}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+0, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+64, arg1: node+66}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+73, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+71, arg1: node+74}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -215,6 +223,14 @@ fn F(param: i32) { // CHECK:STDOUT: node+66, // CHECK:STDOUT: node+67, // CHECK:STDOUT: node+68, +// CHECK:STDOUT: node+69, +// CHECK:STDOUT: node+70, +// CHECK:STDOUT: node+71, +// CHECK:STDOUT: node+72, +// CHECK:STDOUT: node+73, +// CHECK:STDOUT: node+74, +// CHECK:STDOUT: node+75, +// CHECK:STDOUT: node+76, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, @@ -229,16 +245,16 @@ fn F(param: i32) { // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+36, -// CHECK:STDOUT: node+37, +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+41, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+44, -// CHECK:STDOUT: node+46, +// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+50, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -254,23 +270,27 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc8_35: i32 = stub_reference %.loc8_37 // CHECK:STDOUT: %.loc8_45: i32 = int_literal 2 // CHECK:STDOUT: %.loc8_43: i32 = stub_reference %.loc8_45 -// CHECK:STDOUT: %.loc8_46: {.a: i32, .b: i32} = struct_value (%.loc8_35, %.loc8_43) -// CHECK:STDOUT: assign %s, %.loc8_46 +// CHECK:STDOUT: %.loc8_46.1: {.a: i32, .b: i32} = struct_value (%.loc8_35, %.loc8_43) +// CHECK:STDOUT: %.loc8_46.2: {.a: i32, .b: i32} = initialize_from %.loc8_46.1 +// CHECK:STDOUT: assign %s, %.loc8_46.2 // 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: {.a: i32, .b: i32}* = var -// CHECK:STDOUT: %.loc10_32: {.a: i32, .b: i32}* = address_of %s -// CHECK:STDOUT: assign %p, %.loc10_32 +// CHECK:STDOUT: %.loc10_32.1: {.a: i32, .b: i32}* = address_of %s +// CHECK:STDOUT: %.loc10_32.2: {.a: i32, .b: i32}* = initialize_from %.loc10_32.1 +// CHECK:STDOUT: assign %p, %.loc10_32.2 // CHECK:STDOUT: %.loc11_13: type = ptr_type i32 // CHECK:STDOUT: %q: i32* = var // CHECK:STDOUT: %.loc11_19: i32 = struct_access %s, member0 -// CHECK:STDOUT: %.loc11_17: i32* = address_of %.loc11_19 -// CHECK:STDOUT: assign %q, %.loc11_17 +// CHECK:STDOUT: %.loc11_17.1: i32* = address_of %.loc11_19 +// CHECK:STDOUT: %.loc11_17.2: i32* = initialize_from %.loc11_17.1 +// CHECK:STDOUT: assign %q, %.loc11_17.2 // CHECK:STDOUT: %.loc12_13: type = ptr_type i32 // CHECK:STDOUT: %r: i32* = var // CHECK:STDOUT: %.loc12_19: i32 = struct_access %s, member1 -// CHECK:STDOUT: %.loc12_17: i32* = address_of %.loc12_19 -// CHECK:STDOUT: assign %r, %.loc12_17 +// CHECK:STDOUT: %.loc12_17.1: i32* = address_of %.loc12_19 +// CHECK:STDOUT: %.loc12_17.2: i32* = initialize_from %.loc12_17.1 +// CHECK:STDOUT: assign %r, %.loc12_17.2 // CHECK:STDOUT: %.loc14_11: type = stub_reference i32 // CHECK:STDOUT: %.loc14_16: type = stub_reference i32 // CHECK:STDOUT: %.loc14_19.1: type = tuple_type (type, type) @@ -281,23 +301,27 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc14_24.2: i32 = stub_reference %.loc14_24.1 // CHECK:STDOUT: %.loc14_27.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc14_27.2: i32 = stub_reference %.loc14_27.1 -// CHECK:STDOUT: %.loc14_28: (i32, i32) = tuple_value (%.loc14_24.2, %.loc14_27.2) -// CHECK:STDOUT: assign %t, %.loc14_28 +// CHECK:STDOUT: %.loc14_28.1: (i32, i32) = tuple_value (%.loc14_24.2, %.loc14_27.2) +// CHECK:STDOUT: %.loc14_28.2: (i32, i32) = initialize_from %.loc14_28.1 +// CHECK:STDOUT: assign %t, %.loc14_28.2 // CHECK:STDOUT: %.loc15_14: type = ptr_type i32 // CHECK:STDOUT: %t0: i32* = var // CHECK:STDOUT: %.loc15_21: i32 = int_literal 0 // CHECK:STDOUT: %.loc15_22: i32 = tuple_index %t, %.loc15_21 -// CHECK:STDOUT: %.loc15_18: i32* = address_of %.loc15_22 -// CHECK:STDOUT: assign %t0, %.loc15_18 +// CHECK:STDOUT: %.loc15_18.1: i32* = address_of %.loc15_22 +// CHECK:STDOUT: %.loc15_18.2: i32* = initialize_from %.loc15_18.1 +// CHECK:STDOUT: assign %t0, %.loc15_18.2 // CHECK:STDOUT: %.loc16_14: type = ptr_type i32 // CHECK:STDOUT: %t1: i32* = var // CHECK:STDOUT: %.loc16_21: i32 = int_literal 1 // CHECK:STDOUT: %.loc16_22: i32 = tuple_index %t, %.loc16_21 -// CHECK:STDOUT: %.loc16_18: i32* = address_of %.loc16_22 -// CHECK:STDOUT: assign %t1, %.loc16_18 +// CHECK:STDOUT: %.loc16_18.1: i32* = address_of %.loc16_22 +// CHECK:STDOUT: %.loc16_18.2: i32* = initialize_from %.loc16_18.1 +// CHECK:STDOUT: assign %t1, %.loc16_18.2 // CHECK:STDOUT: %.loc20_22: type = ptr_type i32 // CHECK:STDOUT: %param_addr: i32* = var -// CHECK:STDOUT: %.loc20_26: i32* = address_of %param -// CHECK:STDOUT: assign %param_addr, %.loc20_26 +// CHECK:STDOUT: %.loc20_26.1: i32* = address_of %param +// CHECK:STDOUT: %.loc20_26.2: i32* = initialize_from %.loc20_26.1 +// CHECK:STDOUT: assign %param_addr, %.loc20_26.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/basic.carbon b/toolchain/semantics/testdata/pointer/basic.carbon index b7d8c80413e85..3938d80800d4f 100644 --- a/toolchain/semantics/testdata/pointer/basic.carbon +++ b/toolchain/semantics/testdata/pointer/basic.carbon @@ -27,7 +27,7 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -36,14 +36,19 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+8}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -63,6 +68,11 @@ fn F() -> i32 { // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -73,12 +83,17 @@ fn F() -> i32 { // CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 -// CHECK:STDOUT: assign %n, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %n, %.loc8_16.2 // CHECK:STDOUT: %.loc9_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var -// CHECK:STDOUT: %.loc9_17: i32* = address_of %n -// CHECK:STDOUT: assign %p, %.loc9_17 -// CHECK:STDOUT: %.loc11: i32 = dereference %p -// CHECK:STDOUT: return %.loc11 +// CHECK:STDOUT: %.loc9_17.1: i32* = address_of %n +// CHECK:STDOUT: %.loc9_17.2: i32* = initialize_from %.loc9_17.1 +// CHECK:STDOUT: assign %p, %.loc9_17.2 +// CHECK:STDOUT: %.loc9_7: i32* = value_binding %p +// CHECK:STDOUT: %.loc11_10.1: i32 = dereference %.loc9_7 +// CHECK:STDOUT: %.loc11_10.2: i32 = value_binding %.loc11_10.1 +// CHECK:STDOUT: %.loc11_10.3: i32 = initialize_from %.loc11_10.2 +// CHECK:STDOUT: return %.loc11_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index c09b25b149533..af08dfde77d28 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -43,21 +43,28 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+9}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+12}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+16, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+19}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+15}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+21}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, // CHECK:STDOUT: {kind: Branch, arg0: unreachable}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -75,6 +82,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,6 +92,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_10.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon index 8824332ec2535..ddf154b0895c7 100644 --- a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon @@ -32,7 +32,8 @@ fn Main() -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -43,6 +44,7 @@ fn Main() -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -53,5 +55,6 @@ fn Main() -> i32 { // CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11: f64 = real_literal 10e-1 -// CHECK:STDOUT: return +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/value.carbon b/toolchain/semantics/testdata/return/value.carbon index 45a55ff9b5912..0f45fb1aa761e 100644 --- a/toolchain/semantics/testdata/return/value.carbon +++ b/toolchain/semantics/testdata/return/value.carbon @@ -28,7 +28,8 @@ fn Main() -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -39,6 +40,7 @@ fn Main() -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -48,6 +50,7 @@ fn Main() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 -// CHECK:STDOUT: return %.loc8 +// CHECK:STDOUT: %.loc8_10.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/member_access.carbon b/toolchain/semantics/testdata/struct/member_access.carbon index 0a875ce395e04..5f0466ad75c4c 100644 --- a/toolchain/semantics/testdata/struct/member_access.carbon +++ b/toolchain/semantics/testdata/struct/member_access.carbon @@ -44,14 +44,19 @@ var z: i32 = y; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+3, arg1: member1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+15}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+18}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+17, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+13}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+20, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -75,6 +80,11 @@ var z: i32 = y; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -97,11 +107,16 @@ var z: i32 = y; // CHECK:STDOUT: %.loc7_33: f64 = stub_reference %.loc7_35 // CHECK:STDOUT: %.loc7_45: i32 = int_literal 1 // CHECK:STDOUT: %.loc7_43: i32 = stub_reference %.loc7_45 -// CHECK:STDOUT: %.loc7_46: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) -// CHECK:STDOUT: assign %x, %.loc7_46 +// CHECK:STDOUT: %.loc7_46.1: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) +// CHECK:STDOUT: %.loc7_46.2: {.a: f64, .b: i32} = initialize_from %.loc7_46.1 +// CHECK:STDOUT: assign %x, %.loc7_46.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.loc8: i32 = struct_access %x, member1 -// CHECK:STDOUT: assign %y, %.loc8 +// CHECK:STDOUT: %.loc8_15.1: i32 = struct_access %x, member1 +// CHECK:STDOUT: %.loc8_15.2: i32 = value_binding %.loc8_15.1 +// CHECK:STDOUT: %.loc8_15.3: i32 = initialize_from %.loc8_15.2 +// CHECK:STDOUT: assign %y, %.loc8_15.3 // CHECK:STDOUT: %z: i32 = var -// CHECK:STDOUT: assign %z, %y +// CHECK:STDOUT: %.loc8_5.1: i32 = value_binding %y +// CHECK:STDOUT: %.loc8_5.2: i32 = initialize_from %.loc8_5.1 +// CHECK:STDOUT: assign %z, %.loc8_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon index 3fe51b0fbaae4..15a4563ededc1 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon @@ -34,7 +34,8 @@ var x: () = (66); // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -46,6 +47,7 @@ var x: () = (66); // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -54,5 +56,6 @@ var x: () = (66); // CHECK:STDOUT: %.loc10_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var // CHECK:STDOUT: %.loc10_14: i32 = int_literal 66 -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/decl_with_init.carbon b/toolchain/semantics/testdata/var/decl_with_init.carbon index f17fb393b3b23..47c6986ed3a48 100644 --- a/toolchain/semantics/testdata/var/decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/decl_with_init.carbon @@ -31,7 +31,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -46,6 +47,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -56,7 +58,8 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 -// CHECK:STDOUT: assign %x, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %x, %.loc8_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon index 109cdfb680d5f..1875f8c3384e9 100644 --- a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon +++ b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon @@ -40,11 +40,13 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+6, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -63,6 +65,8 @@ fn Main() { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -73,10 +77,12 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.loc9: i32 = var -// CHECK:STDOUT: %.loc9: i32 = int_literal 0 -// CHECK:STDOUT: assign %x.loc9, %.loc9 +// CHECK:STDOUT: %.loc9_16.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc9_16.2: i32 = initialize_from %.loc9_16.1 +// CHECK:STDOUT: assign %x.loc9, %.loc9_16.2 // CHECK:STDOUT: %x.loc16: i32 = var -// CHECK:STDOUT: %.loc16: i32 = int_literal 0 -// CHECK:STDOUT: assign %x.loc16, %.loc16 +// CHECK:STDOUT: %.loc16_16.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc16_16.2: i32 = initialize_from %.loc16_16.1 +// CHECK:STDOUT: assign %x.loc16, %.loc16_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon index ad18a8d01ef37..697315240f792 100644 --- a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon +++ b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon @@ -35,7 +35,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,6 +51,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -61,6 +63,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 10e-1 -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon index c39bd8140ca6e..97c20639690fe 100644 --- a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon +++ b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon @@ -36,7 +36,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: typeError}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -52,6 +53,7 @@ fn Main() { // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -64,6 +66,7 @@ fn Main() { // CHECK:STDOUT: %.loc11_10: i32 = int_literal 1 // CHECK:STDOUT: %x: = var // CHECK:STDOUT: %.loc11_14: i32 = int_literal 1 -// CHECK:STDOUT: assign %x, +// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_decl_with_init.carbon b/toolchain/semantics/testdata/var/global_decl_with_init.carbon index 99932570d46c4..4d07c6e9f4c97 100644 --- a/toolchain/semantics/testdata/var/global_decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/global_decl_with_init.carbon @@ -26,7 +26,8 @@ var x: i32 = 0; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -36,11 +37,13 @@ var x: i32 = 0; // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 -// CHECK:STDOUT: assign %x, %.loc7 +// CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup.carbon b/toolchain/semantics/testdata/var/global_lookup.carbon index 786171ca5c8e4..27972fe10dea7 100644 --- a/toolchain/semantics/testdata/var/global_lookup.carbon +++ b/toolchain/semantics/testdata/var/global_lookup.carbon @@ -28,10 +28,13 @@ var y: i32 = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+4, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -44,13 +47,19 @@ var y: i32 = x; // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 -// CHECK:STDOUT: assign %x, %.loc7 +// CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5.1: i32 = value_binding %x +// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon index 038c287d678a7..a47c1eb30578f 100644 --- a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon +++ b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon @@ -33,11 +33,14 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -49,25 +52,31 @@ fn Main() { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 -// CHECK:STDOUT: assign %x, %.loc7 +// CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc9 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: assign %y, package.%x +// CHECK:STDOUT: %.loc7_5.1: i32 = value_binding package.%x +// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 +// CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/lookup.carbon b/toolchain/semantics/testdata/var/lookup.carbon index 986c27f12e050..50a1895a5e755 100644 --- a/toolchain/semantics/testdata/var/lookup.carbon +++ b/toolchain/semantics/testdata/var/lookup.carbon @@ -32,7 +32,8 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -47,6 +48,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -57,7 +59,8 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_literal 0 -// CHECK:STDOUT: assign %x, %.loc8 +// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: assign %x, %.loc8_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } From c5ccea52293163d25c609c5d154d2074bd913c2c Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 11 Aug 2023 16:05:18 -0700 Subject: [PATCH 04/21] Start tracking the initialization target as part of an initialization node. --- .../lowering_handle_expression_category.cpp | 4 +- toolchain/semantics/semantics_context.cpp | 45 ++++- toolchain/semantics/semantics_context.h | 21 +- .../semantics/semantics_handle_function.cpp | 21 +- .../semantics/semantics_handle_operator.cpp | 3 +- .../semantics_handle_parameter_list.cpp | 2 + .../semantics/semantics_handle_statement.cpp | 3 +- .../semantics/semantics_handle_variable.cpp | 5 +- toolchain/semantics/semantics_ir.h | 7 + .../semantics/semantics_ir_formatter.cpp | 9 + toolchain/semantics/semantics_node.h | 3 +- toolchain/semantics/semantics_node_stack.h | 3 +- .../testdata/basics/builtin_types.carbon | 16 +- .../basics/fail_non_type_as_type.carbon | 4 +- .../basics/fail_qualifier_unsupported.carbon | 4 +- .../semantics/testdata/basics/parens.carbon | 4 +- .../semantics/testdata/const/collapse.carbon | 16 +- .../testdata/const/fail_collapse.carbon | 16 +- .../function/call/empty_struct.carbon | 28 +-- .../testdata/function/call/empty_tuple.carbon | 28 +-- .../call/fail_return_type_mismatch.carbon | 28 +-- .../testdata/function/call/i32.carbon | 34 ++-- .../function/call/return_implicit.carbon | 4 +- .../if/fail_reachable_fallthrough.carbon | 98 +++++---- .../semantics/testdata/if/fail_scope.carbon | 40 ++-- .../if/unreachable_fallthrough.carbon | 28 +-- .../testdata/if_expression/basic.carbon | 38 ++-- .../if_expression/constant_condition.carbon | 100 ++++++---- .../if_expression/control_flow.carbon | 72 ++++--- .../testdata/if_expression/nested.carbon | 62 +++--- .../testdata/index/element_access.carbon | 12 +- .../testdata/index/fail_large_index.carbon | 12 +- .../testdata/index/fail_name_not_found.carbon | 4 +- .../index/fail_negative_indexing.carbon | 2 +- .../index/fail_non_deterministic_type.carbon | 12 +- .../index/fail_non_int_indexing.carbon | 8 +- .../index/fail_out_of_bound_access.carbon | 8 +- .../testdata/index/return_value_access.carbon | 44 +++-- .../ir/duplicate_name_same_line.carbon | 8 +- .../semantics/testdata/operators/and.carbon | 64 +++--- .../testdata/operators/assignment.carbon | 44 ++--- .../testdata/operators/binary_op.carbon | 16 +- .../fail_assigment_to_non_assignable.carbon | 186 +++++++++--------- .../operators/fail_type_mismatch.carbon | 16 +- .../fail_type_mismatch_assignment.carbon | 8 +- .../operators/fail_type_mismatch_once.carbon | 18 +- .../semantics/testdata/operators/or.carbon | 68 ++++--- .../testdata/operators/unary_op.carbon | 16 +- .../testdata/pointer/address_of_deref.carbon | 34 ++-- .../testdata/pointer/address_of_lvalue.carbon | 32 +-- .../semantics/testdata/pointer/basic.carbon | 40 ++-- .../pointer/fail_address_of_value.carbon | 134 +++++++------ .../pointer/fail_type_mismatch.carbon | 16 +- .../testdata/pointer/nested_const.carbon | 24 ++- .../semantics/testdata/pointer/types.carbon | 46 +++-- .../testdata/return/code_after_return.carbon | 2 +- .../return/code_after_return_value.carbon | 26 +-- .../return/fail_missing_return.carbon | 8 +- .../fail_missing_return_empty_tuple.carbon | 8 +- .../testdata/return/fail_type_mismatch.carbon | 14 +- .../testdata/return/fail_value_missing.carbon | 8 +- .../semantics/testdata/return/struct.carbon | 28 +-- .../semantics/testdata/return/tuple.carbon | 28 +-- .../semantics/testdata/return/value.carbon | 14 +- .../semantics/testdata/struct/empty.carbon | 8 +- .../testdata/struct/fail_assign_empty.carbon | 4 +- .../testdata/struct/fail_assign_nested.carbon | 4 +- .../struct/fail_assign_to_empty.carbon | 4 +- .../struct/fail_field_name_mismatch.carbon | 4 +- .../struct/fail_field_type_mismatch.carbon | 4 +- .../struct/fail_member_access_type.carbon | 8 +- .../struct/fail_non_member_access.carbon | 8 +- .../struct/fail_too_few_values.carbon | 4 +- .../testdata/struct/fail_type_assign.carbon | 4 +- .../testdata/struct/member_access.carbon | 12 +- .../testdata/struct/one_entry.carbon | 8 +- .../testdata/struct/tuple_as_element.carbon | 8 +- .../testdata/struct/two_entries.carbon | 8 +- .../semantics/testdata/tuples/empty.carbon | 8 +- .../testdata/tuples/fail_assign_empty.carbon | 4 +- .../testdata/tuples/fail_assign_nested.carbon | 4 +- .../tuples/fail_assign_to_empty.carbon | 4 +- .../tuples/fail_element_type_mismatch.carbon | 4 +- .../tuples/fail_too_few_element.carbon | 4 +- .../testdata/tuples/fail_type_assign.carbon | 4 +- .../testdata/tuples/nested_tuple.carbon | 4 +- .../testdata/tuples/one_element.carbon | 8 +- .../testdata/tuples/two_elements.carbon | 8 +- .../testdata/var/decl_with_init.carbon | 4 +- .../testdata/var/fail_duplicate_decl.carbon | 8 +- .../var/fail_init_type_mismatch.carbon | 4 +- .../testdata/var/fail_init_with_self.carbon | 4 +- .../var/fail_lookup_outside_scope.carbon | 4 +- .../var/fail_storage_is_literal.carbon | 4 +- .../testdata/var/global_decl_with_init.carbon | 4 +- .../testdata/var/global_lookup.carbon | 8 +- .../var/global_lookup_in_scope.carbon | 8 +- .../semantics/testdata/var/lookup.carbon | 4 +- 98 files changed, 1107 insertions(+), 839 deletions(-) diff --git a/toolchain/lowering/lowering_handle_expression_category.cpp b/toolchain/lowering/lowering_handle_expression_category.cpp index 533ae80161eea..f966a3b7a5a50 100644 --- a/toolchain/lowering/lowering_handle_expression_category.cpp +++ b/toolchain/lowering/lowering_handle_expression_category.cpp @@ -9,7 +9,9 @@ namespace Carbon { auto LoweringHandleInitializeFrom(LoweringFunctionContext& context, SemanticsNodeId node_id, SemanticsNode node) -> void { - context.SetLocal(node_id, context.GetLocal(node.GetAsInitializeFrom())); + // TODO: If the value representation is indirect, perform the copy. + auto [init_value_id, target_id] = node.GetAsInitializeFrom(); + context.SetLocal(node_id, context.GetLocal(init_value_id)); } auto LoweringHandleMaterializeTemporary(LoweringFunctionContext& context, diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 3546c2dbfc94a..f9501a7334003 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -268,8 +268,8 @@ auto SemanticsContext::is_current_position_reachable() -> bool { } } -auto SemanticsContext::ConvertToInitializingExpression(SemanticsNodeId expr_id) - -> SemanticsNodeId { +auto SemanticsContext::ConvertToInitializingExpression( + SemanticsNodeId expr_id, SemanticsNodeId target_id) -> SemanticsNodeId { SemanticsNode expr = semantics_ir().GetNode(expr_id); switch (GetSemanticsExpressionCategory(semantics_ir(), expr_id)) { case SemanticsExpressionCategory::NotExpression: @@ -291,9 +291,10 @@ auto SemanticsContext::ConvertToInitializingExpression(SemanticsNodeId expr_id) // TODO: For class types, use an interface to determine how to perform // this operation. return AddNode(SemanticsNode::InitializeFrom::Make( - expr.parse_node(), expr.type_id(), expr_id)); + expr.parse_node(), expr.type_id(), expr_id, target_id)); case SemanticsExpressionCategory::Initializing: + MarkInitializerFor(expr_id, target_id); return expr_id; } } @@ -306,12 +307,16 @@ auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) CARBON_FATAL() << "Converting non-expression node " << expr << " to value expression"; - case SemanticsExpressionCategory::Initializing: + case SemanticsExpressionCategory::Initializing: { // TODO: For class types, use an interface to determine how to perform // this operation. - expr_id = AddNode(SemanticsNode::MaterializeTemporary::Make( + auto temp_id = AddNode(SemanticsNode::MaterializeTemporary::Make( expr.parse_node(), expr.type_id(), expr_id)); + // TODO: The temporary materialization appears later in the IR than the + // expression that initializes it. + MarkInitializerFor(expr_id, temp_id); [[fallthrough]]; + } case SemanticsExpressionCategory::DurableReference: case SemanticsExpressionCategory::EphemeralReference: @@ -324,6 +329,36 @@ auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) } } +auto SemanticsContext::MarkInitializerFor(SemanticsNodeId init_id, + SemanticsNodeId target_id) -> void { + SemanticsNode init = semantics_ir().GetNode(init_id); + CARBON_CHECK(GetSemanticsExpressionCategory(semantics_ir(), init_id) == + SemanticsExpressionCategory::Initializing) + << "initialization from non-initializing node " << init; + (void)target_id; + while (true) { + switch (init.kind()) { + default: + CARBON_FATAL() << "Initialization from unexpected node " << init; + + case SemanticsNodeKind::Call: + case SemanticsNodeKind::StructAccess: + case SemanticsNodeKind::StructValue: + case SemanticsNodeKind::TupleIndex: + case SemanticsNodeKind::TupleValue: + CARBON_FATAL() << init << " is not modeled as initializing yet"; + + case SemanticsNodeKind::StubReference: { + init_id = init.GetAsStubReference(); + continue; + } + + case SemanticsNodeKind::InitializeFrom: + CARBON_FATAL() << init << " should be created with a destination"; + } + } +} + auto SemanticsContext::ImplicitAsForArgs( SemanticsNodeBlockId arg_refs_id, ParseTree::Node param_parse_node, SemanticsNodeBlockId param_refs_id, diff --git a/toolchain/semantics/semantics_context.h b/toolchain/semantics/semantics_context.h index 76f4e364fcdfd..1a442a9d1cc9a 100644 --- a/toolchain/semantics/semantics_context.h +++ b/toolchain/semantics/semantics_context.h @@ -111,19 +111,22 @@ class SemanticsContext { auto is_current_position_reachable() -> bool; // Convert the given expression to an initializing expression of the same - // type. - auto ConvertToInitializingExpression(SemanticsNodeId expr_id) + // type. `target_id` is a reference expression describing the object that is + // initialized. + auto ConvertToInitializingExpression(SemanticsNodeId expr_id, + SemanticsNodeId target_id) -> SemanticsNodeId; // Convert the given expression to a value expression of the same type. auto ConvertToValueExpression(SemanticsNodeId expr_id) -> SemanticsNodeId; - // Converts `value_id` to an initializing expression of type `type_id`. - auto ConvertToInitializerOfType(ParseTree::Node parse_node, - SemanticsNodeId value_id, - SemanticsTypeId type_id) -> SemanticsNodeId { + // Performs initialization of `target_id` from `value_id`. Returns the + // converted initializer value. + auto Initialize(ParseTree::Node parse_node, SemanticsNodeId target_id, + SemanticsNodeId value_id) -> SemanticsNodeId { + auto type_id = semantics_ir().GetNode(target_id).type_id(); return ConvertToInitializingExpression( - ImplicitAsRequired(parse_node, value_id, type_id)); + ImplicitAsRequired(parse_node, value_id, type_id), target_id); } // Converts `value_id` to a value expression of type `type_id`. @@ -286,6 +289,10 @@ class SemanticsContext { // TODO: This likely needs to track things which need to be destructed. }; + // Marks the initializer `init_id` as initializing `target_id`. + auto MarkInitializerFor(SemanticsNodeId target_id, SemanticsNodeId init_id) + -> void; + // Runs ImplicitAs behavior to convert `value` to `as_type`, returning the // result type. The result will be the node to use to replace `value`. // diff --git a/toolchain/semantics/semantics_handle_function.cpp b/toolchain/semantics/semantics_handle_function.cpp index e6d7cd2eb492e..aa3baa9ce9451 100644 --- a/toolchain/semantics/semantics_handle_function.cpp +++ b/toolchain/semantics/semantics_handle_function.cpp @@ -11,10 +11,14 @@ namespace Carbon { // definition syntax. static auto BuildFunctionDeclaration(SemanticsContext& context) -> std::pair { - SemanticsTypeId return_type_id = SemanticsTypeId::Invalid; + auto return_type_id = SemanticsTypeId::Invalid; + auto return_slot_id = SemanticsNodeId::Invalid; if (context.parse_tree().node_kind(context.node_stack().PeekParseNode()) == ParseNodeKind::ReturnType) { - return_type_id = context.node_stack().Pop(); + return_slot_id = context.node_stack().Pop(); + // TODO: Consider removing return_type_id from SemanticsFunction, as it can + // be derived from the return_slot_id. + return_type_id = context.semantics_ir().GetNode(return_slot_id).type_id(); } SemanticsNodeBlockId param_refs_id = context.node_stack().Pop(); @@ -34,6 +38,7 @@ static auto BuildFunctionDeclaration(SemanticsContext& context) : SemanticsStringId(SemanticsStringId::InvalidIndex), .param_refs_id = param_refs_id, .return_type_id = return_type_id, + .return_slot_id = return_slot_id, .body_block_ids = {}}); auto decl_id = context.AddNode( SemanticsNode::FunctionDeclaration::Make(fn_node, function_id)); @@ -113,8 +118,16 @@ auto SemanticsHandleReturnType(SemanticsContext& context, // Propagate the type expression. auto [type_parse_node, type_node_id] = context.node_stack().PopExpressionWithParseNode(); - auto cast_node_id = context.ExpressionAsType(type_parse_node, type_node_id); - context.node_stack().Push(parse_node, cast_node_id); + auto type_id = context.ExpressionAsType(type_parse_node, type_node_id); + // TODO: Like the function parameters, the return slot is added to an + // unreferenced node block. We should either stop constructing this block or + // store it somewhere. + // + // See also SemanticsHandleParameterList. + context.node_block_stack().Push(); + context.AddNodeAndPush(parse_node, + SemanticsNode::VarStorage::Make(parse_node, type_id)); + context.node_block_stack().Pop(); return true; } diff --git a/toolchain/semantics/semantics_handle_operator.cpp b/toolchain/semantics/semantics_handle_operator.cpp index 1e0abb0dc9300..814b5d934726c 100644 --- a/toolchain/semantics/semantics_handle_operator.cpp +++ b/toolchain/semantics/semantics_handle_operator.cpp @@ -60,8 +60,7 @@ auto SemanticsHandleInfixOperator(SemanticsContext& context, "Expression is not assignable."); context.emitter().Emit(lhs_node, AssignmentToNonAssignable); } - rhs_id = context.ConvertToInitializerOfType( - parse_node, rhs_id, context.semantics_ir().GetNode(lhs_id).type_id()); + rhs_id = context.Initialize(parse_node, lhs_id, rhs_id); context.AddNodeAndPush( parse_node, SemanticsNode::Assign::Make(parse_node, lhs_id, rhs_id)); return true; diff --git a/toolchain/semantics/semantics_handle_parameter_list.cpp b/toolchain/semantics/semantics_handle_parameter_list.cpp index b97b7ff826979..0d540796a29bd 100644 --- a/toolchain/semantics/semantics_handle_parameter_list.cpp +++ b/toolchain/semantics/semantics_handle_parameter_list.cpp @@ -27,6 +27,8 @@ auto SemanticsHandleParameterList(SemanticsContext& context, // Note, the underlying issue is that the LLVM IR has nowhere clear to emit, // so changing storage would require addressing that problem. For comparison // with function calls, the IR needs to be emitted prior to the call. + // + // The same applies to the return slot. See also SemanticsHandleReturnType. context.node_block_stack().Pop(); context.PopScope(); diff --git a/toolchain/semantics/semantics_handle_statement.cpp b/toolchain/semantics/semantics_handle_statement.cpp index 29eb14a88b717..4dd1369558e52 100644 --- a/toolchain/semantics/semantics_handle_statement.cpp +++ b/toolchain/semantics/semantics_handle_statement.cpp @@ -57,8 +57,7 @@ auto SemanticsHandleReturnStatement(SemanticsContext& context, .Note(fn_node.parse_node(), ReturnStatementImplicitNote) .Emit(); } else { - arg = context.ConvertToInitializerOfType(parse_node, arg, - callable.return_type_id); + arg = context.Initialize(parse_node, callable.return_slot_id, arg); } context.AddNode(SemanticsNode::ReturnExpression::Make(parse_node, arg)); diff --git a/toolchain/semantics/semantics_handle_variable.cpp b/toolchain/semantics/semantics_handle_variable.cpp index 79baa1fe40a1f..f37fa96f4639a 100644 --- a/toolchain/semantics/semantics_handle_variable.cpp +++ b/toolchain/semantics/semantics_handle_variable.cpp @@ -28,9 +28,8 @@ auto SemanticsHandleVariableDeclaration(SemanticsContext& context, context.AddNameToLookup(binding.parse_node(), name_id, storage_id); // If there was an initializer, assign it to storage. if (has_init) { - auto cast_value_id = context.ConvertToInitializerOfType( - parse_node, expr_node_id, - context.semantics_ir().GetNode(storage_id).type_id()); + auto cast_value_id = + context.Initialize(parse_node, storage_id, expr_node_id); context.AddNode( SemanticsNode::Assign::Make(parse_node, storage_id, cast_value_id)); } diff --git a/toolchain/semantics/semantics_ir.h b/toolchain/semantics/semantics_ir.h index ee208fe6e3e3b..cea1d1efe3315 100644 --- a/toolchain/semantics/semantics_ir.h +++ b/toolchain/semantics/semantics_ir.h @@ -22,6 +22,9 @@ struct SemanticsFunction { if (return_type_id.is_valid()) { out << ", return_type: " << return_type_id; } + if (return_slot_id.is_valid()) { + out << ", return_slot: " << return_slot_id; + } if (!body_block_ids.empty()) { out << llvm::formatv( ", body: {{{0}}}", @@ -36,6 +39,10 @@ struct SemanticsFunction { SemanticsNodeBlockId param_refs_id; // The return type. This will be invalid if the return type wasn't specified. SemanticsTypeId return_type_id; + // The storage for the return value, which is a reference expression whose + // type is the return type of the function. Will be invalid if the return type + // wasn't specified. + SemanticsNodeId return_slot_id; // A list of the statically reachable code blocks in the body of the // function, in lexical order. The first block is the entry block. This will // be empty for declarations that don't have a visible definition. diff --git a/toolchain/semantics/semantics_ir_formatter.cpp b/toolchain/semantics/semantics_ir_formatter.cpp index 66bf1da1f5f6c..ef37f82f8a6b0 100644 --- a/toolchain/semantics/semantics_ir_formatter.cpp +++ b/toolchain/semantics/semantics_ir_formatter.cpp @@ -54,6 +54,13 @@ class NodeNamer { fn.name_id.is_valid() ? semantics_ir.GetString(fn.name_id).str() : ""); CollectNamesInBlock(fn_scope, fn.param_refs_id); + if (fn.return_slot_id.is_valid()) { + nodes[fn.return_slot_id.index] = { + fn_scope, + GetScopeInfo(fn_scope).nodes.AllocateName( + *this, semantics_ir.GetNode(fn.return_slot_id).parse_node(), + "return")}; + } if (!fn.body_block_ids.empty()) { AddBlockLabel(fn_scope, fn.body_block_ids.front(), "entry", fn_loc); } @@ -436,6 +443,8 @@ class SemanticsIRFormatter { out_ << ")"; if (fn.return_type_id.is_valid()) { out_ << " -> "; + FormatNodeName(fn.return_slot_id); + out_ << ": "; FormatType(fn.return_type_id); } diff --git a/toolchain/semantics/semantics_node.h b/toolchain/semantics/semantics_node.h index 4bb342f6aea67..55b3ee75551f9 100644 --- a/toolchain/semantics/semantics_node.h +++ b/toolchain/semantics/semantics_node.h @@ -387,7 +387,8 @@ class SemanticsNode { SemanticsFunctionId /*function_id*/>; using InitializeFrom = - Factory; + Factory; using IntegerLiteral = Factory; diff --git a/toolchain/semantics/semantics_node_stack.h b/toolchain/semantics/semantics_node_stack.h index 7ffb61d7a1697..db1b7290103e8 100644 --- a/toolchain/semantics/semantics_node_stack.h +++ b/toolchain/semantics/semantics_node_stack.h @@ -253,6 +253,7 @@ class SemanticsNodeStack { case ParseNodeKind::PatternBinding: case ParseNodeKind::PostfixOperator: case ParseNodeKind::PrefixOperator: + case ParseNodeKind::ReturnType: case ParseNodeKind::ShortCircuitOperand: case ParseNodeKind::StructFieldValue: case ParseNodeKind::StructLiteral: @@ -268,8 +269,6 @@ class SemanticsNodeStack { return IdKind::SemanticsFunctionId; case ParseNodeKind::Name: return IdKind::SemanticsStringId; - case ParseNodeKind::ReturnType: - return IdKind::SemanticsTypeId; case ParseNodeKind::CodeBlockStart: case ParseNodeKind::FunctionIntroducer: case ParseNodeKind::IfCondition: diff --git a/toolchain/semantics/testdata/basics/builtin_types.carbon b/toolchain/semantics/testdata/basics/builtin_types.carbon index 713edd99348c4..b82a306e73da4 100644 --- a/toolchain/semantics/testdata/basics/builtin_types.carbon +++ b/toolchain/semantics/testdata/basics/builtin_types.carbon @@ -36,21 +36,21 @@ var test_type: type = i32; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type1}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type2}, // CHECK:STDOUT: {kind: StringLiteral, arg0: str3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+10, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+13}, // CHECK:STDOUT: {kind: VarStorage, type: typeTypeType}, // CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+15, type: typeTypeType}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeIntegerType, type: typeTypeType}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeIntegerType, arg1: node+15, type: typeTypeType}, // CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -82,17 +82,17 @@ var test_type: type = i32; // CHECK:STDOUT: package { // CHECK:STDOUT: %test_i32: i32 = var // CHECK:STDOUT: %.loc7_21.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_21.2: i32 = initialize_from %.loc7_21.1 +// CHECK:STDOUT: %.loc7_21.2: i32 = initialize_from %.loc7_21.1, %test_i32 // CHECK:STDOUT: assign %test_i32, %.loc7_21.2 // CHECK:STDOUT: %test_f64: f64 = var // CHECK:STDOUT: %.loc8_21.1: f64 = real_literal 1e-1 -// CHECK:STDOUT: %.loc8_21.2: f64 = initialize_from %.loc8_21.1 +// CHECK:STDOUT: %.loc8_21.2: f64 = initialize_from %.loc8_21.1, %test_f64 // CHECK:STDOUT: assign %test_f64, %.loc8_21.2 // CHECK:STDOUT: %test_str: String = var // CHECK:STDOUT: %.loc9_24.1: String = string_literal "Test" -// CHECK:STDOUT: %.loc9_24.2: String = initialize_from %.loc9_24.1 +// CHECK:STDOUT: %.loc9_24.2: String = initialize_from %.loc9_24.1, %test_str // CHECK:STDOUT: assign %test_str, %.loc9_24.2 // CHECK:STDOUT: %test_type: type = var -// CHECK:STDOUT: %.1: type = initialize_from i32 +// CHECK:STDOUT: %.1: type = initialize_from i32, %test_type // CHECK:STDOUT: assign %test_type, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon index 366e2da6dde8e..e7f04383bceea 100644 --- a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon +++ b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon @@ -29,7 +29,7 @@ var x: type = 42; // CHECK:STDOUT: {kind: VarStorage, type: typeTypeType}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: typeTypeType}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+0, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -47,6 +47,6 @@ var x: type = 42; // CHECK:STDOUT: package { // CHECK:STDOUT: %x: type = var // CHECK:STDOUT: %.loc10: i32 = int_literal 42 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon index d6463d4d9e1c7..49e8ef0a4457f 100644 --- a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon +++ b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon @@ -32,7 +32,7 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -51,6 +51,6 @@ var y: i32 = x.b; // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %y // CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/parens.carbon b/toolchain/semantics/testdata/basics/parens.carbon index a706d0600f992..284e604cb94f9 100644 --- a/toolchain/semantics/testdata/basics/parens.carbon +++ b/toolchain/semantics/testdata/basics/parens.carbon @@ -29,7 +29,7 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+3, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -51,6 +51,6 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: %.loc7_23: i32 = int_literal 1 // CHECK:STDOUT: %.loc7_29: i32 = int_literal 2 // CHECK:STDOUT: %.loc7_26.1: i32 = add %.loc7_23, %.loc7_29 -// CHECK:STDOUT: %.loc7_26.2: i32 = initialize_from %.loc7_26.1 +// CHECK:STDOUT: %.loc7_26.2: i32 = initialize_from %.loc7_26.1, %test_i32 // CHECK:STDOUT: assign %test_i32, %.loc7_26.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index 99254517f0955..c4a8db422ff83 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -14,7 +14,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type3, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type3, return_slot: node+9, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -42,10 +42,11 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: {kind: ConstType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, type: type3}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+9, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -65,12 +66,15 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -82,9 +86,9 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: %.loc11_1 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%p: const i32**) -> const i32** { +// CHECK:STDOUT: fn @F(%p: const i32**) -> %return: const i32** { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_6.1: const i32** = value_binding %p -// CHECK:STDOUT: %.loc11_6.2: const i32** = initialize_from %.loc11_6.1 +// CHECK:STDOUT: %.loc11_6.2: const i32** = initialize_from %.loc11_6.1, %return // CHECK:STDOUT: return %.loc11_6.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/fail_collapse.carbon b/toolchain/semantics/testdata/const/fail_collapse.carbon index a2ad5e8cde7c9..fefb72a224ea7 100644 --- a/toolchain/semantics/testdata/const/fail_collapse.carbon +++ b/toolchain/semantics/testdata/const/fail_collapse.carbon @@ -16,7 +16,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type5, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type5, return_slot: node+8, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -45,9 +45,10 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+4, type: type3}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type4, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type5}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+8, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -66,11 +67,14 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,8 +84,8 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: %.loc10_1 = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(%p: const i32**) -> i32** { +// CHECK:STDOUT: fn @G(%p: const i32**) -> %return: i32** { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index 9eead8b54beb7..cc9cb0dbfa016 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -14,8 +14,8 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: {block4}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+5, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -37,14 +37,15 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -61,22 +62,25 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -86,10 +90,10 @@ fn Main() { // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Echo(%a: {}) -> {} { +// CHECK:STDOUT: fn @Echo(%a: {}) -> %return: {} { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_9.1: {} = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: {} = initialize_from %.loc7_9.1 +// CHECK:STDOUT: %.loc7_9.2: {} = initialize_from %.loc7_9.1, %return // CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index 9c30a04914655..d0bd87fd1df1d 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -14,8 +14,8 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: {block4}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+5, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -39,14 +39,15 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -63,22 +64,25 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -88,10 +92,10 @@ fn Main() { // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Echo(%a: ()) -> () { +// CHECK:STDOUT: fn @Echo(%a: ()) -> %return: () { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_9.1: () = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: () = initialize_from %.loc7_9.1 +// CHECK:STDOUT: %.loc7_9.2: () = initialize_from %.loc7_9.1, %return // CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon index f03c27d9d0c6f..50f6ed25d4ce6 100644 --- a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon @@ -15,8 +15,8 @@ fn Run() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -35,16 +35,17 @@ fn Run() { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+6, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -52,20 +53,23 @@ fn Run() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -74,10 +78,10 @@ fn Run() { // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Foo() -> f64 { +// CHECK:STDOUT: fn @Foo() -> %return: f64 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_26.1: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.loc7_26.2: f64 = initialize_from %.loc7_26.1 +// CHECK:STDOUT: %.loc7_26.2: f64 = initialize_from %.loc7_26.1, %return // CHECK:STDOUT: return %.loc7_26.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -85,7 +89,7 @@ fn Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc13: f64 = call @Foo() -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index ea03c959e210e..6f3e89e17bfab 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -14,8 +14,8 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: {block4}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+2, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -36,18 +36,19 @@ fn Main() { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+7, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+8, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+12}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+13}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -62,15 +63,17 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, @@ -78,9 +81,10 @@ fn Main() { // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -89,10 +93,10 @@ fn Main() { // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Echo(%a: i32) -> i32 { +// CHECK:STDOUT: fn @Echo(%a: i32) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_9.1: i32 = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: i32 = initialize_from %.loc7_9.1 +// CHECK:STDOUT: %.loc7_9.2: i32 = initialize_from %.loc7_9.1, %return // CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -102,7 +106,7 @@ fn Main() { // CHECK:STDOUT: %.loc12_21.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc12_21.2: i32 = stub_reference %.loc12_21.1 // CHECK:STDOUT: %.loc12_20.1: i32 = call @Echo(%.loc12_21.2) -// CHECK:STDOUT: %.loc12_20.2: i32 = initialize_from %.loc12_20.1 +// CHECK:STDOUT: %.loc12_20.2: i32 = initialize_from %.loc12_20.1, %b // CHECK:STDOUT: assign %b, %.loc12_20.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/return_implicit.carbon b/toolchain/semantics/testdata/function/call/return_implicit.carbon index db09cef4fd2ce..6545566fa4b72 100644 --- a/toolchain/semantics/testdata/function/call/return_implicit.carbon +++ b/toolchain/semantics/testdata/function/call/return_implicit.carbon @@ -41,7 +41,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -83,7 +83,7 @@ fn Main() { // CHECK:STDOUT: %.loc11_11.2: () = tuple_value () // CHECK:STDOUT: %b: () = var // CHECK:STDOUT: %.loc11_37.1: () = call @MakeImplicitEmptyTuple() -// CHECK:STDOUT: %.loc11_37.2: () = initialize_from %.loc11_37.1 +// CHECK:STDOUT: %.loc11_37.2: () = initialize_from %.loc11_37.1, %b // CHECK:STDOUT: assign %b, %.loc11_37.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index b1f5452ddb65a..45311876e66f6 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -35,9 +35,9 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block6, block7}}}, -// CHECK:STDOUT: {name: str2, param_refs: block9, return_type: type1, body: {block10, block11, block12, block13}}}, -// CHECK:STDOUT: {name: str3, param_refs: block15, return_type: type1, body: {block16, block17, block18}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block5, block6, block7, block8}}}, +// CHECK:STDOUT: {name: str2, param_refs: block10, return_type: type1, return_slot: node+13, body: {block12, block13, block14, block15}}}, +// CHECK:STDOUT: {name: str3, param_refs: block17, return_type: type1, return_slot: node+24, body: {block19, block20, block21}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -61,34 +61,37 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, -// CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+4}, // CHECK:STDOUT: {kind: Branch, arg0: block7}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+13}, -// CHECK:STDOUT: {kind: Branch, arg0: block12}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+15}, +// CHECK:STDOUT: {kind: Branch, arg0: block14}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, -// CHECK:STDOUT: {kind: Branch, arg0: block13}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, +// CHECK:STDOUT: {kind: Branch, arg0: block15}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+20, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+22, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+23}, -// CHECK:STDOUT: {kind: Branch, arg0: block18}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+22, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block20, arg1: node+26}, +// CHECK:STDOUT: {kind: Branch, arg0: block21}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+26, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+27}, -// CHECK:STDOUT: {kind: Branch, arg0: block18}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+29, arg1: node+24, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+30}, +// CHECK:STDOUT: {kind: Branch, arg0: block21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -102,57 +105,61 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+22, // CHECK:STDOUT: node+23, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+25, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+26, @@ -160,6 +167,11 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+30, +// CHECK:STDOUT: node+31, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -169,14 +181,14 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: %.loc27 = fn_decl @If3 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @If1(%b: bool) -> i32 { +// CHECK:STDOUT: fn @If1(%b: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc9_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 +// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1, %return // CHECK:STDOUT: return %.loc9_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: @@ -185,7 +197,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: !if.done: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @If2(%b: bool) -> i32 { +// CHECK:STDOUT: fn @If2(%b: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc17: bool = value_binding %b // CHECK:STDOUT: if %.loc17 br !if.then else br !if.else @@ -195,20 +207,20 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: %.loc20_12.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc20_12.2: i32 = initialize_from %.loc20_12.1 +// CHECK:STDOUT: %.loc20_12.2: i32 = initialize_from %.loc20_12.1, %return // CHECK:STDOUT: return %.loc20_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.done: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @If3(%b: bool) -> i32 { +// CHECK:STDOUT: fn @If3(%b: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc27: bool = value_binding %b // CHECK:STDOUT: if %.loc27 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc29_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc29_12.2: i32 = initialize_from %.loc29_12.1 +// CHECK:STDOUT: %.loc29_12.2: i32 = initialize_from %.loc29_12.1, %return // CHECK:STDOUT: return %.loc29_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index a2ff16ea3dc33..9df85585e7eba 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -17,7 +17,7 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block5, block6, block7}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 2, @@ -38,21 +38,22 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, -// CHECK:STDOUT: {kind: Branch, arg0: block6}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+4}, +// CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, -// CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, arg1: node+7, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: Branch, arg0: block7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -69,11 +70,13 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, @@ -81,10 +84,11 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -92,7 +96,7 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @VarScope // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @VarScope(%b: bool) -> i32 { +// CHECK:STDOUT: fn @VarScope(%b: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else @@ -100,13 +104,13 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n: i32 = var // CHECK:STDOUT: %.loc9_18.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc9_18.2: i32 = initialize_from %.loc9_18.1 +// CHECK:STDOUT: %.loc9_18.2: i32 = initialize_from %.loc9_18.1, %n // CHECK:STDOUT: assign %n, %.loc9_18.2 // CHECK:STDOUT: %.loc9_9.1: i32 = value_binding %n -// CHECK:STDOUT: %.loc9_9.2: i32 = initialize_from %.loc9_9.1 +// CHECK:STDOUT: %.loc9_9.2: i32 = initialize_from %.loc9_9.1, %return // CHECK:STDOUT: return %.loc9_9.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index a6a55cbbe14ce..279cbeb407c0a 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -15,7 +15,7 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block5, block6, block7}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -36,16 +36,17 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, -// CHECK:STDOUT: {kind: Branch, arg0: block6}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+4}, +// CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -62,18 +63,21 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -81,18 +85,18 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @If // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @If(%b: bool) -> i32 { +// CHECK:STDOUT: fn @If(%b: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc9_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 +// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1, %return // CHECK:STDOUT: return %.loc9_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: %.loc11_12.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc11_12.2: i32 = initialize_from %.loc11_12.1 +// CHECK:STDOUT: %.loc11_12.2: i32 = initialize_from %.loc11_12.1, %return // CHECK:STDOUT: return %.loc11_12.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index be988e63ce51f..a2ff76582a709 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -10,7 +10,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block6, block7}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+6, body: {block5, block6, block7, block8}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -35,21 +35,22 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+4, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, -// CHECK:STDOUT: {kind: Branch, arg0: block6}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+8}, +// CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+10, arg1: node+11, type: type1}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+11, arg1: node+12, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+13, arg1: node+14, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+12}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+15}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+14, arg1: node+15, type: type1}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block8, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block8, arg1: node+16}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block8, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -72,25 +73,28 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -98,7 +102,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%b: bool, %n: i32, %m: i32) -> i32 { +// CHECK:STDOUT: fn @F(%b: bool, %n: i32, %m: i32) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_6: bool = value_binding %b // CHECK:STDOUT: if %.loc7_6 br !if.expr.then else br !if.expr.else @@ -117,6 +121,6 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1, %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/constant_condition.carbon b/toolchain/semantics/testdata/if_expression/constant_condition.carbon index ab35232e494da..55965b14d894e 100644 --- a/toolchain/semantics/testdata/if_expression/constant_condition.carbon +++ b/toolchain/semantics/testdata/if_expression/constant_condition.carbon @@ -17,10 +17,10 @@ fn G() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: {block3}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: {block4, block5, block6, block7}}}, -// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, body: {block8, block9, block10, block11}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9, block10}}}, +// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, return_slot: node+22, body: {block12, block13, block14, block15}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -41,92 +41,108 @@ fn G() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+9}, -// CHECK:STDOUT: {kind: Branch, arg0: block6}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+12}, +// CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+12}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+13}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+15}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+20}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+20}, -// CHECK:STDOUT: {kind: Branch, arg0: block10}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+24}, +// CHECK:STDOUT: {kind: Branch, arg0: block14}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+23}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+24}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block11, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+28}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+27}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+28}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block15, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+31, arg1: node+22, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+32}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, // CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+28, // CHECK:STDOUT: node+29, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+30, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+32, +// CHECK:STDOUT: node+33, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -136,21 +152,21 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc14 = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @A() -> i32 { +// CHECK:STDOUT: fn @A() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 +// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1, %return // CHECK:STDOUT: return %.loc7_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @B() -> i32 { +// CHECK:STDOUT: fn @B() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_24.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 +// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1, %return // CHECK:STDOUT: return %.loc8_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> i32 { +// CHECK:STDOUT: fn @F() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_13: bool = bool_literal true // CHECK:STDOUT: if %.loc11_13 br !if.expr.then else br !if.expr.else @@ -165,11 +181,11 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 +// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1, %return // CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() -> i32 { +// CHECK:STDOUT: fn @G() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc15_13: bool = bool_literal false // CHECK:STDOUT: if %.loc15_13 br !if.expr.then else br !if.expr.else @@ -184,6 +200,6 @@ fn G() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc15_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc15_10.2: i32 = initialize_from %.loc15_10.1 +// CHECK:STDOUT: %.loc15_10.2: i32 = initialize_from %.loc15_10.1, %return // CHECK:STDOUT: return %.loc15_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index 4798c7cbfb6f9..3624222eccb57 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -13,9 +13,9 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: {block3}}}, -// CHECK:STDOUT: {name: str2, param_refs: block5, return_type: type0, body: {block6, block7, block8, block9}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type0, return_slot: node+12, body: {block9, block10, block11, block12}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -36,71 +36,83 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+8, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+10, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+8, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+11}, -// CHECK:STDOUT: {kind: Branch, arg0: block8}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type1}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+14}, +// CHECK:STDOUT: {kind: Branch, arg0: block11}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+15}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+17}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+18}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+12, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+22}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -109,21 +121,21 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: %.loc10 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @A() -> i32 { +// CHECK:STDOUT: fn @A() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 +// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1, %return // CHECK:STDOUT: return %.loc7_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @B() -> i32 { +// CHECK:STDOUT: fn @B() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_24.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 +// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1, %return // CHECK:STDOUT: return %.loc8_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%b: bool) -> i32 { +// CHECK:STDOUT: fn @F(%b: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10: bool = value_binding %b // CHECK:STDOUT: if %.loc10 br !if.expr.then else br !if.expr.else @@ -138,6 +150,6 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 +// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1, %return // CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index eecfbfd5017b3..8789e86f0d5e2 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -10,7 +10,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block7, block8, block9, block6, block10, block11, block12, block13}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+6, body: {block5, block6, block8, block9, block10, block7, block11, block12, block13, block14}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -39,31 +39,32 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+4, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, -// CHECK:STDOUT: {kind: Branch, arg0: block6}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+8}, +// CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+10}, -// CHECK:STDOUT: {kind: Branch, arg0: block8}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+11}, +// CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+13}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type1}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+14}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+15}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+18}, -// CHECK:STDOUT: {kind: Branch, arg0: block11}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+19}, +// CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+21}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+22}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+17}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+25}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+22}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+23}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+28, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+29}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+18}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+26}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block14, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+29, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+30}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -86,47 +87,50 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+22, // CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+23, // CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+26, // CHECK:STDOUT: node+28, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+29, // CHECK:STDOUT: node+30, +// CHECK:STDOUT: node+31, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -134,7 +138,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%a: bool, %b: bool, %c: bool) -> i32 { +// CHECK:STDOUT: fn @F(%a: bool, %b: bool, %c: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_6: bool = value_binding %a // CHECK:STDOUT: if %.loc7_6 br !if.expr.then.loc8_10 else br !if.expr.else.loc8_10 @@ -173,6 +177,6 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc8_10: // CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !if.expr.result.loc8_10 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1, %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/element_access.carbon b/toolchain/semantics/testdata/index/element_access.carbon index ae63d1b09dcfd..c8d010b10f216 100644 --- a/toolchain/semantics/testdata/index/element_access.carbon +++ b/toolchain/semantics/testdata/index/element_access.carbon @@ -45,21 +45,21 @@ var c: i32 = b[0]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+13, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: TupleIndex, arg0: node+13, arg1: node+20, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+18, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -112,18 +112,18 @@ var c: i32 = b[0]; // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 // CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 +// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1, %a // CHECK:STDOUT: assign %a, %.loc7_21.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var // CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1, %b // CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 // CHECK:STDOUT: %.loc9_17.1: i32 = tuple_index %b, %.loc9_16 // CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 -// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2 +// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2, %c // CHECK:STDOUT: assign %c, %.loc9_17.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_large_index.carbon b/toolchain/semantics/testdata/index/fail_large_index.carbon index 8065fe86e34c8..11988ed66160e 100644 --- a/toolchain/semantics/testdata/index/fail_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_large_index.carbon @@ -48,19 +48,19 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+13, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+18, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -111,16 +111,16 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 // CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 +// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1, %a // CHECK:STDOUT: assign %a, %.loc7_21.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var // CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1, %b // CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc12: i32 = int_literal -1 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %c // CHECK:STDOUT: assign %c, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_name_not_found.carbon b/toolchain/semantics/testdata/index/fail_name_not_found.carbon index cb3bc19aa17cf..e5f22a1186820 100644 --- a/toolchain/semantics/testdata/index/fail_name_not_found.carbon +++ b/toolchain/semantics/testdata/index/fail_name_not_found.carbon @@ -35,7 +35,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+1, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -63,7 +63,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 0 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %b // CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_negative_indexing.carbon b/toolchain/semantics/testdata/index/fail_negative_indexing.carbon index 985bc80194f9b..1af4209bfb7a7 100644 --- a/toolchain/semantics/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_negative_indexing.carbon @@ -52,7 +52,7 @@ var b: i32 = a[-10]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, diff --git a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon index 9505a16f25481..a0a05cc98e0e4 100644 --- a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon +++ b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon @@ -54,16 +54,16 @@ var c: i32 = a[b]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+19, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+19, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -116,13 +116,13 @@ var c: i32 = a[b]; // CHECK:STDOUT: %.loc7_25.1: i32 = int_literal 3 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 // CHECK:STDOUT: %.loc7_26.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = initialize_from %.loc7_26.1 +// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = initialize_from %.loc7_26.1, %a // CHECK:STDOUT: assign %a, %.loc7_26.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1 +// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1, %b // CHECK:STDOUT: assign %b, %.loc8_14.2 // CHECK:STDOUT: %c: i32 = var -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %c // CHECK:STDOUT: assign %c, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon b/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon index 57db4c342b2b2..980ce958c7de7 100644 --- a/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon @@ -53,12 +53,12 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+14, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -107,10 +107,10 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_26.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 // CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 +// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1, %a // CHECK:STDOUT: assign %a, %.loc7_27.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 26e-1 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %b // CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon b/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon index d2c1deb909dd2..2e970b44298e3 100644 --- a/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon +++ b/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon @@ -52,12 +52,12 @@ var b: i32 = a[2]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+14, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -106,10 +106,10 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_26.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 // CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 +// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1, %a // CHECK:STDOUT: assign %a, %.loc7_27.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 2 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %b // CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/return_value_access.carbon b/toolchain/semantics/testdata/index/return_value_access.carbon index 682dac745f30f..1ef085842e722 100644 --- a/toolchain/semantics/testdata/index/return_value_access.carbon +++ b/toolchain/semantics/testdata/index/return_value_access.carbon @@ -12,8 +12,8 @@ fn Run() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: {block3}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, return_slot: node+4, body: {block4}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, return_slot: node+11, body: {block7}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -43,18 +43,20 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+11, arg1: node+12, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+13, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+13, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+11, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -64,28 +66,34 @@ fn Run() -> i32 { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -98,20 +106,20 @@ fn Run() -> i32 { // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> (i32,) { +// CHECK:STDOUT: fn @F() -> %return: (i32,) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_28.1: i32 = int_literal 0 // CHECK:STDOUT: %.loc7_28.2: i32 = stub_reference %.loc7_28.1 // CHECK:STDOUT: %.loc7_30.1: (i32,) = tuple_value (%.loc7_28.2) -// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1 +// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1, %return // CHECK:STDOUT: return %.loc7_30.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Run() -> i32 { +// CHECK:STDOUT: fn @Run() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_11: (i32,) = call @F() // CHECK:STDOUT: %.loc10_14: i32 = int_literal 0 // CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11, %.loc10_14 -// CHECK:STDOUT: %.loc10_15.2: i32 = initialize_from %.loc10_15.1 +// CHECK:STDOUT: %.loc10_15.2: i32 = initialize_from %.loc10_15.1, %return // CHECK:STDOUT: return %.loc10_15.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon index 2d72bc8b1b7f1..5d8cc56935a5c 100644 --- a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon +++ b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon @@ -31,7 +31,7 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, // CHECK:STDOUT: {kind: BranchIf, arg0: block3, arg1: node+6}, @@ -39,7 +39,7 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+9, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+9, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+9, arg1: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block4}, // CHECK:STDOUT: {kind: Return}, @@ -81,7 +81,7 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n.loc7_14: i32 = var // CHECK:STDOUT: %.loc7_23.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_23.2: i32 = initialize_from %.loc7_23.1 +// CHECK:STDOUT: %.loc7_23.2: i32 = initialize_from %.loc7_23.1, %n.loc7_14 // CHECK:STDOUT: assign %n.loc7_14, %.loc7_23.2 // CHECK:STDOUT: %.loc7_30: bool = bool_literal true // CHECK:STDOUT: if %.loc7_30 br !if.then else br !if.else @@ -89,7 +89,7 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n.loc7_42: i32 = var // CHECK:STDOUT: %.loc7_51.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc7_51.2: i32 = initialize_from %.loc7_51.1 +// CHECK:STDOUT: %.loc7_51.2: i32 = initialize_from %.loc7_51.1, %n.loc7_42 // CHECK:STDOUT: assign %n.loc7_42, %.loc7_51.2 // CHECK:STDOUT: br !if.else // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/operators/and.carbon b/toolchain/semantics/testdata/operators/and.carbon index f78bf140ceea9..7fd59ec0ad9cd 100644 --- a/toolchain/semantics/testdata/operators/and.carbon +++ b/toolchain/semantics/testdata/operators/and.carbon @@ -13,9 +13,9 @@ fn And() -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: {block3}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: {block4, block5, block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -32,58 +32,70 @@ fn And() -> bool { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+9}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+10}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+13}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+13}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block6, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+16}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -92,21 +104,21 @@ fn And() -> bool { // CHECK:STDOUT: %.loc10 = fn_decl @And // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> bool { +// CHECK:STDOUT: fn @F() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 +// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1, %return // CHECK:STDOUT: return %.loc7_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() -> bool { +// CHECK:STDOUT: fn @G() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 +// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1, %return // CHECK:STDOUT: return %.loc8_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @And() -> bool { +// CHECK:STDOUT: fn @And() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_11: bool = call @F() // CHECK:STDOUT: %.loc11_14.1: bool = bool_literal false @@ -118,6 +130,6 @@ fn And() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: !and.result: // CHECK:STDOUT: %.loc11_14.2: bool = block_arg !and.result -// CHECK:STDOUT: %.loc11_14.3: bool = initialize_from %.loc11_14.2 +// CHECK:STDOUT: %.loc11_14.3: bool = initialize_from %.loc11_14.2, %return // CHECK:STDOUT: return %.loc11_14.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/assignment.carbon b/toolchain/semantics/testdata/operators/assignment.carbon index 43fa0469b7ba1..1e60e4a307f15 100644 --- a/toolchain/semantics/testdata/operators/assignment.carbon +++ b/toolchain/semantics/testdata/operators/assignment.carbon @@ -74,10 +74,10 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+7}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, @@ -91,17 +91,17 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, arg1: node+14, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+21}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+23, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+24, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+24, arg1: node+26}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, // CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+28, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, arg1: node+29, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+29, arg1: node+31}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, @@ -115,26 +115,26 @@ fn Main() { // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+41, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+44, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+44, arg1: node+36, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+36, arg1: node+45}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+36, arg1: member0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+48, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+48, arg1: node+47, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+47, arg1: node+49}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+36, arg1: member1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+52, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+52, arg1: node+51, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+51, arg1: node+53}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type4}, // CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+56, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+58, type: type4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+58, arg1: node+56, type: type4}, // CHECK:STDOUT: {kind: Assign, arg0: node+56, arg1: node+59}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+56, type: type4}, // CHECK:STDOUT: {kind: Dereference, arg0: node+61, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+63, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+63, arg1: node+62, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+62, arg1: node+64}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type5}, // CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+66}, @@ -146,7 +146,7 @@ fn Main() { // CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type4}, // CHECK:STDOUT: {kind: Dereference, arg0: node+73, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+75, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+75, arg1: node+74, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+74, arg1: node+76}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -270,10 +270,10 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 12 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %a // CHECK:STDOUT: assign %a, %.loc8_16.2 // CHECK:STDOUT: %.loc9_7.1: i32 = int_literal -7 -// CHECK:STDOUT: %.loc9_7.2: i32 = initialize_from %.loc9_7.1 +// CHECK:STDOUT: %.loc9_7.2: i32 = initialize_from %.loc9_7.1, %a // CHECK:STDOUT: assign %a, %.loc9_7.2 // CHECK:STDOUT: %.loc11_11: type = stub_reference i32 // CHECK:STDOUT: %.loc11_16: type = stub_reference i32 @@ -286,17 +286,17 @@ fn Main() { // CHECK:STDOUT: %.loc11_27.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc11_27.2: i32 = stub_reference %.loc11_27.1 // CHECK:STDOUT: %.loc11_28.1: (i32, i32) = tuple_value (%.loc11_24.2, %.loc11_27.2) -// CHECK:STDOUT: %.loc11_28.2: (i32, i32) = initialize_from %.loc11_28.1 +// CHECK:STDOUT: %.loc11_28.2: (i32, i32) = initialize_from %.loc11_28.1, %b // CHECK:STDOUT: assign %b, %.loc11_28.2 // CHECK:STDOUT: %.loc12_5: i32 = int_literal 0 // CHECK:STDOUT: %.loc12_6: i32 = tuple_index %b, %.loc12_5 // CHECK:STDOUT: %.loc12_10.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc12_10.2: i32 = initialize_from %.loc12_10.1 +// CHECK:STDOUT: %.loc12_10.2: i32 = initialize_from %.loc12_10.1, %.loc12_6 // CHECK:STDOUT: assign %.loc12_6, %.loc12_10.2 // CHECK:STDOUT: %.loc13_5: i32 = int_literal 1 // CHECK:STDOUT: %.loc13_6: i32 = tuple_index %b, %.loc13_5 // CHECK:STDOUT: %.loc13_10.1: i32 = int_literal 4 -// CHECK:STDOUT: %.loc13_10.2: i32 = initialize_from %.loc13_10.1 +// CHECK:STDOUT: %.loc13_10.2: i32 = initialize_from %.loc13_10.1, %.loc13_6 // CHECK:STDOUT: assign %.loc13_6, %.loc13_10.2 // CHECK:STDOUT: %.loc15_27: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %c: {.a: i32, .b: i32} = var @@ -305,25 +305,25 @@ fn Main() { // CHECK:STDOUT: %.loc15_45: i32 = int_literal 2 // CHECK:STDOUT: %.loc15_43: i32 = stub_reference %.loc15_45 // CHECK:STDOUT: %.loc15_46.1: {.a: i32, .b: i32} = struct_value (%.loc15_35, %.loc15_43) -// CHECK:STDOUT: %.loc15_46.2: {.a: i32, .b: i32} = initialize_from %.loc15_46.1 +// CHECK:STDOUT: %.loc15_46.2: {.a: i32, .b: i32} = initialize_from %.loc15_46.1, %c // CHECK:STDOUT: assign %c, %.loc15_46.2 // CHECK:STDOUT: %.loc16_4: i32 = struct_access %c, member0 // CHECK:STDOUT: %.loc16_9.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc16_9.2: i32 = initialize_from %.loc16_9.1 +// CHECK:STDOUT: %.loc16_9.2: i32 = initialize_from %.loc16_9.1, %.loc16_4 // CHECK:STDOUT: assign %.loc16_4, %.loc16_9.2 // CHECK:STDOUT: %.loc17_4: i32 = struct_access %c, member1 // CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 4 -// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1, %.loc17_4 // CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 // CHECK:STDOUT: %.loc19_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var // CHECK:STDOUT: %.loc19_17.1: i32* = address_of %a -// CHECK:STDOUT: %.loc19_17.2: i32* = initialize_from %.loc19_17.1 +// CHECK:STDOUT: %.loc19_17.2: i32* = initialize_from %.loc19_17.1, %p // CHECK:STDOUT: assign %p, %.loc19_17.2 // CHECK:STDOUT: %.loc19_7.1: i32* = value_binding %p // CHECK:STDOUT: %.loc20_3: i32 = dereference %.loc19_7.1 // CHECK:STDOUT: %.loc20_8.1: i32 = int_literal 5 -// CHECK:STDOUT: %.loc20_8.2: i32 = initialize_from %.loc20_8.1 +// CHECK:STDOUT: %.loc20_8.2: i32 = initialize_from %.loc20_8.1, %.loc20_3 // CHECK:STDOUT: assign %.loc20_3, %.loc20_8.2 // CHECK:STDOUT: %.loc22_8: bool = bool_literal true // CHECK:STDOUT: if %.loc22_8 br !if.expr.then else br !if.expr.else @@ -340,7 +340,7 @@ fn Main() { // CHECK:STDOUT: %.loc22_5: i32* = block_arg !if.expr.result // CHECK:STDOUT: %.loc22_3: i32 = dereference %.loc22_5 // CHECK:STDOUT: %.loc22_31.1: i32 = int_literal 10 -// CHECK:STDOUT: %.loc22_31.2: i32 = initialize_from %.loc22_31.1 +// CHECK:STDOUT: %.loc22_31.2: i32 = initialize_from %.loc22_31.1, %.loc22_3 // CHECK:STDOUT: assign %.loc22_3, %.loc22_31.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/binary_op.carbon b/toolchain/semantics/testdata/operators/binary_op.carbon index e5f77260db2ef..ecbbafee6fe13 100644 --- a/toolchain/semantics/testdata/operators/binary_op.carbon +++ b/toolchain/semantics/testdata/operators/binary_op.carbon @@ -10,7 +10,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -27,12 +27,13 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+1, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+3, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -42,10 +43,13 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -53,11 +57,11 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> i32 { +// CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc8_15: i32 = int_literal 34 // CHECK:STDOUT: %.loc8_13.1: i32 = add %.loc8_10, %.loc8_15 -// CHECK:STDOUT: %.loc8_13.2: i32 = initialize_from %.loc8_13.1 +// CHECK:STDOUT: %.loc8_13.2: i32 = initialize_from %.loc8_13.1, %return // CHECK:STDOUT: return %.loc8_13.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon index a15a460250d72..a1f9d8098bcec 100644 --- a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -47,8 +47,8 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block2, block11, block12, block13, block14, block15, block16}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0}, +// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block3, block12, block13, block14, block15, block16, block17}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -82,8 +82,8 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+49, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+50, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -93,90 +93,91 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+3, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+5}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+7, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+21}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+16, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+22}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+23, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+24, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+23, arg1: node+26}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+23, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+28, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+23, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+26, arg1: node+24, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+24, arg1: node+27}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+24, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+29, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+24, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+31, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+33, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+34, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+35, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+37, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+32, arg1: node+38}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block7, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+38, arg1: node+33, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+33, arg1: node+39}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+40, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+41}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+41, arg1: nodeIntegerType, type: typeTypeType}, +// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+42}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+43, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+44, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+46, type: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block7, type: typeTypeType}, -// CHECK:STDOUT: {kind: StructValue, arg0: block8, type: type2}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+47, type: type0}, +// CHECK:STDOUT: {kind: StructType, arg0: block8, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructValue, arg0: block9, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+51, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+52, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+54, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block10, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+57, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+50, arg1: node+58}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+55, type: type0}, +// CHECK:STDOUT: {kind: StructValue, arg0: block11, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+58, arg1: node+51, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+51, arg1: node+59}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+60}, -// CHECK:STDOUT: {kind: Branch, arg0: block12}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block12, arg1: node+61}, +// CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int15, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+63}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+64}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+64}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+65}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int16, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+68, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+67, arg1: node+69}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+69, arg1: node+68, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+68, arg1: node+70}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+71, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+72, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block14, arg1: node+73}, -// CHECK:STDOUT: {kind: Branch, arg0: block15}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+71, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+71, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+76}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+77}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block16, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+74}, +// CHECK:STDOUT: {kind: Branch, arg0: block16}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+72, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+72, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+77}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+78}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block17, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int17, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+81, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+80, arg1: node+82}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+82, arg1: node+81, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+81, arg1: node+83}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -184,10 +185,12 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, @@ -229,64 +232,64 @@ fn Main() { // CHECK:STDOUT: node+41, // CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, -// CHECK:STDOUT: node+45, +// CHECK:STDOUT: node+44, // CHECK:STDOUT: node+46, -// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+47, // CHECK:STDOUT: node+49, // CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, -// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+52, // CHECK:STDOUT: node+54, -// CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: node+57, // CHECK:STDOUT: node+58, // CHECK:STDOUT: node+59, // CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, // CHECK:STDOUT: node+62, +// CHECK:STDOUT: node+63, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+29, -// CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+34, -// CHECK:STDOUT: node+36, +// CHECK:STDOUT: node+30, +// CHECK:STDOUT: node+32, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+44, -// CHECK:STDOUT: node+47, +// CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+37, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+45, // CHECK:STDOUT: node+48, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+52, -// CHECK:STDOUT: node+55, +// CHECK:STDOUT: node+46, +// CHECK:STDOUT: node+49, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+53, // CHECK:STDOUT: node+56, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+63, -// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+57, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+64, // CHECK:STDOUT: node+66, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+65, // CHECK:STDOUT: node+67, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+68, // CHECK:STDOUT: node+69, // CHECK:STDOUT: node+70, @@ -295,21 +298,22 @@ fn Main() { // CHECK:STDOUT: node+73, // CHECK:STDOUT: node+74, // CHECK:STDOUT: node+75, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+76, -// CHECK:STDOUT: node+78, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+77, // CHECK:STDOUT: node+79, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+78, // CHECK:STDOUT: node+80, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+81, // CHECK:STDOUT: node+82, // CHECK:STDOUT: node+83, // CHECK:STDOUT: node+84, +// CHECK:STDOUT: node+85, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -318,17 +322,17 @@ fn Main() { // CHECK:STDOUT: %.loc9 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> i32; +// CHECK:STDOUT: fn @F() -> %return: i32; // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc13_3: i32 = int_literal 1 // CHECK:STDOUT: %.loc13_7.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc13_7.2: i32 = initialize_from %.loc13_7.1 +// CHECK:STDOUT: %.loc13_7.2: i32 = initialize_from %.loc13_7.1, %.loc13_3 // CHECK:STDOUT: assign %.loc13_3, %.loc13_7.2 // CHECK:STDOUT: %.loc17_4: i32 = call @F() // CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1, %.loc17_4 // CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 // CHECK:STDOUT: %.loc21_4.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc21_4.2: i32 = stub_reference %.loc21_4.1 @@ -341,11 +345,11 @@ fn Main() { // CHECK:STDOUT: %.loc21_16.1: i32 = int_literal 4 // CHECK:STDOUT: %.loc21_16.2: i32 = stub_reference %.loc21_16.1 // CHECK:STDOUT: %.loc21_17.1: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) -// CHECK:STDOUT: %.loc21_17.2: (i32, i32) = initialize_from %.loc21_17.1 +// CHECK:STDOUT: %.loc21_17.2: (i32, i32) = initialize_from %.loc21_17.1, %.loc21_8.2 // CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17.2 // CHECK:STDOUT: %n: i32 = var // CHECK:STDOUT: %.loc22_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc22_16.2: i32 = initialize_from %.loc22_16.1 +// CHECK:STDOUT: %.loc22_16.2: i32 = initialize_from %.loc22_16.1, %n // CHECK:STDOUT: assign %n, %.loc22_16.2 // CHECK:STDOUT: %.loc22_7.1: i32 = value_binding %n // CHECK:STDOUT: %.loc26_4: i32 = stub_reference %.loc22_7.1 @@ -357,10 +361,10 @@ fn Main() { // CHECK:STDOUT: %.loc26_16.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc26_16.2: i32 = stub_reference %.loc26_16.1 // CHECK:STDOUT: %.loc26_17.1: (i32, i32) = tuple_value (%.loc26_13.2, %.loc26_16.2) -// CHECK:STDOUT: %.loc26_17.2: (i32, i32) = initialize_from %.loc26_17.1 +// CHECK:STDOUT: %.loc26_17.2: (i32, i32) = initialize_from %.loc26_17.1, %.loc26_8 // CHECK:STDOUT: assign %.loc26_8, %.loc26_17.2 // CHECK:STDOUT: %.loc30_12.1: type = ptr_type i32 -// CHECK:STDOUT: %.loc30_12.2: type = initialize_from %.loc30_12.1 +// CHECK:STDOUT: %.loc30_12.2: type = initialize_from %.loc30_12.1, i32 // CHECK:STDOUT: assign i32, %.loc30_12.2 // CHECK:STDOUT: %.loc34_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc34_7: i32 = stub_reference %.loc34_9 @@ -373,7 +377,7 @@ fn Main() { // CHECK:STDOUT: %.loc34_36: i32 = int_literal 4 // CHECK:STDOUT: %.loc34_34: i32 = stub_reference %.loc34_36 // CHECK:STDOUT: %.loc34_37.1: {.x: i32, .y: i32} = struct_value (%.loc34_26, %.loc34_34) -// CHECK:STDOUT: %.loc34_37.2: {.x: i32, .y: i32} = initialize_from %.loc34_37.1 +// CHECK:STDOUT: %.loc34_37.2: {.x: i32, .y: i32} = initialize_from %.loc34_37.1, %.loc34_18.2 // CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37.2 // CHECK:STDOUT: %.loc38_7: bool = bool_literal true // CHECK:STDOUT: if %.loc38_7 br !if.expr.then.loc38 else br !if.expr.else.loc38 @@ -389,7 +393,7 @@ fn Main() { // CHECK:STDOUT: !if.expr.result.loc38: // CHECK:STDOUT: %.loc38_4: i32 = block_arg !if.expr.result.loc38 // CHECK:STDOUT: %.loc38_29.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc38_29.2: i32 = initialize_from %.loc38_29.1 +// CHECK:STDOUT: %.loc38_29.2: i32 = initialize_from %.loc38_29.1, %.loc38_4 // CHECK:STDOUT: assign %.loc38_4, %.loc38_29.2 // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc45_7: bool = bool_literal true @@ -406,7 +410,7 @@ fn Main() { // CHECK:STDOUT: !if.expr.result.loc45: // CHECK:STDOUT: %.loc45_4: i32 = block_arg !if.expr.result.loc45 // CHECK:STDOUT: %.loc45_29.1: i32 = int_literal 10 -// CHECK:STDOUT: %.loc45_29.2: i32 = initialize_from %.loc45_29.1 +// CHECK:STDOUT: %.loc45_29.2: i32 = initialize_from %.loc45_29.1, %.loc45_4 // CHECK:STDOUT: assign %.loc45_4, %.loc45_29.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon index cef6a67177997..07b09c4e96c61 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -31,12 +31,13 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+3, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+0, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -46,10 +47,13 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -57,11 +61,11 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> i32 { +// CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc11_15: f64 = real_literal 34e-1 // CHECK:STDOUT: %.loc11_13: = add , %.loc11_15 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon index 4a4765946ae27..c0671b5e370e5 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon @@ -37,10 +37,10 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+1, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+7}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -71,10 +71,10 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %a // CHECK:STDOUT: assign %a, %.loc8_16.2 // CHECK:STDOUT: %.loc12: f64 = real_literal 56e-1 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %a // CHECK:STDOUT: assign %a, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon index 3d2f488647318..2fa9de31d9969 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon @@ -15,7 +15,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -34,14 +34,15 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+2, type: typeError}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+3, type: typeError}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+4, type: typeError}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+5, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+0, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -51,12 +52,15 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -64,13 +68,13 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> i32 { +// CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc13_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc13_15: f64 = real_literal 34e-1 // CHECK:STDOUT: %.loc13_13: = add , %.loc13_15 // CHECK:STDOUT: %.loc13_21: i32 = int_literal 12 // CHECK:STDOUT: %.loc13_19: = add , %.loc13_21 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/or.carbon b/toolchain/semantics/testdata/operators/or.carbon index bdb0c10338a9c..578431a3aed4f 100644 --- a/toolchain/semantics/testdata/operators/or.carbon +++ b/toolchain/semantics/testdata/operators/or.carbon @@ -13,9 +13,9 @@ fn Or() -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: {block3}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: {block4, block5, block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -32,60 +32,72 @@ fn Or() -> bool { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+12, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+10}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+11}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+14}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block6, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+17}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -94,21 +106,21 @@ fn Or() -> bool { // CHECK:STDOUT: %.loc10 = fn_decl @Or // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> bool { +// CHECK:STDOUT: fn @F() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 +// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1, %return // CHECK:STDOUT: return %.loc7_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() -> bool { +// CHECK:STDOUT: fn @G() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 +// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1, %return // CHECK:STDOUT: return %.loc8_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Or() -> bool { +// CHECK:STDOUT: fn @Or() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_11: bool = call @F() // CHECK:STDOUT: %.loc11_14.1: bool = not %.loc11_11 @@ -121,6 +133,6 @@ fn Or() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: !or.result: // CHECK:STDOUT: %.loc11_14.3: bool = block_arg !or.result -// CHECK:STDOUT: %.loc11_14.4: bool = initialize_from %.loc11_14.3 +// CHECK:STDOUT: %.loc11_14.4: bool = initialize_from %.loc11_14.3, %return // CHECK:STDOUT: return %.loc11_14.4 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/unary_op.carbon b/toolchain/semantics/testdata/operators/unary_op.carbon index 0fc83b1fb0810..089a5869de5fb 100644 --- a/toolchain/semantics/testdata/operators/unary_op.carbon +++ b/toolchain/semantics/testdata/operators/unary_op.carbon @@ -10,7 +10,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+2, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -28,11 +28,12 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, arg1: node+2, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -49,9 +50,12 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -59,10 +63,10 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: %.loc7 = fn_decl @Not // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Not(%b: bool) -> bool { +// CHECK:STDOUT: fn @Not(%b: bool) -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b // CHECK:STDOUT: %.loc8_10.1: bool = not %.loc7 -// CHECK:STDOUT: %.loc8_10.2: bool = initialize_from %.loc8_10.1 +// CHECK:STDOUT: %.loc8_10.2: bool = initialize_from %.loc8_10.1, %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_deref.carbon b/toolchain/semantics/testdata/pointer/address_of_deref.carbon index 8c249836b11ff..04cf789f8fb58 100644 --- a/toolchain/semantics/testdata/pointer/address_of_deref.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_deref.carbon @@ -11,7 +11,7 @@ fn F() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -24,25 +24,26 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+7, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+8, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+9, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -52,6 +53,8 @@ fn F() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, @@ -64,6 +67,7 @@ fn F() -> i32 { // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -71,11 +75,11 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> i32 { +// CHECK:STDOUT: fn @F() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %n // CHECK:STDOUT: assign %n, %.loc8_16.2 // CHECK:STDOUT: %.loc9_13.1: type = ptr_type i32 // CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n @@ -83,6 +87,6 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 // CHECK:STDOUT: %.loc9_10.1: i32 = dereference %.loc9_11 // CHECK:STDOUT: %.loc9_10.2: i32 = value_binding %.loc9_10.1 -// CHECK:STDOUT: %.loc9_10.3: i32 = initialize_from %.loc9_10.2 +// CHECK:STDOUT: %.loc9_10.3: i32 = initialize_from %.loc9_10.2, %return // CHECK:STDOUT: return %.loc9_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon index 5b55384cf3c6c..5deed7b460483 100644 --- a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon @@ -82,7 +82,7 @@ fn F(param: i32) { // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, arg1: node+6, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+15}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, @@ -91,21 +91,21 @@ fn F(param: i32) { // CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+21, type: type2}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+6, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, arg1: node+21, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+24}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: BindName, arg0: str6, arg1: node+27, type: type3}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+6, arg1: member0, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+29, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, arg1: node+27, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+27, arg1: node+31}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: BindName, arg0: str7, arg1: node+34, type: type3}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+6, arg1: member1, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+36, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+37, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+37, arg1: node+34, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+34, arg1: node+38}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, @@ -119,7 +119,7 @@ fn F(param: i32) { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+49, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block10, type: type5}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+51, type: type5}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+51, arg1: node+45, type: type5}, // CHECK:STDOUT: {kind: Assign, arg0: node+45, arg1: node+52}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, @@ -127,7 +127,7 @@ fn F(param: i32) { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: TupleIndex, arg0: node+45, arg1: node+57, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+58, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+59, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+59, arg1: node+55, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+55, arg1: node+60}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, @@ -135,13 +135,13 @@ fn F(param: i32) { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, // CHECK:STDOUT: {kind: TupleIndex, arg0: node+45, arg1: node+65, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+66, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+67, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+67, arg1: node+63, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+63, arg1: node+68}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: BindName, arg0: str11, arg1: node+71, type: type3}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+0, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+73, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+73, arg1: node+71, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+71, arg1: node+74}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -271,25 +271,25 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc8_45: i32 = int_literal 2 // CHECK:STDOUT: %.loc8_43: i32 = stub_reference %.loc8_45 // CHECK:STDOUT: %.loc8_46.1: {.a: i32, .b: i32} = struct_value (%.loc8_35, %.loc8_43) -// CHECK:STDOUT: %.loc8_46.2: {.a: i32, .b: i32} = initialize_from %.loc8_46.1 +// CHECK:STDOUT: %.loc8_46.2: {.a: i32, .b: i32} = initialize_from %.loc8_46.1, %s // CHECK:STDOUT: assign %s, %.loc8_46.2 // 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: {.a: i32, .b: i32}* = var // CHECK:STDOUT: %.loc10_32.1: {.a: i32, .b: i32}* = address_of %s -// CHECK:STDOUT: %.loc10_32.2: {.a: i32, .b: i32}* = initialize_from %.loc10_32.1 +// CHECK:STDOUT: %.loc10_32.2: {.a: i32, .b: i32}* = initialize_from %.loc10_32.1, %p // CHECK:STDOUT: assign %p, %.loc10_32.2 // CHECK:STDOUT: %.loc11_13: type = ptr_type i32 // CHECK:STDOUT: %q: i32* = var // CHECK:STDOUT: %.loc11_19: i32 = struct_access %s, member0 // CHECK:STDOUT: %.loc11_17.1: i32* = address_of %.loc11_19 -// CHECK:STDOUT: %.loc11_17.2: i32* = initialize_from %.loc11_17.1 +// CHECK:STDOUT: %.loc11_17.2: i32* = initialize_from %.loc11_17.1, %q // CHECK:STDOUT: assign %q, %.loc11_17.2 // CHECK:STDOUT: %.loc12_13: type = ptr_type i32 // CHECK:STDOUT: %r: i32* = var // CHECK:STDOUT: %.loc12_19: i32 = struct_access %s, member1 // CHECK:STDOUT: %.loc12_17.1: i32* = address_of %.loc12_19 -// CHECK:STDOUT: %.loc12_17.2: i32* = initialize_from %.loc12_17.1 +// CHECK:STDOUT: %.loc12_17.2: i32* = initialize_from %.loc12_17.1, %r // CHECK:STDOUT: assign %r, %.loc12_17.2 // CHECK:STDOUT: %.loc14_11: type = stub_reference i32 // CHECK:STDOUT: %.loc14_16: type = stub_reference i32 @@ -302,26 +302,26 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc14_27.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc14_27.2: i32 = stub_reference %.loc14_27.1 // CHECK:STDOUT: %.loc14_28.1: (i32, i32) = tuple_value (%.loc14_24.2, %.loc14_27.2) -// CHECK:STDOUT: %.loc14_28.2: (i32, i32) = initialize_from %.loc14_28.1 +// CHECK:STDOUT: %.loc14_28.2: (i32, i32) = initialize_from %.loc14_28.1, %t // CHECK:STDOUT: assign %t, %.loc14_28.2 // CHECK:STDOUT: %.loc15_14: type = ptr_type i32 // CHECK:STDOUT: %t0: i32* = var // CHECK:STDOUT: %.loc15_21: i32 = int_literal 0 // CHECK:STDOUT: %.loc15_22: i32 = tuple_index %t, %.loc15_21 // CHECK:STDOUT: %.loc15_18.1: i32* = address_of %.loc15_22 -// CHECK:STDOUT: %.loc15_18.2: i32* = initialize_from %.loc15_18.1 +// CHECK:STDOUT: %.loc15_18.2: i32* = initialize_from %.loc15_18.1, %t0 // CHECK:STDOUT: assign %t0, %.loc15_18.2 // CHECK:STDOUT: %.loc16_14: type = ptr_type i32 // CHECK:STDOUT: %t1: i32* = var // CHECK:STDOUT: %.loc16_21: i32 = int_literal 1 // CHECK:STDOUT: %.loc16_22: i32 = tuple_index %t, %.loc16_21 // CHECK:STDOUT: %.loc16_18.1: i32* = address_of %.loc16_22 -// CHECK:STDOUT: %.loc16_18.2: i32* = initialize_from %.loc16_18.1 +// CHECK:STDOUT: %.loc16_18.2: i32* = initialize_from %.loc16_18.1, %t1 // CHECK:STDOUT: assign %t1, %.loc16_18.2 // CHECK:STDOUT: %.loc20_22: type = ptr_type i32 // CHECK:STDOUT: %param_addr: i32* = var // CHECK:STDOUT: %.loc20_26.1: i32* = address_of %param -// CHECK:STDOUT: %.loc20_26.2: i32* = initialize_from %.loc20_26.1 +// CHECK:STDOUT: %.loc20_26.2: i32* = initialize_from %.loc20_26.1, %param_addr // CHECK:STDOUT: assign %param_addr, %.loc20_26.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/basic.carbon b/toolchain/semantics/testdata/pointer/basic.carbon index 3938d80800d4f..f7f04318efc87 100644 --- a/toolchain/semantics/testdata/pointer/basic.carbon +++ b/toolchain/semantics/testdata/pointer/basic.carbon @@ -13,7 +13,7 @@ fn F() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -27,28 +27,29 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+10}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+12, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+8, type: type1}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+8, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+11}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -58,6 +59,8 @@ fn F() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, @@ -73,6 +76,7 @@ fn F() -> i32 { // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,20 +84,20 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> i32 { +// CHECK:STDOUT: fn @F() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %n // CHECK:STDOUT: assign %n, %.loc8_16.2 // CHECK:STDOUT: %.loc9_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var // CHECK:STDOUT: %.loc9_17.1: i32* = address_of %n -// CHECK:STDOUT: %.loc9_17.2: i32* = initialize_from %.loc9_17.1 +// CHECK:STDOUT: %.loc9_17.2: i32* = initialize_from %.loc9_17.1, %p // CHECK:STDOUT: assign %p, %.loc9_17.2 // CHECK:STDOUT: %.loc9_7: i32* = value_binding %p // CHECK:STDOUT: %.loc11_10.1: i32 = dereference %.loc9_7 // CHECK:STDOUT: %.loc11_10.2: i32 = value_binding %.loc11_10.1 -// CHECK:STDOUT: %.loc11_10.3: i32 = initialize_from %.loc11_10.2 +// CHECK:STDOUT: %.loc11_10.3: i32 = initialize_from %.loc11_10.2, %return // CHECK:STDOUT: return %.loc11_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon index 498ebfef1f2fa..64880da3b966f 100644 --- a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon @@ -77,13 +77,13 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1}, -// CHECK:STDOUT: {name: str3, param_refs: block0, body: {block3}}}, -// CHECK:STDOUT: {name: str5, param_refs: block0, body: {block7}}}, -// CHECK:STDOUT: {name: str6, param_refs: block0, body: {block8}}}, -// CHECK:STDOUT: {name: str7, param_refs: block0, body: {block9}}}, -// CHECK:STDOUT: {name: str8, param_refs: block0, body: {block10}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, return_slot: node+4}, +// CHECK:STDOUT: {name: str3, param_refs: block0, body: {block5}}}, +// CHECK:STDOUT: {name: str5, param_refs: block0, body: {block9}}}, +// CHECK:STDOUT: {name: str6, param_refs: block0, body: {block10}}}, +// CHECK:STDOUT: {name: str7, param_refs: block0, body: {block11}}}, +// CHECK:STDOUT: {name: str8, param_refs: block0, body: {block12}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -112,19 +112,19 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: nodeFloatingPointType, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: nodeStringType, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+29, -// CHECK:STDOUT: node+49, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+31, // CHECK:STDOUT: node+51, +// CHECK:STDOUT: node+53, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -133,70 +133,72 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+5, type: type2}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+7, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, // CHECK:STDOUT: {kind: PointerType, arg0: type3, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+8, type: type4}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+10, type: type4}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type5}, // CHECK:STDOUT: {kind: PointerType, arg0: type5, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+11, type: type6}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+13, type: type6}, // CHECK:STDOUT: {kind: StringLiteral, arg0: str4, type: type7}, // CHECK:STDOUT: {kind: PointerType, arg0: type7, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+14, type: type8}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+16, type: type8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+21, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type9}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type9}, // CHECK:STDOUT: {kind: PointerType, arg0: type9, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+22, type: type10}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+24, type: type10}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+25, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block6, type: type1}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: StructValue, arg0: block8, type: type1}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+28, type: type11}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+30, type: type11}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+33, arg1: node+34, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+35, type: type2}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+35, arg1: node+36, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+37, type: type2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+37, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+38, type: type2}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+39, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+40, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+40, type: type3}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+41, type: type4}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+42, type: type3}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+43, type: type4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function4}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+45, type: type2}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+47, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function5}, // CHECK:STDOUT: {kind: PointerType, arg0: typeTypeType, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: nodeIntegerType, type: type12}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type13, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+52, type: type12}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+54, type: type12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+56, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+58, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block11, type: type9}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+60, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block13, type: type9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+60, arg1: node+61, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+62, type: type2}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+62, arg1: node+63, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+64, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -204,21 +206,25 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+32, -// CHECK:STDOUT: node+44, -// CHECK:STDOUT: node+48, -// CHECK:STDOUT: node+55, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+46, +// CHECK:STDOUT: node+50, +// CHECK:STDOUT: node+57, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, @@ -238,25 +244,25 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, // CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+28, // CHECK:STDOUT: node+29, // CHECK:STDOUT: node+30, // CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+32, +// CHECK:STDOUT: node+33, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+33, -// CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, // CHECK:STDOUT: node+37, @@ -266,23 +272,23 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+41, // CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, +// CHECK:STDOUT: node+44, +// CHECK:STDOUT: node+45, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+45, -// CHECK:STDOUT: node+46, // CHECK:STDOUT: node+47, +// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+49, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+49, -// CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, // CHECK:STDOUT: node+52, // CHECK:STDOUT: node+53, // CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+55, +// CHECK:STDOUT: node+56, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+56, -// CHECK:STDOUT: node+57, // CHECK:STDOUT: node+58, // CHECK:STDOUT: node+59, // CHECK:STDOUT: node+60, @@ -290,10 +296,12 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, // CHECK:STDOUT: node+64, +// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+66, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+57, // CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+61, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -308,9 +316,9 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: %.loc71 = fn_decl @AddressOfTupleElementValue // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() -> i32; +// CHECK:STDOUT: fn @G() -> %return: i32; // CHECK:STDOUT: -// CHECK:STDOUT: fn @H() -> {.a: i32}; +// CHECK:STDOUT: fn @H() -> %return: {.a: i32}; // CHECK:STDOUT: // CHECK:STDOUT: fn @AddressOfLiteral() { // CHECK:STDOUT: !entry: diff --git a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon index 4a151579287bf..1d70b81c10381 100644 --- a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type4, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type4, return_slot: node+9, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -42,9 +42,10 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: ConstType, arg0: type3, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type4}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+9, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -64,11 +65,14 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -79,8 +83,8 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: %.loc7_1 = fn_decl @ConstMismatch // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> const ({}*) { +// CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> %return: const ({}*) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index c4f83d2e6de6c..05713a85f48e2 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -11,7 +11,7 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+8, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -40,14 +40,15 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: {kind: VarStorage, type: type5}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type5}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type5}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type3}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type3}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+11, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+13, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+10, type: type3}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type3}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+12, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, arg1: node+8, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -66,16 +67,19 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,13 +88,13 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: %.loc8_1 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> const i32 { +// CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> %return: const i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8: const (const (const i32*)*) = value_binding %p // CHECK:STDOUT: %.loc9_11.1: const (const i32*) = dereference %.loc8 // CHECK:STDOUT: %.loc9_11.2: const (const i32*) = value_binding %.loc9_11.1 // CHECK:STDOUT: %.loc9_10.1: const i32 = dereference %.loc9_11.2 // CHECK:STDOUT: %.loc9_10.2: const i32 = value_binding %.loc9_10.1 -// CHECK:STDOUT: %.loc9_10.3: const i32 = initialize_from %.loc9_10.2 +// CHECK:STDOUT: %.loc9_10.3: const i32 = initialize_from %.loc9_10.2, %return // CHECK:STDOUT: return %.loc9_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index 342f43dc072c3..7681626eba3d7 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -14,8 +14,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4}}}, -// CHECK:STDOUT: {name: str2, param_refs: block6, return_type: type3, body: {block7}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+4, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type3, return_slot: node+15, body: {block9}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -29,8 +29,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -39,20 +39,22 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type1}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, arg1: node+4, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type3}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type3}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, arg1: node+15, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -67,29 +69,35 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -101,16 +109,16 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: %.loc11_1 = fn_decl @ConstPtr // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Ptr(%p: i32*) -> i32* { +// CHECK:STDOUT: fn @Ptr(%p: i32*) -> %return: i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_8.1: i32* = value_binding %p -// CHECK:STDOUT: %.loc7_8.2: i32* = initialize_from %.loc7_8.1 +// CHECK:STDOUT: %.loc7_8.2: i32* = initialize_from %.loc7_8.1, %return // CHECK:STDOUT: return %.loc7_8.2 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> const i32* { +// CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> %return: const i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_13.1: const i32* = value_binding %p -// CHECK:STDOUT: %.loc11_13.2: const i32* = initialize_from %.loc11_13.1 +// CHECK:STDOUT: %.loc11_13.2: const i32* = initialize_from %.loc11_13.1, %return // CHECK:STDOUT: return %.loc11_13.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/code_after_return.carbon b/toolchain/semantics/testdata/return/code_after_return.carbon index 02a670390dcd7..8a6a931fa8fe7 100644 --- a/toolchain/semantics/testdata/return/code_after_return.carbon +++ b/toolchain/semantics/testdata/return/code_after_return.carbon @@ -36,7 +36,7 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+4, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index af08dfde77d28..498742d7bdb47 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -18,7 +18,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -41,27 +41,28 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+12}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+7, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+13}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+17, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+20}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+21}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+22}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, // CHECK:STDOUT: {kind: Branch, arg0: unreachable}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, @@ -81,8 +82,11 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -90,9 +94,9 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%b: bool) -> i32 { +// CHECK:STDOUT: fn @F(%b: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_10.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1, %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_missing_return.carbon b/toolchain/semantics/testdata/return/fail_missing_return.carbon index 97a66bd536a4c..e0adca0e53f36 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return.carbon @@ -12,7 +12,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -27,6 +27,7 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -36,6 +37,9 @@ fn Main() -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -43,6 +47,6 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> i32 { +// CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon index 579e03d22dee8..12f0939a97044 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon @@ -12,7 +12,7 @@ fn F() -> () { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+2, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -31,6 +31,7 @@ fn F() -> () { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -39,6 +40,9 @@ fn F() -> () { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -51,6 +55,6 @@ fn F() -> () { // CHECK:STDOUT: %.loc7_1 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> () { +// CHECK:STDOUT: fn @F() -> %return: () { // CHECK:STDOUT: !entry: // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon index ddf154b0895c7..0df8fcd019ba2 100644 --- a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -30,10 +30,11 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+0, type: typeError}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -43,8 +44,11 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -52,9 +56,9 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> i32 { +// CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_value_missing.carbon b/toolchain/semantics/testdata/return/fail_value_missing.carbon index bde7eaa7095b7..7777409d2c980 100644 --- a/toolchain/semantics/testdata/return/fail_value_missing.carbon +++ b/toolchain/semantics/testdata/return/fail_value_missing.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -28,6 +28,7 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -40,13 +41,16 @@ fn Main() -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> i32 { +// CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/struct.carbon b/toolchain/semantics/testdata/return/struct.carbon index 06d290090d182..f8e0fdb3e1c1b 100644 --- a/toolchain/semantics/testdata/return/struct.carbon +++ b/toolchain/semantics/testdata/return/struct.carbon @@ -10,7 +10,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type1, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type1, return_slot: node+2, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 3, @@ -30,13 +30,14 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block5, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: StructValue, arg0: block6, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -44,23 +45,26 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -69,11 +73,11 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: %.loc7_1 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> {.a: i32} { +// CHECK:STDOUT: fn @Main() -> %return: {.a: i32} { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_16: i32 = int_literal 3 // CHECK:STDOUT: %.loc8_14: i32 = stub_reference %.loc8_16 // CHECK:STDOUT: %.loc8_17.1: {.a: i32} = struct_value (%.loc8_14) -// CHECK:STDOUT: %.loc8_17.2: {.a: i32} = initialize_from %.loc8_17.1 +// CHECK:STDOUT: %.loc8_17.2: {.a: i32} = initialize_from %.loc8_17.1, %return // CHECK:STDOUT: return %.loc8_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/tuple.carbon b/toolchain/semantics/testdata/return/tuple.carbon index d7b3fa5c4b54c..d53c04ae9edbb 100644 --- a/toolchain/semantics/testdata/return/tuple.carbon +++ b/toolchain/semantics/testdata/return/tuple.carbon @@ -11,7 +11,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, return_slot: node+5, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 15, @@ -43,14 +43,15 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -61,24 +62,27 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -91,13 +95,13 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: %.loc8_1 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> (i32, i32) { +// CHECK:STDOUT: fn @Main() -> %return: (i32, i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc9_11.1: i32 = int_literal 15 // CHECK:STDOUT: %.loc9_11.2: i32 = stub_reference %.loc9_11.1 // CHECK:STDOUT: %.loc9_15.1: i32 = int_literal 35 // CHECK:STDOUT: %.loc9_15.2: i32 = stub_reference %.loc9_15.1 // CHECK:STDOUT: %.loc9_17.1: (i32, i32) = tuple_value (%.loc9_11.2, %.loc9_15.2) -// CHECK:STDOUT: %.loc9_17.2: (i32, i32) = initialize_from %.loc9_17.1 +// CHECK:STDOUT: %.loc9_17.2: (i32, i32) = initialize_from %.loc9_17.1, %return // CHECK:STDOUT: return %.loc9_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/value.carbon b/toolchain/semantics/testdata/return/value.carbon index 0f45fb1aa761e..3498703c53461 100644 --- a/toolchain/semantics/testdata/return/value.carbon +++ b/toolchain/semantics/testdata/return/value.carbon @@ -10,7 +10,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block2}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -26,10 +26,11 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -39,8 +40,11 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -48,9 +52,9 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> i32 { +// CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_10.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1, %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/empty.carbon b/toolchain/semantics/testdata/struct/empty.carbon index f5ba458d3d8d9..2c1349b42b6d2 100644 --- a/toolchain/semantics/testdata/struct/empty.carbon +++ b/toolchain/semantics/testdata/struct/empty.carbon @@ -29,13 +29,13 @@ var y: {} = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+8, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -63,11 +63,11 @@ var y: {} = x; // CHECK:STDOUT: %.loc7_9.2: {} = struct_value () // CHECK:STDOUT: %x: {} = var // CHECK:STDOUT: %.loc7_14.1: {} = struct_value () -// CHECK:STDOUT: %.loc7_14.2: {} = initialize_from %.loc7_14.1 +// CHECK:STDOUT: %.loc7_14.2: {} = initialize_from %.loc7_14.1, %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc8: {} = struct_value () // CHECK:STDOUT: %y: {} = var // CHECK:STDOUT: %.loc7_5.1: {} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {} = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: {} = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon index a0032bd3d9c1f..826880cd8284c 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon @@ -34,7 +34,7 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: StructType, arg0: block0, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -60,6 +60,6 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc10_21.1: type = struct_type {} // CHECK:STDOUT: %.loc10_21.2: {} = struct_value () -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_nested.carbon b/toolchain/semantics/testdata/struct/fail_assign_nested.carbon index 804d99573aaa8..f0ded42f900b5 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_nested.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_nested.carbon @@ -40,7 +40,7 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+4, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -80,6 +80,6 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: %.loc10_23: {} = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: {}} // CHECK:STDOUT: %.loc10_27.2: {.b: {}} = struct_value (%.loc10_23) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon index 284f824ffbf4e..7cddbac4f3c2d 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon @@ -38,7 +38,7 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type1}, // CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -72,6 +72,6 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: %.loc10_17: i32 = stub_reference %.loc10_19 // CHECK:STDOUT: %.loc10_20.1: type = struct_type {.a: i32} // CHECK:STDOUT: %.loc10_20.2: {.a: i32} = struct_value (%.loc10_17) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon index 8a330ed469990..149e457af578b 100644 --- a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon @@ -39,7 +39,7 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -75,6 +75,6 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: %.loc10_24: i32 = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: i32} // CHECK:STDOUT: %.loc10_27.2: {.b: i32} = struct_value (%.loc10_24) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon index e5af7f504aa1e..30f74c7476cd1 100644 --- a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon @@ -40,7 +40,7 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type2}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -76,6 +76,6 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: %.loc10_24: f64 = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_29.1: type = struct_type {.b: f64} // CHECK:STDOUT: %.loc10_29.2: {.b: f64} = struct_value (%.loc10_24) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon index 2eb5c312bc4db..01d25d3631483 100644 --- a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon @@ -40,11 +40,11 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+10, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -82,9 +82,9 @@ var y: i32 = x.b; // CHECK:STDOUT: %.loc7_26: f64 = real_literal 40e-1 // CHECK:STDOUT: %.loc7_24: f64 = stub_reference %.loc7_26 // CHECK:STDOUT: %.loc7_29.1: {.a: f64} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_29.2: {.a: f64} = initialize_from %.loc7_29.1 +// CHECK:STDOUT: %.loc7_29.2: {.a: f64} = initialize_from %.loc7_29.1, %x // CHECK:STDOUT: assign %x, %.loc7_29.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %y // CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon index 5f97313c3ae11..cfaa33ac69362 100644 --- a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon +++ b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon @@ -39,11 +39,11 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+10, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -81,9 +81,9 @@ var y: i32 = x.b; // CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_24: i32 = stub_reference %.loc7_26 // CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1 +// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1, %x // CHECK:STDOUT: assign %x, %.loc7_27.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %y // CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon index 3122f925b366f..f2792e6770fd1 100644 --- a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon +++ b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon @@ -40,7 +40,7 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+3, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -78,6 +78,6 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: %.loc10_33: i32 = stub_reference %.loc10_35 // CHECK:STDOUT: %.loc10_36.1: type = struct_type {.a: i32} // CHECK:STDOUT: %.loc10_36.2: {.a: i32} = struct_value (%.loc10_33) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_type_assign.carbon b/toolchain/semantics/testdata/struct/fail_type_assign.carbon index d3d1662825a11..a00a43b83e074 100644 --- a/toolchain/semantics/testdata/struct/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/struct/fail_type_assign.carbon @@ -33,7 +33,7 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -61,6 +61,6 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc10_28: type = struct_type {.a: i32} -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/member_access.carbon b/toolchain/semantics/testdata/struct/member_access.carbon index 5f0466ad75c4c..934c7f8e71c29 100644 --- a/toolchain/semantics/testdata/struct/member_access.carbon +++ b/toolchain/semantics/testdata/struct/member_access.carbon @@ -44,18 +44,18 @@ var z: i32 = y; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+3, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+3, arg1: member1, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, arg1: node+14, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+18}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+20, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+20, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -108,15 +108,15 @@ var z: i32 = y; // CHECK:STDOUT: %.loc7_45: i32 = int_literal 1 // CHECK:STDOUT: %.loc7_43: i32 = stub_reference %.loc7_45 // CHECK:STDOUT: %.loc7_46.1: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) -// CHECK:STDOUT: %.loc7_46.2: {.a: f64, .b: i32} = initialize_from %.loc7_46.1 +// CHECK:STDOUT: %.loc7_46.2: {.a: f64, .b: i32} = initialize_from %.loc7_46.1, %x // CHECK:STDOUT: assign %x, %.loc7_46.2 // CHECK:STDOUT: %y: i32 = var // CHECK:STDOUT: %.loc8_15.1: i32 = struct_access %x, member1 // CHECK:STDOUT: %.loc8_15.2: i32 = value_binding %.loc8_15.1 -// CHECK:STDOUT: %.loc8_15.3: i32 = initialize_from %.loc8_15.2 +// CHECK:STDOUT: %.loc8_15.3: i32 = initialize_from %.loc8_15.2, %y // CHECK:STDOUT: assign %y, %.loc8_15.3 // CHECK:STDOUT: %z: i32 = var // CHECK:STDOUT: %.loc8_5.1: i32 = value_binding %y -// CHECK:STDOUT: %.loc8_5.2: i32 = initialize_from %.loc8_5.1 +// CHECK:STDOUT: %.loc8_5.2: i32 = initialize_from %.loc8_5.1, %z // CHECK:STDOUT: assign %z, %.loc8_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/one_entry.carbon b/toolchain/semantics/testdata/struct/one_entry.carbon index 75ed0417dfe12..5d552e031ed82 100644 --- a/toolchain/semantics/testdata/struct/one_entry.carbon +++ b/toolchain/semantics/testdata/struct/one_entry.carbon @@ -35,14 +35,14 @@ var y: {.a: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+12, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, arg1: node+12, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+15}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -86,11 +86,11 @@ var y: {.a: i32} = x; // CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_24: i32 = stub_reference %.loc7_26 // CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1 +// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1, %x // CHECK:STDOUT: assign %x, %.loc7_27.2 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32} // CHECK:STDOUT: %y: {.a: i32} = var // CHECK:STDOUT: %.loc7_5.1: {.a: i32} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32} = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: {.a: i32} = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/tuple_as_element.carbon b/toolchain/semantics/testdata/struct/tuple_as_element.carbon index 25d1aa7e88348..db5f0fa7f288d 100644 --- a/toolchain/semantics/testdata/struct/tuple_as_element.carbon +++ b/toolchain/semantics/testdata/struct/tuple_as_element.carbon @@ -55,7 +55,7 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type2}, // CHECK:STDOUT: {kind: StructValue, arg0: block5, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, arg1: node+7, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+18}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, @@ -65,7 +65,7 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+25, type: type3}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, arg1: node+25, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+28}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -142,13 +142,13 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc7_49: (i32,) = tuple_value (%.loc7_47.2) // CHECK:STDOUT: %.loc7_44: (i32,) = stub_reference %.loc7_49 // CHECK:STDOUT: %.loc7_50.1: {.a: i32, .b: (i32,)} = struct_value (%.loc7_36, %.loc7_44) -// CHECK:STDOUT: %.loc7_50.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_50.1 +// CHECK:STDOUT: %.loc7_50.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_50.1, %x // CHECK:STDOUT: assign %x, %.loc7_50.2 // CHECK:STDOUT: %.loc8_23: type = stub_reference i32 // CHECK:STDOUT: %.loc8_27: (type,) = tuple_value (%.loc8_23) // CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} // CHECK:STDOUT: %y: {.a: i32, .b: (i32,)} = var // CHECK:STDOUT: %.loc7_5.1: {.a: i32, .b: (i32,)} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/two_entries.carbon b/toolchain/semantics/testdata/struct/two_entries.carbon index 2473d9fe6e9bd..8221a4da6b49f 100644 --- a/toolchain/semantics/testdata/struct/two_entries.carbon +++ b/toolchain/semantics/testdata/struct/two_entries.carbon @@ -41,7 +41,7 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+3, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+12}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, @@ -49,7 +49,7 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+17, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+17, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -103,11 +103,11 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: %.loc7_43: i32 = int_literal 2 // CHECK:STDOUT: %.loc7_41: i32 = stub_reference %.loc7_43 // CHECK:STDOUT: %.loc7_44.1: {.a: i32, .b: i32} = struct_value (%.loc7_33, %.loc7_41) -// CHECK:STDOUT: %.loc7_44.2: {.a: i32, .b: i32} = initialize_from %.loc7_44.1 +// CHECK:STDOUT: %.loc7_44.2: {.a: i32, .b: i32} = initialize_from %.loc7_44.1, %x // CHECK:STDOUT: assign %x, %.loc7_44.2 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %y: {.a: i32, .b: i32} = var // CHECK:STDOUT: %.loc7_5.1: {.a: i32, .b: i32} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: i32} = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: i32} = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/empty.carbon b/toolchain/semantics/testdata/tuples/empty.carbon index a4eb083ccfcbc..13bb48d48f3d0 100644 --- a/toolchain/semantics/testdata/tuples/empty.carbon +++ b/toolchain/semantics/testdata/tuples/empty.carbon @@ -31,13 +31,13 @@ var y: () = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+8, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -65,11 +65,11 @@ var y: () = x; // CHECK:STDOUT: %.loc7_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var // CHECK:STDOUT: %.loc7_14.1: () = tuple_value () -// CHECK:STDOUT: %.loc7_14.2: () = initialize_from %.loc7_14.1 +// CHECK:STDOUT: %.loc7_14.2: () = initialize_from %.loc7_14.1, %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc8: () = tuple_value () // CHECK:STDOUT: %y: () = var // CHECK:STDOUT: %.loc7_5.1: () = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: () = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: () = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon index 03e4b6db3d6d6..215cd68fc4598 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon @@ -44,7 +44,7 @@ var x: (i32,) = (); // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+4, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -75,6 +75,6 @@ var x: (i32,) = (); // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc10_18.1: type = tuple_type () // CHECK:STDOUT: %.loc10_18.2: () = tuple_value () -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon b/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon index 19c4e8748721f..6ccba2db38ce0 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon @@ -96,7 +96,7 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type5}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock5, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type6}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+13, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+34}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -202,6 +202,6 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: %.loc10_55.2: (i32, i32, i32) = stub_reference %.loc10_55.1 // CHECK:STDOUT: %.loc10_56.1: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) // CHECK:STDOUT: %.loc10_56.2: ((i32, i32, i32), (i32, i32, i32)) = tuple_value (%.loc10_44.3, %.loc10_55.2) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon index 15a4563ededc1..c0ee2a9b90efe 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon @@ -34,7 +34,7 @@ var x: () = (66); // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -56,6 +56,6 @@ var x: () = (66); // CHECK:STDOUT: %.loc10_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var // CHECK:STDOUT: %.loc10_14: i32 = int_literal 66 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon index 2c29d0dff294f..ad0fa8e588fdf 100644 --- a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon +++ b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon @@ -56,7 +56,7 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type3}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type4}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+5, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+13}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -102,6 +102,6 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: %.loc10_25.2: f64 = stub_reference %.loc10_25.1 // CHECK:STDOUT: %.loc10_30.1: type = tuple_type (i32, f64) // CHECK:STDOUT: %.loc10_30.2: (i32, f64) = tuple_value (%.loc10_22.2, %.loc10_25.2) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon index 2b463383d942c..40026c33534b9 100644 --- a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon +++ b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon @@ -51,7 +51,7 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+5, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -92,6 +92,6 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: %.loc10_22.2: i32 = stub_reference %.loc10_22.1 // CHECK:STDOUT: %.loc10_25.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc10_25.2: (i32,) = tuple_value (%.loc10_22.2) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon index 456a446aae384..0290ac65fe9ef 100644 --- a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon @@ -41,7 +41,7 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+4, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -75,6 +75,6 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc10_19: type = stub_reference i32 // CHECK:STDOUT: %.loc10_24: (type,) = tuple_value (%.loc10_19) -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/nested_tuple.carbon b/toolchain/semantics/testdata/tuples/nested_tuple.carbon index 6cc2a2ff00070..f6db85bff7c45 100644 --- a/toolchain/semantics/testdata/tuples/nested_tuple.carbon +++ b/toolchain/semantics/testdata/tuples/nested_tuple.carbon @@ -66,7 +66,7 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type2}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type4}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, type: type4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, arg1: node+10, type: type4}, // CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -136,6 +136,6 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: %.loc7_39.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_39.2: i32 = stub_reference %.loc7_39.1 // CHECK:STDOUT: %.loc7_40.1: ((i32, i32), i32) = tuple_value (%.loc7_36.2, %.loc7_39.2) -// CHECK:STDOUT: %.loc7_40.2: ((i32, i32), i32) = initialize_from %.loc7_40.1 +// CHECK:STDOUT: %.loc7_40.2: ((i32, i32), i32) = initialize_from %.loc7_40.1, %x // CHECK:STDOUT: assign %x, %.loc7_40.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/one_element.carbon b/toolchain/semantics/testdata/tuples/one_element.carbon index f042b0947605e..bf5006f236b40 100644 --- a/toolchain/semantics/testdata/tuples/one_element.carbon +++ b/toolchain/semantics/testdata/tuples/one_element.carbon @@ -42,14 +42,14 @@ var y: (i32,) = x; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+13, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -95,12 +95,12 @@ var y: (i32,) = x; // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 // CHECK:STDOUT: %.loc7_20.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_20.2: (i32,) = initialize_from %.loc7_20.1 +// CHECK:STDOUT: %.loc7_20.2: (i32,) = initialize_from %.loc7_20.1, %x // CHECK:STDOUT: assign %x, %.loc7_20.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %y: (i32,) = var // CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/two_elements.carbon b/toolchain/semantics/testdata/tuples/two_elements.carbon index 87218a1e7eb3f..6f80327d79e59 100644 --- a/toolchain/semantics/testdata/tuples/two_elements.carbon +++ b/toolchain/semantics/testdata/tuples/two_elements.carbon @@ -48,7 +48,7 @@ var y: (i32, i32) = x; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, @@ -56,7 +56,7 @@ var y: (i32, i32) = x; // CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+17, type: type2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+17, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -112,13 +112,13 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %.loc7_25.1: i32 = int_literal 102 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 // CHECK:STDOUT: %.loc7_28.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: %.loc7_28.2: (i32, i32) = initialize_from %.loc7_28.1 +// CHECK:STDOUT: %.loc7_28.2: (i32, i32) = initialize_from %.loc7_28.1, %x // CHECK:STDOUT: assign %x, %.loc7_28.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_14: type = stub_reference i32 // CHECK:STDOUT: %.loc8_17: (type, type) = tuple_value (%.loc8_9, %.loc8_14) // CHECK:STDOUT: %y: (i32, i32) = var // CHECK:STDOUT: %.loc7_5.1: (i32, i32) = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: (i32, i32) = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: (i32, i32) = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/decl_with_init.carbon b/toolchain/semantics/testdata/var/decl_with_init.carbon index 47c6986ed3a48..5c589287d090a 100644 --- a/toolchain/semantics/testdata/var/decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/decl_with_init.carbon @@ -31,7 +31,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -59,7 +59,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %x // CHECK:STDOUT: assign %x, %.loc8_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon index 1875f8c3384e9..a562ccbac0b74 100644 --- a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon +++ b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon @@ -40,12 +40,12 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+6, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+6, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -78,11 +78,11 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.loc9: i32 = var // CHECK:STDOUT: %.loc9_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_16.2: i32 = initialize_from %.loc9_16.1 +// CHECK:STDOUT: %.loc9_16.2: i32 = initialize_from %.loc9_16.1, %x.loc9 // CHECK:STDOUT: assign %x.loc9, %.loc9_16.2 // CHECK:STDOUT: %x.loc16: i32 = var // CHECK:STDOUT: %.loc16_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc16_16.2: i32 = initialize_from %.loc16_16.1 +// CHECK:STDOUT: %.loc16_16.2: i32 = initialize_from %.loc16_16.1, %x.loc16 // CHECK:STDOUT: assign %x.loc16, %.loc16_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon index 697315240f792..1d962d141894f 100644 --- a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon +++ b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon @@ -35,7 +35,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+1, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -63,7 +63,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_with_self.carbon b/toolchain/semantics/testdata/var/fail_init_with_self.carbon index 42d270f427a6d..a33bf20eaa26c 100644 --- a/toolchain/semantics/testdata/var/fail_init_with_self.carbon +++ b/toolchain/semantics/testdata/var/fail_init_with_self.carbon @@ -32,7 +32,7 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+1, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -58,7 +58,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon index 92d9d73834e40..60afbcd12d2df 100644 --- a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon +++ b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon @@ -38,7 +38,7 @@ var y: i32 = x; // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+4, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+4, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -61,7 +61,7 @@ var y: i32 = x; // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %y // CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon index 97c20639690fe..74a6f11a97005 100644 --- a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon +++ b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon @@ -36,7 +36,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: typeError}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, type: typeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -66,7 +66,7 @@ fn Main() { // CHECK:STDOUT: %.loc11_10: i32 = int_literal 1 // CHECK:STDOUT: %x: = var // CHECK:STDOUT: %.loc11_14: i32 = int_literal 1 -// CHECK:STDOUT: %.1: = initialize_from +// CHECK:STDOUT: %.1: = initialize_from , %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_decl_with_init.carbon b/toolchain/semantics/testdata/var/global_decl_with_init.carbon index 4d07c6e9f4c97..8cfee90ea3fa2 100644 --- a/toolchain/semantics/testdata/var/global_decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/global_decl_with_init.carbon @@ -26,7 +26,7 @@ var x: i32 = 0; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -44,6 +44,6 @@ var x: i32 = 0; // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1, %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup.carbon b/toolchain/semantics/testdata/var/global_lookup.carbon index 27972fe10dea7..468738677883c 100644 --- a/toolchain/semantics/testdata/var/global_lookup.carbon +++ b/toolchain/semantics/testdata/var/global_lookup.carbon @@ -28,12 +28,12 @@ var y: i32 = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -56,10 +56,10 @@ var y: i32 = x; // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1, %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %y: i32 = var // CHECK:STDOUT: %.loc7_5.1: i32 = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon index a47c1eb30578f..6d66d4b50d9d5 100644 --- a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon +++ b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon @@ -33,13 +33,13 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+6, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -67,7 +67,7 @@ fn Main() { // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1, %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc9 = fn_decl @Main // CHECK:STDOUT: } @@ -76,7 +76,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %y: i32 = var // CHECK:STDOUT: %.loc7_5.1: i32 = value_binding package.%x -// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 +// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1, %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/lookup.carbon b/toolchain/semantics/testdata/var/lookup.carbon index 50a1895a5e755..74c28e1943274 100644 --- a/toolchain/semantics/testdata/var/lookup.carbon +++ b/toolchain/semantics/testdata/var/lookup.carbon @@ -32,7 +32,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -60,7 +60,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %x // CHECK:STDOUT: assign %x, %.loc8_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } From 5d0873bf133bca6cf9b9be38d7b7b1d348c953d1 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 11 Aug 2023 17:33:02 -0700 Subject: [PATCH 05/21] Model calls as initializing expressions rather than value expressions. --- toolchain/lowering/lowering_handle.cpp | 13 +- .../call/implicit_empty_tuple_as_arg.carbon | 3 +- toolchain/semantics/semantics_context.cpp | 65 +++++++--- toolchain/semantics/semantics_context.h | 17 +++ .../semantics_handle_call_expression.cpp | 10 +- .../semantics/semantics_handle_function.cpp | 14 ++- .../semantics/semantics_handle_index.cpp | 1 + toolchain/semantics/semantics_handle_name.cpp | 5 +- .../semantics/semantics_handle_statement.cpp | 5 +- toolchain/semantics/semantics_ir.cpp | 5 +- .../semantics/semantics_ir_formatter.cpp | 44 ++++++- .../testdata/basics/builtin_types.carbon | 8 +- .../basics/fail_non_type_as_type.carbon | 2 +- .../basics/fail_qualifier_unsupported.carbon | 2 +- .../semantics/testdata/basics/parens.carbon | 2 +- .../semantics/testdata/const/collapse.carbon | 2 +- .../testdata/const/fail_collapse.carbon | 2 +- .../function/call/empty_struct.carbon | 8 +- .../testdata/function/call/empty_tuple.carbon | 8 +- .../call/fail_return_type_mismatch.carbon | 11 +- .../testdata/function/call/i32.carbon | 12 +- .../function/call/more_param_ir.carbon | 3 + .../testdata/function/call/params_one.carbon | 3 + .../function/call/params_one_comma.carbon | 12 +- .../testdata/function/call/params_two.carbon | 3 + .../function/call/params_two_comma.carbon | 16 ++- .../testdata/function/call/params_zero.carbon | 3 + .../function/call/return_implicit.carbon | 9 +- .../function/declaration/simple.carbon | 3 + toolchain/semantics/testdata/if/else.carbon | 21 +++- .../if/fail_reachable_fallthrough.carbon | 6 +- .../semantics/testdata/if/fail_scope.carbon | 6 +- .../semantics/testdata/if/no_else.carbon | 10 +- .../if/unreachable_fallthrough.carbon | 4 +- .../testdata/if_expression/basic.carbon | 2 +- .../if_expression/constant_condition.carbon | 114 ++++++++++++------ .../if_expression/control_flow.carbon | 54 ++++++--- .../testdata/if_expression/nested.carbon | 2 +- .../testdata/index/element_access.carbon | 6 +- .../index/fail_empty_tuple_access.carbon | 3 + .../testdata/index/fail_large_index.carbon | 6 +- .../testdata/index/fail_name_not_found.carbon | 2 +- .../index/fail_non_deterministic_type.carbon | 6 +- .../index/fail_non_int_indexing.carbon | 4 +- .../index/fail_out_of_bound_access.carbon | 4 +- .../testdata/index/return_value_access.carbon | 30 +++-- .../ir/duplicate_name_same_line.carbon | 4 +- .../testdata/namespace/function.carbon | 3 + .../testdata/namespace/nested.carbon | 3 + .../semantics/testdata/operators/and.carbon | 54 ++++++--- .../testdata/operators/assignment.carbon | 22 ++-- .../testdata/operators/binary_op.carbon | 2 +- .../fail_assigment_to_non_assignable.carbon | 61 +++++----- .../operators/fail_type_mismatch.carbon | 2 +- .../fail_type_mismatch_assignment.carbon | 4 +- .../operators/fail_type_mismatch_once.carbon | 2 +- .../semantics/testdata/operators/or.carbon | 56 ++++++--- .../testdata/operators/unary_op.carbon | 2 +- .../testdata/pointer/address_of_deref.carbon | 4 +- .../testdata/pointer/address_of_lvalue.carbon | 16 +-- .../semantics/testdata/pointer/basic.carbon | 6 +- .../pointer/fail_address_of_value.carbon | 69 ++++++----- .../pointer/fail_type_mismatch.carbon | 2 +- .../testdata/pointer/nested_const.carbon | 2 +- .../semantics/testdata/pointer/types.carbon | 4 +- .../return/code_after_return_value.carbon | 2 +- .../testdata/return/fail_type_mismatch.carbon | 2 +- .../semantics/testdata/return/struct.carbon | 2 +- .../semantics/testdata/return/tuple.carbon | 5 +- .../semantics/testdata/return/value.carbon | 2 +- .../semantics/testdata/struct/empty.carbon | 4 +- .../testdata/struct/fail_assign_empty.carbon | 2 +- .../testdata/struct/fail_assign_nested.carbon | 2 +- .../struct/fail_assign_to_empty.carbon | 2 +- .../struct/fail_field_name_mismatch.carbon | 2 +- .../struct/fail_field_type_mismatch.carbon | 2 +- .../struct/fail_member_access_type.carbon | 4 +- .../struct/fail_non_member_access.carbon | 4 +- .../struct/fail_too_few_values.carbon | 2 +- .../testdata/struct/fail_type_assign.carbon | 2 +- .../testdata/struct/member_access.carbon | 6 +- .../testdata/struct/one_entry.carbon | 4 +- .../testdata/struct/tuple_as_element.carbon | 4 +- .../testdata/struct/two_entries.carbon | 4 +- .../semantics/testdata/tuples/empty.carbon | 4 +- .../testdata/tuples/fail_assign_empty.carbon | 2 +- .../testdata/tuples/fail_assign_nested.carbon | 2 +- .../tuples/fail_assign_to_empty.carbon | 2 +- .../tuples/fail_element_type_mismatch.carbon | 2 +- .../tuples/fail_too_few_element.carbon | 2 +- .../testdata/tuples/fail_type_assign.carbon | 2 +- .../testdata/tuples/nested_tuple.carbon | 2 +- .../testdata/tuples/one_element.carbon | 4 +- .../testdata/tuples/two_elements.carbon | 4 +- .../testdata/var/decl_with_init.carbon | 2 +- .../testdata/var/fail_duplicate_decl.carbon | 4 +- .../var/fail_init_type_mismatch.carbon | 2 +- .../testdata/var/fail_init_with_self.carbon | 2 +- .../var/fail_lookup_outside_scope.carbon | 2 +- .../var/fail_storage_is_literal.carbon | 2 +- .../testdata/var/global_decl_with_init.carbon | 2 +- .../testdata/var/global_lookup.carbon | 4 +- .../var/global_lookup_in_scope.carbon | 4 +- .../semantics/testdata/var/lookup.carbon | 2 +- 104 files changed, 635 insertions(+), 363 deletions(-) diff --git a/toolchain/lowering/lowering_handle.cpp b/toolchain/lowering/lowering_handle.cpp index e4fb758376f5e..ea8532dcc5106 100644 --- a/toolchain/lowering/lowering_handle.cpp +++ b/toolchain/lowering/lowering_handle.cpp @@ -125,10 +125,21 @@ auto LoweringHandleCall(LoweringFunctionContext& context, SemanticsNodeId node_id, SemanticsNode node) -> void { auto [refs_id, function_id] = node.GetAsCall(); auto* function = context.GetFunction(function_id); + + llvm::ArrayRef arg_ids = + context.semantics_ir().GetNodeBlock(refs_id); + if (context.semantics_ir() + .GetFunction(function_id) + .return_slot_id.is_valid()) { + // TODO: Pass the return slot into the function. + arg_ids = arg_ids.drop_back(); + } + std::vector args; - for (auto ref_id : context.semantics_ir().GetNodeBlock(refs_id)) { + for (auto ref_id : arg_ids) { args.push_back(context.GetLocalLoaded(ref_id)); } + if (function->getReturnType()->isVoidTy()) { context.builder().CreateCall(function, args); // TODO: use empty tuple type. diff --git a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon index 7d603339bb924..1c220e916254d 100644 --- a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon +++ b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon @@ -30,7 +30,8 @@ fn Main() { // CHECK:STDOUT: call void @Foo() // CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: %1 = load {}, ptr %call.result, align 1 -// CHECK:STDOUT: %Bar = call {} @Bar({} %1) +// CHECK:STDOUT: %2 = load {}, ptr %call.result, align 1 +// CHECK:STDOUT: %Bar = call {} @Bar({} %2) // CHECK:STDOUT: store {} %Bar, ptr %var, align 1 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index f9501a7334003..475db6c17ba49 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -299,30 +299,43 @@ auto SemanticsContext::ConvertToInitializingExpression( } } +auto SemanticsContext::MaterializeTemporary(SemanticsNodeId init_id) + -> SemanticsNodeId { + SemanticsNode init = semantics_ir().GetNode(init_id); + CARBON_CHECK(GetSemanticsExpressionCategory(semantics_ir(), init_id) == + SemanticsExpressionCategory::Initializing) + << "can only materialize initializing initessions, found " << init; + + auto temporary_id = AddNode(SemanticsNode::MaterializeTemporary::Make( + init.parse_node(), init.type_id(), init_id)); + // TODO: The temporary materialization appears later in the IR than the + // initession that initializes it. + MarkInitializerFor(init_id, temporary_id); + return temporary_id; +} + auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) -> SemanticsNodeId { - SemanticsNode expr = semantics_ir().GetNode(expr_id); switch (GetSemanticsExpressionCategory(semantics_ir(), expr_id)) { case SemanticsExpressionCategory::NotExpression: - CARBON_FATAL() << "Converting non-expression node " << expr + CARBON_FATAL() << "Converting non-expression node " + << semantics_ir().GetNode(expr_id) << " to value expression"; case SemanticsExpressionCategory::Initializing: { // TODO: For class types, use an interface to determine how to perform // this operation. - auto temp_id = AddNode(SemanticsNode::MaterializeTemporary::Make( - expr.parse_node(), expr.type_id(), expr_id)); - // TODO: The temporary materialization appears later in the IR than the - // expression that initializes it. - MarkInitializerFor(expr_id, temp_id); + expr_id = MaterializeTemporary(expr_id); [[fallthrough]]; } case SemanticsExpressionCategory::DurableReference: - case SemanticsExpressionCategory::EphemeralReference: + case SemanticsExpressionCategory::EphemeralReference: { // TODO: Support types with custom value representations. + SemanticsNode expr = semantics_ir().GetNode(expr_id); return AddNode(SemanticsNode::ValueBinding::Make( expr.parse_node(), expr.type_id(), expr_id)); + } case SemanticsExpressionCategory::Value: return expr_id; @@ -331,20 +344,16 @@ auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) auto SemanticsContext::MarkInitializerFor(SemanticsNodeId init_id, SemanticsNodeId target_id) -> void { - SemanticsNode init = semantics_ir().GetNode(init_id); - CARBON_CHECK(GetSemanticsExpressionCategory(semantics_ir(), init_id) == - SemanticsExpressionCategory::Initializing) - << "initialization from non-initializing node " << init; - (void)target_id; while (true) { + SemanticsNode init = semantics_ir().GetNode(init_id); + CARBON_CHECK(GetSemanticsExpressionCategory(semantics_ir(), init_id) == + SemanticsExpressionCategory::Initializing) + << "initialization from non-initializing node " << init; switch (init.kind()) { default: CARBON_FATAL() << "Initialization from unexpected node " << init; - case SemanticsNodeKind::Call: - case SemanticsNodeKind::StructAccess: case SemanticsNodeKind::StructValue: - case SemanticsNodeKind::TupleIndex: case SemanticsNodeKind::TupleValue: CARBON_FATAL() << init << " is not modeled as initializing yet"; @@ -353,12 +362,36 @@ auto SemanticsContext::MarkInitializerFor(SemanticsNodeId init_id, continue; } + case SemanticsNodeKind::Call: { + // If the callee has a return slot, point it at our target. + // TODO: Consider treating calls to functions without a return slot as + // value expressions, to avoid materializing unused temporaries. + auto [refs_id, callee_id] = init.GetAsCall(); + if (semantics_ir().GetFunction(callee_id).return_slot_id.is_valid()) { + auto& refs = semantics_ir().GetNodeBlock(refs_id); + CARBON_CHECK(!refs.back().is_valid()) + << "return slot for function call set multiple times, have " + << init << ", new return slot is " << target_id; + refs.back() = target_id; + } + return; + } + case SemanticsNodeKind::InitializeFrom: CARBON_FATAL() << init << " should be created with a destination"; } } } +auto SemanticsContext::HandleDiscardedExpression(SemanticsNodeId expr_id) + -> void { + // If we discard an initializing expression, materialize it first. + expr_id = MaterializeIfInitializing(expr_id); + + // TODO: This will eventually need to do some "do not discard" analysis. + (void)expr_id; +} + auto SemanticsContext::ImplicitAsForArgs( SemanticsNodeBlockId arg_refs_id, ParseTree::Node param_parse_node, SemanticsNodeBlockId param_refs_id, diff --git a/toolchain/semantics/semantics_context.h b/toolchain/semantics/semantics_context.h index 1a442a9d1cc9a..6763bea5c7a6b 100644 --- a/toolchain/semantics/semantics_context.h +++ b/toolchain/semantics/semantics_context.h @@ -117,6 +117,16 @@ class SemanticsContext { SemanticsNodeId target_id) -> SemanticsNodeId; + // Converts the given expression to an ephemeral reference to a temporary if + // it is an initializing expression. + auto MaterializeIfInitializing(SemanticsNodeId expr_id) -> SemanticsNodeId { + if (GetSemanticsExpressionCategory(semantics_ir(), expr_id) == + SemanticsExpressionCategory::Initializing) { + return MaterializeTemporary(expr_id); + } + return expr_id; + } + // Convert the given expression to a value expression of the same type. auto ConvertToValueExpression(SemanticsNodeId expr_id) -> SemanticsNodeId; @@ -145,6 +155,9 @@ class SemanticsContext { CanonicalizeType(SemanticsNodeId::BuiltinBoolType)); } + // Handles an expression whose result is discarded. + auto HandleDiscardedExpression(SemanticsNodeId id) -> void; + // Runs ImplicitAsImpl for a set of arguments and parameters. // // This will eventually need to support checking against multiple possible @@ -289,6 +302,10 @@ class SemanticsContext { // TODO: This likely needs to track things which need to be destructed. }; + // Materializes a temporary to store the result of initializing expression + // `init_id`. + auto MaterializeTemporary(SemanticsNodeId init_id) -> SemanticsNodeId; + // Marks the initializer `init_id` as initializing `target_id`. auto MarkInitializerFor(SemanticsNodeId target_id, SemanticsNodeId init_id) -> void; diff --git a/toolchain/semantics/semantics_handle_call_expression.cpp b/toolchain/semantics/semantics_handle_call_expression.cpp index 8246ea54a929b..4a9399b84e5b6 100644 --- a/toolchain/semantics/semantics_handle_call_expression.cpp +++ b/toolchain/semantics/semantics_handle_call_expression.cpp @@ -44,9 +44,17 @@ auto SemanticsHandleCallExpression(SemanticsContext& context, // TODO: Propagate return types from callable. SemanticsTypeId type_id = callable.return_type_id; // For functions with an implicit return type, set the return type to empty - // tuple type. + // tuple type. Otherwise, add a location for the return slot to the arguments. + // The actual return slot location will be filled in by + // `SemanticsContext::MarkInitializerFor`. if (type_id == SemanticsTypeId::Invalid) { type_id = context.CanonicalizeTupleType(call_expr_parse_node, {}); + } else { + if (refs_id == SemanticsNodeBlockId::Empty) { + refs_id = context.semantics_ir().AddNodeBlock(); + } + context.semantics_ir().GetNodeBlock(refs_id).push_back( + SemanticsNodeId::Invalid); } auto call_node_id = context.AddNode(SemanticsNode::Call::Make( call_expr_parse_node, type_id, refs_id, function_id)); diff --git a/toolchain/semantics/semantics_handle_function.cpp b/toolchain/semantics/semantics_handle_function.cpp index aa3baa9ce9451..0f60b53a5b5c5 100644 --- a/toolchain/semantics/semantics_handle_function.cpp +++ b/toolchain/semantics/semantics_handle_function.cpp @@ -115,18 +115,20 @@ auto SemanticsHandleFunctionIntroducer(SemanticsContext& context, auto SemanticsHandleReturnType(SemanticsContext& context, ParseTree::Node parse_node) -> bool { + // TODO: Like the function parameters, the return slot and any conversion + // nodes needed for its type are added to an unreferenced node block. We + // should either stop constructing this block or store it somewhere. + // + // See also SemanticsHandleParameterList. + context.node_block_stack().Push(); + // Propagate the type expression. auto [type_parse_node, type_node_id] = context.node_stack().PopExpressionWithParseNode(); auto type_id = context.ExpressionAsType(type_parse_node, type_node_id); - // TODO: Like the function parameters, the return slot is added to an - // unreferenced node block. We should either stop constructing this block or - // store it somewhere. - // - // See also SemanticsHandleParameterList. - context.node_block_stack().Push(); context.AddNodeAndPush(parse_node, SemanticsNode::VarStorage::Make(parse_node, type_id)); + context.node_block_stack().Pop(); return true; } diff --git a/toolchain/semantics/semantics_handle_index.cpp b/toolchain/semantics/semantics_handle_index.cpp index 8d8a682b61a82..913a502d41ae0 100644 --- a/toolchain/semantics/semantics_handle_index.cpp +++ b/toolchain/semantics/semantics_handle_index.cpp @@ -22,6 +22,7 @@ auto SemanticsHandleIndexExpression(SemanticsContext& context, auto index_node_id = context.node_stack().PopExpression(); auto index_node = context.semantics_ir().GetNode(index_node_id); auto name_node_id = context.node_stack().PopExpression(); + name_node_id = context.MaterializeIfInitializing(name_node_id); auto name_node = context.semantics_ir().GetNode(name_node_id); auto name_type_id = context.semantics_ir().GetTypeAllowBuiltinTypes(name_node.type_id()); diff --git a/toolchain/semantics/semantics_handle_name.cpp b/toolchain/semantics/semantics_handle_name.cpp index 47c5fa84e9d1d..8480f2f95d947 100644 --- a/toolchain/semantics/semantics_handle_name.cpp +++ b/toolchain/semantics/semantics_handle_name.cpp @@ -14,10 +14,7 @@ auto SemanticsHandleMemberAccessExpression(SemanticsContext& context, auto base_id = context.node_stack().PopExpression(); // Materialize a temporary for the base expression if necessary. - if (GetSemanticsExpressionCategory(context.semantics_ir(), base_id) == - SemanticsExpressionCategory::Initializing) { - base_id = context.ConvertToValueExpression(base_id); - } + base_id = context.MaterializeIfInitializing(base_id); auto base = context.semantics_ir().GetNode(base_id); if (base.kind() == SemanticsNodeKind::Namespace) { diff --git a/toolchain/semantics/semantics_handle_statement.cpp b/toolchain/semantics/semantics_handle_statement.cpp index 4dd1369558e52..467bf6661396e 100644 --- a/toolchain/semantics/semantics_handle_statement.cpp +++ b/toolchain/semantics/semantics_handle_statement.cpp @@ -10,10 +10,7 @@ namespace Carbon { auto SemanticsHandleExpressionStatement(SemanticsContext& context, ParseTree::Node /*parse_node*/) -> bool { - // Pop the expression without investigating its contents. - // TODO: This will probably eventually need to do some "do not discard" - // analysis. - context.node_stack().PopExpression(); + context.HandleDiscardedExpression(context.node_stack().PopExpression()); return true; } diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index f3668015febed..18369dd7712c1 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -445,10 +445,6 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, continue; } - case SemanticsNodeKind::Call: - // TODO: This should eventually be Initializing. - return SemanticsExpressionCategory::Value; - case SemanticsNodeKind::BindName: { auto [name_id, value_id] = node.GetAsBindName(); node_id = value_id; @@ -496,6 +492,7 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, // struct/tuple value construction. return SemanticsExpressionCategory::Value; + case SemanticsNodeKind::Call: case SemanticsNodeKind::InitializeFrom: return SemanticsExpressionCategory::Initializing; diff --git a/toolchain/semantics/semantics_ir_formatter.cpp b/toolchain/semantics/semantics_ir_formatter.cpp index ef37f82f8a6b0..aa47892f57b44 100644 --- a/toolchain/semantics/semantics_ir_formatter.cpp +++ b/toolchain/semantics/semantics_ir_formatter.cpp @@ -335,6 +335,9 @@ class NodeNamer { // that it's giving a name to, so we need to do this before assigning // fallback names. for (auto node_id : semantics_ir_.GetNodeBlock(block_id)) { + if (!node_id.is_valid()) { + continue; + } auto node = semantics_ir_.GetNode(node_id); switch (node.kind()) { case SemanticsNodeKind::BindName: { @@ -367,6 +370,9 @@ class NodeNamer { // Sequentially number all remaining values. for (auto node_id : semantics_ir_.GetNodeBlock(block_id)) { + if (!node_id.is_valid()) { + continue; + } auto node = semantics_ir_.GetNode(node_id); if (node.kind() != SemanticsNodeKind::BindName && node.kind().value_kind() != SemanticsNodeValueKind::None) { @@ -434,6 +440,10 @@ class SemanticsIRFormatter { for (const SemanticsNodeId param_id : semantics_ir_.GetNodeBlock(fn.param_refs_id)) { out_ << sep; + if (!param_id.is_valid()) { + out_ << "invalid"; + continue; + } auto param = semantics_ir_.GetNode(param_id); auto [name_id, node_id] = param.GetAsBindName(); FormatNodeName(node_id); @@ -591,7 +601,29 @@ class SemanticsIRFormatter { out_ << " "; auto [args_id, callee_id] = node.GetAsCall(); FormatArg(callee_id); - FormatArg(args_id); + + llvm::ArrayRef args = semantics_ir_.GetNodeBlock(args_id); + + bool has_return_slot = + semantics_ir_.GetFunction(callee_id).return_slot_id.is_valid(); + SemanticsNodeId return_slot_id = SemanticsNodeId::Invalid; + if (has_return_slot) { + return_slot_id = args.back(); + args = args.drop_back(); + } + + llvm::ListSeparator sep; + out_ << '('; + for (auto node_id : args) { + out_ << sep; + FormatArg(node_id); + } + out_ << ')'; + + if (has_return_slot) { + out_ << " to "; + FormatArg(return_slot_id); + } } template <> @@ -603,6 +635,16 @@ class SemanticsIRFormatter { out_ << " " << xref_id << "." << node_id; } + template <> + auto FormatInstructionRHS(SemanticsNode node) + -> void { + auto [init_id, target_id] = node.GetAsInitializeFrom(); + out_ << " "; + FormatArg(init_id); + out_ << " to "; + FormatArg(target_id); + } + // StructTypeFields are formatted as part of their StructType. template <> auto FormatInstruction(SemanticsNodeId, diff --git a/toolchain/semantics/testdata/basics/builtin_types.carbon b/toolchain/semantics/testdata/basics/builtin_types.carbon index b82a306e73da4..3280c5bf2714d 100644 --- a/toolchain/semantics/testdata/basics/builtin_types.carbon +++ b/toolchain/semantics/testdata/basics/builtin_types.carbon @@ -82,17 +82,17 @@ var test_type: type = i32; // CHECK:STDOUT: package { // CHECK:STDOUT: %test_i32: i32 = var // CHECK:STDOUT: %.loc7_21.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_21.2: i32 = initialize_from %.loc7_21.1, %test_i32 +// CHECK:STDOUT: %.loc7_21.2: i32 = initialize_from %.loc7_21.1 to %test_i32 // CHECK:STDOUT: assign %test_i32, %.loc7_21.2 // CHECK:STDOUT: %test_f64: f64 = var // CHECK:STDOUT: %.loc8_21.1: f64 = real_literal 1e-1 -// CHECK:STDOUT: %.loc8_21.2: f64 = initialize_from %.loc8_21.1, %test_f64 +// CHECK:STDOUT: %.loc8_21.2: f64 = initialize_from %.loc8_21.1 to %test_f64 // CHECK:STDOUT: assign %test_f64, %.loc8_21.2 // CHECK:STDOUT: %test_str: String = var // CHECK:STDOUT: %.loc9_24.1: String = string_literal "Test" -// CHECK:STDOUT: %.loc9_24.2: String = initialize_from %.loc9_24.1, %test_str +// CHECK:STDOUT: %.loc9_24.2: String = initialize_from %.loc9_24.1 to %test_str // CHECK:STDOUT: assign %test_str, %.loc9_24.2 // CHECK:STDOUT: %test_type: type = var -// CHECK:STDOUT: %.1: type = initialize_from i32, %test_type +// CHECK:STDOUT: %.1: type = initialize_from i32 to %test_type // CHECK:STDOUT: assign %test_type, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon index e7f04383bceea..68888e28ac8e9 100644 --- a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon +++ b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon @@ -47,6 +47,6 @@ var x: type = 42; // CHECK:STDOUT: package { // CHECK:STDOUT: %x: type = var // CHECK:STDOUT: %.loc10: i32 = int_literal 42 -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon index 49e8ef0a4457f..0449bf0978a13 100644 --- a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon +++ b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon @@ -51,6 +51,6 @@ var y: i32 = x.b; // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from , %y +// CHECK:STDOUT: %.1: = initialize_from to %y // CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/parens.carbon b/toolchain/semantics/testdata/basics/parens.carbon index 284e604cb94f9..5c40b9eb76d03 100644 --- a/toolchain/semantics/testdata/basics/parens.carbon +++ b/toolchain/semantics/testdata/basics/parens.carbon @@ -51,6 +51,6 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: %.loc7_23: i32 = int_literal 1 // CHECK:STDOUT: %.loc7_29: i32 = int_literal 2 // CHECK:STDOUT: %.loc7_26.1: i32 = add %.loc7_23, %.loc7_29 -// CHECK:STDOUT: %.loc7_26.2: i32 = initialize_from %.loc7_26.1, %test_i32 +// CHECK:STDOUT: %.loc7_26.2: i32 = initialize_from %.loc7_26.1 to %test_i32 // CHECK:STDOUT: assign %test_i32, %.loc7_26.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index c4a8db422ff83..dde28de99d4a1 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -89,6 +89,6 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: fn @F(%p: const i32**) -> %return: const i32** { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_6.1: const i32** = value_binding %p -// CHECK:STDOUT: %.loc11_6.2: const i32** = initialize_from %.loc11_6.1, %return +// CHECK:STDOUT: %.loc11_6.2: const i32** = initialize_from %.loc11_6.1 to %return // CHECK:STDOUT: return %.loc11_6.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/fail_collapse.carbon b/toolchain/semantics/testdata/const/fail_collapse.carbon index fefb72a224ea7..79d3719b3e947 100644 --- a/toolchain/semantics/testdata/const/fail_collapse.carbon +++ b/toolchain/semantics/testdata/const/fail_collapse.carbon @@ -86,6 +86,6 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%p: const i32**) -> %return: i32** { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.1: = initialize_from , %return +// CHECK:STDOUT: %.1: = initialize_from to %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index cc9cb0dbfa016..75530ca418f24 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -46,6 +46,7 @@ fn Main() { // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -78,9 +79,11 @@ fn Main() { // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -93,7 +96,7 @@ fn Main() { // CHECK:STDOUT: fn @Echo(%a: {}) -> %return: {} { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_9.1: {} = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: {} = initialize_from %.loc7_9.1, %return +// CHECK:STDOUT: %.loc7_9.2: {} = initialize_from %.loc7_9.1 to %return // CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -101,6 +104,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc12_9.1: {} = struct_value () // CHECK:STDOUT: %.loc12_9.2: {} = stub_reference %.loc12_9.1 -// CHECK:STDOUT: %.loc12_7: {} = call @Echo(%.loc12_9.2) +// CHECK:STDOUT: %.loc12_7.1: {} = call @Echo(%.loc12_9.2) to %.loc12_7.2 +// CHECK:STDOUT: %.loc12_7.2: {} = materialize_temporary %.loc12_7.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index d0bd87fd1df1d..a049c0e131041 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -48,6 +48,7 @@ fn Main() { // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -80,9 +81,11 @@ fn Main() { // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -95,7 +98,7 @@ fn Main() { // CHECK:STDOUT: fn @Echo(%a: ()) -> %return: () { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_9.1: () = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: () = initialize_from %.loc7_9.1, %return +// CHECK:STDOUT: %.loc7_9.2: () = initialize_from %.loc7_9.1 to %return // CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -103,6 +106,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc12_9.1: () = tuple_value () // CHECK:STDOUT: %.loc12_9.2: () = stub_reference %.loc12_9.1 -// CHECK:STDOUT: %.loc12_7: () = call @Echo(%.loc12_9.2) +// CHECK:STDOUT: %.loc12_7.1: () = call @Echo(%.loc12_9.2) to %.loc12_7.2 +// CHECK:STDOUT: %.loc12_7.2: () = materialize_temporary %.loc12_7.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon index 50f6ed25d4ce6..95879f06b4540 100644 --- a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon @@ -43,7 +43,7 @@ fn Run() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block5, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+6, type: typeError}, // CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, @@ -71,6 +71,9 @@ fn Run() { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -81,15 +84,15 @@ fn Run() { // CHECK:STDOUT: fn @Foo() -> %return: f64 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_26.1: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.loc7_26.2: f64 = initialize_from %.loc7_26.1, %return +// CHECK:STDOUT: %.loc7_26.2: f64 = initialize_from %.loc7_26.1 to %return // CHECK:STDOUT: return %.loc7_26.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc13: f64 = call @Foo() -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.loc13: f64 = call @Foo() to invalid +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index 6f3e89e17bfab..1909d7db4cbcd 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -47,8 +47,7 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+8, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+13}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -81,10 +80,10 @@ fn Main() { // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -96,7 +95,7 @@ fn Main() { // CHECK:STDOUT: fn @Echo(%a: i32) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_9.1: i32 = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: i32 = initialize_from %.loc7_9.1, %return +// CHECK:STDOUT: %.loc7_9.2: i32 = initialize_from %.loc7_9.1 to %return // CHECK:STDOUT: return %.loc7_9.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -105,8 +104,7 @@ fn Main() { // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc12_21.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc12_21.2: i32 = stub_reference %.loc12_21.1 -// CHECK:STDOUT: %.loc12_20.1: i32 = call @Echo(%.loc12_21.2) -// CHECK:STDOUT: %.loc12_20.2: i32 = initialize_from %.loc12_20.1, %b -// CHECK:STDOUT: assign %b, %.loc12_20.2 +// CHECK:STDOUT: %.loc12_20: i32 = call @Echo(%.loc12_21.2) to %b +// CHECK:STDOUT: assign %b, %.loc12_20 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/more_param_ir.carbon b/toolchain/semantics/testdata/function/call/more_param_ir.carbon index e56940ce894cb..12d524ed38d54 100644 --- a/toolchain/semantics/testdata/function/call/more_param_ir.carbon +++ b/toolchain/semantics/testdata/function/call/more_param_ir.carbon @@ -65,6 +65,7 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+22, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -106,6 +107,7 @@ fn Main() { // CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, // CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+14, @@ -140,5 +142,6 @@ fn Main() { // CHECK:STDOUT: %.loc11_25.2: i32 = stub_reference %.loc11_25.1 // CHECK:STDOUT: %.loc11_6.1: type = tuple_type () // CHECK:STDOUT: %.loc11_6.2: () = call @Foo(%.loc11_13.2, %.loc11_20.2, %.loc11_25.2) +// CHECK:STDOUT: %.loc11_6.3: () = materialize_temporary %.loc11_6.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_one.carbon b/toolchain/semantics/testdata/function/call/params_one.carbon index 252495205fa35..43b649ae36e53 100644 --- a/toolchain/semantics/testdata/function/call/params_one.carbon +++ b/toolchain/semantics/testdata/function/call/params_one.carbon @@ -43,6 +43,7 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -68,6 +69,7 @@ fn Main() { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, @@ -90,5 +92,6 @@ fn Main() { // CHECK:STDOUT: %.loc10_7.2: i32 = stub_reference %.loc10_7.1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo(%.loc10_7.2) +// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_one_comma.carbon b/toolchain/semantics/testdata/function/call/params_one_comma.carbon index e1d7d9025a824..cec585e0494fa 100644 --- a/toolchain/semantics/testdata/function/call/params_one_comma.carbon +++ b/toolchain/semantics/testdata/function/call/params_one_comma.carbon @@ -45,9 +45,11 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -76,12 +78,14 @@ fn Main() { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -101,8 +105,10 @@ fn Main() { // CHECK:STDOUT: %.loc10_7.2: i32 = stub_reference %.loc10_7.1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo(%.loc10_7.2) +// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: %.loc11_7.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_7.2: i32 = stub_reference %.loc11_7.1 -// CHECK:STDOUT: %.loc11_6: () = call @Foo(%.loc11_7.2) +// CHECK:STDOUT: %.loc11_6.1: () = call @Foo(%.loc11_7.2) +// CHECK:STDOUT: %.loc11_6.2: () = materialize_temporary %.loc11_6.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_two.carbon b/toolchain/semantics/testdata/function/call/params_two.carbon index da85124cb7010..d5738f47487ca 100644 --- a/toolchain/semantics/testdata/function/call/params_two.carbon +++ b/toolchain/semantics/testdata/function/call/params_two.carbon @@ -49,6 +49,7 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -79,6 +80,7 @@ fn Main() { // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+8, @@ -104,5 +106,6 @@ fn Main() { // CHECK:STDOUT: %.loc10_10.2: i32 = stub_reference %.loc10_10.1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo(%.loc10_7.2, %.loc10_10.2) +// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_two_comma.carbon b/toolchain/semantics/testdata/function/call/params_two_comma.carbon index e2c5fc5e61230..b5ff39f1824cd 100644 --- a/toolchain/semantics/testdata/function/call/params_two_comma.carbon +++ b/toolchain/semantics/testdata/function/call/params_two_comma.carbon @@ -52,11 +52,13 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+15, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+18, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -92,14 +94,16 @@ fn Main() { // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -121,10 +125,12 @@ fn Main() { // CHECK:STDOUT: %.loc10_10.2: i32 = stub_reference %.loc10_10.1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo(%.loc10_7.2, %.loc10_10.2) +// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: %.loc11_7.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_7.2: i32 = stub_reference %.loc11_7.1 // CHECK:STDOUT: %.loc11_10.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc11_10.2: i32 = stub_reference %.loc11_10.1 -// CHECK:STDOUT: %.loc11_6: () = call @Foo(%.loc11_7.2, %.loc11_10.2) +// CHECK:STDOUT: %.loc11_6.1: () = call @Foo(%.loc11_7.2, %.loc11_10.2) +// CHECK:STDOUT: %.loc11_6.2: () = materialize_temporary %.loc11_6.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_zero.carbon b/toolchain/semantics/testdata/function/call/params_zero.carbon index d0f487a3ed375..9cd4dbb8f3836 100644 --- a/toolchain/semantics/testdata/function/call/params_zero.carbon +++ b/toolchain/semantics/testdata/function/call/params_zero.carbon @@ -36,6 +36,7 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -52,6 +53,7 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -69,5 +71,6 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo() +// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/return_implicit.carbon b/toolchain/semantics/testdata/function/call/return_implicit.carbon index 6545566fa4b72..46c8f4c53af8a 100644 --- a/toolchain/semantics/testdata/function/call/return_implicit.carbon +++ b/toolchain/semantics/testdata/function/call/return_implicit.carbon @@ -41,8 +41,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -63,7 +62,6 @@ fn Main() { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -82,8 +80,7 @@ fn Main() { // CHECK:STDOUT: %.loc11_11.1: type = tuple_type () // CHECK:STDOUT: %.loc11_11.2: () = tuple_value () // CHECK:STDOUT: %b: () = var -// CHECK:STDOUT: %.loc11_37.1: () = call @MakeImplicitEmptyTuple() -// CHECK:STDOUT: %.loc11_37.2: () = initialize_from %.loc11_37.1, %b -// CHECK:STDOUT: assign %b, %.loc11_37.2 +// CHECK:STDOUT: %.loc11_37: () = call @MakeImplicitEmptyTuple() +// CHECK:STDOUT: assign %b, %.loc11_37 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/declaration/simple.carbon b/toolchain/semantics/testdata/function/declaration/simple.carbon index 49f83992d85e5..4e9da5a1a5711 100644 --- a/toolchain/semantics/testdata/function/declaration/simple.carbon +++ b/toolchain/semantics/testdata/function/declaration/simple.carbon @@ -33,6 +33,7 @@ fn G() { F(); } // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+3, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -46,6 +47,7 @@ fn G() { F(); } // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -60,5 +62,6 @@ fn G() { F(); } // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc9_11.1: type = tuple_type () // CHECK:STDOUT: %.loc9_11.2: () = call @F() +// CHECK:STDOUT: %.loc9_11.3: () = materialize_temporary %.loc9_11.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/else.carbon b/toolchain/semantics/testdata/if/else.carbon index 9f0e067b64237..efa35fd367b49 100644 --- a/toolchain/semantics/testdata/if/else.carbon +++ b/toolchain/semantics/testdata/if/else.carbon @@ -58,10 +58,13 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+15, type: type1}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function2, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+19, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -97,15 +100,18 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -139,13 +145,16 @@ fn If(b: bool) { // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc13_6.1: type = tuple_type () // CHECK:STDOUT: %.loc13_6.2: () = call @F() +// CHECK:STDOUT: %.loc13_6.3: () = materialize_temporary %.loc13_6.2 // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.loc15: () = call @G() +// CHECK:STDOUT: %.loc15_6.1: () = call @G() +// CHECK:STDOUT: %.loc15_6.2: () = materialize_temporary %.loc15_6.1 // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.done: -// CHECK:STDOUT: %.loc17: () = call @H() +// CHECK:STDOUT: %.loc17_4.1: () = call @H() +// CHECK:STDOUT: %.loc17_4.2: () = materialize_temporary %.loc17_4.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index 45311876e66f6..ada86c6e777c8 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -188,7 +188,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc9_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1, %return +// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 to %return // CHECK:STDOUT: return %.loc9_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: @@ -207,7 +207,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: %.loc20_12.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc20_12.2: i32 = initialize_from %.loc20_12.1, %return +// CHECK:STDOUT: %.loc20_12.2: i32 = initialize_from %.loc20_12.1 to %return // CHECK:STDOUT: return %.loc20_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.done: @@ -220,7 +220,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc29_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc29_12.2: i32 = initialize_from %.loc29_12.1, %return +// CHECK:STDOUT: %.loc29_12.2: i32 = initialize_from %.loc29_12.1 to %return // CHECK:STDOUT: return %.loc29_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index 9df85585e7eba..8f1e1f793ab06 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -104,13 +104,13 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n: i32 = var // CHECK:STDOUT: %.loc9_18.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc9_18.2: i32 = initialize_from %.loc9_18.1, %n +// CHECK:STDOUT: %.loc9_18.2: i32 = initialize_from %.loc9_18.1 to %n // CHECK:STDOUT: assign %n, %.loc9_18.2 // CHECK:STDOUT: %.loc9_9.1: i32 = value_binding %n -// CHECK:STDOUT: %.loc9_9.2: i32 = initialize_from %.loc9_9.1, %return +// CHECK:STDOUT: %.loc9_9.2: i32 = initialize_from %.loc9_9.1 to %return // CHECK:STDOUT: return %.loc9_9.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.1: = initialize_from , %return +// CHECK:STDOUT: %.1: = initialize_from to %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/no_else.carbon b/toolchain/semantics/testdata/if/no_else.carbon index 347ada443c0d1..47fbeca0dcc2e 100644 --- a/toolchain/semantics/testdata/if/no_else.carbon +++ b/toolchain/semantics/testdata/if/no_else.carbon @@ -51,8 +51,10 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+11, type: type1}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+14, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -85,10 +87,12 @@ fn If(b: bool) { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -116,9 +120,11 @@ fn If(b: bool) { // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc12_6.1: type = tuple_type () // CHECK:STDOUT: %.loc12_6.2: () = call @F() +// CHECK:STDOUT: %.loc12_6.3: () = materialize_temporary %.loc12_6.2 // CHECK:STDOUT: br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.loc14: () = call @G() +// CHECK:STDOUT: %.loc14_4.1: () = call @G() +// CHECK:STDOUT: %.loc14_4.2: () = materialize_temporary %.loc14_4.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index 279cbeb407c0a..36ff91230c5d4 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -92,11 +92,11 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc9_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1, %return +// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 to %return // CHECK:STDOUT: return %.loc9_12.2 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: %.loc11_12.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc11_12.2: i32 = initialize_from %.loc11_12.1, %return +// CHECK:STDOUT: %.loc11_12.2: i32 = initialize_from %.loc11_12.1 to %return // CHECK:STDOUT: return %.loc11_12.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index a2ff76582a709..4ceb2e1f5fe42 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -121,6 +121,6 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1, %return +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 to %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/constant_condition.carbon b/toolchain/semantics/testdata/if_expression/constant_condition.carbon index 55965b14d894e..1e7952654f1ae 100644 --- a/toolchain/semantics/testdata/if_expression/constant_condition.carbon +++ b/toolchain/semantics/testdata/if_expression/constant_condition.carbon @@ -19,8 +19,8 @@ fn G() -> i32 { // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9, block10}}}, -// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, return_slot: node+22, body: {block12, block13, block14, block15}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9, block12}}}, +// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, return_slot: node+26, body: {block14, block15, block16, block19}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -56,25 +56,33 @@ fn G() -> i32 { // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, // CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+20}, +// CHECK:STDOUT: {kind: Call, arg0: block10, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+15, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+17}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+20}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+24}, -// CHECK:STDOUT: {kind: Branch, arg0: block14}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+27}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+28}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block15, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+31, arg1: node+22, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+32}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+28}, +// CHECK:STDOUT: {kind: Branch, arg0: block16}, +// CHECK:STDOUT: {kind: Call, arg0: block17, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+31, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+32, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block18, arg1: function1, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+34, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+35, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block19, arg1: node+33}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block19, arg1: node+36}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block19, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+39, arg1: node+26, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+40}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -86,7 +94,7 @@ fn G() -> i32 { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, @@ -111,37 +119,57 @@ fn G() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+18, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, // CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: node+30, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+32, // CHECK:STDOUT: node+33, +// CHECK:STDOUT: node+37, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+36, +// CHECK:STDOUT: node+38, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+32, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+35, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+39, +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+41, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -155,14 +183,14 @@ fn G() -> i32 { // CHECK:STDOUT: fn @A() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1, %return +// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 to %return // CHECK:STDOUT: return %.loc7_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @B() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_24.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1, %return +// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 to %return // CHECK:STDOUT: return %.loc8_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -172,16 +200,20 @@ 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: %.loc11_24: i32 = call @A() -// CHECK:STDOUT: br !if.expr.result(%.loc11_24) +// CHECK:STDOUT: %.loc11_24.1: i32 = call @A() to %.loc11_24.2 +// CHECK:STDOUT: %.loc11_24.2: i32 = materialize_temporary %.loc11_24.1 +// CHECK:STDOUT: %.loc11_24.3: i32 = value_binding %.loc11_24.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_24.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_33: i32 = call @B() -// CHECK:STDOUT: br !if.expr.result(%.loc11_33) +// CHECK:STDOUT: %.loc11_33.1: i32 = call @B() to %.loc11_33.2 +// CHECK:STDOUT: %.loc11_33.2: i32 = materialize_temporary %.loc11_33.1 +// CHECK:STDOUT: %.loc11_33.3: i32 = value_binding %.loc11_33.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_33.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1, %return +// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 to %return // CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -191,15 +223,19 @@ 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: %.loc15_25: i32 = call @A() -// CHECK:STDOUT: br !if.expr.result(%.loc15_25) +// CHECK:STDOUT: %.loc15_25.1: i32 = call @A() to %.loc15_25.2 +// CHECK:STDOUT: %.loc15_25.2: i32 = materialize_temporary %.loc15_25.1 +// CHECK:STDOUT: %.loc15_25.3: i32 = value_binding %.loc15_25.2 +// CHECK:STDOUT: br !if.expr.result(%.loc15_25.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc15_34: i32 = call @B() -// CHECK:STDOUT: br !if.expr.result(%.loc15_34) +// CHECK:STDOUT: %.loc15_34.1: i32 = call @B() to %.loc15_34.2 +// CHECK:STDOUT: %.loc15_34.2: i32 = materialize_temporary %.loc15_34.1 +// CHECK:STDOUT: %.loc15_34.3: i32 = value_binding %.loc15_34.2 +// CHECK:STDOUT: br !if.expr.result(%.loc15_34.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc15_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc15_10.2: i32 = initialize_from %.loc15_10.1, %return +// CHECK:STDOUT: %.loc15_10.2: i32 = initialize_from %.loc15_10.1 to %return // CHECK:STDOUT: return %.loc15_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index 3624222eccb57..2d65c59b45eb1 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -15,7 +15,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type0, return_slot: node+12, body: {block9, block10, block11, block12}}}, +// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type0, return_slot: node+12, body: {block9, block10, block11, block14}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -53,13 +53,17 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type1}, // CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+14}, // CHECK:STDOUT: {kind: Branch, arg0: block11}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+17}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+18}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+12, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+22}, +// CHECK:STDOUT: {kind: Call, arg0: block12, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+17, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block13, arg1: function1, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+22}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block14, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+12, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+26}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -102,16 +106,26 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+23, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -124,14 +138,14 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: fn @A() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1, %return +// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 to %return // CHECK:STDOUT: return %.loc7_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @B() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_24.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1, %return +// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 to %return // CHECK:STDOUT: return %.loc8_24.2 // CHECK:STDOUT: } // CHECK:STDOUT: @@ -141,15 +155,19 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: if %.loc10 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc11_21: i32 = call @A() -// CHECK:STDOUT: br !if.expr.result(%.loc11_21) +// CHECK:STDOUT: %.loc11_21.1: i32 = call @A() to %.loc11_21.2 +// CHECK:STDOUT: %.loc11_21.2: i32 = materialize_temporary %.loc11_21.1 +// CHECK:STDOUT: %.loc11_21.3: i32 = value_binding %.loc11_21.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_21.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_30: i32 = call @B() -// CHECK:STDOUT: br !if.expr.result(%.loc11_30) +// CHECK:STDOUT: %.loc11_30.1: i32 = call @B() to %.loc11_30.2 +// CHECK:STDOUT: %.loc11_30.2: i32 = materialize_temporary %.loc11_30.1 +// CHECK:STDOUT: %.loc11_30.3: i32 = value_binding %.loc11_30.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_30.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1, %return +// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 to %return // CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index 8789e86f0d5e2..60fe92113788e 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -177,6 +177,6 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc8_10: // CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !if.expr.result.loc8_10 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1, %return +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 to %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/element_access.carbon b/toolchain/semantics/testdata/index/element_access.carbon index c8d010b10f216..5307ef88c3ced 100644 --- a/toolchain/semantics/testdata/index/element_access.carbon +++ b/toolchain/semantics/testdata/index/element_access.carbon @@ -112,18 +112,18 @@ var c: i32 = b[0]; // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 // CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1, %a +// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 to %a // CHECK:STDOUT: assign %a, %.loc7_21.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var // CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1, %b +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 to %b // CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 // CHECK:STDOUT: %.loc9_17.1: i32 = tuple_index %b, %.loc9_16 // CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 -// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2, %c +// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2 to %c // CHECK:STDOUT: assign %c, %.loc9_17.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_empty_tuple_access.carbon b/toolchain/semantics/testdata/index/fail_empty_tuple_access.carbon index 3664b0e412c5a..9da59b76992bb 100644 --- a/toolchain/semantics/testdata/index/fail_empty_tuple_access.carbon +++ b/toolchain/semantics/testdata/index/fail_empty_tuple_access.carbon @@ -42,6 +42,7 @@ fn Run() { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -59,6 +60,7 @@ fn Run() { // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -77,5 +79,6 @@ fn Run() { // CHECK:STDOUT: %.loc13_4.1: type = tuple_type () // CHECK:STDOUT: %.loc13_4.2: () = call @F() // CHECK:STDOUT: %.loc13_7: i32 = int_literal 0 +// CHECK:STDOUT: %.loc13_4.3: () = materialize_temporary %.loc13_4.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_large_index.carbon b/toolchain/semantics/testdata/index/fail_large_index.carbon index 11988ed66160e..6377569c866ac 100644 --- a/toolchain/semantics/testdata/index/fail_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_large_index.carbon @@ -111,16 +111,16 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 // CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1, %a +// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 to %a // CHECK:STDOUT: assign %a, %.loc7_21.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var // CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1, %b +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 to %b // CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc12: i32 = int_literal -1 -// CHECK:STDOUT: %.1: = initialize_from , %c +// CHECK:STDOUT: %.1: = initialize_from to %c // CHECK:STDOUT: assign %c, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_name_not_found.carbon b/toolchain/semantics/testdata/index/fail_name_not_found.carbon index e5f22a1186820..f63361e1c1ce9 100644 --- a/toolchain/semantics/testdata/index/fail_name_not_found.carbon +++ b/toolchain/semantics/testdata/index/fail_name_not_found.carbon @@ -63,7 +63,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 0 -// CHECK:STDOUT: %.1: = initialize_from , %b +// CHECK:STDOUT: %.1: = initialize_from to %b // CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon index a0a05cc98e0e4..15ac2a9de6b2a 100644 --- a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon +++ b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon @@ -116,13 +116,13 @@ var c: i32 = a[b]; // CHECK:STDOUT: %.loc7_25.1: i32 = int_literal 3 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 // CHECK:STDOUT: %.loc7_26.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = initialize_from %.loc7_26.1, %a +// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = initialize_from %.loc7_26.1 to %a // CHECK:STDOUT: assign %a, %.loc7_26.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1, %b +// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1 to %b // CHECK:STDOUT: assign %b, %.loc8_14.2 // CHECK:STDOUT: %c: i32 = var -// CHECK:STDOUT: %.1: = initialize_from , %c +// CHECK:STDOUT: %.1: = initialize_from to %c // CHECK:STDOUT: assign %c, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon b/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon index 980ce958c7de7..1c524434600c1 100644 --- a/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_non_int_indexing.carbon @@ -107,10 +107,10 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_26.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 // CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1, %a +// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 to %a // CHECK:STDOUT: assign %a, %.loc7_27.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 26e-1 -// CHECK:STDOUT: %.1: = initialize_from , %b +// CHECK:STDOUT: %.1: = initialize_from to %b // CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon b/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon index 2e970b44298e3..a218d23b42f63 100644 --- a/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon +++ b/toolchain/semantics/testdata/index/fail_out_of_bound_access.carbon @@ -106,10 +106,10 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_26.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 // CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1, %a +// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 to %a // CHECK:STDOUT: assign %a, %.loc7_27.2 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 2 -// CHECK:STDOUT: %.1: = initialize_from , %b +// CHECK:STDOUT: %.1: = initialize_from to %b // CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/return_value_access.carbon b/toolchain/semantics/testdata/index/return_value_access.carbon index 1ef085842e722..abae24400dc7c 100644 --- a/toolchain/semantics/testdata/index/return_value_access.carbon +++ b/toolchain/semantics/testdata/index/return_value_access.carbon @@ -52,11 +52,13 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, +// CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+13, arg1: node+14, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+11, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type2}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+15, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, arg1: node+11, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -65,7 +67,6 @@ fn Run() -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+12, // CHECK:STDOUT: ], @@ -73,6 +74,7 @@ fn Run() -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -94,6 +96,11 @@ fn Run() -> i32 { // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -101,7 +108,6 @@ fn Run() -> i32 { // CHECK:STDOUT: %.loc7_12: type = stub_reference i32 // CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) // CHECK:STDOUT: %.loc7_16.2: (type,) = tuple_value (%.loc7_12) -// CHECK:STDOUT: %.loc7_16.3: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_1 = fn_decl @F // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } @@ -111,15 +117,17 @@ fn Run() -> i32 { // CHECK:STDOUT: %.loc7_28.1: i32 = int_literal 0 // CHECK:STDOUT: %.loc7_28.2: i32 = stub_reference %.loc7_28.1 // CHECK:STDOUT: %.loc7_30.1: (i32,) = tuple_value (%.loc7_28.2) -// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1, %return +// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1 to %return // CHECK:STDOUT: return %.loc7_30.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> %return: i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10_11: (i32,) = call @F() +// CHECK:STDOUT: %.loc10_11.1: (i32,) = call @F() to %.loc10_11.2 // CHECK:STDOUT: %.loc10_14: i32 = int_literal 0 -// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11, %.loc10_14 -// CHECK:STDOUT: %.loc10_15.2: i32 = initialize_from %.loc10_15.1, %return -// CHECK:STDOUT: return %.loc10_15.2 +// CHECK:STDOUT: %.loc10_11.2: (i32,) = materialize_temporary %.loc10_11.1 +// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11.2, %.loc10_14 +// CHECK:STDOUT: %.loc10_15.2: i32 = value_binding %.loc10_15.1 +// CHECK:STDOUT: %.loc10_15.3: i32 = initialize_from %.loc10_15.2 to %return +// CHECK:STDOUT: return %.loc10_15.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon index 5d8cc56935a5c..e14ba5a7a08a7 100644 --- a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon +++ b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon @@ -81,7 +81,7 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n.loc7_14: i32 = var // CHECK:STDOUT: %.loc7_23.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_23.2: i32 = initialize_from %.loc7_23.1, %n.loc7_14 +// CHECK:STDOUT: %.loc7_23.2: i32 = initialize_from %.loc7_23.1 to %n.loc7_14 // CHECK:STDOUT: assign %n.loc7_14, %.loc7_23.2 // CHECK:STDOUT: %.loc7_30: bool = bool_literal true // CHECK:STDOUT: if %.loc7_30 br !if.then else br !if.else @@ -89,7 +89,7 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n.loc7_42: i32 = var // CHECK:STDOUT: %.loc7_51.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc7_51.2: i32 = initialize_from %.loc7_51.1, %n.loc7_42 +// CHECK:STDOUT: %.loc7_51.2: i32 = initialize_from %.loc7_51.1 to %n.loc7_42 // CHECK:STDOUT: assign %n.loc7_42, %.loc7_51.2 // CHECK:STDOUT: br !if.else // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/namespace/function.carbon b/toolchain/semantics/testdata/namespace/function.carbon index a31971d86dd7e..68d66099973fb 100644 --- a/toolchain/semantics/testdata/namespace/function.carbon +++ b/toolchain/semantics/testdata/namespace/function.carbon @@ -48,6 +48,7 @@ fn Bar() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+7, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -69,6 +70,7 @@ fn Bar() { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -93,5 +95,6 @@ fn Bar() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc17_10.1: type = tuple_type () // CHECK:STDOUT: %.loc17_10.2: () = call @Baz.2() +// CHECK:STDOUT: %.loc17_10.3: () = materialize_temporary %.loc17_10.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/namespace/nested.carbon b/toolchain/semantics/testdata/namespace/nested.carbon index 8b6f9bb49f4e1..02f646762626c 100644 --- a/toolchain/semantics/testdata/namespace/nested.carbon +++ b/toolchain/semantics/testdata/namespace/nested.carbon @@ -44,6 +44,7 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+6, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -62,6 +63,7 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -81,5 +83,6 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc14_14.1: type = tuple_type () // CHECK:STDOUT: %.loc14_14.2: () = call @Wiz() +// CHECK:STDOUT: %.loc14_14.3: () = materialize_temporary %.loc14_14.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/and.carbon b/toolchain/semantics/testdata/operators/and.carbon index 7fd59ec0ad9cd..1e68c52c4c020 100644 --- a/toolchain/semantics/testdata/operators/and.carbon +++ b/toolchain/semantics/testdata/operators/and.carbon @@ -15,7 +15,7 @@ fn And() -> bool { // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block9, block10}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -44,15 +44,19 @@ fn And() -> bool { // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+12}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+13}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+16}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+14}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+15}, +// CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+20}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -86,15 +90,25 @@ fn And() -> bool { // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -107,29 +121,33 @@ fn And() -> bool { // CHECK:STDOUT: fn @F() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1, %return +// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 to %return // CHECK:STDOUT: return %.loc7_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1, %return +// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 to %return // CHECK:STDOUT: return %.loc8_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @And() -> %return: bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11: bool = call @F() +// CHECK:STDOUT: %.loc11_11.1: bool = call @F() to %.loc11_11.2 +// CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary %.loc11_11.1 +// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 // CHECK:STDOUT: %.loc11_14.1: bool = bool_literal false -// CHECK:STDOUT: if %.loc11_11 br !and.rhs else br !and.result(%.loc11_14.1) +// CHECK:STDOUT: if %.loc11_11.3 br !and.rhs else br !and.result(%.loc11_14.1) // CHECK:STDOUT: // CHECK:STDOUT: !and.rhs: -// CHECK:STDOUT: %.loc11_19: bool = call @G() -// CHECK:STDOUT: br !and.result(%.loc11_19) +// CHECK:STDOUT: %.loc11_19.1: bool = call @G() to %.loc11_19.2 +// CHECK:STDOUT: %.loc11_19.2: bool = materialize_temporary %.loc11_19.1 +// CHECK:STDOUT: %.loc11_19.3: bool = value_binding %.loc11_19.2 +// CHECK:STDOUT: br !and.result(%.loc11_19.3) // CHECK:STDOUT: // CHECK:STDOUT: !and.result: // CHECK:STDOUT: %.loc11_14.2: bool = block_arg !and.result -// CHECK:STDOUT: %.loc11_14.3: bool = initialize_from %.loc11_14.2, %return +// CHECK:STDOUT: %.loc11_14.3: bool = initialize_from %.loc11_14.2 to %return // CHECK:STDOUT: return %.loc11_14.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/assignment.carbon b/toolchain/semantics/testdata/operators/assignment.carbon index 1e60e4a307f15..c938adf632f6a 100644 --- a/toolchain/semantics/testdata/operators/assignment.carbon +++ b/toolchain/semantics/testdata/operators/assignment.carbon @@ -270,10 +270,10 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 12 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %a +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %a // CHECK:STDOUT: assign %a, %.loc8_16.2 // CHECK:STDOUT: %.loc9_7.1: i32 = int_literal -7 -// CHECK:STDOUT: %.loc9_7.2: i32 = initialize_from %.loc9_7.1, %a +// CHECK:STDOUT: %.loc9_7.2: i32 = initialize_from %.loc9_7.1 to %a // CHECK:STDOUT: assign %a, %.loc9_7.2 // CHECK:STDOUT: %.loc11_11: type = stub_reference i32 // CHECK:STDOUT: %.loc11_16: type = stub_reference i32 @@ -286,17 +286,17 @@ fn Main() { // CHECK:STDOUT: %.loc11_27.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc11_27.2: i32 = stub_reference %.loc11_27.1 // CHECK:STDOUT: %.loc11_28.1: (i32, i32) = tuple_value (%.loc11_24.2, %.loc11_27.2) -// CHECK:STDOUT: %.loc11_28.2: (i32, i32) = initialize_from %.loc11_28.1, %b +// CHECK:STDOUT: %.loc11_28.2: (i32, i32) = initialize_from %.loc11_28.1 to %b // CHECK:STDOUT: assign %b, %.loc11_28.2 // CHECK:STDOUT: %.loc12_5: i32 = int_literal 0 // CHECK:STDOUT: %.loc12_6: i32 = tuple_index %b, %.loc12_5 // CHECK:STDOUT: %.loc12_10.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc12_10.2: i32 = initialize_from %.loc12_10.1, %.loc12_6 +// CHECK:STDOUT: %.loc12_10.2: i32 = initialize_from %.loc12_10.1 to %.loc12_6 // CHECK:STDOUT: assign %.loc12_6, %.loc12_10.2 // CHECK:STDOUT: %.loc13_5: i32 = int_literal 1 // CHECK:STDOUT: %.loc13_6: i32 = tuple_index %b, %.loc13_5 // CHECK:STDOUT: %.loc13_10.1: i32 = int_literal 4 -// CHECK:STDOUT: %.loc13_10.2: i32 = initialize_from %.loc13_10.1, %.loc13_6 +// CHECK:STDOUT: %.loc13_10.2: i32 = initialize_from %.loc13_10.1 to %.loc13_6 // CHECK:STDOUT: assign %.loc13_6, %.loc13_10.2 // CHECK:STDOUT: %.loc15_27: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %c: {.a: i32, .b: i32} = var @@ -305,25 +305,25 @@ fn Main() { // CHECK:STDOUT: %.loc15_45: i32 = int_literal 2 // CHECK:STDOUT: %.loc15_43: i32 = stub_reference %.loc15_45 // CHECK:STDOUT: %.loc15_46.1: {.a: i32, .b: i32} = struct_value (%.loc15_35, %.loc15_43) -// CHECK:STDOUT: %.loc15_46.2: {.a: i32, .b: i32} = initialize_from %.loc15_46.1, %c +// CHECK:STDOUT: %.loc15_46.2: {.a: i32, .b: i32} = initialize_from %.loc15_46.1 to %c // CHECK:STDOUT: assign %c, %.loc15_46.2 // CHECK:STDOUT: %.loc16_4: i32 = struct_access %c, member0 // CHECK:STDOUT: %.loc16_9.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc16_9.2: i32 = initialize_from %.loc16_9.1, %.loc16_4 +// CHECK:STDOUT: %.loc16_9.2: i32 = initialize_from %.loc16_9.1 to %.loc16_4 // CHECK:STDOUT: assign %.loc16_4, %.loc16_9.2 // CHECK:STDOUT: %.loc17_4: i32 = struct_access %c, member1 // CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 4 -// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1, %.loc17_4 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 to %.loc17_4 // CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 // CHECK:STDOUT: %.loc19_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var // CHECK:STDOUT: %.loc19_17.1: i32* = address_of %a -// CHECK:STDOUT: %.loc19_17.2: i32* = initialize_from %.loc19_17.1, %p +// CHECK:STDOUT: %.loc19_17.2: i32* = initialize_from %.loc19_17.1 to %p // CHECK:STDOUT: assign %p, %.loc19_17.2 // CHECK:STDOUT: %.loc19_7.1: i32* = value_binding %p // CHECK:STDOUT: %.loc20_3: i32 = dereference %.loc19_7.1 // CHECK:STDOUT: %.loc20_8.1: i32 = int_literal 5 -// CHECK:STDOUT: %.loc20_8.2: i32 = initialize_from %.loc20_8.1, %.loc20_3 +// CHECK:STDOUT: %.loc20_8.2: i32 = initialize_from %.loc20_8.1 to %.loc20_3 // CHECK:STDOUT: assign %.loc20_3, %.loc20_8.2 // CHECK:STDOUT: %.loc22_8: bool = bool_literal true // CHECK:STDOUT: if %.loc22_8 br !if.expr.then else br !if.expr.else @@ -340,7 +340,7 @@ fn Main() { // CHECK:STDOUT: %.loc22_5: i32* = block_arg !if.expr.result // CHECK:STDOUT: %.loc22_3: i32 = dereference %.loc22_5 // CHECK:STDOUT: %.loc22_31.1: i32 = int_literal 10 -// CHECK:STDOUT: %.loc22_31.2: i32 = initialize_from %.loc22_31.1, %.loc22_3 +// CHECK:STDOUT: %.loc22_31.2: i32 = initialize_from %.loc22_31.1 to %.loc22_3 // CHECK:STDOUT: assign %.loc22_3, %.loc22_31.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/binary_op.carbon b/toolchain/semantics/testdata/operators/binary_op.carbon index ecbbafee6fe13..5817dfa5db05f 100644 --- a/toolchain/semantics/testdata/operators/binary_op.carbon +++ b/toolchain/semantics/testdata/operators/binary_op.carbon @@ -62,6 +62,6 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc8_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc8_15: i32 = int_literal 34 // CHECK:STDOUT: %.loc8_13.1: i32 = add %.loc8_10, %.loc8_15 -// CHECK:STDOUT: %.loc8_13.2: i32 = initialize_from %.loc8_13.1, %return +// CHECK:STDOUT: %.loc8_13.2: i32 = initialize_from %.loc8_13.1 to %return // CHECK:STDOUT: return %.loc8_13.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon index a1f9d8098bcec..41cd4dd1d2661 100644 --- a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -48,7 +48,7 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block3, block12, block13, block14, block15, block16, block17}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block3, block13, block14, block15, block16, block17, block18}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -100,7 +100,7 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+3, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+5}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block4, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+7, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+9}, @@ -109,12 +109,12 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+16, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+22}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, @@ -126,12 +126,12 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+29, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+24, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+31, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block7, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+34, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block7, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block8, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+38, arg1: node+33, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+33, arg1: node+39}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, @@ -143,38 +143,38 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+47, type: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block8, type: typeTypeType}, -// CHECK:STDOUT: {kind: StructValue, arg0: block9, type: type2}, +// CHECK:STDOUT: {kind: StructType, arg0: block9, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructValue, arg0: block10, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+52, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+55, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block11, type: type2}, +// CHECK:STDOUT: {kind: StructValue, arg0: block12, type: type2}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+58, arg1: node+51, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+51, arg1: node+59}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block12, arg1: node+61}, -// CHECK:STDOUT: {kind: Branch, arg0: block13}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+61}, +// CHECK:STDOUT: {kind: Branch, arg0: block14}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int15, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+64}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+65}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block14, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+64}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+65}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block15, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int16, type: type0}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+69, arg1: node+68, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+68, arg1: node+70}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+72, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+74}, -// CHECK:STDOUT: {kind: Branch, arg0: block16}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block16, arg1: node+74}, +// CHECK:STDOUT: {kind: Branch, arg0: block17}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+72, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+72, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+77}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+78}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block17, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block18, arg1: node+77}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block18, arg1: node+78}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block18, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int17, type: type0}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+82, arg1: node+81, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+81, arg1: node+83}, @@ -250,6 +250,9 @@ fn Main() { // CHECK:STDOUT: node+63, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+14, // CHECK:STDOUT: ], @@ -328,11 +331,11 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc13_3: i32 = int_literal 1 // CHECK:STDOUT: %.loc13_7.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc13_7.2: i32 = initialize_from %.loc13_7.1, %.loc13_3 +// CHECK:STDOUT: %.loc13_7.2: i32 = initialize_from %.loc13_7.1 to %.loc13_3 // CHECK:STDOUT: assign %.loc13_3, %.loc13_7.2 -// CHECK:STDOUT: %.loc17_4: i32 = call @F() +// CHECK:STDOUT: %.loc17_4: i32 = call @F() to invalid // CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1, %.loc17_4 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 to %.loc17_4 // CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 // CHECK:STDOUT: %.loc21_4.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc21_4.2: i32 = stub_reference %.loc21_4.1 @@ -345,11 +348,11 @@ fn Main() { // CHECK:STDOUT: %.loc21_16.1: i32 = int_literal 4 // CHECK:STDOUT: %.loc21_16.2: i32 = stub_reference %.loc21_16.1 // CHECK:STDOUT: %.loc21_17.1: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) -// CHECK:STDOUT: %.loc21_17.2: (i32, i32) = initialize_from %.loc21_17.1, %.loc21_8.2 +// CHECK:STDOUT: %.loc21_17.2: (i32, i32) = initialize_from %.loc21_17.1 to %.loc21_8.2 // CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17.2 // CHECK:STDOUT: %n: i32 = var // CHECK:STDOUT: %.loc22_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc22_16.2: i32 = initialize_from %.loc22_16.1, %n +// CHECK:STDOUT: %.loc22_16.2: i32 = initialize_from %.loc22_16.1 to %n // CHECK:STDOUT: assign %n, %.loc22_16.2 // CHECK:STDOUT: %.loc22_7.1: i32 = value_binding %n // CHECK:STDOUT: %.loc26_4: i32 = stub_reference %.loc22_7.1 @@ -361,10 +364,10 @@ fn Main() { // CHECK:STDOUT: %.loc26_16.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc26_16.2: i32 = stub_reference %.loc26_16.1 // CHECK:STDOUT: %.loc26_17.1: (i32, i32) = tuple_value (%.loc26_13.2, %.loc26_16.2) -// CHECK:STDOUT: %.loc26_17.2: (i32, i32) = initialize_from %.loc26_17.1, %.loc26_8 +// CHECK:STDOUT: %.loc26_17.2: (i32, i32) = initialize_from %.loc26_17.1 to %.loc26_8 // CHECK:STDOUT: assign %.loc26_8, %.loc26_17.2 // CHECK:STDOUT: %.loc30_12.1: type = ptr_type i32 -// CHECK:STDOUT: %.loc30_12.2: type = initialize_from %.loc30_12.1, i32 +// CHECK:STDOUT: %.loc30_12.2: type = initialize_from %.loc30_12.1 to i32 // CHECK:STDOUT: assign i32, %.loc30_12.2 // CHECK:STDOUT: %.loc34_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc34_7: i32 = stub_reference %.loc34_9 @@ -377,7 +380,7 @@ fn Main() { // CHECK:STDOUT: %.loc34_36: i32 = int_literal 4 // CHECK:STDOUT: %.loc34_34: i32 = stub_reference %.loc34_36 // CHECK:STDOUT: %.loc34_37.1: {.x: i32, .y: i32} = struct_value (%.loc34_26, %.loc34_34) -// CHECK:STDOUT: %.loc34_37.2: {.x: i32, .y: i32} = initialize_from %.loc34_37.1, %.loc34_18.2 +// CHECK:STDOUT: %.loc34_37.2: {.x: i32, .y: i32} = initialize_from %.loc34_37.1 to %.loc34_18.2 // CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37.2 // CHECK:STDOUT: %.loc38_7: bool = bool_literal true // CHECK:STDOUT: if %.loc38_7 br !if.expr.then.loc38 else br !if.expr.else.loc38 @@ -393,7 +396,7 @@ fn Main() { // CHECK:STDOUT: !if.expr.result.loc38: // CHECK:STDOUT: %.loc38_4: i32 = block_arg !if.expr.result.loc38 // CHECK:STDOUT: %.loc38_29.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc38_29.2: i32 = initialize_from %.loc38_29.1, %.loc38_4 +// CHECK:STDOUT: %.loc38_29.2: i32 = initialize_from %.loc38_29.1 to %.loc38_4 // CHECK:STDOUT: assign %.loc38_4, %.loc38_29.2 // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc45_7: bool = bool_literal true @@ -410,7 +413,7 @@ fn Main() { // CHECK:STDOUT: !if.expr.result.loc45: // CHECK:STDOUT: %.loc45_4: i32 = block_arg !if.expr.result.loc45 // CHECK:STDOUT: %.loc45_29.1: i32 = int_literal 10 -// CHECK:STDOUT: %.loc45_29.2: i32 = initialize_from %.loc45_29.1, %.loc45_4 +// CHECK:STDOUT: %.loc45_29.2: i32 = initialize_from %.loc45_29.1 to %.loc45_4 // CHECK:STDOUT: assign %.loc45_4, %.loc45_29.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon index 07b09c4e96c61..2dde457080819 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon @@ -66,6 +66,6 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc11_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc11_15: f64 = real_literal 34e-1 // CHECK:STDOUT: %.loc11_13: = add , %.loc11_15 -// CHECK:STDOUT: %.1: = initialize_from , %return +// CHECK:STDOUT: %.1: = initialize_from to %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon index c0671b5e370e5..62198639cb98f 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon @@ -71,10 +71,10 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %a +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %a // CHECK:STDOUT: assign %a, %.loc8_16.2 // CHECK:STDOUT: %.loc12: f64 = real_literal 56e-1 -// CHECK:STDOUT: %.1: = initialize_from , %a +// CHECK:STDOUT: %.1: = initialize_from to %a // CHECK:STDOUT: assign %a, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon index 2fa9de31d9969..60aa2884e3ed9 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon @@ -75,6 +75,6 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc13_13: = add , %.loc13_15 // CHECK:STDOUT: %.loc13_21: i32 = int_literal 12 // CHECK:STDOUT: %.loc13_19: = add , %.loc13_21 -// CHECK:STDOUT: %.1: = initialize_from , %return +// CHECK:STDOUT: %.1: = initialize_from to %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/or.carbon b/toolchain/semantics/testdata/operators/or.carbon index 578431a3aed4f..52e85b42cf418 100644 --- a/toolchain/semantics/testdata/operators/or.carbon +++ b/toolchain/semantics/testdata/operators/or.carbon @@ -15,7 +15,7 @@ fn Or() -> bool { // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block9, block10}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -44,16 +44,20 @@ fn Or() -> bool { // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+14, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+13}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+17}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+20}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+15}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, +// CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+21}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -88,15 +92,25 @@ fn Or() -> bool { // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -109,30 +123,34 @@ fn Or() -> bool { // CHECK:STDOUT: fn @F() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1, %return +// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 to %return // CHECK:STDOUT: return %.loc7_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G() -> %return: bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1, %return +// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 to %return // CHECK:STDOUT: return %.loc8_25.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Or() -> %return: bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11: bool = call @F() -// CHECK:STDOUT: %.loc11_14.1: bool = not %.loc11_11 +// CHECK:STDOUT: %.loc11_11.1: bool = call @F() to %.loc11_11.2 +// CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary %.loc11_11.1 +// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 +// CHECK:STDOUT: %.loc11_14.1: bool = not %.loc11_11.3 // CHECK:STDOUT: %.loc11_14.2: bool = bool_literal true // CHECK:STDOUT: if %.loc11_14.1 br !or.rhs else br !or.result(%.loc11_14.2) // CHECK:STDOUT: // CHECK:STDOUT: !or.rhs: -// CHECK:STDOUT: %.loc11_18: bool = call @G() -// CHECK:STDOUT: br !or.result(%.loc11_18) +// CHECK:STDOUT: %.loc11_18.1: bool = call @G() to %.loc11_18.2 +// CHECK:STDOUT: %.loc11_18.2: bool = materialize_temporary %.loc11_18.1 +// CHECK:STDOUT: %.loc11_18.3: bool = value_binding %.loc11_18.2 +// CHECK:STDOUT: br !or.result(%.loc11_18.3) // CHECK:STDOUT: // CHECK:STDOUT: !or.result: // CHECK:STDOUT: %.loc11_14.3: bool = block_arg !or.result -// CHECK:STDOUT: %.loc11_14.4: bool = initialize_from %.loc11_14.3, %return +// CHECK:STDOUT: %.loc11_14.4: bool = initialize_from %.loc11_14.3 to %return // CHECK:STDOUT: return %.loc11_14.4 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/unary_op.carbon b/toolchain/semantics/testdata/operators/unary_op.carbon index 089a5869de5fb..1094df71c9ef4 100644 --- a/toolchain/semantics/testdata/operators/unary_op.carbon +++ b/toolchain/semantics/testdata/operators/unary_op.carbon @@ -67,6 +67,6 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b // CHECK:STDOUT: %.loc8_10.1: bool = not %.loc7 -// CHECK:STDOUT: %.loc8_10.2: bool = initialize_from %.loc8_10.1, %return +// CHECK:STDOUT: %.loc8_10.2: bool = initialize_from %.loc8_10.1 to %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_deref.carbon b/toolchain/semantics/testdata/pointer/address_of_deref.carbon index 04cf789f8fb58..16a59c5eb4e4f 100644 --- a/toolchain/semantics/testdata/pointer/address_of_deref.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_deref.carbon @@ -79,7 +79,7 @@ fn F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %n +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %n // CHECK:STDOUT: assign %n, %.loc8_16.2 // CHECK:STDOUT: %.loc9_13.1: type = ptr_type i32 // CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n @@ -87,6 +87,6 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 // CHECK:STDOUT: %.loc9_10.1: i32 = dereference %.loc9_11 // CHECK:STDOUT: %.loc9_10.2: i32 = value_binding %.loc9_10.1 -// CHECK:STDOUT: %.loc9_10.3: i32 = initialize_from %.loc9_10.2, %return +// CHECK:STDOUT: %.loc9_10.3: i32 = initialize_from %.loc9_10.2 to %return // CHECK:STDOUT: return %.loc9_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon index 5deed7b460483..afe3d107a771f 100644 --- a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon @@ -271,25 +271,25 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc8_45: i32 = int_literal 2 // CHECK:STDOUT: %.loc8_43: i32 = stub_reference %.loc8_45 // CHECK:STDOUT: %.loc8_46.1: {.a: i32, .b: i32} = struct_value (%.loc8_35, %.loc8_43) -// CHECK:STDOUT: %.loc8_46.2: {.a: i32, .b: i32} = initialize_from %.loc8_46.1, %s +// CHECK:STDOUT: %.loc8_46.2: {.a: i32, .b: i32} = initialize_from %.loc8_46.1 to %s // CHECK:STDOUT: assign %s, %.loc8_46.2 // 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: {.a: i32, .b: i32}* = var // CHECK:STDOUT: %.loc10_32.1: {.a: i32, .b: i32}* = address_of %s -// CHECK:STDOUT: %.loc10_32.2: {.a: i32, .b: i32}* = initialize_from %.loc10_32.1, %p +// CHECK:STDOUT: %.loc10_32.2: {.a: i32, .b: i32}* = initialize_from %.loc10_32.1 to %p // CHECK:STDOUT: assign %p, %.loc10_32.2 // CHECK:STDOUT: %.loc11_13: type = ptr_type i32 // CHECK:STDOUT: %q: i32* = var // CHECK:STDOUT: %.loc11_19: i32 = struct_access %s, member0 // CHECK:STDOUT: %.loc11_17.1: i32* = address_of %.loc11_19 -// CHECK:STDOUT: %.loc11_17.2: i32* = initialize_from %.loc11_17.1, %q +// CHECK:STDOUT: %.loc11_17.2: i32* = initialize_from %.loc11_17.1 to %q // CHECK:STDOUT: assign %q, %.loc11_17.2 // CHECK:STDOUT: %.loc12_13: type = ptr_type i32 // CHECK:STDOUT: %r: i32* = var // CHECK:STDOUT: %.loc12_19: i32 = struct_access %s, member1 // CHECK:STDOUT: %.loc12_17.1: i32* = address_of %.loc12_19 -// CHECK:STDOUT: %.loc12_17.2: i32* = initialize_from %.loc12_17.1, %r +// CHECK:STDOUT: %.loc12_17.2: i32* = initialize_from %.loc12_17.1 to %r // CHECK:STDOUT: assign %r, %.loc12_17.2 // CHECK:STDOUT: %.loc14_11: type = stub_reference i32 // CHECK:STDOUT: %.loc14_16: type = stub_reference i32 @@ -302,26 +302,26 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc14_27.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc14_27.2: i32 = stub_reference %.loc14_27.1 // CHECK:STDOUT: %.loc14_28.1: (i32, i32) = tuple_value (%.loc14_24.2, %.loc14_27.2) -// CHECK:STDOUT: %.loc14_28.2: (i32, i32) = initialize_from %.loc14_28.1, %t +// CHECK:STDOUT: %.loc14_28.2: (i32, i32) = initialize_from %.loc14_28.1 to %t // CHECK:STDOUT: assign %t, %.loc14_28.2 // CHECK:STDOUT: %.loc15_14: type = ptr_type i32 // CHECK:STDOUT: %t0: i32* = var // CHECK:STDOUT: %.loc15_21: i32 = int_literal 0 // CHECK:STDOUT: %.loc15_22: i32 = tuple_index %t, %.loc15_21 // CHECK:STDOUT: %.loc15_18.1: i32* = address_of %.loc15_22 -// CHECK:STDOUT: %.loc15_18.2: i32* = initialize_from %.loc15_18.1, %t0 +// CHECK:STDOUT: %.loc15_18.2: i32* = initialize_from %.loc15_18.1 to %t0 // CHECK:STDOUT: assign %t0, %.loc15_18.2 // CHECK:STDOUT: %.loc16_14: type = ptr_type i32 // CHECK:STDOUT: %t1: i32* = var // CHECK:STDOUT: %.loc16_21: i32 = int_literal 1 // CHECK:STDOUT: %.loc16_22: i32 = tuple_index %t, %.loc16_21 // CHECK:STDOUT: %.loc16_18.1: i32* = address_of %.loc16_22 -// CHECK:STDOUT: %.loc16_18.2: i32* = initialize_from %.loc16_18.1, %t1 +// CHECK:STDOUT: %.loc16_18.2: i32* = initialize_from %.loc16_18.1 to %t1 // CHECK:STDOUT: assign %t1, %.loc16_18.2 // CHECK:STDOUT: %.loc20_22: type = ptr_type i32 // CHECK:STDOUT: %param_addr: i32* = var // CHECK:STDOUT: %.loc20_26.1: i32* = address_of %param -// CHECK:STDOUT: %.loc20_26.2: i32* = initialize_from %.loc20_26.1, %param_addr +// CHECK:STDOUT: %.loc20_26.2: i32* = initialize_from %.loc20_26.1 to %param_addr // CHECK:STDOUT: assign %param_addr, %.loc20_26.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/basic.carbon b/toolchain/semantics/testdata/pointer/basic.carbon index f7f04318efc87..ed125a90b3c17 100644 --- a/toolchain/semantics/testdata/pointer/basic.carbon +++ b/toolchain/semantics/testdata/pointer/basic.carbon @@ -88,16 +88,16 @@ fn F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %n +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %n // CHECK:STDOUT: assign %n, %.loc8_16.2 // CHECK:STDOUT: %.loc9_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var // CHECK:STDOUT: %.loc9_17.1: i32* = address_of %n -// CHECK:STDOUT: %.loc9_17.2: i32* = initialize_from %.loc9_17.1, %p +// CHECK:STDOUT: %.loc9_17.2: i32* = initialize_from %.loc9_17.1 to %p // CHECK:STDOUT: assign %p, %.loc9_17.2 // CHECK:STDOUT: %.loc9_7: i32* = value_binding %p // CHECK:STDOUT: %.loc11_10.1: i32 = dereference %.loc9_7 // CHECK:STDOUT: %.loc11_10.2: i32 = value_binding %.loc11_10.1 -// CHECK:STDOUT: %.loc11_10.3: i32 = initialize_from %.loc11_10.2, %return +// CHECK:STDOUT: %.loc11_10.3: i32 = initialize_from %.loc11_10.2 to %return // CHECK:STDOUT: return %.loc11_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon index 64880da3b966f..9526b282aab09 100644 --- a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon @@ -40,7 +40,7 @@ fn AddressOfOperator() { // CHECK:STDERR: &(1 + 1); // CHECK:STDERR: ^ &(1 + 1); - // CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+3]]:3: Cannot take the address of non-reference expression. + // CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+3]]:3: Cannot take the address of a temporary object. // CHECK:STDERR: &H().a; // CHECK:STDERR: ^ &H().a; @@ -81,9 +81,9 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, return_slot: node+4}, // CHECK:STDOUT: {name: str3, param_refs: block0, body: {block5}}}, // CHECK:STDOUT: {name: str5, param_refs: block0, body: {block9}}}, -// CHECK:STDOUT: {name: str6, param_refs: block0, body: {block10}}}, -// CHECK:STDOUT: {name: str7, param_refs: block0, body: {block11}}}, -// CHECK:STDOUT: {name: str8, param_refs: block0, body: {block12}}}, +// CHECK:STDOUT: {name: str6, param_refs: block0, body: {block11}}}, +// CHECK:STDOUT: {name: str7, param_refs: block0, body: {block13}}}, +// CHECK:STDOUT: {name: str8, param_refs: block0, body: {block14}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -123,8 +123,8 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+25, // CHECK:STDOUT: node+31, -// CHECK:STDOUT: node+51, -// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+52, +// CHECK:STDOUT: node+54, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -172,33 +172,34 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+35, arg1: node+36, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+37, type: type2}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+39, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+40, type: type2}, +// CHECK:STDOUT: {kind: Call, arg0: block10, arg1: function1, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+39, type: type1}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+40, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+41, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+42, type: type3}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+43, type: type4}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+43, type: type3}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+44, type: type4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function4}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+47, type: type2}, +// CHECK:STDOUT: {kind: Call, arg0: block12, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+48, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function5}, // CHECK:STDOUT: {kind: PointerType, arg0: typeTypeType, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: nodeIntegerType, type: type12}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type13, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+54, type: type12}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+55, type: type12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+58, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+59, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+60, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block13, type: type9}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+61, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block15, type: type9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+62, arg1: node+63, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+64, type: type2}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+63, arg1: node+64, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+65, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -214,9 +215,9 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+34, -// CHECK:STDOUT: node+46, -// CHECK:STDOUT: node+50, -// CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+47, +// CHECK:STDOUT: node+51, +// CHECK:STDOUT: node+58, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, @@ -274,22 +275,28 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+43, // CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, +// CHECK:STDOUT: node+46, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+40, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+47, // CHECK:STDOUT: node+48, // CHECK:STDOUT: node+49, +// CHECK:STDOUT: node+50, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+51, // CHECK:STDOUT: node+52, // CHECK:STDOUT: node+53, // CHECK:STDOUT: node+54, // CHECK:STDOUT: node+55, // CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+57, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+58, // CHECK:STDOUT: node+59, // CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, @@ -298,10 +305,11 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+64, // CHECK:STDOUT: node+65, // CHECK:STDOUT: node+66, +// CHECK:STDOUT: node+67, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+59, -// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+62, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -356,8 +364,9 @@ fn AddressOfTupleElementValue() { // 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: %.loc46_5: {.a: i32} = call @H() -// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5, member0 +// CHECK:STDOUT: %.loc46_5.1: {.a: i32} = call @H() to %.loc46_5.2 +// CHECK:STDOUT: %.loc46_5.2: {.a: i32} = materialize_temporary %.loc46_5.1 +// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5.2, member0 // CHECK:STDOUT: %.loc46_3: i32* = address_of %.loc46_7 // CHECK:STDOUT: %.loc50_9: bool = bool_literal true // CHECK:STDOUT: %.loc50_5: bool = not %.loc50_9 @@ -367,7 +376,7 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: // CHECK:STDOUT: fn @AddressOfCall() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc57_5: i32 = call @G() +// CHECK:STDOUT: %.loc57_5: i32 = call @G() to invalid // CHECK:STDOUT: %.loc57_3: i32* = address_of %.loc57_5 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon index 1d70b81c10381..33386eab2db5b 100644 --- a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon @@ -85,6 +85,6 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> %return: const ({}*) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.1: = initialize_from , %return +// CHECK:STDOUT: %.1: = initialize_from to %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index 05713a85f48e2..dea0725b5a2ac 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -95,6 +95,6 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: %.loc9_11.2: const (const i32*) = value_binding %.loc9_11.1 // CHECK:STDOUT: %.loc9_10.1: const i32 = dereference %.loc9_11.2 // CHECK:STDOUT: %.loc9_10.2: const i32 = value_binding %.loc9_10.1 -// CHECK:STDOUT: %.loc9_10.3: const i32 = initialize_from %.loc9_10.2, %return +// CHECK:STDOUT: %.loc9_10.3: const i32 = initialize_from %.loc9_10.2 to %return // CHECK:STDOUT: return %.loc9_10.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index 7681626eba3d7..84859724aa499 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -112,13 +112,13 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: fn @Ptr(%p: i32*) -> %return: i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_8.1: i32* = value_binding %p -// CHECK:STDOUT: %.loc7_8.2: i32* = initialize_from %.loc7_8.1, %return +// CHECK:STDOUT: %.loc7_8.2: i32* = initialize_from %.loc7_8.1 to %return // CHECK:STDOUT: return %.loc7_8.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> %return: const i32* { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_13.1: const i32* = value_binding %p -// CHECK:STDOUT: %.loc11_13.2: const i32* = initialize_from %.loc11_13.1, %return +// CHECK:STDOUT: %.loc11_13.2: const i32* = initialize_from %.loc11_13.1 to %return // CHECK:STDOUT: return %.loc11_13.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index 498742d7bdb47..1d0c765e078e0 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -97,6 +97,6 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: fn @F(%b: bool) -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_10.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1, %return +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 to %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon index 0df8fcd019ba2..38195d2dc87e6 100644 --- a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon @@ -59,6 +59,6 @@ fn Main() -> i32 { // CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.1: = initialize_from , %return +// CHECK:STDOUT: %.1: = initialize_from to %return // CHECK:STDOUT: return %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/struct.carbon b/toolchain/semantics/testdata/return/struct.carbon index f8e0fdb3e1c1b..6663500081503 100644 --- a/toolchain/semantics/testdata/return/struct.carbon +++ b/toolchain/semantics/testdata/return/struct.carbon @@ -78,6 +78,6 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: %.loc8_16: i32 = int_literal 3 // CHECK:STDOUT: %.loc8_14: i32 = stub_reference %.loc8_16 // CHECK:STDOUT: %.loc8_17.1: {.a: i32} = struct_value (%.loc8_14) -// CHECK:STDOUT: %.loc8_17.2: {.a: i32} = initialize_from %.loc8_17.1, %return +// CHECK:STDOUT: %.loc8_17.2: {.a: i32} = initialize_from %.loc8_17.1 to %return // CHECK:STDOUT: return %.loc8_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/tuple.carbon b/toolchain/semantics/testdata/return/tuple.carbon index d53c04ae9edbb..4d495f128803f 100644 --- a/toolchain/semantics/testdata/return/tuple.carbon +++ b/toolchain/semantics/testdata/return/tuple.carbon @@ -61,7 +61,6 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -69,6 +68,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ @@ -91,7 +91,6 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: %.loc8_20: type = stub_reference i32 // CHECK:STDOUT: %.loc8_23.1: type = tuple_type (type, type) // CHECK:STDOUT: %.loc8_23.2: (type, type) = tuple_value (%.loc8_15, %.loc8_20) -// CHECK:STDOUT: %.loc8_23.3: type = tuple_type (i32, i32) // CHECK:STDOUT: %.loc8_1 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: @@ -102,6 +101,6 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: %.loc9_15.1: i32 = int_literal 35 // CHECK:STDOUT: %.loc9_15.2: i32 = stub_reference %.loc9_15.1 // CHECK:STDOUT: %.loc9_17.1: (i32, i32) = tuple_value (%.loc9_11.2, %.loc9_15.2) -// CHECK:STDOUT: %.loc9_17.2: (i32, i32) = initialize_from %.loc9_17.1, %return +// CHECK:STDOUT: %.loc9_17.2: (i32, i32) = initialize_from %.loc9_17.1 to %return // CHECK:STDOUT: return %.loc9_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/value.carbon b/toolchain/semantics/testdata/return/value.carbon index 3498703c53461..73d81ca65fdc4 100644 --- a/toolchain/semantics/testdata/return/value.carbon +++ b/toolchain/semantics/testdata/return/value.carbon @@ -55,6 +55,6 @@ fn Main() -> i32 { // CHECK:STDOUT: fn @Main() -> %return: i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_10.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1, %return +// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 to %return // CHECK:STDOUT: return %.loc8_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/empty.carbon b/toolchain/semantics/testdata/struct/empty.carbon index 2c1349b42b6d2..5349719d2f67e 100644 --- a/toolchain/semantics/testdata/struct/empty.carbon +++ b/toolchain/semantics/testdata/struct/empty.carbon @@ -63,11 +63,11 @@ var y: {} = x; // CHECK:STDOUT: %.loc7_9.2: {} = struct_value () // CHECK:STDOUT: %x: {} = var // CHECK:STDOUT: %.loc7_14.1: {} = struct_value () -// CHECK:STDOUT: %.loc7_14.2: {} = initialize_from %.loc7_14.1, %x +// CHECK:STDOUT: %.loc7_14.2: {} = initialize_from %.loc7_14.1 to %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc8: {} = struct_value () // CHECK:STDOUT: %y: {} = var // CHECK:STDOUT: %.loc7_5.1: {} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {} = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: {} = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon index 826880cd8284c..d489b7883235f 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon @@ -60,6 +60,6 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc10_21.1: type = struct_type {} // CHECK:STDOUT: %.loc10_21.2: {} = struct_value () -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_nested.carbon b/toolchain/semantics/testdata/struct/fail_assign_nested.carbon index f0ded42f900b5..26adc09a3a867 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_nested.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_nested.carbon @@ -80,6 +80,6 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: %.loc10_23: {} = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: {}} // CHECK:STDOUT: %.loc10_27.2: {.b: {}} = struct_value (%.loc10_23) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon index 7cddbac4f3c2d..92b3bc77ea096 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon @@ -72,6 +72,6 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: %.loc10_17: i32 = stub_reference %.loc10_19 // CHECK:STDOUT: %.loc10_20.1: type = struct_type {.a: i32} // CHECK:STDOUT: %.loc10_20.2: {.a: i32} = struct_value (%.loc10_17) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon index 149e457af578b..29d87ad71648d 100644 --- a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon @@ -75,6 +75,6 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: %.loc10_24: i32 = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: i32} // CHECK:STDOUT: %.loc10_27.2: {.b: i32} = struct_value (%.loc10_24) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon index 30f74c7476cd1..f5654b033cada 100644 --- a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon @@ -76,6 +76,6 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: %.loc10_24: f64 = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_29.1: type = struct_type {.b: f64} // CHECK:STDOUT: %.loc10_29.2: {.b: f64} = struct_value (%.loc10_24) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon index 01d25d3631483..5633dda5ab0a7 100644 --- a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon @@ -82,9 +82,9 @@ var y: i32 = x.b; // CHECK:STDOUT: %.loc7_26: f64 = real_literal 40e-1 // CHECK:STDOUT: %.loc7_24: f64 = stub_reference %.loc7_26 // CHECK:STDOUT: %.loc7_29.1: {.a: f64} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_29.2: {.a: f64} = initialize_from %.loc7_29.1, %x +// CHECK:STDOUT: %.loc7_29.2: {.a: f64} = initialize_from %.loc7_29.1 to %x // CHECK:STDOUT: assign %x, %.loc7_29.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from , %y +// CHECK:STDOUT: %.1: = initialize_from to %y // CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon index cfaa33ac69362..a6f03be0f2692 100644 --- a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon +++ b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon @@ -81,9 +81,9 @@ var y: i32 = x.b; // CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_24: i32 = stub_reference %.loc7_26 // CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1, %x +// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1 to %x // CHECK:STDOUT: assign %x, %.loc7_27.2 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from , %y +// CHECK:STDOUT: %.1: = initialize_from to %y // CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon index f2792e6770fd1..b7f32b2cfb3ba 100644 --- a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon +++ b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon @@ -78,6 +78,6 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: %.loc10_33: i32 = stub_reference %.loc10_35 // CHECK:STDOUT: %.loc10_36.1: type = struct_type {.a: i32} // CHECK:STDOUT: %.loc10_36.2: {.a: i32} = struct_value (%.loc10_33) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_type_assign.carbon b/toolchain/semantics/testdata/struct/fail_type_assign.carbon index a00a43b83e074..76d90ccf1fc4e 100644 --- a/toolchain/semantics/testdata/struct/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/struct/fail_type_assign.carbon @@ -61,6 +61,6 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc10_28: type = struct_type {.a: i32} -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/member_access.carbon b/toolchain/semantics/testdata/struct/member_access.carbon index 934c7f8e71c29..8b65b90e87951 100644 --- a/toolchain/semantics/testdata/struct/member_access.carbon +++ b/toolchain/semantics/testdata/struct/member_access.carbon @@ -108,15 +108,15 @@ var z: i32 = y; // CHECK:STDOUT: %.loc7_45: i32 = int_literal 1 // CHECK:STDOUT: %.loc7_43: i32 = stub_reference %.loc7_45 // CHECK:STDOUT: %.loc7_46.1: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) -// CHECK:STDOUT: %.loc7_46.2: {.a: f64, .b: i32} = initialize_from %.loc7_46.1, %x +// CHECK:STDOUT: %.loc7_46.2: {.a: f64, .b: i32} = initialize_from %.loc7_46.1 to %x // CHECK:STDOUT: assign %x, %.loc7_46.2 // CHECK:STDOUT: %y: i32 = var // CHECK:STDOUT: %.loc8_15.1: i32 = struct_access %x, member1 // CHECK:STDOUT: %.loc8_15.2: i32 = value_binding %.loc8_15.1 -// CHECK:STDOUT: %.loc8_15.3: i32 = initialize_from %.loc8_15.2, %y +// CHECK:STDOUT: %.loc8_15.3: i32 = initialize_from %.loc8_15.2 to %y // CHECK:STDOUT: assign %y, %.loc8_15.3 // CHECK:STDOUT: %z: i32 = var // CHECK:STDOUT: %.loc8_5.1: i32 = value_binding %y -// CHECK:STDOUT: %.loc8_5.2: i32 = initialize_from %.loc8_5.1, %z +// CHECK:STDOUT: %.loc8_5.2: i32 = initialize_from %.loc8_5.1 to %z // CHECK:STDOUT: assign %z, %.loc8_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/one_entry.carbon b/toolchain/semantics/testdata/struct/one_entry.carbon index 5d552e031ed82..dd7008c2a5329 100644 --- a/toolchain/semantics/testdata/struct/one_entry.carbon +++ b/toolchain/semantics/testdata/struct/one_entry.carbon @@ -86,11 +86,11 @@ var y: {.a: i32} = x; // CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_24: i32 = stub_reference %.loc7_26 // CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1, %x +// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1 to %x // CHECK:STDOUT: assign %x, %.loc7_27.2 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32} // CHECK:STDOUT: %y: {.a: i32} = var // CHECK:STDOUT: %.loc7_5.1: {.a: i32} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32} = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: {.a: i32} = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/tuple_as_element.carbon b/toolchain/semantics/testdata/struct/tuple_as_element.carbon index db5f0fa7f288d..a631604e1af2a 100644 --- a/toolchain/semantics/testdata/struct/tuple_as_element.carbon +++ b/toolchain/semantics/testdata/struct/tuple_as_element.carbon @@ -142,13 +142,13 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc7_49: (i32,) = tuple_value (%.loc7_47.2) // CHECK:STDOUT: %.loc7_44: (i32,) = stub_reference %.loc7_49 // CHECK:STDOUT: %.loc7_50.1: {.a: i32, .b: (i32,)} = struct_value (%.loc7_36, %.loc7_44) -// CHECK:STDOUT: %.loc7_50.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_50.1, %x +// CHECK:STDOUT: %.loc7_50.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_50.1 to %x // CHECK:STDOUT: assign %x, %.loc7_50.2 // CHECK:STDOUT: %.loc8_23: type = stub_reference i32 // CHECK:STDOUT: %.loc8_27: (type,) = tuple_value (%.loc8_23) // CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} // CHECK:STDOUT: %y: {.a: i32, .b: (i32,)} = var // CHECK:STDOUT: %.loc7_5.1: {.a: i32, .b: (i32,)} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/two_entries.carbon b/toolchain/semantics/testdata/struct/two_entries.carbon index 8221a4da6b49f..62970ffd2348b 100644 --- a/toolchain/semantics/testdata/struct/two_entries.carbon +++ b/toolchain/semantics/testdata/struct/two_entries.carbon @@ -103,11 +103,11 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: %.loc7_43: i32 = int_literal 2 // CHECK:STDOUT: %.loc7_41: i32 = stub_reference %.loc7_43 // CHECK:STDOUT: %.loc7_44.1: {.a: i32, .b: i32} = struct_value (%.loc7_33, %.loc7_41) -// CHECK:STDOUT: %.loc7_44.2: {.a: i32, .b: i32} = initialize_from %.loc7_44.1, %x +// CHECK:STDOUT: %.loc7_44.2: {.a: i32, .b: i32} = initialize_from %.loc7_44.1 to %x // CHECK:STDOUT: assign %x, %.loc7_44.2 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %y: {.a: i32, .b: i32} = var // CHECK:STDOUT: %.loc7_5.1: {.a: i32, .b: i32} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: i32} = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: i32} = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/empty.carbon b/toolchain/semantics/testdata/tuples/empty.carbon index 13bb48d48f3d0..fc9c52c8a95f0 100644 --- a/toolchain/semantics/testdata/tuples/empty.carbon +++ b/toolchain/semantics/testdata/tuples/empty.carbon @@ -65,11 +65,11 @@ var y: () = x; // CHECK:STDOUT: %.loc7_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var // CHECK:STDOUT: %.loc7_14.1: () = tuple_value () -// CHECK:STDOUT: %.loc7_14.2: () = initialize_from %.loc7_14.1, %x +// CHECK:STDOUT: %.loc7_14.2: () = initialize_from %.loc7_14.1 to %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc8: () = tuple_value () // CHECK:STDOUT: %y: () = var // CHECK:STDOUT: %.loc7_5.1: () = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: () = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: () = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon index 215cd68fc4598..02ba0c7f84177 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon @@ -75,6 +75,6 @@ var x: (i32,) = (); // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc10_18.1: type = tuple_type () // CHECK:STDOUT: %.loc10_18.2: () = tuple_value () -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon b/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon index 6ccba2db38ce0..18858c6c3f08b 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon @@ -202,6 +202,6 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: %.loc10_55.2: (i32, i32, i32) = stub_reference %.loc10_55.1 // CHECK:STDOUT: %.loc10_56.1: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) // CHECK:STDOUT: %.loc10_56.2: ((i32, i32, i32), (i32, i32, i32)) = tuple_value (%.loc10_44.3, %.loc10_55.2) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon index c0ee2a9b90efe..63afbd0bfc79a 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon @@ -56,6 +56,6 @@ var x: () = (66); // CHECK:STDOUT: %.loc10_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var // CHECK:STDOUT: %.loc10_14: i32 = int_literal 66 -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon index ad0fa8e588fdf..3bb87941f25ab 100644 --- a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon +++ b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon @@ -102,6 +102,6 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: %.loc10_25.2: f64 = stub_reference %.loc10_25.1 // CHECK:STDOUT: %.loc10_30.1: type = tuple_type (i32, f64) // CHECK:STDOUT: %.loc10_30.2: (i32, f64) = tuple_value (%.loc10_22.2, %.loc10_25.2) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon index 40026c33534b9..a124797b9364b 100644 --- a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon +++ b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon @@ -92,6 +92,6 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: %.loc10_22.2: i32 = stub_reference %.loc10_22.1 // CHECK:STDOUT: %.loc10_25.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc10_25.2: (i32,) = tuple_value (%.loc10_22.2) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon index 0290ac65fe9ef..05a84c1348f0c 100644 --- a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon @@ -75,6 +75,6 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc10_19: type = stub_reference i32 // CHECK:STDOUT: %.loc10_24: (type,) = tuple_value (%.loc10_19) -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/nested_tuple.carbon b/toolchain/semantics/testdata/tuples/nested_tuple.carbon index f6db85bff7c45..a023b323d6b91 100644 --- a/toolchain/semantics/testdata/tuples/nested_tuple.carbon +++ b/toolchain/semantics/testdata/tuples/nested_tuple.carbon @@ -136,6 +136,6 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: %.loc7_39.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_39.2: i32 = stub_reference %.loc7_39.1 // CHECK:STDOUT: %.loc7_40.1: ((i32, i32), i32) = tuple_value (%.loc7_36.2, %.loc7_39.2) -// CHECK:STDOUT: %.loc7_40.2: ((i32, i32), i32) = initialize_from %.loc7_40.1, %x +// CHECK:STDOUT: %.loc7_40.2: ((i32, i32), i32) = initialize_from %.loc7_40.1 to %x // CHECK:STDOUT: assign %x, %.loc7_40.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/one_element.carbon b/toolchain/semantics/testdata/tuples/one_element.carbon index bf5006f236b40..f1041b640030e 100644 --- a/toolchain/semantics/testdata/tuples/one_element.carbon +++ b/toolchain/semantics/testdata/tuples/one_element.carbon @@ -95,12 +95,12 @@ var y: (i32,) = x; // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 // CHECK:STDOUT: %.loc7_20.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_20.2: (i32,) = initialize_from %.loc7_20.1, %x +// CHECK:STDOUT: %.loc7_20.2: (i32,) = initialize_from %.loc7_20.1 to %x // CHECK:STDOUT: assign %x, %.loc7_20.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %y: (i32,) = var // CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/two_elements.carbon b/toolchain/semantics/testdata/tuples/two_elements.carbon index 6f80327d79e59..5a1ed55ef1edf 100644 --- a/toolchain/semantics/testdata/tuples/two_elements.carbon +++ b/toolchain/semantics/testdata/tuples/two_elements.carbon @@ -112,13 +112,13 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %.loc7_25.1: i32 = int_literal 102 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 // CHECK:STDOUT: %.loc7_28.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: %.loc7_28.2: (i32, i32) = initialize_from %.loc7_28.1, %x +// CHECK:STDOUT: %.loc7_28.2: (i32, i32) = initialize_from %.loc7_28.1 to %x // CHECK:STDOUT: assign %x, %.loc7_28.2 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_14: type = stub_reference i32 // CHECK:STDOUT: %.loc8_17: (type, type) = tuple_value (%.loc8_9, %.loc8_14) // CHECK:STDOUT: %y: (i32, i32) = var // CHECK:STDOUT: %.loc7_5.1: (i32, i32) = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: (i32, i32) = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: (i32, i32) = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/decl_with_init.carbon b/toolchain/semantics/testdata/var/decl_with_init.carbon index 5c589287d090a..6e1248d9dd7e5 100644 --- a/toolchain/semantics/testdata/var/decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/decl_with_init.carbon @@ -59,7 +59,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %x +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %x // CHECK:STDOUT: assign %x, %.loc8_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon index a562ccbac0b74..be1c0e016cbd4 100644 --- a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon +++ b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon @@ -78,11 +78,11 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.loc9: i32 = var // CHECK:STDOUT: %.loc9_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_16.2: i32 = initialize_from %.loc9_16.1, %x.loc9 +// CHECK:STDOUT: %.loc9_16.2: i32 = initialize_from %.loc9_16.1 to %x.loc9 // CHECK:STDOUT: assign %x.loc9, %.loc9_16.2 // CHECK:STDOUT: %x.loc16: i32 = var // CHECK:STDOUT: %.loc16_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc16_16.2: i32 = initialize_from %.loc16_16.1, %x.loc16 +// CHECK:STDOUT: %.loc16_16.2: i32 = initialize_from %.loc16_16.1 to %x.loc16 // CHECK:STDOUT: assign %x.loc16, %.loc16_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon index 1d962d141894f..095345fd00a3f 100644 --- a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon +++ b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon @@ -63,7 +63,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_with_self.carbon b/toolchain/semantics/testdata/var/fail_init_with_self.carbon index a33bf20eaa26c..a27e6d8a40e37 100644 --- a/toolchain/semantics/testdata/var/fail_init_with_self.carbon +++ b/toolchain/semantics/testdata/var/fail_init_with_self.carbon @@ -58,7 +58,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon index 60afbcd12d2df..b44b4f2c6e9a6 100644 --- a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon +++ b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon @@ -61,7 +61,7 @@ var y: i32 = x; // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from , %y +// CHECK:STDOUT: %.1: = initialize_from to %y // CHECK:STDOUT: assign %y, %.1 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon index 74a6f11a97005..dac4b99379099 100644 --- a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon +++ b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon @@ -66,7 +66,7 @@ fn Main() { // CHECK:STDOUT: %.loc11_10: i32 = int_literal 1 // CHECK:STDOUT: %x: = var // CHECK:STDOUT: %.loc11_14: i32 = int_literal 1 -// CHECK:STDOUT: %.1: = initialize_from , %x +// CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_decl_with_init.carbon b/toolchain/semantics/testdata/var/global_decl_with_init.carbon index 8cfee90ea3fa2..429cbffb73904 100644 --- a/toolchain/semantics/testdata/var/global_decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/global_decl_with_init.carbon @@ -44,6 +44,6 @@ var x: i32 = 0; // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1, %x +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 to %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup.carbon b/toolchain/semantics/testdata/var/global_lookup.carbon index 468738677883c..5d5cc6c601869 100644 --- a/toolchain/semantics/testdata/var/global_lookup.carbon +++ b/toolchain/semantics/testdata/var/global_lookup.carbon @@ -56,10 +56,10 @@ var y: i32 = x; // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1, %x +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 to %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %y: i32 = var // CHECK:STDOUT: %.loc7_5.1: i32 = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon index 6d66d4b50d9d5..fb771ebfd9388 100644 --- a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon +++ b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon @@ -67,7 +67,7 @@ fn Main() { // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1, %x +// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 to %x // CHECK:STDOUT: assign %x, %.loc7_14.2 // CHECK:STDOUT: %.loc9 = fn_decl @Main // CHECK:STDOUT: } @@ -76,7 +76,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %y: i32 = var // CHECK:STDOUT: %.loc7_5.1: i32 = value_binding package.%x -// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1, %y +// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 to %y // CHECK:STDOUT: assign %y, %.loc7_5.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/lookup.carbon b/toolchain/semantics/testdata/var/lookup.carbon index 74c28e1943274..006011f350998 100644 --- a/toolchain/semantics/testdata/var/lookup.carbon +++ b/toolchain/semantics/testdata/var/lookup.carbon @@ -60,7 +60,7 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1, %x +// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %x // CHECK:STDOUT: assign %x, %.loc8_16.2 // CHECK:STDOUT: return // CHECK:STDOUT: } From 1a236cc3044d0ef52e669194418843b668e7c8d4 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 15 Aug 2023 17:29:04 -0700 Subject: [PATCH 06/21] Put return type IR in the same block as parameter IR. Don't create a return value slot for functions returning `()` explicitly, to match the calling convention for implicit `()` returns. --- .../semantics_handle_call_expression.cpp | 5 ++- .../semantics/semantics_handle_function.cpp | 36 +++++++++++----- .../semantics_handle_parameter_list.cpp | 11 ----- .../semantics/semantics_handle_statement.cpp | 2 +- toolchain/semantics/semantics_ir.h | 6 ++- .../semantics/semantics_ir_formatter.cpp | 6 ++- .../semantics/testdata/const/collapse.carbon | 20 ++++----- .../testdata/const/fail_collapse.carbon | 14 +++---- .../function/call/empty_struct.carbon | 15 +++---- .../testdata/function/call/empty_tuple.carbon | 42 +++++++------------ .../testdata/function/call/i32.carbon | 10 ++--- .../if/fail_reachable_fallthrough.carbon | 36 +++++++--------- .../semantics/testdata/if/fail_scope.carbon | 12 +++--- .../if/unreachable_fallthrough.carbon | 10 ++--- .../testdata/if_expression/basic.carbon | 16 ++++--- .../if_expression/control_flow.carbon | 20 ++++----- .../testdata/if_expression/nested.carbon | 34 +++++++-------- .../testdata/index/return_value_access.carbon | 13 +++--- .../testdata/operators/unary_op.carbon | 6 +-- .../pointer/fail_address_of_value.carbon | 11 +++-- .../pointer/fail_type_mismatch.carbon | 17 +++----- .../testdata/pointer/nested_const.carbon | 11 ++--- .../semantics/testdata/pointer/types.carbon | 25 ++++------- .../return/code_after_return_value.carbon | 6 +-- .../fail_missing_return_empty_tuple.carbon | 12 +++--- .../semantics/testdata/return/struct.carbon | 7 ++-- .../semantics/testdata/return/tuple.carbon | 12 ++---- 27 files changed, 176 insertions(+), 239 deletions(-) diff --git a/toolchain/semantics/semantics_handle_call_expression.cpp b/toolchain/semantics/semantics_handle_call_expression.cpp index 4a9399b84e5b6..b2500052e52cd 100644 --- a/toolchain/semantics/semantics_handle_call_expression.cpp +++ b/toolchain/semantics/semantics_handle_call_expression.cpp @@ -47,9 +47,10 @@ auto SemanticsHandleCallExpression(SemanticsContext& context, // tuple type. Otherwise, add a location for the return slot to the arguments. // The actual return slot location will be filled in by // `SemanticsContext::MarkInitializerFor`. - if (type_id == SemanticsTypeId::Invalid) { + if (!type_id.is_valid()) { type_id = context.CanonicalizeTupleType(call_expr_parse_node, {}); - } else { + } + if (callable.return_slot_id.is_valid()) { if (refs_id == SemanticsNodeBlockId::Empty) { refs_id = context.semantics_ir().AddNodeBlock(); } diff --git a/toolchain/semantics/semantics_handle_function.cpp b/toolchain/semantics/semantics_handle_function.cpp index 0f60b53a5b5c5..ba60b03ec472e 100644 --- a/toolchain/semantics/semantics_handle_function.cpp +++ b/toolchain/semantics/semantics_handle_function.cpp @@ -11,15 +11,35 @@ namespace Carbon { // definition syntax. static auto BuildFunctionDeclaration(SemanticsContext& context) -> std::pair { + // TODO: This contains the IR block for the parameters and return type. At + // present, it's just loose, but it's not strictly required for parameter + // refs; we should either stop constructing it completely or, if it turns out + // to be needed, store it. Note, the underlying issue is that the LLVM IR has + // nowhere clear to emit, so changing storage would require addressing that + // problem. For comparison with function calls, the IR needs to be emitted + // prior to the call. + context.node_block_stack().Pop(); + auto return_type_id = SemanticsTypeId::Invalid; auto return_slot_id = SemanticsNodeId::Invalid; if (context.parse_tree().node_kind(context.node_stack().PeekParseNode()) == ParseNodeKind::ReturnType) { return_slot_id = context.node_stack().Pop(); - // TODO: Consider removing return_type_id from SemanticsFunction, as it can - // be derived from the return_slot_id. return_type_id = context.semantics_ir().GetNode(return_slot_id).type_id(); + + // If the function has an explicit return type of `()`, it has no return + // slot, to keep the IR for explicit and implicit non-value-returning + // functions consistent. + auto return_type = context.semantics_ir().GetNode( + context.semantics_ir().GetTypeAllowBuiltinTypes(return_type_id)); + if (return_type.kind() == SemanticsNodeKind::TupleType && + context.semantics_ir() + .GetTypeBlock(return_type.GetAsTupleType()) + .empty()) { + return_slot_id = SemanticsNodeId::Invalid; + } } + SemanticsNodeBlockId param_refs_id = context.node_stack().Pop(); auto name_context = context.declaration_name_stack().Pop(); @@ -106,6 +126,9 @@ auto SemanticsHandleFunctionDefinitionStart(SemanticsContext& context, auto SemanticsHandleFunctionIntroducer(SemanticsContext& context, ParseTree::Node parse_node) -> bool { + // Create a node block to hold the nodes created as part of the function + // signature, such as parameter and return types. + context.node_block_stack().Push(); // Push the bracketing node. context.node_stack().Push(parse_node); // A name should always follow. @@ -115,21 +138,12 @@ auto SemanticsHandleFunctionIntroducer(SemanticsContext& context, auto SemanticsHandleReturnType(SemanticsContext& context, ParseTree::Node parse_node) -> bool { - // TODO: Like the function parameters, the return slot and any conversion - // nodes needed for its type are added to an unreferenced node block. We - // should either stop constructing this block or store it somewhere. - // - // See also SemanticsHandleParameterList. - context.node_block_stack().Push(); - // Propagate the type expression. auto [type_parse_node, type_node_id] = context.node_stack().PopExpressionWithParseNode(); auto type_id = context.ExpressionAsType(type_parse_node, type_node_id); context.AddNodeAndPush(parse_node, SemanticsNode::VarStorage::Make(parse_node, type_id)); - - context.node_block_stack().Pop(); return true; } diff --git a/toolchain/semantics/semantics_handle_parameter_list.cpp b/toolchain/semantics/semantics_handle_parameter_list.cpp index 0d540796a29bd..178cae9d9b17b 100644 --- a/toolchain/semantics/semantics_handle_parameter_list.cpp +++ b/toolchain/semantics/semantics_handle_parameter_list.cpp @@ -21,16 +21,6 @@ auto SemanticsHandleParameterList(SemanticsContext& context, ParseTree::Node parse_node) -> bool { auto refs_id = context.ParamOrArgEnd( /*for_args=*/false, ParseNodeKind::ParameterListStart); - // TODO: This contains the IR block for parameters. At present, it's just - // loose, but it's not strictly required for parameter refs; we should either - // stop constructing it completely or, if it turns out to be needed, store it. - // Note, the underlying issue is that the LLVM IR has nowhere clear to emit, - // so changing storage would require addressing that problem. For comparison - // with function calls, the IR needs to be emitted prior to the call. - // - // The same applies to the return slot. See also SemanticsHandleReturnType. - context.node_block_stack().Pop(); - context.PopScope(); context.node_stack() .PopAndDiscardSoloParseNode(); @@ -48,7 +38,6 @@ auto SemanticsHandleParameterListStart(SemanticsContext& context, ParseTree::Node parse_node) -> bool { context.PushScope(); context.node_stack().Push(parse_node); - context.node_block_stack().Push(); context.ParamOrArgStart(); return true; } diff --git a/toolchain/semantics/semantics_handle_statement.cpp b/toolchain/semantics/semantics_handle_statement.cpp index 467bf6661396e..ea9e5a0d1bd76 100644 --- a/toolchain/semantics/semantics_handle_statement.cpp +++ b/toolchain/semantics/semantics_handle_statement.cpp @@ -53,7 +53,7 @@ auto SemanticsHandleReturnStatement(SemanticsContext& context, .Build(parse_node, ReturnStatementDisallowExpression) .Note(fn_node.parse_node(), ReturnStatementImplicitNote) .Emit(); - } else { + } else if (callable.return_slot_id.is_valid()) { arg = context.Initialize(parse_node, callable.return_slot_id, arg); } diff --git a/toolchain/semantics/semantics_ir.h b/toolchain/semantics/semantics_ir.h index cea1d1efe3315..71d661bf34dd2 100644 --- a/toolchain/semantics/semantics_ir.h +++ b/toolchain/semantics/semantics_ir.h @@ -40,8 +40,10 @@ struct SemanticsFunction { // The return type. This will be invalid if the return type wasn't specified. SemanticsTypeId return_type_id; // The storage for the return value, which is a reference expression whose - // type is the return type of the function. Will be invalid if the return type - // wasn't specified. + // type is the return type of the function. Will be invalid if the function + // doesn't have a return slot. If this is valid, a call to the function is + // expected to have an additional final argument corresponding to the return + // slot. SemanticsNodeId return_slot_id; // A list of the statically reachable code blocks in the body of the // function, in lexical order. The first block is the entry block. This will diff --git a/toolchain/semantics/semantics_ir_formatter.cpp b/toolchain/semantics/semantics_ir_formatter.cpp index aa47892f57b44..7243f8c5a2808 100644 --- a/toolchain/semantics/semantics_ir_formatter.cpp +++ b/toolchain/semantics/semantics_ir_formatter.cpp @@ -453,8 +453,10 @@ class SemanticsIRFormatter { out_ << ")"; if (fn.return_type_id.is_valid()) { out_ << " -> "; - FormatNodeName(fn.return_slot_id); - out_ << ": "; + if (fn.return_slot_id.is_valid()) { + FormatNodeName(fn.return_slot_id); + out_ << ": "; + } FormatType(fn.return_type_id); } diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index dde28de99d4a1..be607d2bd1b39 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -14,7 +14,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type3, return_slot: node+9, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type3, return_slot: node+9, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -57,19 +57,17 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, @@ -79,11 +77,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc11_32: type = const_type i32 -// CHECK:STDOUT: %.loc11_25: type = const_type const i32 -// CHECK:STDOUT: %.loc11_42: type = ptr_type const i32 -// CHECK:STDOUT: %.loc11_43: type = ptr_type const i32* -// CHECK:STDOUT: %.loc11_1 = fn_decl @F +// CHECK:STDOUT: %.loc11 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const i32**) -> %return: const i32** { diff --git a/toolchain/semantics/testdata/const/fail_collapse.carbon b/toolchain/semantics/testdata/const/fail_collapse.carbon index 79d3719b3e947..5cc388a1cb349 100644 --- a/toolchain/semantics/testdata/const/fail_collapse.carbon +++ b/toolchain/semantics/testdata/const/fail_collapse.carbon @@ -16,7 +16,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type5, return_slot: node+8, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type5, return_slot: node+8, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -60,28 +60,24 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc10_36: type = ptr_type i32 -// CHECK:STDOUT: %.loc10_37: type = ptr_type i32* -// CHECK:STDOUT: %.loc10_1 = fn_decl @G +// CHECK:STDOUT: %.loc10 = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%p: const i32**) -> %return: i32** { diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index 75530ca418f24..1508762d5549c 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -14,8 +14,8 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+5, body: {block4}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -45,7 +45,7 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -57,19 +57,17 @@ fn Main() { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, @@ -88,8 +86,7 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_20: {} = struct_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @Echo +// CHECK:STDOUT: %.loc7 = fn_decl @Echo // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index a049c0e131041..81fa989db0d42 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -14,8 +14,8 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: {block4}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -41,14 +41,12 @@ fn Main() { // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -59,54 +57,46 @@ fn Main() { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_20: () = tuple_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @Echo +// CHECK:STDOUT: %.loc7 = fn_decl @Echo // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Echo(%a: ()) -> %return: () { +// CHECK:STDOUT: fn @Echo(%a: ()) -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_9.1: () = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: () = initialize_from %.loc7_9.1 to %return -// CHECK:STDOUT: return %.loc7_9.2 +// CHECK:STDOUT: return %a // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc12_9.1: () = tuple_value () // CHECK:STDOUT: %.loc12_9.2: () = stub_reference %.loc12_9.1 -// CHECK:STDOUT: %.loc12_7.1: () = call @Echo(%.loc12_9.2) to %.loc12_7.2 +// CHECK:STDOUT: %.loc12_7.1: () = call @Echo(%.loc12_9.2) // CHECK:STDOUT: %.loc12_7.2: () = materialize_temporary %.loc12_7.1 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index 1909d7db4cbcd..817c9a4977e51 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -14,8 +14,8 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+2, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+2, body: {block4}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -46,7 +46,7 @@ fn Main() { // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+8, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -56,14 +56,12 @@ fn Main() { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index ada86c6e777c8..8474e9ca4f6e8 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -35,9 +35,9 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block5, block6, block7, block8}}}, -// CHECK:STDOUT: {name: str2, param_refs: block10, return_type: type1, return_slot: node+13, body: {block12, block13, block14, block15}}}, -// CHECK:STDOUT: {name: str3, param_refs: block17, return_type: type1, return_slot: node+24, body: {block19, block20, block21}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block4, block5, block6, block7}}}, +// CHECK:STDOUT: {name: str2, param_refs: block9, return_type: type1, return_slot: node+13, body: {block10, block11, block12, block13}}}, +// CHECK:STDOUT: {name: str3, param_refs: block15, return_type: type1, return_slot: node+24, body: {block16, block17, block18}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -64,34 +64,34 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+4}, -// CHECK:STDOUT: {kind: Branch, arg0: block7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+4}, +// CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, -// CHECK:STDOUT: {kind: Branch, arg0: block8}, +// CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+15}, -// CHECK:STDOUT: {kind: Branch, arg0: block14}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+15}, +// CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+13, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, -// CHECK:STDOUT: {kind: Branch, arg0: block15}, +// CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+22, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+22, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block20, arg1: node+26}, -// CHECK:STDOUT: {kind: Branch, arg0: block21}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+26}, +// CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+29, arg1: node+24, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+30}, -// CHECK:STDOUT: {kind: Branch, arg0: block21}, +// CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -99,14 +99,12 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+25, @@ -129,14 +127,12 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, @@ -154,14 +150,12 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+22, // CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+24, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+26, // CHECK:STDOUT: node+27, // CHECK:STDOUT: node+28, diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index 8f1e1f793ab06..7fd54a6432a55 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -17,7 +17,7 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block5, block6, block7}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block4, block5, block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 2, @@ -41,8 +41,8 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+4}, -// CHECK:STDOUT: {kind: Branch, arg0: block7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+4}, +// CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, @@ -51,7 +51,7 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, -// CHECK:STDOUT: {kind: Branch, arg0: block7}, +// CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] @@ -61,14 +61,12 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index 36ff91230c5d4..c22dc3fe8fb43 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -15,7 +15,7 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block5, block6, block7}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block4, block5, block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -39,8 +39,8 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+4}, -// CHECK:STDOUT: {kind: Branch, arg0: block7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+4}, +// CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, @@ -54,14 +54,12 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index 4ceb2e1f5fe42..1fd3fc53cd550 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -10,7 +10,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+6, body: {block5, block6, block7, block8}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+6, body: {block4, block5, block6, block7}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -38,17 +38,17 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+8}, -// CHECK:STDOUT: {kind: Branch, arg0: block7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+8}, +// CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type1}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+11, arg1: node+12, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+14, arg1: node+15, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block8, arg1: node+13}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block8, arg1: node+16}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block8, type: type1}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+16}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+6, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+20}, // CHECK:STDOUT: ] @@ -62,6 +62,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, @@ -69,9 +70,6 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index 2d65c59b45eb1..fa4227864a64f 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -15,7 +15,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type0, return_slot: node+12, body: {block9, block10, block11, block14}}}, +// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type0, return_slot: node+12, body: {block8, block9, block10, block13}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -51,17 +51,17 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+14}, -// CHECK:STDOUT: {kind: Branch, arg0: block11}, -// CHECK:STDOUT: {kind: Call, arg0: block12, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+14}, +// CHECK:STDOUT: {kind: Branch, arg0: block10}, +// CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+17, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block13, arg1: function1, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block12, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+20, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+19}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+22}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block14, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+22}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type0}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+12, type: type0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+26}, // CHECK:STDOUT: ] @@ -92,14 +92,12 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index 60fe92113788e..9c4863a025596 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -10,7 +10,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+6, body: {block5, block6, block8, block9, block10, block7, block11, block12, block13, block14}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+6, body: {block4, block5, block7, block8, block9, block6, block10, block11, block12, block13}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -42,27 +42,27 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block6, arg1: node+8}, -// CHECK:STDOUT: {kind: Branch, arg0: block7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+8}, +// CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+11}, -// CHECK:STDOUT: {kind: Branch, arg0: block9}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+11}, +// CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+14}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+15}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type1}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+15}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+19}, -// CHECK:STDOUT: {kind: Branch, arg0: block12}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+19}, +// CHECK:STDOUT: {kind: Branch, arg0: block11}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+22}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+23}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+22}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+23}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type1}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+18}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+26}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+18}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+26}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block14, type: type1}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+29, arg1: node+6, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+30}, // CHECK:STDOUT: ] @@ -76,6 +76,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, @@ -83,9 +84,6 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/index/return_value_access.carbon b/toolchain/semantics/testdata/index/return_value_access.carbon index abae24400dc7c..553037c60481d 100644 --- a/toolchain/semantics/testdata/index/return_value_access.carbon +++ b/toolchain/semantics/testdata/index/return_value_access.carbon @@ -67,15 +67,15 @@ fn Run() -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, @@ -105,10 +105,7 @@ fn Run() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12: type = stub_reference i32 -// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_16.2: (type,) = tuple_value (%.loc7_12) -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/operators/unary_op.carbon b/toolchain/semantics/testdata/operators/unary_op.carbon index 1094df71c9ef4..38abcf2d2652d 100644 --- a/toolchain/semantics/testdata/operators/unary_op.carbon +++ b/toolchain/semantics/testdata/operators/unary_op.carbon @@ -10,7 +10,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+2, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+2, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -41,14 +41,12 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon index 9526b282aab09..ef394f0eb4e1a 100644 --- a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon @@ -136,7 +136,7 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructType, arg0: block4, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, @@ -210,8 +210,6 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+34, @@ -221,9 +219,11 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, @@ -315,8 +315,7 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @G -// CHECK:STDOUT: %.loc9_19: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc9_1 = fn_decl @H +// CHECK:STDOUT: %.loc9 = fn_decl @H // CHECK:STDOUT: %.loc11 = fn_decl @AddressOfLiteral // CHECK:STDOUT: %.loc38 = fn_decl @AddressOfOperator // CHECK:STDOUT: %.loc53 = fn_decl @AddressOfCall diff --git a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon index 33386eab2db5b..9cf022f3e608a 100644 --- a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type4, return_slot: node+9, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type4, return_slot: node+9, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -57,30 +57,25 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_43: {} = struct_value () -// CHECK:STDOUT: %.loc7_44: type = ptr_type {} -// CHECK:STDOUT: %.loc7_35: type = const_type {}* -// CHECK:STDOUT: %.loc7_1 = fn_decl @ConstMismatch +// CHECK:STDOUT: %.loc7 = fn_decl @ConstMismatch // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> %return: const ({}*) { diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index dea0725b5a2ac..5fd2af701b031 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -11,7 +11,7 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+8, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+8, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -61,18 +61,16 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, @@ -84,8 +82,7 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc8_41: type = const_type i32 -// CHECK:STDOUT: %.loc8_1 = fn_decl @F +// CHECK:STDOUT: %.loc8 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> %return: const i32 { diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index 84859724aa499..373ac1150d0fc 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -14,8 +14,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+4, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type3, return_slot: node+15, body: {block9}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+4, body: {block4}}}, +// CHECK:STDOUT: {name: str2, param_refs: block6, return_type: type3, return_slot: node+15, body: {block7}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -63,21 +63,17 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, @@ -87,14 +83,14 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, @@ -102,11 +98,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_23: type = ptr_type i32 -// CHECK:STDOUT: %.loc7_1 = fn_decl @Ptr -// CHECK:STDOUT: %.loc11_32: type = const_type i32 -// CHECK:STDOUT: %.loc11_42: type = ptr_type const i32 -// CHECK:STDOUT: %.loc11_1 = fn_decl @ConstPtr +// CHECK:STDOUT: %.loc7 = fn_decl @Ptr +// CHECK:STDOUT: %.loc11 = fn_decl @ConstPtr // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Ptr(%p: i32*) -> %return: i32* { diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index 1d0c765e078e0..7f58e61301a02 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -18,7 +18,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -73,14 +73,12 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon index 12f0939a97044..dc8ce78c5488b 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon @@ -12,7 +12,7 @@ fn F() -> () { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+2, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -40,21 +40,19 @@ fn F() -> () { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12.1: type = tuple_type () -// CHECK:STDOUT: %.loc7_12.2: () = tuple_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: () { +// CHECK:STDOUT: fn @F() -> () { // CHECK:STDOUT: !entry: // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/struct.carbon b/toolchain/semantics/testdata/return/struct.carbon index 6663500081503..0d00694e3fe5c 100644 --- a/toolchain/semantics/testdata/return/struct.carbon +++ b/toolchain/semantics/testdata/return/struct.carbon @@ -45,13 +45,13 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, @@ -69,8 +69,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_22: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc7_1 = fn_decl @Main +// CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() -> %return: {.a: i32} { diff --git a/toolchain/semantics/testdata/return/tuple.carbon b/toolchain/semantics/testdata/return/tuple.carbon index 4d495f128803f..51122f282cf21 100644 --- a/toolchain/semantics/testdata/return/tuple.carbon +++ b/toolchain/semantics/testdata/return/tuple.carbon @@ -61,15 +61,15 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, @@ -87,11 +87,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc8_15: type = stub_reference i32 -// CHECK:STDOUT: %.loc8_20: type = stub_reference i32 -// CHECK:STDOUT: %.loc8_23.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc8_23.2: (type, type) = tuple_value (%.loc8_15, %.loc8_20) -// CHECK:STDOUT: %.loc8_1 = fn_decl @Main +// CHECK:STDOUT: %.loc8 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() -> %return: (i32, i32) { From b75b2d57bcda1b945effadb36748c51ab45cf39d Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 21 Aug 2023 13:25:33 -0700 Subject: [PATCH 07/21] Materialize temporaries before the calls to which we pass them as arguments. --- toolchain/lowering/lowering_handle.cpp | 6 + .../lowering_handle_expression_category.cpp | 4 +- .../call/implicit_empty_tuple_as_arg.carbon | 3 +- .../testdata/if_expression/basic.carbon | 20 ++- .../lowering/testdata/operators/and.carbon | 18 ++- .../lowering/testdata/operators/or.carbon | 20 ++- toolchain/semantics/semantics_context.cpp | 111 ++++++++++---- toolchain/semantics/semantics_context.h | 25 ++-- .../semantics_handle_call_expression.cpp | 8 +- toolchain/semantics/semantics_ir.cpp | 3 + toolchain/semantics/semantics_ir.h | 5 + toolchain/semantics/semantics_node.h | 5 +- toolchain/semantics/semantics_node_kind.def | 1 + .../function/call/empty_struct.carbon | 11 +- .../testdata/function/call/empty_tuple.carbon | 5 +- .../call/fail_return_type_mismatch.carbon | 9 +- .../testdata/function/call/i32.carbon | 5 +- .../function/call/more_param_ir.carbon | 3 - .../testdata/function/call/params_one.carbon | 3 - .../function/call/params_one_comma.carbon | 12 +- .../testdata/function/call/params_two.carbon | 3 - .../function/call/params_two_comma.carbon | 16 +- .../testdata/function/call/params_zero.carbon | 3 - .../function/declaration/simple.carbon | 3 - toolchain/semantics/testdata/if/else.carbon | 21 +-- .../semantics/testdata/if/no_else.carbon | 10 +- .../if_expression/constant_condition.carbon | 102 +++++++------ .../if_expression/control_flow.carbon | 42 +++--- .../index/fail_empty_tuple_access.carbon | 4 +- .../testdata/index/return_value_access.carbon | 21 +-- .../testdata/namespace/function.carbon | 3 - .../testdata/namespace/nested.carbon | 3 - .../semantics/testdata/operators/and.carbon | 42 +++--- .../fail_assigment_to_non_assignable.carbon | 137 +++++++++--------- .../semantics/testdata/operators/or.carbon | 44 +++--- .../pointer/fail_address_of_value.carbon | 62 ++++---- 36 files changed, 441 insertions(+), 352 deletions(-) diff --git a/toolchain/lowering/lowering_handle.cpp b/toolchain/lowering/lowering_handle.cpp index ea8532dcc5106..5469bc48b1134 100644 --- a/toolchain/lowering/lowering_handle.cpp +++ b/toolchain/lowering/lowering_handle.cpp @@ -200,6 +200,12 @@ auto LoweringHandleNamespace(LoweringFunctionContext& /*context*/, // No action to take. } +auto LoweringHandleNoOp(LoweringFunctionContext& /*context*/, + SemanticsNodeId /*node_id*/, SemanticsNode /*node*/) + -> void { + // No action to take. +} + auto LoweringHandleRealLiteral(LoweringFunctionContext& context, SemanticsNodeId node_id, SemanticsNode node) -> void { diff --git a/toolchain/lowering/lowering_handle_expression_category.cpp b/toolchain/lowering/lowering_handle_expression_category.cpp index f966a3b7a5a50..36aaa6402040b 100644 --- a/toolchain/lowering/lowering_handle_expression_category.cpp +++ b/toolchain/lowering/lowering_handle_expression_category.cpp @@ -17,7 +17,9 @@ auto LoweringHandleInitializeFrom(LoweringFunctionContext& context, auto LoweringHandleMaterializeTemporary(LoweringFunctionContext& context, SemanticsNodeId node_id, SemanticsNode node) -> void { - context.SetLocal(node_id, context.GetLocal(node.GetAsMaterializeTemporary())); + context.SetLocal( + node_id, context.builder().CreateAlloca(context.GetType(node.type_id()), + nullptr, "temp")); } auto LoweringHandleValueBinding(LoweringFunctionContext& context, diff --git a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon index 1c220e916254d..0bbee54fecc3b 100644 --- a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon +++ b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon @@ -29,7 +29,8 @@ fn Main() { // CHECK:STDOUT: %var = alloca {}, align 8 // CHECK:STDOUT: call void @Foo() // CHECK:STDOUT: %call.result = alloca {}, align 8 -// CHECK:STDOUT: %1 = load {}, ptr %call.result, align 1 +// CHECK:STDOUT: %temp = alloca {}, align 8 +// CHECK:STDOUT: %1 = load {}, ptr %temp, align 1 // CHECK:STDOUT: %2 = load {}, ptr %call.result, align 1 // CHECK:STDOUT: %Bar = call {} @Bar({} %2) // CHECK:STDOUT: store {} %Bar, ptr %var, align 1 diff --git a/toolchain/lowering/testdata/if_expression/basic.carbon b/toolchain/lowering/testdata/if_expression/basic.carbon index 88b5ebc2921a3..6d6ed05642942 100644 --- a/toolchain/lowering/testdata/if_expression/basic.carbon +++ b/toolchain/lowering/testdata/if_expression/basic.carbon @@ -23,17 +23,23 @@ fn Select(b: bool) -> i32 { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define i32 @Select(i1 %b) { -// CHECK:STDOUT: br i1 %b, label %1, label %2 +// CHECK:STDOUT: br i1 %b, label %1, label %3 // CHECK:STDOUT: // CHECK:STDOUT: 1: ; preds = %0 +// CHECK:STDOUT: %temp = alloca i32, align 4 // CHECK:STDOUT: %F = call i32 @F() -// CHECK:STDOUT: br label %3 +// CHECK:STDOUT: store i32 %F, ptr %temp, align 4 +// CHECK:STDOUT: %2 = load i32, ptr %temp, align 4 +// CHECK:STDOUT: br label %5 // CHECK:STDOUT: -// CHECK:STDOUT: 2: ; preds = %0 +// CHECK:STDOUT: 3: ; preds = %0 +// CHECK:STDOUT: %temp1 = alloca i32, align 4 // CHECK:STDOUT: %G = call i32 @G() -// CHECK:STDOUT: br label %3 +// CHECK:STDOUT: store i32 %G, ptr %temp1, align 4 +// CHECK:STDOUT: %4 = load i32, ptr %temp1, align 4 +// CHECK:STDOUT: br label %5 // CHECK:STDOUT: -// CHECK:STDOUT: 3: ; preds = %2, %1 -// CHECK:STDOUT: %4 = phi i32 [ %F, %1 ], [ %G, %2 ] -// CHECK:STDOUT: ret i32 %4 +// CHECK:STDOUT: 5: ; preds = %3, %1 +// CHECK:STDOUT: %6 = phi i32 [ %2, %1 ], [ %4, %3 ] +// CHECK:STDOUT: ret i32 %6 // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/operators/and.carbon b/toolchain/lowering/testdata/operators/and.carbon index 418c98a51447e..93cfc361d73d2 100644 --- a/toolchain/lowering/testdata/operators/and.carbon +++ b/toolchain/lowering/testdata/operators/and.carbon @@ -23,14 +23,20 @@ fn And() -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define i1 @And() { +// CHECK:STDOUT: %temp = alloca i1, align 1 // CHECK:STDOUT: %F = call i1 @F() -// CHECK:STDOUT: br i1 %F, label %1, label %2 +// CHECK:STDOUT: store i1 %F, ptr %temp, align 1 +// CHECK:STDOUT: %1 = load i1, ptr %temp, align 1 +// CHECK:STDOUT: br i1 %1, label %2, label %4 // CHECK:STDOUT: -// CHECK:STDOUT: 1: ; preds = %0 +// CHECK:STDOUT: 2: ; preds = %0 +// CHECK:STDOUT: %temp1 = alloca i1, align 1 // CHECK:STDOUT: %G = call i1 @G() -// CHECK:STDOUT: br label %2 +// CHECK:STDOUT: store i1 %G, ptr %temp1, align 1 +// CHECK:STDOUT: %3 = load i1, ptr %temp1, align 1 +// CHECK:STDOUT: br label %4 // CHECK:STDOUT: -// CHECK:STDOUT: 2: ; preds = %1, %0 -// CHECK:STDOUT: %3 = phi i1 [ false, %0 ], [ %G, %1 ] -// CHECK:STDOUT: ret i1 %3 +// CHECK:STDOUT: 4: ; preds = %2, %0 +// CHECK:STDOUT: %5 = phi i1 [ false, %0 ], [ %3, %2 ] +// CHECK:STDOUT: ret i1 %5 // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/operators/or.carbon b/toolchain/lowering/testdata/operators/or.carbon index b5214337ac68b..2206830c5d61a 100644 --- a/toolchain/lowering/testdata/operators/or.carbon +++ b/toolchain/lowering/testdata/operators/or.carbon @@ -23,15 +23,21 @@ fn Or() -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define i1 @Or() { +// CHECK:STDOUT: %temp = alloca i1, align 1 // CHECK:STDOUT: %F = call i1 @F() -// CHECK:STDOUT: %1 = xor i1 %F, true -// CHECK:STDOUT: br i1 %1, label %2, label %3 +// CHECK:STDOUT: store i1 %F, ptr %temp, align 1 +// CHECK:STDOUT: %1 = load i1, ptr %temp, align 1 +// CHECK:STDOUT: %2 = xor i1 %1, true +// CHECK:STDOUT: br i1 %2, label %3, label %5 // CHECK:STDOUT: -// CHECK:STDOUT: 2: ; preds = %0 +// CHECK:STDOUT: 3: ; preds = %0 +// CHECK:STDOUT: %temp1 = alloca i1, align 1 // CHECK:STDOUT: %G = call i1 @G() -// CHECK:STDOUT: br label %3 +// CHECK:STDOUT: store i1 %G, ptr %temp1, align 1 +// CHECK:STDOUT: %4 = load i1, ptr %temp1, align 1 +// CHECK:STDOUT: br label %5 // CHECK:STDOUT: -// CHECK:STDOUT: 3: ; preds = %2, %0 -// CHECK:STDOUT: %4 = phi i1 [ true, %0 ], [ %G, %2 ] -// CHECK:STDOUT: ret i1 %4 +// CHECK:STDOUT: 5: ; preds = %3, %0 +// CHECK:STDOUT: %6 = phi i1 [ true, %0 ], [ %4, %3 ] +// CHECK:STDOUT: ret i1 %6 // CHECK:STDOUT: } diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 475db6c17ba49..753535fb32077 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -268,9 +268,15 @@ auto SemanticsContext::is_current_position_reachable() -> bool { } } -auto SemanticsContext::ConvertToInitializingExpression( - SemanticsNodeId expr_id, SemanticsNodeId target_id) -> SemanticsNodeId { +auto SemanticsContext::Initialize(ParseTree::Node parse_node, + SemanticsNodeId target_id, + SemanticsNodeId value_id) -> SemanticsNodeId { + // Implicitly convert the value to the type of the target. + auto type_id = semantics_ir().GetNode(target_id).type_id(); + auto expr_id = ImplicitAsRequired(parse_node, value_id, type_id); SemanticsNode expr = semantics_ir().GetNode(expr_id); + + // Perform initialization now that we have an expression of the right type. switch (GetSemanticsExpressionCategory(semantics_ir(), expr_id)) { case SemanticsExpressionCategory::NotExpression: CARBON_FATAL() << "Converting non-expression node " << expr @@ -299,21 +305,6 @@ auto SemanticsContext::ConvertToInitializingExpression( } } -auto SemanticsContext::MaterializeTemporary(SemanticsNodeId init_id) - -> SemanticsNodeId { - SemanticsNode init = semantics_ir().GetNode(init_id); - CARBON_CHECK(GetSemanticsExpressionCategory(semantics_ir(), init_id) == - SemanticsExpressionCategory::Initializing) - << "can only materialize initializing initessions, found " << init; - - auto temporary_id = AddNode(SemanticsNode::MaterializeTemporary::Make( - init.parse_node(), init.type_id(), init_id)); - // TODO: The temporary materialization appears later in the IR than the - // initession that initializes it. - MarkInitializerFor(init_id, temporary_id); - return temporary_id; -} - auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) -> SemanticsNodeId { switch (GetSemanticsExpressionCategory(semantics_ir(), expr_id)) { @@ -323,9 +314,8 @@ auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) << " to value expression"; case SemanticsExpressionCategory::Initializing: { - // TODO: For class types, use an interface to determine how to perform - // this operation. - expr_id = MaterializeTemporary(expr_id); + // Commit to using a temporary for this initializing expression. + expr_id = FinalizeTemporary(expr_id, /*discarded=*/false); [[fallthrough]]; } @@ -342,6 +332,64 @@ auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) } } +auto SemanticsContext::FinalizeTemporary(SemanticsNodeId init_id, + bool discarded) -> SemanticsNodeId { + // TODO: See if we can refactor this with MarkInitializerFor once recursion + // through struct and tuple values is properly handled. + while (true) { + SemanticsNode init = semantics_ir().GetNode(init_id); + CARBON_CHECK(GetSemanticsExpressionCategory(semantics_ir(), init_id) == + SemanticsExpressionCategory::Initializing) + << "Can only materialize initializing expressions, found " << init; + switch (init.kind()) { + default: + CARBON_FATAL() << "Initialization from unexpected node " << init; + + case SemanticsNodeKind::StructValue: + case SemanticsNodeKind::TupleValue: + CARBON_FATAL() << init << " is not modeled as initializing yet"; + + case SemanticsNodeKind::StubReference: { + init_id = init.GetAsStubReference(); + continue; + } + + case SemanticsNodeKind::Call: { + auto [refs_id, callee_id] = init.GetAsCall(); + if (!semantics_ir().GetFunction(callee_id).return_slot_id.is_valid()) { + if (discarded) { + // Don't invent a temporary that we're going to discard. + return SemanticsNodeId::Invalid; + } + + // The function has no return slot, which means it represents an + // empty tuple. Materialize one now. + auto temporary_id = AddNode(SemanticsNode::MaterializeTemporary::Make( + init.parse_node(), CanonicalizeTupleType(init.parse_node(), {}))); + // TODO: Do we need to create an empty TupleValue and Assign it to the + // temporary? + return temporary_id; + } + + // The return slot should have a materialized temporary in it. Assign + // the initializer to it and return its address. + auto temporary_id = semantics_ir().GetNodeBlock(refs_id).back(); + auto temporary = semantics_ir().GetNode(temporary_id); + CARBON_CHECK(temporary.kind() == + SemanticsNodeKind::MaterializeTemporary) + << "Return slot for function call does not contain a temporary; " + << "initialized multiple times? Have " << temporary; + AddNode(SemanticsNode::Assign::Make(temporary.parse_node(), + temporary_id, init_id)); + return temporary_id; + } + + case SemanticsNodeKind::InitializeFrom: + CARBON_FATAL() << init << " should be created with a destination"; + } + } +} + auto SemanticsContext::MarkInitializerFor(SemanticsNodeId init_id, SemanticsNodeId target_id) -> void { while (true) { @@ -364,15 +412,19 @@ auto SemanticsContext::MarkInitializerFor(SemanticsNodeId init_id, case SemanticsNodeKind::Call: { // If the callee has a return slot, point it at our target. - // TODO: Consider treating calls to functions without a return slot as - // value expressions, to avoid materializing unused temporaries. auto [refs_id, callee_id] = init.GetAsCall(); if (semantics_ir().GetFunction(callee_id).return_slot_id.is_valid()) { - auto& refs = semantics_ir().GetNodeBlock(refs_id); - CARBON_CHECK(!refs.back().is_valid()) - << "return slot for function call set multiple times, have " - << init << ", new return slot is " << target_id; - refs.back() = target_id; + // Replace the return slot with our given target, and remove the + // tentatively-created temporary. + auto temporary_id = std::exchange( + semantics_ir().GetNodeBlock(refs_id).back(), target_id); + auto temporary = semantics_ir().GetNode(temporary_id); + CARBON_CHECK(temporary.kind() == + SemanticsNodeKind::MaterializeTemporary) + << "Return slot for function call does not contain a temporary; " + << "initialized multiple times? Have " << temporary; + semantics_ir().ReplaceNode( + temporary_id, SemanticsNode::NoOp::Make(temporary.parse_node())); } return; } @@ -386,7 +438,10 @@ auto SemanticsContext::MarkInitializerFor(SemanticsNodeId init_id, auto SemanticsContext::HandleDiscardedExpression(SemanticsNodeId expr_id) -> void { // If we discard an initializing expression, materialize it first. - expr_id = MaterializeIfInitializing(expr_id); + if (GetSemanticsExpressionCategory(semantics_ir(), expr_id) == + SemanticsExpressionCategory::Initializing) { + FinalizeTemporary(expr_id, /*discarded=*/true); + } // TODO: This will eventually need to do some "do not discard" analysis. (void)expr_id; diff --git a/toolchain/semantics/semantics_context.h b/toolchain/semantics/semantics_context.h index 6763bea5c7a6b..4fa8063660cc7 100644 --- a/toolchain/semantics/semantics_context.h +++ b/toolchain/semantics/semantics_context.h @@ -110,19 +110,12 @@ class SemanticsContext { // Returns whether the current position in the current block is reachable. auto is_current_position_reachable() -> bool; - // Convert the given expression to an initializing expression of the same - // type. `target_id` is a reference expression describing the object that is - // initialized. - auto ConvertToInitializingExpression(SemanticsNodeId expr_id, - SemanticsNodeId target_id) - -> SemanticsNodeId; - // Converts the given expression to an ephemeral reference to a temporary if // it is an initializing expression. auto MaterializeIfInitializing(SemanticsNodeId expr_id) -> SemanticsNodeId { if (GetSemanticsExpressionCategory(semantics_ir(), expr_id) == SemanticsExpressionCategory::Initializing) { - return MaterializeTemporary(expr_id); + return FinalizeTemporary(expr_id, /*discarded=*/false); } return expr_id; } @@ -133,11 +126,7 @@ class SemanticsContext { // Performs initialization of `target_id` from `value_id`. Returns the // converted initializer value. auto Initialize(ParseTree::Node parse_node, SemanticsNodeId target_id, - SemanticsNodeId value_id) -> SemanticsNodeId { - auto type_id = semantics_ir().GetNode(target_id).type_id(); - return ConvertToInitializingExpression( - ImplicitAsRequired(parse_node, value_id, type_id), target_id); - } + SemanticsNodeId value_id) -> SemanticsNodeId; // Converts `value_id` to a value expression of type `type_id`. auto ConvertToValueOfType(ParseTree::Node parse_node, @@ -302,9 +291,13 @@ class SemanticsContext { // TODO: This likely needs to track things which need to be destructed. }; - // Materializes a temporary to store the result of initializing expression - // `init_id`. - auto MaterializeTemporary(SemanticsNodeId init_id) -> SemanticsNodeId; + // Commits to using a temporary to store the result of the initializing + // expression described by `init_id`, and returns the location of the + // temporary. If `discarded` is `true`, the result is discarded, and no + // temporary will be created if possible; if no temporary is created, the + // return value will be `SemanticsNodeId::Invalid`. + auto FinalizeTemporary(SemanticsNodeId init_id, bool discarded) + -> SemanticsNodeId; // Marks the initializer `init_id` as initializing `target_id`. auto MarkInitializerFor(SemanticsNodeId target_id, SemanticsNodeId init_id) diff --git a/toolchain/semantics/semantics_handle_call_expression.cpp b/toolchain/semantics/semantics_handle_call_expression.cpp index b2500052e52cd..374f9333411ba 100644 --- a/toolchain/semantics/semantics_handle_call_expression.cpp +++ b/toolchain/semantics/semantics_handle_call_expression.cpp @@ -54,8 +54,12 @@ auto SemanticsHandleCallExpression(SemanticsContext& context, if (refs_id == SemanticsNodeBlockId::Empty) { refs_id = context.semantics_ir().AddNodeBlock(); } - context.semantics_ir().GetNodeBlock(refs_id).push_back( - SemanticsNodeId::Invalid); + // Tentatively put a materialized temporary in the function's return slot. + // This will be replaced if necessary when we perform initialization. + auto return_slot_id = + context.AddNode(SemanticsNode::MaterializeTemporary::Make( + call_expr_parse_node, callable.return_type_id)); + context.semantics_ir().GetNodeBlock(refs_id).push_back(return_slot_id); } auto call_node_id = context.AddNode(SemanticsNode::Call::Make( call_expr_parse_node, type_id, refs_id, function_id)); diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index 18369dd7712c1..1a0b27333c2da 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -237,6 +237,7 @@ static auto GetTypePrecedence(SemanticsNodeKind kind) -> int { case SemanticsNodeKind::Invalid: case SemanticsNodeKind::MaterializeTemporary: case SemanticsNodeKind::Namespace: + case SemanticsNodeKind::NoOp: case SemanticsNodeKind::RealLiteral: case SemanticsNodeKind::Return: case SemanticsNodeKind::ReturnExpression: @@ -383,6 +384,7 @@ auto SemanticsIR::StringifyType(SemanticsTypeId type_id, case SemanticsNodeKind::IntegerLiteral: case SemanticsNodeKind::MaterializeTemporary: case SemanticsNodeKind::Namespace: + case SemanticsNodeKind::NoOp: case SemanticsNodeKind::RealLiteral: case SemanticsNodeKind::Return: case SemanticsNodeKind::ReturnExpression: @@ -433,6 +435,7 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, case SemanticsNodeKind::BranchWithArg: case SemanticsNodeKind::FunctionDeclaration: case SemanticsNodeKind::Namespace: + case SemanticsNodeKind::NoOp: case SemanticsNodeKind::Return: case SemanticsNodeKind::ReturnExpression: case SemanticsNodeKind::StructTypeField: diff --git a/toolchain/semantics/semantics_ir.h b/toolchain/semantics/semantics_ir.h index 71d661bf34dd2..712f6ca6e1a7d 100644 --- a/toolchain/semantics/semantics_ir.h +++ b/toolchain/semantics/semantics_ir.h @@ -161,6 +161,11 @@ class SemanticsIR { return node_id; } + // Overwrites a given node with a new value. + auto ReplaceNode(SemanticsNodeId node_id, SemanticsNode node) -> void { + nodes_[node_id.index] = node; + } + // Returns the requested node. auto GetNode(SemanticsNodeId node_id) const -> SemanticsNode { return nodes_[node_id.index]; diff --git a/toolchain/semantics/semantics_node.h b/toolchain/semantics/semantics_node.h index 55b3ee75551f9..2d3b198167186 100644 --- a/toolchain/semantics/semantics_node.h +++ b/toolchain/semantics/semantics_node.h @@ -393,12 +393,13 @@ class SemanticsNode { using IntegerLiteral = Factory; - using MaterializeTemporary = Factory; + using MaterializeTemporary = Factory; using Namespace = FactoryNoType; + using NoOp = FactoryNoType; + using PointerType = Factory; diff --git a/toolchain/semantics/semantics_node_kind.def b/toolchain/semantics/semantics_node_kind.def index 45565f121017d..33946b147adde 100644 --- a/toolchain/semantics/semantics_node_kind.def +++ b/toolchain/semantics/semantics_node_kind.def @@ -68,6 +68,7 @@ CARBON_SEMANTICS_NODE_KIND_IMPL(IntegerLiteral, "int_literal", Typed, CARBON_SEMANTICS_NODE_KIND_IMPL(MaterializeTemporary, "materialize_temporary", Typed, 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(PointerType, "ptr_type", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(RealLiteral, "real_literal", Typed, NotTerminator) diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index 1508762d5549c..164f1e4f2053a 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -45,8 +45,9 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+14}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -78,10 +79,11 @@ fn Main() { // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -101,7 +103,8 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc12_9.1: {} = struct_value () // CHECK:STDOUT: %.loc12_9.2: {} = stub_reference %.loc12_9.1 -// CHECK:STDOUT: %.loc12_7.1: {} = call @Echo(%.loc12_9.2) to %.loc12_7.2 -// CHECK:STDOUT: %.loc12_7.2: {} = materialize_temporary %.loc12_7.1 +// CHECK:STDOUT: %.loc12_7.1: {} = materialize_temporary +// CHECK:STDOUT: %.loc12_7.2: {} = call @Echo(%.loc12_9.2) to %.loc12_7.1 +// CHECK:STDOUT: assign %.loc12_7.1, %.loc12_7.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index 81fa989db0d42..1cf88363622ad 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -46,7 +46,6 @@ fn Main() { // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -75,7 +74,6 @@ fn Main() { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, @@ -96,7 +94,6 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc12_9.1: () = tuple_value () // CHECK:STDOUT: %.loc12_9.2: () = stub_reference %.loc12_9.1 -// CHECK:STDOUT: %.loc12_7.1: () = call @Echo(%.loc12_9.2) -// CHECK:STDOUT: %.loc12_7.2: () = materialize_temporary %.loc12_7.1 +// CHECK:STDOUT: %.loc12_7: () = call @Echo(%.loc12_9.2) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon index 95879f06b4540..bac503437d7b9 100644 --- a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon @@ -43,9 +43,10 @@ fn Run() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block5, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+6, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+10}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -70,9 +71,10 @@ fn Run() { // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -91,7 +93,8 @@ fn Run() { // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc13: f64 = call @Foo() to invalid +// CHECK:STDOUT: %.loc13_19.1: f64 = materialize_temporary +// CHECK:STDOUT: %.loc13_19.2: f64 = call @Foo() to %.loc13_19.1 // CHECK:STDOUT: %.1: = initialize_from to %x // CHECK:STDOUT: assign %x, %.1 // CHECK:STDOUT: return diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index 817c9a4977e51..bddf807f09db4 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -46,8 +46,9 @@ fn Main() { // CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+8, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: NoOp}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+13}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -78,6 +79,7 @@ fn Main() { // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, @@ -102,6 +104,7 @@ fn Main() { // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc12_21.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc12_21.2: i32 = stub_reference %.loc12_21.1 +// CHECK:STDOUT: no_op // CHECK:STDOUT: %.loc12_20: i32 = call @Echo(%.loc12_21.2) to %b // CHECK:STDOUT: assign %b, %.loc12_20 // CHECK:STDOUT: return diff --git a/toolchain/semantics/testdata/function/call/more_param_ir.carbon b/toolchain/semantics/testdata/function/call/more_param_ir.carbon index 12d524ed38d54..e56940ce894cb 100644 --- a/toolchain/semantics/testdata/function/call/more_param_ir.carbon +++ b/toolchain/semantics/testdata/function/call/more_param_ir.carbon @@ -65,7 +65,6 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+22, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -107,7 +106,6 @@ fn Main() { // CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, // CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+14, @@ -142,6 +140,5 @@ fn Main() { // CHECK:STDOUT: %.loc11_25.2: i32 = stub_reference %.loc11_25.1 // CHECK:STDOUT: %.loc11_6.1: type = tuple_type () // CHECK:STDOUT: %.loc11_6.2: () = call @Foo(%.loc11_13.2, %.loc11_20.2, %.loc11_25.2) -// CHECK:STDOUT: %.loc11_6.3: () = materialize_temporary %.loc11_6.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_one.carbon b/toolchain/semantics/testdata/function/call/params_one.carbon index 43b649ae36e53..252495205fa35 100644 --- a/toolchain/semantics/testdata/function/call/params_one.carbon +++ b/toolchain/semantics/testdata/function/call/params_one.carbon @@ -43,7 +43,6 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -69,7 +68,6 @@ fn Main() { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, @@ -92,6 +90,5 @@ fn Main() { // CHECK:STDOUT: %.loc10_7.2: i32 = stub_reference %.loc10_7.1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo(%.loc10_7.2) -// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_one_comma.carbon b/toolchain/semantics/testdata/function/call/params_one_comma.carbon index cec585e0494fa..e1d7d9025a824 100644 --- a/toolchain/semantics/testdata/function/call/params_one_comma.carbon +++ b/toolchain/semantics/testdata/function/call/params_one_comma.carbon @@ -45,11 +45,9 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -78,14 +76,12 @@ fn Main() { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -105,10 +101,8 @@ fn Main() { // CHECK:STDOUT: %.loc10_7.2: i32 = stub_reference %.loc10_7.1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo(%.loc10_7.2) -// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: %.loc11_7.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_7.2: i32 = stub_reference %.loc11_7.1 -// CHECK:STDOUT: %.loc11_6.1: () = call @Foo(%.loc11_7.2) -// CHECK:STDOUT: %.loc11_6.2: () = materialize_temporary %.loc11_6.1 +// CHECK:STDOUT: %.loc11_6: () = call @Foo(%.loc11_7.2) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_two.carbon b/toolchain/semantics/testdata/function/call/params_two.carbon index d5738f47487ca..da85124cb7010 100644 --- a/toolchain/semantics/testdata/function/call/params_two.carbon +++ b/toolchain/semantics/testdata/function/call/params_two.carbon @@ -49,7 +49,6 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -80,7 +79,6 @@ fn Main() { // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+8, @@ -106,6 +104,5 @@ fn Main() { // CHECK:STDOUT: %.loc10_10.2: i32 = stub_reference %.loc10_10.1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo(%.loc10_7.2, %.loc10_10.2) -// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_two_comma.carbon b/toolchain/semantics/testdata/function/call/params_two_comma.carbon index b5ff39f1824cd..e2c5fc5e61230 100644 --- a/toolchain/semantics/testdata/function/call/params_two_comma.carbon +++ b/toolchain/semantics/testdata/function/call/params_two_comma.carbon @@ -52,13 +52,11 @@ fn Main() { // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+15, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+18, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -94,16 +92,14 @@ fn Main() { // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -125,12 +121,10 @@ fn Main() { // CHECK:STDOUT: %.loc10_10.2: i32 = stub_reference %.loc10_10.1 // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo(%.loc10_7.2, %.loc10_10.2) -// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: %.loc11_7.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc11_7.2: i32 = stub_reference %.loc11_7.1 // CHECK:STDOUT: %.loc11_10.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc11_10.2: i32 = stub_reference %.loc11_10.1 -// CHECK:STDOUT: %.loc11_6.1: () = call @Foo(%.loc11_7.2, %.loc11_10.2) -// CHECK:STDOUT: %.loc11_6.2: () = materialize_temporary %.loc11_6.1 +// CHECK:STDOUT: %.loc11_6: () = call @Foo(%.loc11_7.2, %.loc11_10.2) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/params_zero.carbon b/toolchain/semantics/testdata/function/call/params_zero.carbon index 9cd4dbb8f3836..d0f487a3ed375 100644 --- a/toolchain/semantics/testdata/function/call/params_zero.carbon +++ b/toolchain/semantics/testdata/function/call/params_zero.carbon @@ -36,7 +36,6 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -53,7 +52,6 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -71,6 +69,5 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10_6.1: type = tuple_type () // CHECK:STDOUT: %.loc10_6.2: () = call @Foo() -// CHECK:STDOUT: %.loc10_6.3: () = materialize_temporary %.loc10_6.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/declaration/simple.carbon b/toolchain/semantics/testdata/function/declaration/simple.carbon index 4e9da5a1a5711..49f83992d85e5 100644 --- a/toolchain/semantics/testdata/function/declaration/simple.carbon +++ b/toolchain/semantics/testdata/function/declaration/simple.carbon @@ -33,7 +33,6 @@ fn G() { F(); } // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+3, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -47,7 +46,6 @@ fn G() { F(); } // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -62,6 +60,5 @@ fn G() { F(); } // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc9_11.1: type = tuple_type () // CHECK:STDOUT: %.loc9_11.2: () = call @F() -// CHECK:STDOUT: %.loc9_11.3: () = materialize_temporary %.loc9_11.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/else.carbon b/toolchain/semantics/testdata/if/else.carbon index efa35fd367b49..9f0e067b64237 100644 --- a/toolchain/semantics/testdata/if/else.carbon +++ b/toolchain/semantics/testdata/if/else.carbon @@ -58,13 +58,10 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+15, type: type1}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function2, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+19, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -100,18 +97,15 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -145,16 +139,13 @@ fn If(b: bool) { // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc13_6.1: type = tuple_type () // CHECK:STDOUT: %.loc13_6.2: () = call @F() -// CHECK:STDOUT: %.loc13_6.3: () = materialize_temporary %.loc13_6.2 // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.loc15_6.1: () = call @G() -// CHECK:STDOUT: %.loc15_6.2: () = materialize_temporary %.loc15_6.1 +// CHECK:STDOUT: %.loc15: () = call @G() // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.done: -// CHECK:STDOUT: %.loc17_4.1: () = call @H() -// CHECK:STDOUT: %.loc17_4.2: () = materialize_temporary %.loc17_4.1 +// CHECK:STDOUT: %.loc17: () = call @H() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/no_else.carbon b/toolchain/semantics/testdata/if/no_else.carbon index 47fbeca0dcc2e..347ada443c0d1 100644 --- a/toolchain/semantics/testdata/if/no_else.carbon +++ b/toolchain/semantics/testdata/if/no_else.carbon @@ -51,10 +51,8 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+11, type: type1}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+14, type: type1}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -87,12 +85,10 @@ fn If(b: bool) { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -120,11 +116,9 @@ fn If(b: bool) { // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc12_6.1: type = tuple_type () // CHECK:STDOUT: %.loc12_6.2: () = call @F() -// CHECK:STDOUT: %.loc12_6.3: () = materialize_temporary %.loc12_6.2 // CHECK:STDOUT: br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.loc14_4.1: () = call @G() -// CHECK:STDOUT: %.loc14_4.2: () = materialize_temporary %.loc14_4.1 +// CHECK:STDOUT: %.loc14: () = call @G() // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/constant_condition.carbon b/toolchain/semantics/testdata/if_expression/constant_condition.carbon index 1e7952654f1ae..5b26f323d1c0b 100644 --- a/toolchain/semantics/testdata/if_expression/constant_condition.carbon +++ b/toolchain/semantics/testdata/if_expression/constant_condition.carbon @@ -20,7 +20,7 @@ fn G() -> i32 { // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, // CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, // CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9, block12}}}, -// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, return_slot: node+26, body: {block14, block15, block16, block19}}}, +// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, return_slot: node+28, body: {block14, block15, block16, block19}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -56,33 +56,37 @@ fn G() -> i32 { // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, // CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block10, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+15, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+16}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+15, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+20}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+17}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+20}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+18}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+22}, // CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+26}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+28}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+30}, // CHECK:STDOUT: {kind: Branch, arg0: block16}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block17, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+31, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+32, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+33, arg1: node+34}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+33, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block18, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+34, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+35, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block19, arg1: node+33}, +// CHECK:STDOUT: {kind: Assign, arg0: node+37, arg1: node+38}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+37, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block19, arg1: node+36}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block19, arg1: node+40}, // CHECK:STDOUT: {kind: BlockArg, arg0: block19, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+39, arg1: node+26, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+40}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+43, arg1: node+28, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+44}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -94,7 +98,7 @@ fn G() -> i32 { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, @@ -121,55 +125,59 @@ fn G() -> i32 { // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+24, // CHECK:STDOUT: node+25, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+28, -// CHECK:STDOUT: node+29, -// CHECK:STDOUT: node+30, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+30, // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+32, -// CHECK:STDOUT: node+33, -// CHECK:STDOUT: node+37, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+33, // CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, +// CHECK:STDOUT: node+41, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+37, // CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+39, +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+42, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+32, +// CHECK:STDOUT: node+33, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+37, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+39, -// CHECK:STDOUT: node+40, -// CHECK:STDOUT: node+41, +// CHECK:STDOUT: node+43, +// CHECK:STDOUT: node+44, +// CHECK:STDOUT: node+45, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -200,15 +208,17 @@ 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: %.loc11_24.1: i32 = call @A() to %.loc11_24.2 -// CHECK:STDOUT: %.loc11_24.2: i32 = materialize_temporary %.loc11_24.1 -// CHECK:STDOUT: %.loc11_24.3: i32 = value_binding %.loc11_24.2 +// CHECK:STDOUT: %.loc11_24.1: i32 = materialize_temporary +// CHECK:STDOUT: %.loc11_24.2: i32 = call @A() to %.loc11_24.1 +// CHECK:STDOUT: assign %.loc11_24.1, %.loc11_24.2 +// CHECK:STDOUT: %.loc11_24.3: i32 = value_binding %.loc11_24.1 // CHECK:STDOUT: br !if.expr.result(%.loc11_24.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_33.1: i32 = call @B() to %.loc11_33.2 -// CHECK:STDOUT: %.loc11_33.2: i32 = materialize_temporary %.loc11_33.1 -// CHECK:STDOUT: %.loc11_33.3: i32 = value_binding %.loc11_33.2 +// CHECK:STDOUT: %.loc11_33.1: i32 = materialize_temporary +// CHECK:STDOUT: %.loc11_33.2: i32 = call @B() to %.loc11_33.1 +// CHECK:STDOUT: assign %.loc11_33.1, %.loc11_33.2 +// CHECK:STDOUT: %.loc11_33.3: i32 = value_binding %.loc11_33.1 // CHECK:STDOUT: br !if.expr.result(%.loc11_33.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: @@ -223,15 +233,17 @@ 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: %.loc15_25.1: i32 = call @A() to %.loc15_25.2 -// CHECK:STDOUT: %.loc15_25.2: i32 = materialize_temporary %.loc15_25.1 -// CHECK:STDOUT: %.loc15_25.3: i32 = value_binding %.loc15_25.2 +// CHECK:STDOUT: %.loc15_25.1: i32 = materialize_temporary +// CHECK:STDOUT: %.loc15_25.2: i32 = call @A() to %.loc15_25.1 +// CHECK:STDOUT: assign %.loc15_25.1, %.loc15_25.2 +// CHECK:STDOUT: %.loc15_25.3: i32 = value_binding %.loc15_25.1 // CHECK:STDOUT: br !if.expr.result(%.loc15_25.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc15_34.1: i32 = call @B() to %.loc15_34.2 -// CHECK:STDOUT: %.loc15_34.2: i32 = materialize_temporary %.loc15_34.1 -// CHECK:STDOUT: %.loc15_34.3: i32 = value_binding %.loc15_34.2 +// CHECK:STDOUT: %.loc15_34.1: i32 = materialize_temporary +// CHECK:STDOUT: %.loc15_34.2: i32 = call @B() to %.loc15_34.1 +// CHECK:STDOUT: assign %.loc15_34.1, %.loc15_34.2 +// CHECK:STDOUT: %.loc15_34.3: i32 = value_binding %.loc15_34.1 // CHECK:STDOUT: br !if.expr.result(%.loc15_34.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index fa4227864a64f..2efd247e1e8b5 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -53,17 +53,19 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type1}, // CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+14}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+17, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+18}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+17, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block12, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+22}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+19}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+22}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+20}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+24}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+12, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+26}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, arg1: node+12, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+28}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -106,24 +108,26 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+25, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+26, // CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -153,15 +157,17 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: if %.loc10 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc11_21.1: i32 = call @A() to %.loc11_21.2 -// CHECK:STDOUT: %.loc11_21.2: i32 = materialize_temporary %.loc11_21.1 -// CHECK:STDOUT: %.loc11_21.3: i32 = value_binding %.loc11_21.2 +// CHECK:STDOUT: %.loc11_21.1: i32 = materialize_temporary +// CHECK:STDOUT: %.loc11_21.2: i32 = call @A() to %.loc11_21.1 +// CHECK:STDOUT: assign %.loc11_21.1, %.loc11_21.2 +// CHECK:STDOUT: %.loc11_21.3: i32 = value_binding %.loc11_21.1 // CHECK:STDOUT: br !if.expr.result(%.loc11_21.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_30.1: i32 = call @B() to %.loc11_30.2 -// CHECK:STDOUT: %.loc11_30.2: i32 = materialize_temporary %.loc11_30.1 -// CHECK:STDOUT: %.loc11_30.3: i32 = value_binding %.loc11_30.2 +// CHECK:STDOUT: %.loc11_30.1: i32 = materialize_temporary +// CHECK:STDOUT: %.loc11_30.2: i32 = call @B() to %.loc11_30.1 +// CHECK:STDOUT: assign %.loc11_30.1, %.loc11_30.2 +// CHECK:STDOUT: %.loc11_30.3: i32 = value_binding %.loc11_30.1 // CHECK:STDOUT: br !if.expr.result(%.loc11_30.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: diff --git a/toolchain/semantics/testdata/index/fail_empty_tuple_access.carbon b/toolchain/semantics/testdata/index/fail_empty_tuple_access.carbon index 9da59b76992bb..4d014e2c8a321 100644 --- a/toolchain/semantics/testdata/index/fail_empty_tuple_access.carbon +++ b/toolchain/semantics/testdata/index/fail_empty_tuple_access.carbon @@ -42,7 +42,7 @@ fn Run() { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -79,6 +79,6 @@ fn Run() { // CHECK:STDOUT: %.loc13_4.1: type = tuple_type () // CHECK:STDOUT: %.loc13_4.2: () = call @F() // CHECK:STDOUT: %.loc13_7: i32 = int_literal 0 -// CHECK:STDOUT: %.loc13_4.3: () = materialize_temporary %.loc13_4.2 +// CHECK:STDOUT: %.loc13_4.3: () = materialize_temporary // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/return_value_access.carbon b/toolchain/semantics/testdata/index/return_value_access.carbon index 553037c60481d..28df3e8e0b8f2 100644 --- a/toolchain/semantics/testdata/index/return_value_access.carbon +++ b/toolchain/semantics/testdata/index/return_value_access.carbon @@ -52,13 +52,14 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, // CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+13, type: type2}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+15, arg1: node+14, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, arg1: node+11, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+18}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+14}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+13, arg1: node+15, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+17, type: type1}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+11, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -98,9 +99,10 @@ fn Run() -> i32 { // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -120,10 +122,11 @@ fn Run() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> %return: i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10_11.1: (i32,) = call @F() to %.loc10_11.2 +// CHECK:STDOUT: %.loc10_11.1: (i32,) = materialize_temporary +// CHECK:STDOUT: %.loc10_11.2: (i32,) = call @F() to %.loc10_11.1 // CHECK:STDOUT: %.loc10_14: i32 = int_literal 0 -// CHECK:STDOUT: %.loc10_11.2: (i32,) = materialize_temporary %.loc10_11.1 -// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11.2, %.loc10_14 +// CHECK:STDOUT: assign %.loc10_11.1, %.loc10_11.2 +// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11.1, %.loc10_14 // CHECK:STDOUT: %.loc10_15.2: i32 = value_binding %.loc10_15.1 // CHECK:STDOUT: %.loc10_15.3: i32 = initialize_from %.loc10_15.2 to %return // CHECK:STDOUT: return %.loc10_15.3 diff --git a/toolchain/semantics/testdata/namespace/function.carbon b/toolchain/semantics/testdata/namespace/function.carbon index 68d66099973fb..a31971d86dd7e 100644 --- a/toolchain/semantics/testdata/namespace/function.carbon +++ b/toolchain/semantics/testdata/namespace/function.carbon @@ -48,7 +48,6 @@ fn Bar() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+7, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -70,7 +69,6 @@ fn Bar() { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -95,6 +93,5 @@ fn Bar() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc17_10.1: type = tuple_type () // CHECK:STDOUT: %.loc17_10.2: () = call @Baz.2() -// CHECK:STDOUT: %.loc17_10.3: () = materialize_temporary %.loc17_10.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/namespace/nested.carbon b/toolchain/semantics/testdata/namespace/nested.carbon index 02f646762626c..8b6f9bb49f4e1 100644 --- a/toolchain/semantics/testdata/namespace/nested.carbon +++ b/toolchain/semantics/testdata/namespace/nested.carbon @@ -44,7 +44,6 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+6, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -63,7 +62,6 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -83,6 +81,5 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc14_14.1: type = tuple_type () // CHECK:STDOUT: %.loc14_14.2: () = call @Wiz() -// CHECK:STDOUT: %.loc14_14.3: () = materialize_temporary %.loc14_14.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/and.carbon b/toolchain/semantics/testdata/operators/and.carbon index 1e68c52c4c020..1c65d2dd18533 100644 --- a/toolchain/semantics/testdata/operators/and.carbon +++ b/toolchain/semantics/testdata/operators/and.carbon @@ -44,19 +44,21 @@ fn And() -> bool { // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+13}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+14}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+15}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+15}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+20}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+20}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+22}, // CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+24, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+25}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -92,20 +94,22 @@ fn And() -> bool { // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+22, // CHECK:STDOUT: node+23, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+19, @@ -134,16 +138,18 @@ fn And() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @And() -> %return: bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11.1: bool = call @F() to %.loc11_11.2 -// CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary %.loc11_11.1 -// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 +// CHECK:STDOUT: %.loc11_11.1: bool = materialize_temporary +// CHECK:STDOUT: %.loc11_11.2: bool = call @F() to %.loc11_11.1 +// CHECK:STDOUT: assign %.loc11_11.1, %.loc11_11.2 +// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.1 // CHECK:STDOUT: %.loc11_14.1: bool = bool_literal false // CHECK:STDOUT: if %.loc11_11.3 br !and.rhs else br !and.result(%.loc11_14.1) // CHECK:STDOUT: // CHECK:STDOUT: !and.rhs: -// CHECK:STDOUT: %.loc11_19.1: bool = call @G() to %.loc11_19.2 -// CHECK:STDOUT: %.loc11_19.2: bool = materialize_temporary %.loc11_19.1 -// CHECK:STDOUT: %.loc11_19.3: bool = value_binding %.loc11_19.2 +// CHECK:STDOUT: %.loc11_19.1: bool = materialize_temporary +// CHECK:STDOUT: %.loc11_19.2: bool = call @G() to %.loc11_19.1 +// CHECK:STDOUT: assign %.loc11_19.1, %.loc11_19.2 +// CHECK:STDOUT: %.loc11_19.3: bool = value_binding %.loc11_19.1 // CHECK:STDOUT: br !and.result(%.loc11_19.3) // CHECK:STDOUT: // CHECK:STDOUT: !and.result: diff --git a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon index 41cd4dd1d2661..49bf6b3e35bd5 100644 --- a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -82,8 +82,8 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+50, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+51, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -100,84 +100,85 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+3, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+5}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block4, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+9}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+10}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+12, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+13, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+20, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+16, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+22}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+17, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+23}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+24, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+25, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+26, arg1: node+24, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+24, arg1: node+27}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+24, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+29, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+24, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+31, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, arg1: node+25, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+28}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+32, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block7, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+34, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+35, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+37, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block8, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+38, arg1: node+33, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+33, arg1: node+39}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+39, arg1: node+34, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+34, arg1: node+40}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+41, arg1: nodeIntegerType, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+42}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+42, arg1: nodeIntegerType, type: typeTypeType}, +// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+43}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+44, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+45, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+47, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+48, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block9, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block10, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+52, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+53, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+55, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+56, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block12, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+58, arg1: node+51, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+51, arg1: node+59}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+59, arg1: node+52, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+52, arg1: node+60}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+61}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+62}, // CHECK:STDOUT: {kind: Branch, arg0: block14}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int15, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+64}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+65}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+66}, // CHECK:STDOUT: {kind: BlockArg, arg0: block15, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int16, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+69, arg1: node+68, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+68, arg1: node+70}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+70, arg1: node+69, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+69, arg1: node+71}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+72, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+73, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block16, arg1: node+74}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block16, arg1: node+75}, // CHECK:STDOUT: {kind: Branch, arg0: block17}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+72, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+72, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block18, arg1: node+77}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+73, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+73, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block18, arg1: node+78}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block18, arg1: node+79}, // CHECK:STDOUT: {kind: BlockArg, arg0: block18, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int17, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+82, arg1: node+81, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+81, arg1: node+83}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+83, arg1: node+82, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+82, arg1: node+84}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -233,67 +234,67 @@ fn Main() { // CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, // CHECK:STDOUT: node+44, -// CHECK:STDOUT: node+46, +// CHECK:STDOUT: node+45, // CHECK:STDOUT: node+47, -// CHECK:STDOUT: node+49, +// CHECK:STDOUT: node+48, // CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, // CHECK:STDOUT: node+52, -// CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+53, // CHECK:STDOUT: node+55, -// CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+56, // CHECK:STDOUT: node+58, // CHECK:STDOUT: node+59, // CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, // CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, +// CHECK:STDOUT: node+64, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+30, -// CHECK:STDOUT: node+32, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+35, -// CHECK:STDOUT: node+37, +// CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+33, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+45, -// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+36, +// CHECK:STDOUT: node+38, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+46, // CHECK:STDOUT: node+49, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+53, -// CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+47, +// CHECK:STDOUT: node+50, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+54, // CHECK:STDOUT: node+57, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+64, -// CHECK:STDOUT: node+66, +// CHECK:STDOUT: node+55, +// CHECK:STDOUT: node+58, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+65, // CHECK:STDOUT: node+67, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+66, // CHECK:STDOUT: node+68, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+69, // CHECK:STDOUT: node+70, // CHECK:STDOUT: node+71, @@ -302,21 +303,22 @@ fn Main() { // CHECK:STDOUT: node+74, // CHECK:STDOUT: node+75, // CHECK:STDOUT: node+76, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+77, -// CHECK:STDOUT: node+79, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+78, // CHECK:STDOUT: node+80, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+79, // CHECK:STDOUT: node+81, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+82, // CHECK:STDOUT: node+83, // CHECK:STDOUT: node+84, // CHECK:STDOUT: node+85, +// CHECK:STDOUT: node+86, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -333,10 +335,11 @@ fn Main() { // CHECK:STDOUT: %.loc13_7.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc13_7.2: i32 = initialize_from %.loc13_7.1 to %.loc13_3 // CHECK:STDOUT: assign %.loc13_3, %.loc13_7.2 -// CHECK:STDOUT: %.loc17_4: i32 = call @F() to invalid +// CHECK:STDOUT: %.loc17_4.1: i32 = materialize_temporary +// CHECK:STDOUT: %.loc17_4.2: i32 = call @F() to %.loc17_4.1 // CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 to %.loc17_4 -// CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 +// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 to %.loc17_4.2 +// CHECK:STDOUT: assign %.loc17_4.2, %.loc17_9.2 // CHECK:STDOUT: %.loc21_4.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc21_4.2: i32 = stub_reference %.loc21_4.1 // CHECK:STDOUT: %.loc21_7.1: i32 = int_literal 2 diff --git a/toolchain/semantics/testdata/operators/or.carbon b/toolchain/semantics/testdata/operators/or.carbon index 52e85b42cf418..3ca153eda52d2 100644 --- a/toolchain/semantics/testdata/operators/or.carbon +++ b/toolchain/semantics/testdata/operators/or.carbon @@ -44,20 +44,22 @@ fn Or() -> bool { // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+12, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+13}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+15, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+16}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+17}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+21}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+21}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+23}, // CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+26}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -94,20 +96,22 @@ fn Or() -> bool { // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+20, @@ -136,17 +140,19 @@ fn Or() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @Or() -> %return: bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11.1: bool = call @F() to %.loc11_11.2 -// CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary %.loc11_11.1 -// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 +// CHECK:STDOUT: %.loc11_11.1: bool = materialize_temporary +// CHECK:STDOUT: %.loc11_11.2: bool = call @F() to %.loc11_11.1 +// CHECK:STDOUT: assign %.loc11_11.1, %.loc11_11.2 +// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.1 // CHECK:STDOUT: %.loc11_14.1: bool = not %.loc11_11.3 // CHECK:STDOUT: %.loc11_14.2: bool = bool_literal true // CHECK:STDOUT: if %.loc11_14.1 br !or.rhs else br !or.result(%.loc11_14.2) // CHECK:STDOUT: // CHECK:STDOUT: !or.rhs: -// CHECK:STDOUT: %.loc11_18.1: bool = call @G() to %.loc11_18.2 -// CHECK:STDOUT: %.loc11_18.2: bool = materialize_temporary %.loc11_18.1 -// CHECK:STDOUT: %.loc11_18.3: bool = value_binding %.loc11_18.2 +// CHECK:STDOUT: %.loc11_18.1: bool = materialize_temporary +// CHECK:STDOUT: %.loc11_18.2: bool = call @G() to %.loc11_18.1 +// CHECK:STDOUT: assign %.loc11_18.1, %.loc11_18.2 +// CHECK:STDOUT: %.loc11_18.3: bool = value_binding %.loc11_18.1 // CHECK:STDOUT: br !or.result(%.loc11_18.3) // CHECK:STDOUT: // CHECK:STDOUT: !or.result: diff --git a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon index ef394f0eb4e1a..646e0b3c9cbdd 100644 --- a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon @@ -123,8 +123,8 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+25, // CHECK:STDOUT: node+31, -// CHECK:STDOUT: node+52, // CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+56, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -172,34 +172,36 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+35, arg1: node+36, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+37, type: type2}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type1}, // CHECK:STDOUT: {kind: Call, arg0: block10, arg1: function1, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, arg0: node+39, type: type1}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+40, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+41, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+39, arg1: node+40}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+39, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+42, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+43, type: type3}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+44, type: type4}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+44, type: type3}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+45, type: type4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function4}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block12, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+48, type: type2}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+50, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function5}, // CHECK:STDOUT: {kind: PointerType, arg0: typeTypeType, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: nodeIntegerType, type: type12}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type13, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+55, type: type12}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+57, type: type12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+59, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+61, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+63, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block15, type: type9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+63, arg1: node+64, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+65, type: type2}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+65, arg1: node+66, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+67, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -213,9 +215,9 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+34, -// CHECK:STDOUT: node+47, -// CHECK:STDOUT: node+51, -// CHECK:STDOUT: node+58, +// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+60, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, @@ -276,29 +278,29 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, // CHECK:STDOUT: node+46, +// CHECK:STDOUT: node+47, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+39, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+48, // CHECK:STDOUT: node+49, // CHECK:STDOUT: node+50, +// CHECK:STDOUT: node+51, +// CHECK:STDOUT: node+52, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node, +// CHECK:STDOUT: node+49, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+52, -// CHECK:STDOUT: node+53, // CHECK:STDOUT: node+54, // CHECK:STDOUT: node+55, // CHECK:STDOUT: node+56, // CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+58, +// CHECK:STDOUT: node+59, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+59, -// CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, // CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, @@ -306,10 +308,12 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+65, // CHECK:STDOUT: node+66, // CHECK:STDOUT: node+67, +// CHECK:STDOUT: node+68, +// CHECK:STDOUT: node+69, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+60, // CHECK:STDOUT: node+62, +// CHECK:STDOUT: node+64, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -363,9 +367,10 @@ fn AddressOfTupleElementValue() { // 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: %.loc46_5.1: {.a: i32} = call @H() to %.loc46_5.2 -// CHECK:STDOUT: %.loc46_5.2: {.a: i32} = materialize_temporary %.loc46_5.1 -// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5.2, member0 +// CHECK:STDOUT: %.loc46_5.1: {.a: i32} = materialize_temporary +// CHECK:STDOUT: %.loc46_5.2: {.a: i32} = call @H() to %.loc46_5.1 +// CHECK:STDOUT: assign %.loc46_5.1, %.loc46_5.2 +// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5.1, member0 // CHECK:STDOUT: %.loc46_3: i32* = address_of %.loc46_7 // CHECK:STDOUT: %.loc50_9: bool = bool_literal true // CHECK:STDOUT: %.loc50_5: bool = not %.loc50_9 @@ -375,8 +380,9 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: // CHECK:STDOUT: fn @AddressOfCall() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc57_5: i32 = call @G() to invalid -// CHECK:STDOUT: %.loc57_3: i32* = address_of %.loc57_5 +// CHECK:STDOUT: %.loc57_5.1: i32 = materialize_temporary +// CHECK:STDOUT: %.loc57_5.2: i32 = call @G() to %.loc57_5.1 +// CHECK:STDOUT: %.loc57_3: i32* = address_of %.loc57_5.2 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: From bcdfacdd57c2ad89c4941802666c6da8db870d36 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 21 Aug 2023 17:37:23 -0700 Subject: [PATCH 08/21] Autoupdate after merge. --- .../testdata/array/assign_return_value.carbon | 1 + .../index/array_element_access.carbon | 27 +++++--- .../index/tuple_return_value_access.carbon | 7 +- .../testdata/array/assign_return_value.carbon | 64 +++++++++++-------- .../testdata/array/assign_var.carbon | 24 ++++--- .../semantics/testdata/array/base.carbon | 57 ++++++++++------- .../testdata/array/fail_out_of_bound.carbon | 7 +- .../testdata/array/fail_type_mismatch.carbon | 7 +- .../index/array_element_access.carbon | 50 ++++++++++----- .../index/fail_array_large_index.carbon | 16 +++-- .../index/fail_array_non_int_indexing.carbon | 16 +++-- .../fail_array_out_of_bound_access.carbon | 16 +++-- 12 files changed, 186 insertions(+), 106 deletions(-) diff --git a/toolchain/lowering/testdata/array/assign_return_value.carbon b/toolchain/lowering/testdata/array/assign_return_value.carbon index e660a23a3af6a..be2cd8a2d7c08 100644 --- a/toolchain/lowering/testdata/array/assign_return_value.carbon +++ b/toolchain/lowering/testdata/array/assign_return_value.carbon @@ -25,6 +25,7 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %var = alloca [2 x i32], align 4 +// CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %F = call { i32, i32 } @F() // CHECK:STDOUT: %array = alloca [2 x i32], align 4 // CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %F, 0 diff --git a/toolchain/lowering/testdata/index/array_element_access.carbon b/toolchain/lowering/testdata/index/array_element_access.carbon index b24836c855aa9..52044d9917c61 100644 --- a/toolchain/lowering/testdata/index/array_element_access.carbon +++ b/toolchain/lowering/testdata/index/array_element_access.carbon @@ -48,6 +48,7 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %var = alloca [2 x i32], align 4 +// CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %A = call { i32, i32 } @A() // CHECK:STDOUT: %array = alloca [2 x i32], align 4 // CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %A, 0 @@ -59,17 +60,23 @@ fn Run() { // CHECK:STDOUT: %3 = load [2 x i32], ptr %array, align 4 // CHECK:STDOUT: store [2 x i32] %3, ptr %var, align 4 // CHECK:STDOUT: %var2 = alloca i32, align 4 -// CHECK:STDOUT: %A3 = call { i32, i32 } @A() -// CHECK:STDOUT: %tuple.index = extractvalue { i32, i32 } %A3, 0 -// CHECK:STDOUT: store i32 %tuple.index, ptr %var2, align 4 -// CHECK:STDOUT: %var4 = alloca i32, align 4 -// CHECK:STDOUT: %4 = load i32, ptr %var2, align 4 -// CHECK:STDOUT: %array.index = getelementptr inbounds [2 x i32], ptr %var, i32 %4 -// CHECK:STDOUT: %5 = load i32, ptr %array.index, align 4 -// CHECK:STDOUT: store i32 %5, ptr %var4, align 4 +// CHECK:STDOUT: %temp3 = alloca { i32, i32 }, align 8 +// CHECK:STDOUT: %A4 = call { i32, i32 } @A() +// CHECK:STDOUT: store { i32, i32 } %A4, ptr %temp3, align 4 +// CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp3, i32 0, i32 0 +// CHECK:STDOUT: %4 = load i32, ptr %tuple.index, align 4 +// CHECK:STDOUT: store i32 %4, ptr %var2, align 4 // CHECK:STDOUT: %var5 = alloca i32, align 4 +// CHECK:STDOUT: %5 = load i32, ptr %var2, align 4 +// CHECK:STDOUT: %array.index = getelementptr inbounds [2 x i32], ptr %var, i32 %5 +// CHECK:STDOUT: %6 = load i32, ptr %array.index, align 4 +// CHECK:STDOUT: store i32 %6, ptr %var5, align 4 +// CHECK:STDOUT: %var6 = alloca i32, align 4 +// CHECK:STDOUT: %temp7 = alloca [2 x i32], align 4 // CHECK:STDOUT: %B = call [2 x i32] @B() -// CHECK:STDOUT: %array.index6 = extractvalue [2 x i32] %B, 1 -// CHECK:STDOUT: store i32 %array.index6, ptr %var5, align 4 +// CHECK:STDOUT: store [2 x i32] %B, ptr %temp7, align 4 +// CHECK:STDOUT: %array.index8 = getelementptr inbounds [2 x i32], ptr %temp7, i32 0, i32 1 +// CHECK:STDOUT: %7 = load i32, ptr %array.index8, align 4 +// CHECK:STDOUT: store i32 %7, ptr %var6, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/index/tuple_return_value_access.carbon b/toolchain/lowering/testdata/index/tuple_return_value_access.carbon index 18878150d1788..732b112b7fa41 100644 --- a/toolchain/lowering/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/lowering/testdata/index/tuple_return_value_access.carbon @@ -25,8 +25,11 @@ fn Run() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %var = alloca i32, align 4 +// CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %F = call { i32, i32 } @F() -// CHECK:STDOUT: %tuple.index = extractvalue { i32, i32 } %F, 1 -// CHECK:STDOUT: store i32 %tuple.index, ptr %var, align 4 +// CHECK:STDOUT: store { i32, i32 } %F, ptr %temp, align 4 +// CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp, i32 0, i32 1 +// CHECK:STDOUT: %1 = load i32, ptr %tuple.index, align 4 +// CHECK:STDOUT: store i32 %1, ptr %var, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/assign_return_value.carbon b/toolchain/semantics/testdata/array/assign_return_value.carbon index 22728b513c7f9..ee8de07db15ab 100644 --- a/toolchain/semantics/testdata/array/assign_return_value.carbon +++ b/toolchain/semantics/testdata/array/assign_return_value.carbon @@ -12,8 +12,8 @@ fn Run() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: {block3}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block5}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, return_slot: node+4, body: {block4}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -30,7 +30,7 @@ fn Run() { // CHECK:STDOUT: node+1, // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -45,19 +45,23 @@ fn Run() { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, type: type2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+10, arg1: type1, type: typeTypeType}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+12, arg1: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+12, type: type3}, -// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+14, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+15}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+14, type: type3}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, +// CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type2}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+17, type: type3}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+14, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+19}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -69,47 +73,53 @@ fn Run() { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12: type = stub_reference i32 -// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_16.2: (type,) = tuple_value (%.loc7_12) -// CHECK:STDOUT: %.loc7_16.3: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> (i32,) { +// CHECK:STDOUT: fn @F() -> %return: (i32,) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_28.1: i32 = int_literal 0 // CHECK:STDOUT: %.loc7_28.2: i32 = stub_reference %.loc7_28.1 -// CHECK:STDOUT: %.loc7_30: (i32,) = tuple_value (%.loc7_28.2) -// CHECK:STDOUT: return %.loc7_30 +// CHECK:STDOUT: %.loc7_30.1: (i32,) = tuple_value (%.loc7_28.2) +// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1 to %return +// CHECK:STDOUT: return %.loc7_30.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { @@ -117,8 +127,10 @@ fn Run() { // CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_17: type = array_type %.loc10_16, i32 // CHECK:STDOUT: %t: [i32; 1] = var -// CHECK:STDOUT: %.loc10_22.1: (i32,) = call @F() -// CHECK:STDOUT: %.loc10_22.2: [i32; 1] = array_value %.loc10_22.1 -// CHECK:STDOUT: assign %t, %.loc10_22.2 +// CHECK:STDOUT: %.loc10_22.1: (i32,) = materialize_temporary +// CHECK:STDOUT: %.loc10_22.2: (i32,) = call @F() to %.loc10_22.1 +// CHECK:STDOUT: %.loc10_22.3: [i32; 1] = array_value %.loc10_22.2 +// CHECK:STDOUT: %.loc10_22.4: [i32; 1] = initialize_from %.loc10_22.3 to %t +// CHECK:STDOUT: assign %t, %.loc10_22.4 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/assign_var.carbon b/toolchain/semantics/testdata/array/assign_var.carbon index 0e0c16061a24b..403ac38d2f3b0 100644 --- a/toolchain/semantics/testdata/array/assign_var.carbon +++ b/toolchain/semantics/testdata/array/assign_var.carbon @@ -26,7 +26,7 @@ var b: [i32; 3] = a; // CHECK:STDOUT: node+3, // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -56,13 +56,15 @@ var b: [i32; 3] = a; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, arg1: node+6, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+15}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+16, arg1: type1, type: typeTypeType}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+17, arg1: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+18, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+19, type: type3}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+6, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+20}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+19, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+22}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -90,6 +92,8 @@ var b: [i32; 3] = a; // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -117,11 +121,13 @@ var b: [i32; 3] = a; // CHECK:STDOUT: %.loc7_30.2: i32 = stub_reference %.loc7_30.1 // CHECK:STDOUT: %.loc7_33.1: i32 = int_literal 3 // CHECK:STDOUT: %.loc7_33.2: i32 = stub_reference %.loc7_33.1 -// CHECK:STDOUT: %.loc7_34: (i32, i32, i32) = tuple_value (%.loc7_27.2, %.loc7_30.2, %.loc7_33.2) -// CHECK:STDOUT: assign %a, %.loc7_34 +// CHECK:STDOUT: %.loc7_34.1: (i32, i32, i32) = tuple_value (%.loc7_27.2, %.loc7_30.2, %.loc7_33.2) +// CHECK:STDOUT: %.loc7_34.2: (i32, i32, i32) = initialize_from %.loc7_34.1 to %a +// CHECK:STDOUT: assign %a, %.loc7_34.2 // CHECK:STDOUT: %.loc8_14: i32 = int_literal 3 // CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, i32 // CHECK:STDOUT: %b: [i32; 3] = var -// CHECK:STDOUT: %.loc7_5: [i32; 3] = array_value %a -// CHECK:STDOUT: assign %b, %.loc7_5 +// CHECK:STDOUT: %.loc7_5.1: [i32; 3] = array_value %a +// CHECK:STDOUT: %.loc7_5.2: [i32; 3] = initialize_from %.loc7_5.1 to %b +// CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/base.carbon b/toolchain/semantics/testdata/array/base.carbon index 7cc6c1a14b6c7..51475c4d52691 100644 --- a/toolchain/semantics/testdata/array/base.carbon +++ b/toolchain/semantics/testdata/array/base.carbon @@ -31,11 +31,11 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+6, // CHECK:STDOUT: nodeFloatingPointType, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+40, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -65,27 +65,27 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+10, arg1: type3, type: typeTypeType}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+11, arg1: type3, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type4}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type4}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type4}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type3}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+15, type: type3}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real1, type: type3}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type3}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type3}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type5}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+19, type: type4}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+20}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+20, type: type4}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+13, type: type4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+22}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+24, arg1: type6, type: typeTypeType}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+26, arg1: type6, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type7}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+26, type: type7}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+28, type: type6}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+28, type: type7}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, // CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type6}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, @@ -94,10 +94,13 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: {kind: StubReference, arg0: node+34, type: type6}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, // CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type6}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+38, type: type6}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock3, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type8}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+39, type: type7}, -// CHECK:STDOUT: {kind: Assign, arg0: node+26, arg1: node+40}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+41, type: type7}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+42, arg1: node+28, type: type7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+28, arg1: node+43}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -145,20 +148,23 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, // CHECK:STDOUT: node+41, +// CHECK:STDOUT: node+42, +// CHECK:STDOUT: node+43, +// CHECK:STDOUT: node+44, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+29, // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+33, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+37, +// CHECK:STDOUT: node+39, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -171,7 +177,8 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc7_22.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_22.2: (i32,) = tuple_value (%.loc7_20.2) // CHECK:STDOUT: %.loc7_22.3: [i32; 1] = array_value %.loc7_22.2 -// CHECK:STDOUT: assign %a, %.loc7_22.3 +// CHECK:STDOUT: %.loc7_22.4: [i32; 1] = initialize_from %.loc7_22.3 to %a +// CHECK:STDOUT: assign %a, %.loc7_22.4 // CHECK:STDOUT: %.loc8_14: i32 = int_literal 2 // CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, f64 // CHECK:STDOUT: %b: [f64; 2] = var @@ -182,7 +189,8 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc8_30.1: type = tuple_type (f64, f64) // CHECK:STDOUT: %.loc8_30.2: (f64, f64) = tuple_value (%.loc8_20.2, %.loc8_26.2) // CHECK:STDOUT: %.loc8_30.3: [f64; 2] = array_value %.loc8_30.2 -// CHECK:STDOUT: assign %b, %.loc8_30.3 +// CHECK:STDOUT: %.loc8_30.4: [f64; 2] = initialize_from %.loc8_30.3 to %b +// CHECK:STDOUT: assign %b, %.loc8_30.4 // CHECK:STDOUT: %.loc9_10.1: type = tuple_type () // CHECK:STDOUT: %.loc9_10.2: () = tuple_value () // CHECK:STDOUT: %.loc9_13: i32 = int_literal 5 @@ -201,5 +209,6 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc9_38.1: type = tuple_type ((), (), (), (), ()) // CHECK:STDOUT: %.loc9_38.2: ((), (), (), (), ()) = tuple_value (%.loc9_20.2, %.loc9_24.2, %.loc9_28.2, %.loc9_32.2, %.loc9_36.2) // CHECK:STDOUT: %.loc9_38.3: [(); 5] = array_value %.loc9_38.2 -// CHECK:STDOUT: assign %c, %.loc9_38.3 +// CHECK:STDOUT: %.loc9_38.4: [(); 5] = initialize_from %.loc9_38.3 to %c +// CHECK:STDOUT: assign %c, %.loc9_38.4 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/fail_out_of_bound.carbon b/toolchain/semantics/testdata/array/fail_out_of_bound.carbon index ab69bbaa4d82d..5905a425b8097 100644 --- a/toolchain/semantics/testdata/array/fail_out_of_bound.carbon +++ b/toolchain/semantics/testdata/array/fail_out_of_bound.carbon @@ -48,7 +48,8 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -67,6 +68,7 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -87,5 +89,6 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: %.loc10_26.2: i32 = stub_reference %.loc10_26.1 // CHECK:STDOUT: %.loc10_27.1: type = tuple_type (i32, i32, i32) // CHECK:STDOUT: %.loc10_27.2: (i32, i32, i32) = tuple_value (%.loc10_20.2, %.loc10_23.2, %.loc10_26.2) -// CHECK:STDOUT: assign %a, +// CHECK:STDOUT: %.1: = initialize_from to %a +// CHECK:STDOUT: assign %a, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/fail_type_mismatch.carbon b/toolchain/semantics/testdata/array/fail_type_mismatch.carbon index 884eb02fada64..022b050c9022f 100644 --- a/toolchain/semantics/testdata/array/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/array/fail_type_mismatch.carbon @@ -45,7 +45,8 @@ var a: [i32; 2] = (1, 2.5); // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type2}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -62,6 +63,7 @@ var a: [i32; 2] = (1, 2.5); // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -79,5 +81,6 @@ var a: [i32; 2] = (1, 2.5); // CHECK:STDOUT: %.loc10_23.2: f64 = stub_reference %.loc10_23.1 // CHECK:STDOUT: %.loc10_26.1: type = tuple_type (i32, f64) // CHECK:STDOUT: %.loc10_26.2: (i32, f64) = tuple_value (%.loc10_20.2, %.loc10_23.2) -// CHECK:STDOUT: assign %a, +// CHECK:STDOUT: %.1: = initialize_from to %a +// CHECK:STDOUT: assign %a, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/array_element_access.carbon b/toolchain/semantics/testdata/index/array_element_access.carbon index 8f87c6c1d79ff..4a3653b8327a2 100644 --- a/toolchain/semantics/testdata/index/array_element_access.carbon +++ b/toolchain/semantics/testdata/index/array_element_access.carbon @@ -50,20 +50,26 @@ var d: i32 = a[b]; // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+9, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+10}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+11}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+14}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+13, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+16, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+18, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+19}, +// CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+20, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+18, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+23}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+21, type: type0}, -// CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+12, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+23}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+25, type: type0}, +// CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+13, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+28, arg1: node+25, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+29}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -94,6 +100,12 @@ var d: i32 = a[b]; // CHECK:STDOUT: node+22, // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+30, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -112,15 +124,21 @@ var d: i32 = a[b]; // CHECK:STDOUT: %.loc7_26.1: type = tuple_type (i32, i32) // CHECK:STDOUT: %.loc7_26.2: (i32, i32) = tuple_value (%.loc7_20.2, %.loc7_24.2) // CHECK:STDOUT: %.loc7_26.3: [i32; 2] = array_value %.loc7_26.2 -// CHECK:STDOUT: assign %a, %.loc7_26.3 +// CHECK:STDOUT: %.loc7_26.4: [i32; 2] = initialize_from %.loc7_26.3 to %a +// CHECK:STDOUT: assign %a, %.loc7_26.4 // CHECK:STDOUT: %b: i32 = var -// CHECK:STDOUT: %.loc8: i32 = int_literal 1 -// CHECK:STDOUT: assign %b, %.loc8 +// CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 1 +// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1 to %b +// CHECK:STDOUT: assign %b, %.loc8_14.2 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_17: i32 = array_index %a, %.loc9_16 -// CHECK:STDOUT: assign %c, %.loc9_17 +// CHECK:STDOUT: %.loc9_17.1: i32 = array_index %a, %.loc9_16 +// CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 +// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2 to %c +// CHECK:STDOUT: assign %c, %.loc9_17.3 // CHECK:STDOUT: %d: i32 = var -// CHECK:STDOUT: %.loc10: i32 = array_index %a, %b -// CHECK:STDOUT: assign %d, %.loc10 +// CHECK:STDOUT: %.loc10_17.1: i32 = array_index %a, %b +// CHECK:STDOUT: %.loc10_17.2: i32 = value_binding %.loc10_17.1 +// CHECK:STDOUT: %.loc10_17.3: i32 = initialize_from %.loc10_17.2 to %d +// CHECK:STDOUT: assign %d, %.loc10_17.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_array_large_index.carbon b/toolchain/semantics/testdata/index/fail_array_large_index.carbon index 7ae6fc4a62ad5..3795c124c01a9 100644 --- a/toolchain/semantics/testdata/index/fail_array_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_array_large_index.carbon @@ -44,11 +44,13 @@ var b: i32 = a[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+11, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,6 +70,8 @@ var b: i32 = a[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -83,8 +87,10 @@ var b: i32 = a[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_value (%.loc7_20.2) // CHECK:STDOUT: %.loc7_23.3: [i32; 1] = array_value %.loc7_23.2 -// CHECK:STDOUT: assign %a, %.loc7_23.3 +// CHECK:STDOUT: %.loc7_23.4: [i32; 1] = initialize_from %.loc7_23.3 to %a +// CHECK:STDOUT: assign %a, %.loc7_23.4 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal -1 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from to %b +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_array_non_int_indexing.carbon b/toolchain/semantics/testdata/index/fail_array_non_int_indexing.carbon index 634ac04a57836..21e1e8e2c2e37 100644 --- a/toolchain/semantics/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_array_non_int_indexing.carbon @@ -45,11 +45,13 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+11, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -69,6 +71,8 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -84,8 +88,10 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_value (%.loc7_20.2) // CHECK:STDOUT: %.loc7_23.3: [i32; 1] = array_value %.loc7_23.2 -// CHECK:STDOUT: assign %a, %.loc7_23.3 +// CHECK:STDOUT: %.loc7_23.4: [i32; 1] = initialize_from %.loc7_23.3 to %a +// CHECK:STDOUT: assign %a, %.loc7_23.4 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 26e-1 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from to %b +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_array_out_of_bound_access.carbon b/toolchain/semantics/testdata/index/fail_array_out_of_bound_access.carbon index 6594e9db2e391..c44e3b602bc5b 100644 --- a/toolchain/semantics/testdata/index/fail_array_out_of_bound_access.carbon +++ b/toolchain/semantics/testdata/index/fail_array_out_of_bound_access.carbon @@ -44,11 +44,13 @@ var b: i32 = a[2]; // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+2, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: nodeError}, +// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+11, type: typeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,6 +70,8 @@ var b: i32 = a[2]; // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -83,8 +87,10 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_value (%.loc7_20.2) // CHECK:STDOUT: %.loc7_23.3: [i32; 1] = array_value %.loc7_23.2 -// CHECK:STDOUT: assign %a, %.loc7_23.3 +// CHECK:STDOUT: %.loc7_23.4: [i32; 1] = initialize_from %.loc7_23.3 to %a +// CHECK:STDOUT: assign %a, %.loc7_23.4 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 2 -// CHECK:STDOUT: assign %b, +// CHECK:STDOUT: %.1: = initialize_from to %b +// CHECK:STDOUT: assign %b, %.1 // CHECK:STDOUT: } From c607569c8d6565f3b57a2f4890e981164b134b26 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 12:47:26 -0700 Subject: [PATCH 09/21] Add computation of value representation for a type. --- toolchain/semantics/semantics_ir.cpp | 129 +++++++++++++++++++++++++++ toolchain/semantics/semantics_ir.h | 30 +++++++ 2 files changed, 159 insertions(+) diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index 49d4c502f09ad..a8f022c3aee82 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -533,4 +533,133 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, } } +auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, + SemanticsTypeId type_id) + -> SemanticsValueRepresentation { + const SemanticsIR* ir = &semantics_ir; + SemanticsNodeId node_id = ir->GetType(type_id); + while (true) { + auto node = ir->GetNode(node_id); + switch (node.kind()) { + case SemanticsNodeKind::AddressOf: + case SemanticsNodeKind::ArrayIndex: + case SemanticsNodeKind::ArrayValue: + case SemanticsNodeKind::Assign: + case SemanticsNodeKind::BinaryOperatorAdd: + case SemanticsNodeKind::BlockArg: + case SemanticsNodeKind::BoolLiteral: + case SemanticsNodeKind::Branch: + case SemanticsNodeKind::BranchIf: + case SemanticsNodeKind::BranchWithArg: + case SemanticsNodeKind::Call: + case SemanticsNodeKind::Dereference: + case SemanticsNodeKind::FunctionDeclaration: + case SemanticsNodeKind::InitializeFrom: + case SemanticsNodeKind::IntegerLiteral: + case SemanticsNodeKind::Invalid: + case SemanticsNodeKind::MaterializeTemporary: + case SemanticsNodeKind::Namespace: + case SemanticsNodeKind::NoOp: + case SemanticsNodeKind::RealLiteral: + case SemanticsNodeKind::Return: + case SemanticsNodeKind::ReturnExpression: + case SemanticsNodeKind::StringLiteral: + case SemanticsNodeKind::StructAccess: + case SemanticsNodeKind::StructTypeField: + case SemanticsNodeKind::StructValue: + case SemanticsNodeKind::TupleIndex: + case SemanticsNodeKind::TupleValue: + case SemanticsNodeKind::UnaryOperatorNot: + case SemanticsNodeKind::ValueBinding: + case SemanticsNodeKind::VarStorage: + CARBON_FATAL() << "Type refers to non-type node " << node; + + case SemanticsNodeKind::CrossReference: { + auto [xref_id, xref_node_id] = node.GetAsCrossReference(); + ir = &semantics_ir.GetCrossReferenceIR(xref_id); + node_id = xref_node_id; + continue; + } + + case SemanticsNodeKind::BindName: { + auto [name_id, value_id] = node.GetAsBindName(); + node_id = value_id; + continue; + } + + case SemanticsNodeKind::StubReference: { + node_id = node.GetAsStubReference(); + continue; + } + + case SemanticsNodeKind::ArrayType: + // For arrays, it's convenient to always use a pointer representation, + // even when the array has zero or one element, in order to support + // indexing. + return {.kind = SemanticsValueRepresentation::Pointer, .type = type_id}; + + case SemanticsNodeKind::StructType: { + auto& fields = ir->GetNodeBlock(node.GetAsStructType()); + if (fields.empty()) { + // An empty struct has an empty representation. + return {.kind = SemanticsValueRepresentation::None, + .type = SemanticsTypeId::Invalid}; + } + if (fields.size() == 1) { + // A struct with one field has the same representation as its field. + auto [field_name_id, field_type_id] = + ir->GetNode(fields.front()).GetAsStructTypeField(); + node_id = ir->GetType(field_type_id); + continue; + } + // For any other struct, use a pointer representation. + return {.kind = SemanticsValueRepresentation::Pointer, .type = type_id}; + } + + case SemanticsNodeKind::TupleType: { + auto& elements = ir->GetTypeBlock(node.GetAsTupleType()); + if (elements.empty()) { + // An empty tuple has an empty representation. + return {.kind = SemanticsValueRepresentation::None, + .type = SemanticsTypeId::Invalid}; + } + if (elements.size() == 1) { + // A one-tuple has the same representation as its sole element. + node_id = ir->GetType(elements.front()); + continue; + } + // For any other tuple, use a pointer representation. + return {.kind = SemanticsValueRepresentation::Pointer, .type = type_id}; + } + + case SemanticsNodeKind::Builtin: + switch (node.GetAsBuiltin()) { + case SemanticsBuiltinKind::TypeType: + case SemanticsBuiltinKind::Error: + case SemanticsBuiltinKind::Invalid: + return {.kind = SemanticsValueRepresentation::None, + .type = SemanticsTypeId::Invalid}; + case SemanticsBuiltinKind::BoolType: + case SemanticsBuiltinKind::IntegerType: + case SemanticsBuiltinKind::FloatingPointType: + return {.kind = SemanticsValueRepresentation::Copy, + .type = type_id}; + case SemanticsBuiltinKind::StringType: + // TODO: Decide on string value semantics. This should probably be a + // custom value representation carrying a pointer and size or + // similar. + return {.kind = SemanticsValueRepresentation::Pointer, + .type = type_id}; + } + + case SemanticsNodeKind::PointerType: + return {.kind = SemanticsValueRepresentation::Copy, .type = type_id}; + + case SemanticsNodeKind::ConstType: + node_id = ir->GetType(node.GetAsConstType()); + continue; + } + } +} + } // namespace Carbon diff --git a/toolchain/semantics/semantics_ir.h b/toolchain/semantics/semantics_ir.h index 696fea9548b1c..7f31d83628e8c 100644 --- a/toolchain/semantics/semantics_ir.h +++ b/toolchain/semantics/semantics_ir.h @@ -388,6 +388,36 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, SemanticsNodeId node_id) -> SemanticsExpressionCategory; +// The value representation to use when passing or returning by value. +struct SemanticsValueRepresentation { + enum Kind { + // The type has no value representation. This is used for empty types, such + // as `()`. + None, + // The value representation is a copy of the value. On call boundaries, the + // value itself will be passed or returned. + Copy, + // The value representation is a pointer to the object. When used as a + // parameter, the address of the value is passed. When used as a return + // type, a pointer to a return slot is passed to the function. `type` is the + // pointee type. + Pointer, + // The value representation has been customized, and has the same behavior + // as the value representation of some other type. + // TODO: This is not implemented or used yet. + Custom, + }; + // The kind of value representation used by this type. + Kind kind; + // The type used to model the value representation. + SemanticsTypeId type; +}; + +// Returns information about the value representation to use for a type. +auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, + SemanticsTypeId type_id) + -> SemanticsValueRepresentation; + } // namespace Carbon #endif // CARBON_TOOLCHAIN_SEMANTICS_SEMANTICS_IR_H_ From 49238431752776fff61847964f562e9027f0a8ac Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 13:53:38 -0700 Subject: [PATCH 10/21] Add computation of initializing representation for a type. --- toolchain/semantics/semantics_ir.cpp | 19 +++++++++++++ toolchain/semantics/semantics_ir.h | 40 +++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index a8f022c3aee82..60f851a4a5f32 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -662,4 +662,23 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, } } +auto GetSemanticsInitializingRepresentation(const SemanticsIR& semantics_ir, + SemanticsTypeId type_id) + -> SemanticsInitializingRepresentation { + auto value_rep = GetSemanticsValueRepresentation(semantics_ir, type_id); + switch (value_rep.kind) { + case SemanticsValueRepresentation::None: + return {.kind = SemanticsInitializingRepresentation::None}; + + case SemanticsValueRepresentation::Copy: + // TODO: Use in-place initialization for types that have a non-trivial + // destructor. + return {.kind = SemanticsInitializingRepresentation::ByCopy}; + + case SemanticsValueRepresentation::Pointer: + case SemanticsValueRepresentation::Custom: + return {.kind = SemanticsInitializingRepresentation::InPlace}; + } +} + } // namespace Carbon diff --git a/toolchain/semantics/semantics_ir.h b/toolchain/semantics/semantics_ir.h index 7f31d83628e8c..cf3a7a13412a8 100644 --- a/toolchain/semantics/semantics_ir.h +++ b/toolchain/semantics/semantics_ir.h @@ -388,19 +388,20 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, SemanticsNodeId node_id) -> SemanticsExpressionCategory; -// The value representation to use when passing or returning by value. +// The value representation to use when passing by value. struct SemanticsValueRepresentation { enum Kind { // The type has no value representation. This is used for empty types, such - // as `()`. + // as `()`, where there is no value. None, // The value representation is a copy of the value. On call boundaries, the - // value itself will be passed or returned. + // value itself will be passed. `type` is the value type. + // TODO: `type` should be `const`-qualified, but is currently not. Copy, - // The value representation is a pointer to the object. When used as a - // parameter, the address of the value is passed. When used as a return - // type, a pointer to a return slot is passed to the function. `type` is the - // pointee type. + // The value representation is a pointer to an object. When used as a + // parameter, the argument is a reference expression. `type` is the pointee + // type. + // TODO: `type` should be `const`-qualified, but is currently not. Pointer, // The value representation has been customized, and has the same behavior // as the value representation of some other type. @@ -418,6 +419,31 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, SemanticsTypeId type_id) -> SemanticsValueRepresentation; +// The initializing representation to use when returning by value. +struct SemanticsInitializingRepresentation { + enum Kind { + // The type has no initializing representation. This is used for empty + // types, where no initialization is necessary. + None, + // An initializing expression produces a value, which is copied into the + // initialized object. + ByCopy, + // An initializing expression takes a location as input, which is + // initialized as a side effect of evaluating the expression. + InPlace, + // TODO: Consider adding a kind where the expression takes an advisory + // location and returns a value plus an indicator of whether the location + // was actually initialized. + }; + // The kind of initializing representation used by this type. + Kind kind; +}; + +// Returns information about the initializing representation to use for a type. +auto GetSemanticsInitializingRepresentation(const SemanticsIR& semantics_ir, + SemanticsTypeId type_id) + -> SemanticsInitializingRepresentation; + } // namespace Carbon #endif // CARBON_TOOLCHAIN_SEMANTICS_SEMANTICS_IR_H_ From babd124b84cec0b7d46708ed073bcc4c21b0c881 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 15:34:10 -0700 Subject: [PATCH 11/21] Use initializing representation to pick whether to pass a value into a return slot or return a value. Update lowering to follow the new semantic model for returns. --- toolchain/lowering/lowering_context.cpp | 55 ++++- toolchain/lowering/lowering_handle.cpp | 30 +-- .../testdata/array/assign_return_value.carbon | 13 +- .../testdata/basics/type_values.carbon | 10 +- .../function/call/empty_struct.carbon | 8 +- .../testdata/function/call/empty_tuple.carbon | 7 +- .../call/implicit_empty_tuple_as_arg.carbon | 9 +- .../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 | 3 - .../testdata/function/call/var_param.carbon | 1 - .../function/declaration/simple.carbon | 1 - toolchain/lowering/testdata/if/else.carbon | 3 - toolchain/lowering/testdata/if/no_else.carbon | 2 - .../testdata/if_expression/basic.carbon | 4 +- .../index/array_element_access.carbon | 48 ++-- .../index/tuple_return_value_access.carbon | 8 +- .../testdata/namespace/function.carbon | 1 - .../lowering/testdata/namespace/nested.carbon | 1 - .../lowering/testdata/operators/and.carbon | 4 +- .../lowering/testdata/operators/or.carbon | 4 +- .../testdata/pointer/address_of_field.carbon | 1 - .../lowering/testdata/pointer/basic.carbon | 5 +- toolchain/semantics/semantics_context.cpp | 64 +++-- toolchain/semantics/semantics_context.h | 5 +- .../semantics_handle_call_expression.cpp | 9 +- .../semantics/semantics_handle_function.cpp | 13 +- .../semantics/semantics_handle_operator.cpp | 9 +- .../semantics/semantics_handle_statement.cpp | 19 +- .../semantics/semantics_handle_variable.cpp | 5 +- toolchain/semantics/semantics_ir.cpp | 8 +- toolchain/semantics/semantics_ir.h | 3 + .../testdata/array/assign_return_value.carbon | 44 ++-- .../testdata/array/assign_var.carbon | 24 +- .../semantics/testdata/array/base.carbon | 57 ++--- .../testdata/array/fail_out_of_bound.carbon | 7 +- .../testdata/array/fail_type_mismatch.carbon | 7 +- .../testdata/basics/builtin_types.carbon | 40 ++- .../basics/fail_non_type_as_type.carbon | 7 +- .../basics/fail_qualifier_unsupported.carbon | 7 +- .../semantics/testdata/basics/parens.carbon | 9 +- .../semantics/testdata/const/collapse.carbon | 13 +- .../testdata/const/fail_collapse.carbon | 11 +- .../function/call/empty_struct.carbon | 30 +-- .../testdata/function/call/empty_tuple.carbon | 15 +- .../call/fail_return_type_mismatch.carbon | 36 +-- .../testdata/function/call/i32.carbon | 31 +-- .../function/call/return_implicit.carbon | 3 - .../if/fail_reachable_fallthrough.carbon | 81 +++---- .../semantics/testdata/if/fail_scope.carbon | 31 +-- .../if/unreachable_fallthrough.carbon | 24 +- .../testdata/if_expression/basic.carbon | 13 +- .../if_expression/constant_condition.carbon | 178 ++++++-------- .../if_expression/control_flow.carbon | 117 ++++----- .../testdata/if_expression/nested.carbon | 13 +- .../index/array_element_access.carbon | 44 ++-- .../index/fail_array_large_index.carbon | 16 +- .../index/fail_array_non_int_indexing.carbon | 16 +- .../fail_array_out_of_bound_access.carbon | 16 +- .../testdata/index/fail_name_not_found.carbon | 7 +- .../index/fail_negative_indexing.carbon | 6 +- .../index/fail_non_deterministic_type.carbon | 29 +-- .../index/fail_tuple_large_index.carbon | 31 +-- .../index/fail_tuple_non_int_indexing.carbon | 18 +- .../fail_tuple_out_of_bound_access.carbon | 18 +- .../index/tuple_element_access.carbon | 35 +-- .../index/tuple_return_value_access.carbon | 51 ++-- .../ir/duplicate_name_same_line.carbon | 26 +- .../semantics/testdata/operators/and.carbon | 101 ++++---- .../testdata/operators/assignment.carbon | 181 ++++++-------- .../testdata/operators/binary_op.carbon | 13 +- .../fail_assigment_to_non_assignable.carbon | 227 ++++++++---------- .../operators/fail_type_mismatch.carbon | 11 +- .../fail_type_mismatch_assignment.carbon | 16 +- .../operators/fail_type_mismatch_once.carbon | 11 +- .../semantics/testdata/operators/or.carbon | 103 ++++---- .../testdata/operators/unary_op.carbon | 13 +- .../testdata/pointer/address_of_deref.carbon | 30 +-- .../testdata/pointer/address_of_lvalue.carbon | 120 ++++----- .../semantics/testdata/pointer/basic.carbon | 39 ++- .../pointer/fail_address_of_value.carbon | 73 +++--- .../pointer/fail_type_mismatch.carbon | 11 +- .../testdata/pointer/nested_const.carbon | 11 +- .../semantics/testdata/pointer/types.carbon | 40 ++- .../testdata/return/code_after_return.carbon | 3 +- .../return/code_after_return_value.carbon | 24 +- .../return/fail_missing_return.carbon | 4 +- .../testdata/return/fail_type_mismatch.carbon | 11 +- .../testdata/return/fail_value_missing.carbon | 4 +- .../semantics/testdata/return/struct.carbon | 13 +- .../semantics/testdata/return/tuple.carbon | 10 +- .../semantics/testdata/return/value.carbon | 13 +- .../semantics/testdata/struct/empty.carbon | 20 +- .../testdata/struct/fail_assign_empty.carbon | 7 +- .../testdata/struct/fail_assign_nested.carbon | 7 +- .../struct/fail_assign_to_empty.carbon | 7 +- .../struct/fail_field_name_mismatch.carbon | 7 +- .../struct/fail_field_type_mismatch.carbon | 7 +- .../struct/fail_member_access_type.carbon | 18 +- .../struct/fail_non_member_access.carbon | 18 +- .../struct/fail_too_few_values.carbon | 7 +- .../testdata/struct/fail_type_assign.carbon | 7 +- .../testdata/struct/member_access.carbon | 33 +-- .../testdata/struct/one_entry.carbon | 22 +- .../testdata/struct/tuple_as_element.carbon | 26 +- .../testdata/struct/two_entries.carbon | 22 +- .../semantics/testdata/tuples/empty.carbon | 20 +- .../testdata/tuples/fail_assign_empty.carbon | 7 +- .../testdata/tuples/fail_assign_nested.carbon | 7 +- .../tuples/fail_assign_to_empty.carbon | 7 +- .../tuples/fail_element_type_mismatch.carbon | 7 +- .../tuples/fail_too_few_element.carbon | 7 +- .../testdata/tuples/fail_type_assign.carbon | 7 +- .../testdata/tuples/nested_tuple.carbon | 9 +- .../testdata/tuples/one_element.carbon | 22 +- .../testdata/tuples/two_elements.carbon | 22 +- .../testdata/var/decl_with_init.carbon | 9 +- .../testdata/var/fail_duplicate_decl.carbon | 20 +- .../var/fail_init_type_mismatch.carbon | 7 +- .../testdata/var/fail_init_with_self.carbon | 7 +- .../var/fail_lookup_outside_scope.carbon | 7 +- .../var/fail_storage_is_literal.carbon | 7 +- .../testdata/var/global_decl_with_init.carbon | 9 +- .../testdata/var/global_lookup.carbon | 20 +- .../var/global_lookup_in_scope.carbon | 22 +- .../semantics/testdata/var/lookup.carbon | 9 +- 129 files changed, 1219 insertions(+), 1774 deletions(-) diff --git a/toolchain/lowering/lowering_context.cpp b/toolchain/lowering/lowering_context.cpp index 895ae25e34df0..6a3c7aabe0823 100644 --- a/toolchain/lowering/lowering_context.cpp +++ b/toolchain/lowering/lowering_context.cpp @@ -55,32 +55,56 @@ auto LoweringContext::Run() -> std::unique_ptr { auto LoweringContext::BuildFunctionDeclaration(SemanticsFunctionId function_id) -> llvm::Function* { - auto function = semantics_ir().GetFunction(function_id); + const auto& function = semantics_ir().GetFunction(function_id); + const bool has_return_slot = function.return_slot_id.is_valid(); + const int first_param = has_return_slot ? 1 : 0; + + SemanticsInitializingRepresentation return_rep = + function.return_type_id.is_valid() + ? GetSemanticsInitializingRepresentation(semantics_ir(), + function.return_type_id) + : SemanticsInitializingRepresentation{ + .kind = SemanticsInitializingRepresentation::None}; + CARBON_CHECK(return_rep.has_return_slot() == has_return_slot); // TODO: Lower type information for the arguments prior to building args. auto param_refs = semantics_ir().GetNodeBlock(function.param_refs_id); llvm::SmallVector args; - args.resize_for_overwrite(param_refs.size()); + args.resize_for_overwrite(first_param + param_refs.size()); + if (has_return_slot) { + args[0] = GetType(function.return_type_id)->getPointerTo(); + } for (int i = 0; i < static_cast(param_refs.size()); ++i) { - args[i] = GetType(semantics_ir().GetNode(param_refs[i]).type_id()); + args[first_param + i] = + GetType(semantics_ir().GetNode(param_refs[i]).type_id()); } - // If return type is not valid, the function does not have a return type. - // Hence, set return type to void. - llvm::Type* return_type = function.return_type_id.is_valid() - ? GetType(function.return_type_id) - : llvm::Type::getVoidTy(llvm_context()); + // If the initializing representation doesn't produce a value, set the return + // type to void. + llvm::Type* return_type = + return_rep.kind == SemanticsInitializingRepresentation::ByCopy + ? GetType(function.return_type_id) + : llvm::Type::getVoidTy(llvm_context()); + llvm::FunctionType* function_type = llvm::FunctionType::get(return_type, args, /*isVarArg=*/false); auto* llvm_function = llvm::Function::Create( function_type, llvm::Function::ExternalLinkage, semantics_ir().GetString(function.name_id), llvm_module()); + if (has_return_slot) { + auto* return_slot = llvm_function->getArg(0); + return_slot->addAttr(llvm::Attribute::getWithStructRetType( + llvm_context(), GetType(function.return_type_id))); + return_slot->setName("return"); + } + // Set parameter names. for (int i = 0; i < static_cast(param_refs.size()); ++i) { auto [param_name_id, _] = semantics_ir().GetNode(param_refs[i]).GetAsBindName(); - llvm_function->getArg(i)->setName(semantics_ir().GetString(param_name_id)); + llvm_function->getArg(first_param + i) + ->setName(semantics_ir().GetString(param_name_id)); } return llvm_function; @@ -88,7 +112,7 @@ auto LoweringContext::BuildFunctionDeclaration(SemanticsFunctionId function_id) auto LoweringContext::BuildFunctionDefinition(SemanticsFunctionId function_id) -> void { - auto function = semantics_ir().GetFunction(function_id); + const auto& function = semantics_ir().GetFunction(function_id); const auto& body_block_ids = function.body_block_ids; if (body_block_ids.empty()) { // Function is probably defined in another file; not an error. @@ -98,16 +122,23 @@ auto LoweringContext::BuildFunctionDefinition(SemanticsFunctionId function_id) llvm::Function* llvm_function = GetFunction(function_id); LoweringFunctionContext function_lowering(*this, llvm_function); + const bool has_return_slot = function.return_slot_id.is_valid(); + const int first_param = has_return_slot ? 1 : 0; + // Add parameters to locals. auto param_refs = semantics_ir().GetNodeBlock(function.param_refs_id); + if (has_return_slot) { + function_lowering.SetLocal(function.return_slot_id, + llvm_function->getArg(0)); + } for (int i = 0; i < static_cast(param_refs.size()); ++i) { auto param_storage = semantics_ir().GetNode(param_refs[i]).GetAsBindName().second; - function_lowering.SetLocal(param_storage, llvm_function->getArg(i)); + function_lowering.SetLocal(param_storage, + llvm_function->getArg(first_param + i)); } // Lower all blocks. - // TODO: Determine the set of reachable blocks, and only lower those ones. for (auto block_id : body_block_ids) { CARBON_VLOG() << "Lowering " << block_id << "\n"; auto* llvm_block = function_lowering.GetBlock(block_id); diff --git a/toolchain/lowering/lowering_handle.cpp b/toolchain/lowering/lowering_handle.cpp index 227cfa16e0bd4..518508930ba4f 100644 --- a/toolchain/lowering/lowering_handle.cpp +++ b/toolchain/lowering/lowering_handle.cpp @@ -177,32 +177,32 @@ auto LoweringHandleBuiltin(LoweringFunctionContext& /*context*/, auto LoweringHandleCall(LoweringFunctionContext& context, SemanticsNodeId node_id, SemanticsNode node) -> void { auto [refs_id, function_id] = node.GetAsCall(); - auto* function = context.GetFunction(function_id); + auto* llvm_function = context.GetFunction(function_id); + const auto& function = context.semantics_ir().GetFunction(function_id); + std::vector args; llvm::ArrayRef arg_ids = context.semantics_ir().GetNodeBlock(refs_id); - if (context.semantics_ir() - .GetFunction(function_id) - .return_slot_id.is_valid()) { - // TODO: Pass the return slot into the function. + + if (function.return_slot_id.is_valid()) { + args.push_back(context.GetLocal(arg_ids.back())); arg_ids = arg_ids.drop_back(); } - std::vector args; for (auto ref_id : arg_ids) { args.push_back(context.GetLocalLoaded(ref_id)); } - if (function->getReturnType()->isVoidTy()) { - context.builder().CreateCall(function, args); - // TODO: use empty tuple type. - // TODO: don't create the empty tuple if the call does not get assigned. - context.SetLocal(node_id, context.builder().CreateAlloca( - llvm::StructType::get(context.llvm_context()), - /*ArraySize=*/nullptr, "call.result")); + if (llvm_function->getReturnType()->isVoidTy()) { + context.builder().CreateCall(llvm_function, args); + // TODO: A function with a void return type shouldn't be referred to by + // other nodes. + context.SetLocal(node_id, + llvm::UndefValue::get(context.GetType(node.type_id()))); } else { - context.SetLocal(node_id, context.builder().CreateCall( - function, args, function->getName())); + context.SetLocal(node_id, + context.builder().CreateCall(llvm_function, args, + llvm_function->getName())); } } diff --git a/toolchain/lowering/testdata/array/assign_return_value.carbon b/toolchain/lowering/testdata/array/assign_return_value.carbon index be2cd8a2d7c08..9fb77ec823fb0 100644 --- a/toolchain/lowering/testdata/array/assign_return_value.carbon +++ b/toolchain/lowering/testdata/array/assign_return_value.carbon @@ -13,27 +13,26 @@ fn Run() { // CHECK:STDOUT: ; ModuleID = 'assign_return_value.carbon' // CHECK:STDOUT: source_filename = "assign_return_value.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define { i32, i32 } @F() { +// CHECK:STDOUT: define void @F(ptr sret({ i32, i32 }) %return) { // CHECK:STDOUT: %tuple = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %1 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 0 // CHECK:STDOUT: store i32 12, ptr %1, align 4 // CHECK:STDOUT: %2 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 1 // CHECK:STDOUT: store i32 24, ptr %2, align 4 // CHECK:STDOUT: %3 = load { i32, i32 }, ptr %tuple, align 4 -// CHECK:STDOUT: ret { i32, i32 } %3 +// CHECK:STDOUT: store { i32, i32 } %3, ptr %return, align 4 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %var = alloca [2 x i32], align 4 // CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 -// CHECK:STDOUT: %F = call { i32, i32 } @F() +// CHECK:STDOUT: call void @F(ptr %temp) // CHECK:STDOUT: %array = alloca [2 x i32], align 4 -// CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %F, 0 // CHECK:STDOUT: %1 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 -// CHECK:STDOUT: store i32 %array.element, ptr %1, align 4 -// CHECK:STDOUT: %array.element1 = extractvalue { i32, i32 } %F, 1 +// CHECK:STDOUT: store i32 undef, ptr %1, align 4 // CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 -// CHECK:STDOUT: store i32 %array.element1, ptr %2, align 4 +// CHECK:STDOUT: store i32 undef, ptr %2, align 4 // CHECK:STDOUT: %3 = load [2 x i32], ptr %array, align 4 // CHECK:STDOUT: store [2 x i32] %3, ptr %var, align 4 // CHECK:STDOUT: ret void diff --git a/toolchain/lowering/testdata/basics/type_values.carbon b/toolchain/lowering/testdata/basics/type_values.carbon index 8441016ab0631..7b2b8d014db74 100644 --- a/toolchain/lowering/testdata/basics/type_values.carbon +++ b/toolchain/lowering/testdata/basics/type_values.carbon @@ -15,12 +15,10 @@ fn F64() -> type { // CHECK:STDOUT: ; ModuleID = 'type_values.carbon' // CHECK:STDOUT: source_filename = "type_values.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: %type = type {} -// CHECK:STDOUT: -// CHECK:STDOUT: define %type @I32() { -// CHECK:STDOUT: ret %type zeroinitializer +// CHECK:STDOUT: define void @I32() { +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: define %type @F64() { -// CHECK:STDOUT: ret %type zeroinitializer +// CHECK:STDOUT: define void @F64() { +// CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/empty_struct.carbon b/toolchain/lowering/testdata/function/call/empty_struct.carbon index 42e7921df5087..3ffbd288924d5 100644 --- a/toolchain/lowering/testdata/function/call/empty_struct.carbon +++ b/toolchain/lowering/testdata/function/call/empty_struct.carbon @@ -15,10 +15,9 @@ fn Main() { // CHECK:STDOUT: ; ModuleID = 'empty_struct.carbon' // CHECK:STDOUT: source_filename = "empty_struct.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define {} @Echo({} %a) { +// CHECK:STDOUT: define void @Echo({} %a) { // CHECK:STDOUT: %struct = alloca {}, align 8 -// CHECK:STDOUT: %1 = load {}, ptr %struct, align 1 -// CHECK:STDOUT: ret {} %1 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { @@ -26,7 +25,6 @@ fn Main() { // CHECK:STDOUT: %var = alloca {}, align 8 // CHECK:STDOUT: %struct1 = alloca {}, align 8 // CHECK:STDOUT: %1 = load {}, ptr %struct1, align 1 -// CHECK:STDOUT: %Echo = call {} @Echo({} %1) -// CHECK:STDOUT: store {} %Echo, ptr %var, align 1 +// CHECK:STDOUT: call void @Echo({} %1) // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/empty_tuple.carbon b/toolchain/lowering/testdata/function/call/empty_tuple.carbon index 2fc119f21f449..29a208777f566 100644 --- a/toolchain/lowering/testdata/function/call/empty_tuple.carbon +++ b/toolchain/lowering/testdata/function/call/empty_tuple.carbon @@ -15,8 +15,8 @@ fn Main() { // CHECK:STDOUT: ; ModuleID = 'empty_tuple.carbon' // CHECK:STDOUT: source_filename = "empty_tuple.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define {} @Echo({} %a) { -// CHECK:STDOUT: ret {} %a +// CHECK:STDOUT: define void @Echo({} %a) { +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { @@ -24,7 +24,6 @@ fn Main() { // CHECK:STDOUT: %var = alloca {}, align 8 // CHECK:STDOUT: %tuple1 = alloca {}, align 8 // CHECK:STDOUT: %1 = load {}, ptr %tuple1, align 1 -// CHECK:STDOUT: %Echo = call {} @Echo({} %1) -// CHECK:STDOUT: store {} %Echo, ptr %var, align 1 +// CHECK:STDOUT: call void @Echo({} %1) // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon index 0bbee54fecc3b..1c2daceb12d1b 100644 --- a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon +++ b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon @@ -20,19 +20,16 @@ fn Main() { // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: define {} @Bar({} %a) { -// CHECK:STDOUT: ret {} %a +// CHECK:STDOUT: define void @Bar({} %a) { +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { // CHECK:STDOUT: %tuple = alloca {}, align 8 // CHECK:STDOUT: %var = alloca {}, align 8 // CHECK:STDOUT: call void @Foo() -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: %temp = alloca {}, align 8 // CHECK:STDOUT: %1 = load {}, ptr %temp, align 1 -// CHECK:STDOUT: %2 = load {}, ptr %call.result, align 1 -// CHECK:STDOUT: %Bar = call {} @Bar({} %2) -// CHECK:STDOUT: store {} %Bar, ptr %var, align 1 +// CHECK:STDOUT: call void @Bar({} undef) // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/params_one.carbon b/toolchain/lowering/testdata/function/call/params_one.carbon index 081732d491354..e2b98e29196b8 100644 --- a/toolchain/lowering/testdata/function/call/params_one.carbon +++ b/toolchain/lowering/testdata/function/call/params_one.carbon @@ -19,6 +19,5 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { // CHECK:STDOUT: call void @Foo(i32 1) -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/params_one_comma.carbon b/toolchain/lowering/testdata/function/call/params_one_comma.carbon index af48d73452581..87582a5d6e317 100644 --- a/toolchain/lowering/testdata/function/call/params_one_comma.carbon +++ b/toolchain/lowering/testdata/function/call/params_one_comma.carbon @@ -20,8 +20,6 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { // CHECK:STDOUT: call void @Foo(i32 1) -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: call void @Foo(i32 1) -// CHECK:STDOUT: %call.result1 = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/params_two.carbon b/toolchain/lowering/testdata/function/call/params_two.carbon index 252653615f2d7..841722e141ee2 100644 --- a/toolchain/lowering/testdata/function/call/params_two.carbon +++ b/toolchain/lowering/testdata/function/call/params_two.carbon @@ -19,6 +19,5 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { // CHECK:STDOUT: call void @Foo(i32 1, i32 2) -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/params_two_comma.carbon b/toolchain/lowering/testdata/function/call/params_two_comma.carbon index 9c22f7472f3c5..b22a4330e30fb 100644 --- a/toolchain/lowering/testdata/function/call/params_two_comma.carbon +++ b/toolchain/lowering/testdata/function/call/params_two_comma.carbon @@ -20,8 +20,6 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { // CHECK:STDOUT: call void @Foo(i32 1, i32 2) -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: call void @Foo(i32 1, i32 2) -// CHECK:STDOUT: %call.result1 = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/params_zero.carbon b/toolchain/lowering/testdata/function/call/params_zero.carbon index 4617480b19a5f..bf994c16dddda 100644 --- a/toolchain/lowering/testdata/function/call/params_zero.carbon +++ b/toolchain/lowering/testdata/function/call/params_zero.carbon @@ -19,6 +19,5 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { // CHECK:STDOUT: call void @Foo() -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/return_implicit.carbon b/toolchain/lowering/testdata/function/call/return_implicit.carbon index f047a30c1b7d7..24ced284b624b 100644 --- a/toolchain/lowering/testdata/function/call/return_implicit.carbon +++ b/toolchain/lowering/testdata/function/call/return_implicit.carbon @@ -23,8 +23,5 @@ fn Main() { // CHECK:STDOUT: %tuple = alloca {}, align 8 // CHECK:STDOUT: %var = alloca {}, align 8 // CHECK:STDOUT: call void @MakeImplicitEmptyTuple() -// CHECK:STDOUT: %call.result = alloca {}, align 8 -// CHECK:STDOUT: %1 = load {}, ptr %call.result, align 1 -// CHECK:STDOUT: store {} %1, ptr %var, align 1 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/var_param.carbon b/toolchain/lowering/testdata/function/call/var_param.carbon index 61947f8561eba..17009102c7cbc 100644 --- a/toolchain/lowering/testdata/function/call/var_param.carbon +++ b/toolchain/lowering/testdata/function/call/var_param.carbon @@ -24,6 +24,5 @@ fn Main() { // CHECK:STDOUT: %1 = load i32, ptr %var, align 4 // CHECK:STDOUT: %2 = load i32, ptr %var, align 4 // CHECK:STDOUT: call void @DoNothing(i32 %2) -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/declaration/simple.carbon b/toolchain/lowering/testdata/function/declaration/simple.carbon index 3505e687be240..7792d0b2859b5 100644 --- a/toolchain/lowering/testdata/function/declaration/simple.carbon +++ b/toolchain/lowering/testdata/function/declaration/simple.carbon @@ -15,6 +15,5 @@ fn G(n: i32) { F(n); } // CHECK:STDOUT: // CHECK:STDOUT: define void @G(i32 %n) { // CHECK:STDOUT: call void @F(i32 %n) -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/if/else.carbon b/toolchain/lowering/testdata/if/else.carbon index 21848e35af765..67af395d45dc6 100644 --- a/toolchain/lowering/testdata/if/else.carbon +++ b/toolchain/lowering/testdata/if/else.carbon @@ -37,16 +37,13 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: 1: ; preds = %0 // CHECK:STDOUT: call void @F() -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: br label %3 // CHECK:STDOUT: // CHECK:STDOUT: 2: ; preds = %0 // CHECK:STDOUT: call void @G() -// CHECK:STDOUT: %call.result1 = alloca {}, align 8 // CHECK:STDOUT: br label %3 // CHECK:STDOUT: // CHECK:STDOUT: 3: ; preds = %2, %1 // CHECK:STDOUT: call void @H() -// CHECK:STDOUT: %call.result2 = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/if/no_else.carbon b/toolchain/lowering/testdata/if/no_else.carbon index d6f899d5d8b98..928b8fa6cc004 100644 --- a/toolchain/lowering/testdata/if/no_else.carbon +++ b/toolchain/lowering/testdata/if/no_else.carbon @@ -30,11 +30,9 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: 1: ; preds = %0 // CHECK:STDOUT: call void @F() -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: br label %2 // CHECK:STDOUT: // CHECK:STDOUT: 2: ; preds = %1, %0 // CHECK:STDOUT: call void @G() -// CHECK:STDOUT: %call.result1 = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/if_expression/basic.carbon b/toolchain/lowering/testdata/if_expression/basic.carbon index 6d6ed05642942..8fd9dde431991 100644 --- a/toolchain/lowering/testdata/if_expression/basic.carbon +++ b/toolchain/lowering/testdata/if_expression/basic.carbon @@ -26,15 +26,15 @@ fn Select(b: bool) -> i32 { // CHECK:STDOUT: br i1 %b, label %1, label %3 // CHECK:STDOUT: // CHECK:STDOUT: 1: ; preds = %0 -// CHECK:STDOUT: %temp = alloca i32, align 4 // CHECK:STDOUT: %F = call i32 @F() +// CHECK:STDOUT: %temp = alloca i32, align 4 // CHECK:STDOUT: store i32 %F, ptr %temp, align 4 // CHECK:STDOUT: %2 = load i32, ptr %temp, align 4 // CHECK:STDOUT: br label %5 // CHECK:STDOUT: // CHECK:STDOUT: 3: ; preds = %0 -// CHECK:STDOUT: %temp1 = alloca i32, align 4 // CHECK:STDOUT: %G = call i32 @G() +// CHECK:STDOUT: %temp1 = alloca i32, align 4 // CHECK:STDOUT: store i32 %G, ptr %temp1, align 4 // CHECK:STDOUT: %4 = load i32, ptr %temp1, align 4 // CHECK:STDOUT: br label %5 diff --git a/toolchain/lowering/testdata/index/array_element_access.carbon b/toolchain/lowering/testdata/index/array_element_access.carbon index 52044d9917c61..22e5bffb69371 100644 --- a/toolchain/lowering/testdata/index/array_element_access.carbon +++ b/toolchain/lowering/testdata/index/array_element_access.carbon @@ -17,17 +17,18 @@ fn Run() { // CHECK:STDOUT: ; ModuleID = 'array_element_access.carbon' // CHECK:STDOUT: source_filename = "array_element_access.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define { i32, i32 } @A() { +// CHECK:STDOUT: define void @A(ptr sret({ i32, i32 }) %return) { // CHECK:STDOUT: %tuple = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %1 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 0 // CHECK:STDOUT: store i32 1, ptr %1, align 4 // CHECK:STDOUT: %2 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 1 // CHECK:STDOUT: store i32 2, ptr %2, align 4 // CHECK:STDOUT: %3 = load { i32, i32 }, ptr %tuple, align 4 -// CHECK:STDOUT: ret { i32, i32 } %3 +// CHECK:STDOUT: store { i32, i32 } %3, ptr %return, align 4 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: define [2 x i32] @B() { +// CHECK:STDOUT: define void @B(ptr sret([2 x i32]) %return) { // CHECK:STDOUT: %tuple = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %1 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 0 // CHECK:STDOUT: store i32 1, ptr %1, align 4 @@ -43,40 +44,37 @@ fn Run() { // CHECK:STDOUT: %6 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 // CHECK:STDOUT: store i32 %5, ptr %6, align 4 // CHECK:STDOUT: %7 = load [2 x i32], ptr %array, align 4 -// CHECK:STDOUT: ret [2 x i32] %7 +// CHECK:STDOUT: store [2 x i32] %7, ptr %return, align 4 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %var = alloca [2 x i32], align 4 // CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 -// CHECK:STDOUT: %A = call { i32, i32 } @A() +// CHECK:STDOUT: call void @A(ptr %temp) // CHECK:STDOUT: %array = alloca [2 x i32], align 4 -// CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %A, 0 // CHECK:STDOUT: %1 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 -// CHECK:STDOUT: store i32 %array.element, ptr %1, align 4 -// CHECK:STDOUT: %array.element1 = extractvalue { i32, i32 } %A, 1 +// CHECK:STDOUT: store i32 undef, ptr %1, align 4 // CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 -// CHECK:STDOUT: store i32 %array.element1, ptr %2, align 4 +// CHECK:STDOUT: store i32 undef, ptr %2, align 4 // CHECK:STDOUT: %3 = load [2 x i32], ptr %array, align 4 // CHECK:STDOUT: store [2 x i32] %3, ptr %var, align 4 -// CHECK:STDOUT: %var2 = alloca i32, align 4 -// CHECK:STDOUT: %temp3 = alloca { i32, i32 }, align 8 -// CHECK:STDOUT: %A4 = call { i32, i32 } @A() -// CHECK:STDOUT: store { i32, i32 } %A4, ptr %temp3, align 4 -// CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp3, i32 0, i32 0 +// CHECK:STDOUT: %var1 = alloca i32, align 4 +// CHECK:STDOUT: %temp2 = alloca { i32, i32 }, align 8 +// CHECK:STDOUT: call void @A(ptr %temp2) +// CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp2, i32 0, i32 0 // CHECK:STDOUT: %4 = load i32, ptr %tuple.index, align 4 -// CHECK:STDOUT: store i32 %4, ptr %var2, align 4 -// CHECK:STDOUT: %var5 = alloca i32, align 4 -// CHECK:STDOUT: %5 = load i32, ptr %var2, align 4 +// CHECK:STDOUT: store i32 %4, ptr %var1, align 4 +// CHECK:STDOUT: %var3 = alloca i32, align 4 +// CHECK:STDOUT: %5 = load i32, ptr %var1, align 4 // CHECK:STDOUT: %array.index = getelementptr inbounds [2 x i32], ptr %var, i32 %5 // CHECK:STDOUT: %6 = load i32, ptr %array.index, align 4 -// CHECK:STDOUT: store i32 %6, ptr %var5, align 4 -// CHECK:STDOUT: %var6 = alloca i32, align 4 -// CHECK:STDOUT: %temp7 = alloca [2 x i32], align 4 -// CHECK:STDOUT: %B = call [2 x i32] @B() -// CHECK:STDOUT: store [2 x i32] %B, ptr %temp7, align 4 -// CHECK:STDOUT: %array.index8 = getelementptr inbounds [2 x i32], ptr %temp7, i32 0, i32 1 -// CHECK:STDOUT: %7 = load i32, ptr %array.index8, align 4 -// CHECK:STDOUT: store i32 %7, ptr %var6, align 4 +// CHECK:STDOUT: store i32 %6, ptr %var3, align 4 +// CHECK:STDOUT: %var4 = alloca i32, align 4 +// CHECK:STDOUT: %temp5 = alloca [2 x i32], align 4 +// CHECK:STDOUT: call void @B(ptr %temp5) +// CHECK:STDOUT: %array.index6 = getelementptr inbounds [2 x i32], ptr %temp5, i32 0, i32 1 +// CHECK:STDOUT: %7 = load i32, ptr %array.index6, align 4 +// CHECK:STDOUT: store i32 %7, ptr %var4, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/index/tuple_return_value_access.carbon b/toolchain/lowering/testdata/index/tuple_return_value_access.carbon index 732b112b7fa41..dba94eccee340 100644 --- a/toolchain/lowering/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/lowering/testdata/index/tuple_return_value_access.carbon @@ -13,21 +13,21 @@ fn Run() { // CHECK:STDOUT: ; ModuleID = 'tuple_return_value_access.carbon' // CHECK:STDOUT: source_filename = "tuple_return_value_access.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define { i32, i32 } @F() { +// CHECK:STDOUT: define void @F(ptr sret({ i32, i32 }) %return) { // CHECK:STDOUT: %tuple = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %1 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 0 // CHECK:STDOUT: store i32 12, ptr %1, align 4 // CHECK:STDOUT: %2 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 1 // CHECK:STDOUT: store i32 24, ptr %2, align 4 // CHECK:STDOUT: %3 = load { i32, i32 }, ptr %tuple, align 4 -// CHECK:STDOUT: ret { i32, i32 } %3 +// CHECK:STDOUT: store { i32, i32 } %3, ptr %return, align 4 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %var = alloca i32, align 4 // CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 -// CHECK:STDOUT: %F = call { i32, i32 } @F() -// CHECK:STDOUT: store { i32, i32 } %F, ptr %temp, align 4 +// CHECK:STDOUT: call void @F(ptr %temp) // CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp, i32 0, i32 1 // CHECK:STDOUT: %1 = load i32, ptr %tuple.index, align 4 // CHECK:STDOUT: store i32 %1, ptr %var, align 4 diff --git a/toolchain/lowering/testdata/namespace/function.carbon b/toolchain/lowering/testdata/namespace/function.carbon index 9776134ee1421..393df2acd0807 100644 --- a/toolchain/lowering/testdata/namespace/function.carbon +++ b/toolchain/lowering/testdata/namespace/function.carbon @@ -30,6 +30,5 @@ fn Bar() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Bar() { // CHECK:STDOUT: call void @Baz.1() -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/namespace/nested.carbon b/toolchain/lowering/testdata/namespace/nested.carbon index 9749fa7022883..f51a391c9b0a0 100644 --- a/toolchain/lowering/testdata/namespace/nested.carbon +++ b/toolchain/lowering/testdata/namespace/nested.carbon @@ -23,6 +23,5 @@ fn Foo.Bar.Baz() { // CHECK:STDOUT: // CHECK:STDOUT: define void @Baz() { // CHECK:STDOUT: call void @Wiz() -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/operators/and.carbon b/toolchain/lowering/testdata/operators/and.carbon index 93cfc361d73d2..600d5718ac556 100644 --- a/toolchain/lowering/testdata/operators/and.carbon +++ b/toolchain/lowering/testdata/operators/and.carbon @@ -23,15 +23,15 @@ fn And() -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define i1 @And() { -// CHECK:STDOUT: %temp = alloca i1, align 1 // CHECK:STDOUT: %F = call i1 @F() +// CHECK:STDOUT: %temp = alloca i1, align 1 // CHECK:STDOUT: store i1 %F, ptr %temp, align 1 // CHECK:STDOUT: %1 = load i1, ptr %temp, align 1 // CHECK:STDOUT: br i1 %1, label %2, label %4 // CHECK:STDOUT: // CHECK:STDOUT: 2: ; preds = %0 -// CHECK:STDOUT: %temp1 = alloca i1, align 1 // CHECK:STDOUT: %G = call i1 @G() +// CHECK:STDOUT: %temp1 = alloca i1, align 1 // CHECK:STDOUT: store i1 %G, ptr %temp1, align 1 // CHECK:STDOUT: %3 = load i1, ptr %temp1, align 1 // CHECK:STDOUT: br label %4 diff --git a/toolchain/lowering/testdata/operators/or.carbon b/toolchain/lowering/testdata/operators/or.carbon index 2206830c5d61a..307e51bd9aff1 100644 --- a/toolchain/lowering/testdata/operators/or.carbon +++ b/toolchain/lowering/testdata/operators/or.carbon @@ -23,16 +23,16 @@ fn Or() -> bool { // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define i1 @Or() { -// CHECK:STDOUT: %temp = alloca i1, align 1 // CHECK:STDOUT: %F = call i1 @F() +// CHECK:STDOUT: %temp = alloca i1, align 1 // CHECK:STDOUT: store i1 %F, ptr %temp, align 1 // CHECK:STDOUT: %1 = load i1, ptr %temp, align 1 // CHECK:STDOUT: %2 = xor i1 %1, true // CHECK:STDOUT: br i1 %2, label %3, label %5 // CHECK:STDOUT: // CHECK:STDOUT: 3: ; preds = %0 -// CHECK:STDOUT: %temp1 = alloca i1, align 1 // CHECK:STDOUT: %G = call i1 @G() +// CHECK:STDOUT: %temp1 = alloca i1, align 1 // CHECK:STDOUT: store i1 %G, ptr %temp1, align 1 // CHECK:STDOUT: %4 = load i1, ptr %temp1, align 1 // CHECK:STDOUT: br label %5 diff --git a/toolchain/lowering/testdata/pointer/address_of_field.carbon b/toolchain/lowering/testdata/pointer/address_of_field.carbon index 10e39443ab8c1..5a5f6ad12a128 100644 --- a/toolchain/lowering/testdata/pointer/address_of_field.carbon +++ b/toolchain/lowering/testdata/pointer/address_of_field.carbon @@ -29,6 +29,5 @@ fn F() { // CHECK:STDOUT: %b1 = getelementptr inbounds { i32, i32 }, ptr %var, i32 0, i32 1 // CHECK:STDOUT: %2 = load ptr, ptr %b1, align 8 // CHECK:STDOUT: call void @G(ptr %2) -// CHECK:STDOUT: %call.result = alloca {}, align 8 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/pointer/basic.carbon b/toolchain/lowering/testdata/pointer/basic.carbon index d3c94a24572dd..8b799c5b7d48d 100644 --- a/toolchain/lowering/testdata/pointer/basic.carbon +++ b/toolchain/lowering/testdata/pointer/basic.carbon @@ -26,5 +26,8 @@ fn F() -> i32 { // CHECK:STDOUT: store i32 0, ptr %var, align 4 // CHECK:STDOUT: %1 = load ptr, ptr %var, align 8 // CHECK:STDOUT: %G = call i32 @G(ptr %1) -// CHECK:STDOUT: ret i32 %G +// CHECK:STDOUT: %temp = alloca i32, align 4 +// CHECK:STDOUT: store i32 %G, ptr %temp, align 4 +// CHECK:STDOUT: %2 = load i32, ptr %temp, align 4 +// CHECK:STDOUT: ret i32 %2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 981805df0e1d7..42c3199fd1ce8 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -271,7 +271,7 @@ auto SemanticsContext::is_current_position_reachable() -> bool { auto SemanticsContext::Initialize(ParseTree::Node parse_node, SemanticsNodeId target_id, - SemanticsNodeId value_id) -> SemanticsNodeId { + SemanticsNodeId value_id) -> void { // Implicitly convert the value to the type of the target. auto type_id = semantics_ir().GetNode(target_id).type_id(); auto expr_id = ImplicitAsRequired(parse_node, value_id, type_id); @@ -297,12 +297,13 @@ auto SemanticsContext::Initialize(ParseTree::Node parse_node, case SemanticsExpressionCategory::Value: // TODO: For class types, use an interface to determine how to perform // this operation. - return AddNode(SemanticsNode::InitializeFrom::Make( - expr.parse_node(), expr.type_id(), expr_id, target_id)); + AddNode( + SemanticsNode::Assign::Make(expr.parse_node(), target_id, expr_id)); + return; case SemanticsExpressionCategory::Initializing: MarkInitializerFor(expr_id, target_id); - return expr_id; + return; } } @@ -316,6 +317,8 @@ auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) case SemanticsExpressionCategory::Initializing: { // Commit to using a temporary for this initializing expression. + // TODO: Don't create a temporary if the initializing representation is + // already a value representation. expr_id = FinalizeTemporary(expr_id, /*discarded=*/false); [[fallthrough]]; } @@ -357,31 +360,35 @@ auto SemanticsContext::FinalizeTemporary(SemanticsNodeId init_id, case SemanticsNodeKind::Call: { auto [refs_id, callee_id] = init.GetAsCall(); - if (!semantics_ir().GetFunction(callee_id).return_slot_id.is_valid()) { - if (discarded) { - // Don't invent a temporary that we're going to discard. - return SemanticsNodeId::Invalid; - } - - // The function has no return slot, which means it represents an - // empty tuple. Materialize one now. - auto temporary_id = AddNode(SemanticsNode::MaterializeTemporary::Make( - init.parse_node(), CanonicalizeTupleType(init.parse_node(), {}))); - // TODO: Do we need to create an empty TupleValue and Assign it to the - // temporary? + if (semantics_ir().GetFunction(callee_id).return_slot_id.is_valid()) { + // The return slot should have a materialized temporary in it. + auto temporary_id = semantics_ir().GetNodeBlock(refs_id).back(); + CARBON_CHECK(semantics_ir().GetNode(temporary_id).kind() == + SemanticsNodeKind::MaterializeTemporary) + << "Return slot for function call does not contain a temporary; " + << "initialized multiple times? Have " + << semantics_ir().GetNode(temporary_id); return temporary_id; } - // The return slot should have a materialized temporary in it. Assign - // the initializer to it and return its address. - auto temporary_id = semantics_ir().GetNodeBlock(refs_id).back(); - auto temporary = semantics_ir().GetNode(temporary_id); - CARBON_CHECK(temporary.kind() == - SemanticsNodeKind::MaterializeTemporary) - << "Return slot for function call does not contain a temporary; " - << "initialized multiple times? Have " << temporary; - AddNode(SemanticsNode::Assign::Make(temporary.parse_node(), - temporary_id, init_id)); + if (discarded) { + // Don't invent a temporary that we're going to discard. + return SemanticsNodeId::Invalid; + } + + // The function has no return slot, but we want to produce a temporary + // object. Materialize one now. + auto temporary_id = AddNode(SemanticsNode::MaterializeTemporary::Make( + init.parse_node(), init.type_id())); + if (GetSemanticsInitializingRepresentation(semantics_ir(), + init.type_id()) + .kind != SemanticsInitializingRepresentation::None) { + AddNode(SemanticsNode::Assign::Make(init.parse_node(), temporary_id, + init_id)); + } else { + // TODO: Should we create an empty value and Assign it to the + // temporary? + } return temporary_id; } @@ -426,6 +433,11 @@ auto SemanticsContext::MarkInitializerFor(SemanticsNodeId init_id, << "initialized multiple times? Have " << temporary; semantics_ir().ReplaceNode( temporary_id, SemanticsNode::NoOp::Make(temporary.parse_node())); + } else if (GetSemanticsInitializingRepresentation(semantics_ir(), + init.type_id()) + .kind != SemanticsInitializingRepresentation::None) { + AddNode(SemanticsNode::Assign::Make(init.parse_node(), target_id, + init_id)); } return; } diff --git a/toolchain/semantics/semantics_context.h b/toolchain/semantics/semantics_context.h index 35c72a9dc806c..ef3565a5e0746 100644 --- a/toolchain/semantics/semantics_context.h +++ b/toolchain/semantics/semantics_context.h @@ -123,10 +123,9 @@ class SemanticsContext { // Convert the given expression to a value expression of the same type. auto ConvertToValueExpression(SemanticsNodeId expr_id) -> SemanticsNodeId; - // Performs initialization of `target_id` from `value_id`. Returns the - // converted initializer value. + // Performs initialization of `target_id` from `value_id`. auto Initialize(ParseTree::Node parse_node, SemanticsNodeId target_id, - SemanticsNodeId value_id) -> SemanticsNodeId; + SemanticsNodeId value_id) -> void; // Converts `value_id` to a value expression of type `type_id`. auto ConvertToValueOfType(ParseTree::Node parse_node, diff --git a/toolchain/semantics/semantics_handle_call_expression.cpp b/toolchain/semantics/semantics_handle_call_expression.cpp index 374f9333411ba..921ccf131b093 100644 --- a/toolchain/semantics/semantics_handle_call_expression.cpp +++ b/toolchain/semantics/semantics_handle_call_expression.cpp @@ -41,15 +41,14 @@ auto SemanticsHandleCallExpression(SemanticsContext& context, callable.param_refs_id, /*diagnostic=*/nullptr)); - // TODO: Propagate return types from callable. + // For functions with an implicit return type, the return type is the empty + // tuple type. SemanticsTypeId type_id = callable.return_type_id; - // For functions with an implicit return type, set the return type to empty - // tuple type. Otherwise, add a location for the return slot to the arguments. - // The actual return slot location will be filled in by - // `SemanticsContext::MarkInitializerFor`. if (!type_id.is_valid()) { type_id = context.CanonicalizeTupleType(call_expr_parse_node, {}); } + + // If there is a return slot, add a corresponding argument. if (callable.return_slot_id.is_valid()) { if (refs_id == SemanticsNodeBlockId::Empty) { refs_id = context.semantics_ir().AddNodeBlock(); diff --git a/toolchain/semantics/semantics_handle_function.cpp b/toolchain/semantics/semantics_handle_function.cpp index ba60b03ec472e..e6f39bb345d3a 100644 --- a/toolchain/semantics/semantics_handle_function.cpp +++ b/toolchain/semantics/semantics_handle_function.cpp @@ -27,15 +27,10 @@ static auto BuildFunctionDeclaration(SemanticsContext& context) return_slot_id = context.node_stack().Pop(); return_type_id = context.semantics_ir().GetNode(return_slot_id).type_id(); - // If the function has an explicit return type of `()`, it has no return - // slot, to keep the IR for explicit and implicit non-value-returning - // functions consistent. - auto return_type = context.semantics_ir().GetNode( - context.semantics_ir().GetTypeAllowBuiltinTypes(return_type_id)); - if (return_type.kind() == SemanticsNodeKind::TupleType && - context.semantics_ir() - .GetTypeBlock(return_type.GetAsTupleType()) - .empty()) { + // The function only has a return slot if it uses in-place initialization. + if (!GetSemanticsInitializingRepresentation(context.semantics_ir(), + return_type_id) + .has_return_slot()) { return_slot_id = SemanticsNodeId::Invalid; } } diff --git a/toolchain/semantics/semantics_handle_operator.cpp b/toolchain/semantics/semantics_handle_operator.cpp index 814b5d934726c..bdae7f2a27d45 100644 --- a/toolchain/semantics/semantics_handle_operator.cpp +++ b/toolchain/semantics/semantics_handle_operator.cpp @@ -60,9 +60,12 @@ auto SemanticsHandleInfixOperator(SemanticsContext& context, "Expression is not assignable."); context.emitter().Emit(lhs_node, AssignmentToNonAssignable); } - rhs_id = context.Initialize(parse_node, lhs_id, rhs_id); - context.AddNodeAndPush( - parse_node, SemanticsNode::Assign::Make(parse_node, lhs_id, rhs_id)); + context.Initialize(parse_node, lhs_id, rhs_id); + // We model assignment as an expression, so we need to push a value for + // it, even though it doesn't produce a value. + // TODO: Consider changing our parse tree to model assignment as a + // different kind of statement than an expression statement. + context.node_stack().Push(parse_node, lhs_id); return true; } default: diff --git a/toolchain/semantics/semantics_handle_statement.cpp b/toolchain/semantics/semantics_handle_statement.cpp index ea9e5a0d1bd76..c99a3606993e9 100644 --- a/toolchain/semantics/semantics_handle_statement.cpp +++ b/toolchain/semantics/semantics_handle_statement.cpp @@ -53,11 +53,24 @@ auto SemanticsHandleReturnStatement(SemanticsContext& context, .Build(parse_node, ReturnStatementDisallowExpression) .Note(fn_node.parse_node(), ReturnStatementImplicitNote) .Emit(); + + context.AddNode(SemanticsNode::ReturnExpression::Make(parse_node, arg)); } else if (callable.return_slot_id.is_valid()) { - arg = context.Initialize(parse_node, callable.return_slot_id, arg); - } + context.Initialize(parse_node, callable.return_slot_id, arg); - context.AddNode(SemanticsNode::ReturnExpression::Make(parse_node, arg)); + context.AddNode(SemanticsNode::Return::Make(parse_node)); + } else { + arg = context.ConvertToValueOfType(parse_node, arg, + callable.return_type_id); + + if (GetSemanticsInitializingRepresentation(context.semantics_ir(), + callable.return_type_id) + .kind == SemanticsInitializingRepresentation::None) { + context.AddNode(SemanticsNode::Return::Make(parse_node)); + } else { + context.AddNode(SemanticsNode::ReturnExpression::Make(parse_node, arg)); + } + } } // Switch to a new, unreachable, empty node block. This typically won't diff --git a/toolchain/semantics/semantics_handle_variable.cpp b/toolchain/semantics/semantics_handle_variable.cpp index f37fa96f4639a..1bfab65e8da99 100644 --- a/toolchain/semantics/semantics_handle_variable.cpp +++ b/toolchain/semantics/semantics_handle_variable.cpp @@ -28,10 +28,7 @@ auto SemanticsHandleVariableDeclaration(SemanticsContext& context, context.AddNameToLookup(binding.parse_node(), name_id, storage_id); // If there was an initializer, assign it to storage. if (has_init) { - auto cast_value_id = - context.Initialize(parse_node, storage_id, expr_node_id); - context.AddNode( - SemanticsNode::Assign::Make(parse_node, storage_id, cast_value_id)); + context.Initialize(parse_node, storage_id, expr_node_id); } context.node_stack() diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index 60f851a4a5f32..aedba80df8c14 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -537,7 +537,7 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, SemanticsTypeId type_id) -> SemanticsValueRepresentation { const SemanticsIR* ir = &semantics_ir; - SemanticsNodeId node_id = ir->GetType(type_id); + SemanticsNodeId node_id = ir->GetTypeAllowBuiltinTypes(type_id); while (true) { auto node = ir->GetNode(node_id); switch (node.kind()) { @@ -609,7 +609,7 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, // A struct with one field has the same representation as its field. auto [field_name_id, field_type_id] = ir->GetNode(fields.front()).GetAsStructTypeField(); - node_id = ir->GetType(field_type_id); + node_id = ir->GetTypeAllowBuiltinTypes(field_type_id); continue; } // For any other struct, use a pointer representation. @@ -625,7 +625,7 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, } if (elements.size() == 1) { // A one-tuple has the same representation as its sole element. - node_id = ir->GetType(elements.front()); + node_id = ir->GetTypeAllowBuiltinTypes(elements.front()); continue; } // For any other tuple, use a pointer representation. @@ -656,7 +656,7 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, return {.kind = SemanticsValueRepresentation::Copy, .type = type_id}; case SemanticsNodeKind::ConstType: - node_id = ir->GetType(node.GetAsConstType()); + node_id = ir->GetTypeAllowBuiltinTypes(node.GetAsConstType()); continue; } } diff --git a/toolchain/semantics/semantics_ir.h b/toolchain/semantics/semantics_ir.h index cf3a7a13412a8..067488e1f41b8 100644 --- a/toolchain/semantics/semantics_ir.h +++ b/toolchain/semantics/semantics_ir.h @@ -437,6 +437,9 @@ struct SemanticsInitializingRepresentation { }; // The kind of initializing representation used by this type. Kind kind; + + // Returns whether a return slot is used when returning this type. + bool has_return_slot() const { return kind == InPlace; } }; // Returns information about the initializing representation to use for a type. diff --git a/toolchain/semantics/testdata/array/assign_return_value.carbon b/toolchain/semantics/testdata/array/assign_return_value.carbon index ee8de07db15ab..a0b6891ce2590 100644 --- a/toolchain/semantics/testdata/array/assign_return_value.carbon +++ b/toolchain/semantics/testdata/array/assign_return_value.carbon @@ -12,7 +12,7 @@ fn Run() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, return_slot: node+4, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: {block4}}}, // CHECK:STDOUT: {name: str1, param_refs: block0, body: {block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ @@ -30,7 +30,7 @@ fn Run() { // CHECK:STDOUT: node+1, // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -50,18 +50,15 @@ fn Run() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+12, arg1: type1, type: typeTypeType}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+11, arg1: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+14, type: type3}, -// CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, -// CHECK:STDOUT: {kind: Call, arg0: block7, arg1: function0, type: type2}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+17, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+14, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+19}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+13, type: type3}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+15, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -79,19 +76,19 @@ fn Run() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, @@ -99,12 +96,6 @@ fn Run() { // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -113,13 +104,12 @@ fn Run() { // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: (i32,) { +// CHECK:STDOUT: fn @F() -> (i32,) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_28.1: i32 = int_literal 0 // CHECK:STDOUT: %.loc7_28.2: i32 = stub_reference %.loc7_28.1 -// CHECK:STDOUT: %.loc7_30.1: (i32,) = tuple_value (%.loc7_28.2) -// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1 to %return -// CHECK:STDOUT: return %.loc7_30.2 +// CHECK:STDOUT: %.loc7_30: (i32,) = tuple_value (%.loc7_28.2) +// CHECK:STDOUT: return %.loc7_30 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { @@ -127,10 +117,8 @@ fn Run() { // CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 // CHECK:STDOUT: %.loc10_17: type = array_type %.loc10_16, i32 // CHECK:STDOUT: %t: [i32; 1] = var -// CHECK:STDOUT: %.loc10_22.1: (i32,) = materialize_temporary -// CHECK:STDOUT: %.loc10_22.2: (i32,) = call @F() to %.loc10_22.1 -// CHECK:STDOUT: %.loc10_22.3: [i32; 1] = array_value %.loc10_22.2 -// CHECK:STDOUT: %.loc10_22.4: [i32; 1] = initialize_from %.loc10_22.3 to %t -// CHECK:STDOUT: assign %t, %.loc10_22.4 +// CHECK:STDOUT: %.loc10_22.1: (i32,) = call @F() +// CHECK:STDOUT: %.loc10_22.2: [i32; 1] = array_value %.loc10_22.1 +// CHECK:STDOUT: assign %t, %.loc10_22.2 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/assign_var.carbon b/toolchain/semantics/testdata/array/assign_var.carbon index 403ac38d2f3b0..0e0c16061a24b 100644 --- a/toolchain/semantics/testdata/array/assign_var.carbon +++ b/toolchain/semantics/testdata/array/assign_var.carbon @@ -26,7 +26,7 @@ var b: [i32; 3] = a; // CHECK:STDOUT: node+3, // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -56,15 +56,13 @@ var b: [i32; 3] = a; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, arg1: node+6, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+15}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+14}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+17, arg1: type1, type: typeTypeType}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+16, arg1: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+19, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+18, type: type3}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+6, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+19, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+22}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -92,8 +90,6 @@ var b: [i32; 3] = a; // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -121,13 +117,11 @@ var b: [i32; 3] = a; // CHECK:STDOUT: %.loc7_30.2: i32 = stub_reference %.loc7_30.1 // CHECK:STDOUT: %.loc7_33.1: i32 = int_literal 3 // CHECK:STDOUT: %.loc7_33.2: i32 = stub_reference %.loc7_33.1 -// CHECK:STDOUT: %.loc7_34.1: (i32, i32, i32) = tuple_value (%.loc7_27.2, %.loc7_30.2, %.loc7_33.2) -// CHECK:STDOUT: %.loc7_34.2: (i32, i32, i32) = initialize_from %.loc7_34.1 to %a -// CHECK:STDOUT: assign %a, %.loc7_34.2 +// CHECK:STDOUT: %.loc7_34: (i32, i32, i32) = tuple_value (%.loc7_27.2, %.loc7_30.2, %.loc7_33.2) +// CHECK:STDOUT: assign %a, %.loc7_34 // CHECK:STDOUT: %.loc8_14: i32 = int_literal 3 // CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, i32 // CHECK:STDOUT: %b: [i32; 3] = var -// CHECK:STDOUT: %.loc7_5.1: [i32; 3] = array_value %a -// CHECK:STDOUT: %.loc7_5.2: [i32; 3] = initialize_from %.loc7_5.1 to %b -// CHECK:STDOUT: assign %b, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: [i32; 3] = array_value %a +// CHECK:STDOUT: assign %b, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/base.carbon b/toolchain/semantics/testdata/array/base.carbon index 51475c4d52691..7cc6c1a14b6c7 100644 --- a/toolchain/semantics/testdata/array/base.carbon +++ b/toolchain/semantics/testdata/array/base.carbon @@ -31,11 +31,11 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+6, // CHECK:STDOUT: nodeFloatingPointType, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+38, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -65,27 +65,27 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+11, arg1: type3, type: typeTypeType}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+10, arg1: type3, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type4}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type4}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type4}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+15, type: type3}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type3}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real1, type: type3}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type3}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type3}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type5}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+20, type: type4}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+21, arg1: node+13, type: type4}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+22}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+19, type: type4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+20}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+26, arg1: type6, type: typeTypeType}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+24, arg1: type6, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type7}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+28, type: type7}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+26, type: type7}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+28, type: type6}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, // CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type6}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, @@ -94,13 +94,10 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: {kind: StubReference, arg0: node+34, type: type6}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, // CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type6}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type6}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+38, type: type6}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock3, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type8}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+41, type: type7}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+42, arg1: node+28, type: type7}, -// CHECK:STDOUT: {kind: Assign, arg0: node+28, arg1: node+43}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+39, type: type7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+26, arg1: node+40}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -148,23 +145,20 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, // CHECK:STDOUT: node+41, -// CHECK:STDOUT: node+42, -// CHECK:STDOUT: node+43, -// CHECK:STDOUT: node+44, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+29, // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+33, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+37, -// CHECK:STDOUT: node+39, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -177,8 +171,7 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc7_22.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_22.2: (i32,) = tuple_value (%.loc7_20.2) // CHECK:STDOUT: %.loc7_22.3: [i32; 1] = array_value %.loc7_22.2 -// CHECK:STDOUT: %.loc7_22.4: [i32; 1] = initialize_from %.loc7_22.3 to %a -// CHECK:STDOUT: assign %a, %.loc7_22.4 +// CHECK:STDOUT: assign %a, %.loc7_22.3 // CHECK:STDOUT: %.loc8_14: i32 = int_literal 2 // CHECK:STDOUT: %.loc8_15: type = array_type %.loc8_14, f64 // CHECK:STDOUT: %b: [f64; 2] = var @@ -189,8 +182,7 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc8_30.1: type = tuple_type (f64, f64) // CHECK:STDOUT: %.loc8_30.2: (f64, f64) = tuple_value (%.loc8_20.2, %.loc8_26.2) // CHECK:STDOUT: %.loc8_30.3: [f64; 2] = array_value %.loc8_30.2 -// CHECK:STDOUT: %.loc8_30.4: [f64; 2] = initialize_from %.loc8_30.3 to %b -// CHECK:STDOUT: assign %b, %.loc8_30.4 +// CHECK:STDOUT: assign %b, %.loc8_30.3 // CHECK:STDOUT: %.loc9_10.1: type = tuple_type () // CHECK:STDOUT: %.loc9_10.2: () = tuple_value () // CHECK:STDOUT: %.loc9_13: i32 = int_literal 5 @@ -209,6 +201,5 @@ var c: [(); 5] = ((), (), (), (), (),); // CHECK:STDOUT: %.loc9_38.1: type = tuple_type ((), (), (), (), ()) // CHECK:STDOUT: %.loc9_38.2: ((), (), (), (), ()) = tuple_value (%.loc9_20.2, %.loc9_24.2, %.loc9_28.2, %.loc9_32.2, %.loc9_36.2) // CHECK:STDOUT: %.loc9_38.3: [(); 5] = array_value %.loc9_38.2 -// CHECK:STDOUT: %.loc9_38.4: [(); 5] = initialize_from %.loc9_38.3 to %c -// CHECK:STDOUT: assign %c, %.loc9_38.4 +// CHECK:STDOUT: assign %c, %.loc9_38.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/fail_out_of_bound.carbon b/toolchain/semantics/testdata/array/fail_out_of_bound.carbon index 5905a425b8097..ab69bbaa4d82d 100644 --- a/toolchain/semantics/testdata/array/fail_out_of_bound.carbon +++ b/toolchain/semantics/testdata/array/fail_out_of_bound.carbon @@ -48,8 +48,7 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,7 +67,6 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -89,6 +87,5 @@ var a: [i32; 1] = (1, 2, 3); // CHECK:STDOUT: %.loc10_26.2: i32 = stub_reference %.loc10_26.1 // CHECK:STDOUT: %.loc10_27.1: type = tuple_type (i32, i32, i32) // CHECK:STDOUT: %.loc10_27.2: (i32, i32, i32) = tuple_value (%.loc10_20.2, %.loc10_23.2, %.loc10_26.2) -// CHECK:STDOUT: %.1: = initialize_from to %a -// CHECK:STDOUT: assign %a, %.1 +// CHECK:STDOUT: assign %a, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/fail_type_mismatch.carbon b/toolchain/semantics/testdata/array/fail_type_mismatch.carbon index 022b050c9022f..884eb02fada64 100644 --- a/toolchain/semantics/testdata/array/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/array/fail_type_mismatch.carbon @@ -45,8 +45,7 @@ var a: [i32; 2] = (1, 2.5); // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type2}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+10}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -63,7 +62,6 @@ var a: [i32; 2] = (1, 2.5); // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -81,6 +79,5 @@ var a: [i32; 2] = (1, 2.5); // CHECK:STDOUT: %.loc10_23.2: f64 = stub_reference %.loc10_23.1 // CHECK:STDOUT: %.loc10_26.1: type = tuple_type (i32, f64) // CHECK:STDOUT: %.loc10_26.2: (i32, f64) = tuple_value (%.loc10_20.2, %.loc10_23.2) -// CHECK:STDOUT: %.1: = initialize_from to %a -// CHECK:STDOUT: assign %a, %.1 +// CHECK:STDOUT: assign %a, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/builtin_types.carbon b/toolchain/semantics/testdata/basics/builtin_types.carbon index 3280c5bf2714d..b9da04af87076 100644 --- a/toolchain/semantics/testdata/basics/builtin_types.carbon +++ b/toolchain/semantics/testdata/basics/builtin_types.carbon @@ -36,22 +36,18 @@ var test_type: type = i32; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+4, type: type1}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+6}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+8, type: type2}, // CHECK:STDOUT: {kind: StringLiteral, arg0: str3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+10, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+13}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+10}, // CHECK:STDOUT: {kind: VarStorage, type: typeTypeType}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+15, type: typeTypeType}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeIntegerType, arg1: node+15, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+17}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+12, type: typeTypeType}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: nodeIntegerType}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -72,27 +68,19 @@ var test_type: type = i32; // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %test_i32: i32 = var -// CHECK:STDOUT: %.loc7_21.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_21.2: i32 = initialize_from %.loc7_21.1 to %test_i32 -// CHECK:STDOUT: assign %test_i32, %.loc7_21.2 +// CHECK:STDOUT: %.loc7: i32 = int_literal 0 +// CHECK:STDOUT: assign %test_i32, %.loc7 // CHECK:STDOUT: %test_f64: f64 = var -// CHECK:STDOUT: %.loc8_21.1: f64 = real_literal 1e-1 -// CHECK:STDOUT: %.loc8_21.2: f64 = initialize_from %.loc8_21.1 to %test_f64 -// CHECK:STDOUT: assign %test_f64, %.loc8_21.2 +// CHECK:STDOUT: %.loc8: f64 = real_literal 1e-1 +// CHECK:STDOUT: assign %test_f64, %.loc8 // CHECK:STDOUT: %test_str: String = var -// CHECK:STDOUT: %.loc9_24.1: String = string_literal "Test" -// CHECK:STDOUT: %.loc9_24.2: String = initialize_from %.loc9_24.1 to %test_str -// CHECK:STDOUT: assign %test_str, %.loc9_24.2 +// CHECK:STDOUT: %.loc9: String = string_literal "Test" +// CHECK:STDOUT: assign %test_str, %.loc9 // CHECK:STDOUT: %test_type: type = var -// CHECK:STDOUT: %.1: type = initialize_from i32 to %test_type -// CHECK:STDOUT: assign %test_type, %.1 +// CHECK:STDOUT: assign %test_type, i32 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon index 68888e28ac8e9..28a3523a0fd77 100644 --- a/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon +++ b/toolchain/semantics/testdata/basics/fail_non_type_as_type.carbon @@ -29,8 +29,7 @@ var x: type = 42; // CHECK:STDOUT: {kind: VarStorage, type: typeTypeType}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: typeTypeType}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+0, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -40,13 +39,11 @@ var x: type = 42; // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: type = var // CHECK:STDOUT: %.loc10: i32 = int_literal 42 -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon index 0449bf0978a13..781ad17a96160 100644 --- a/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon +++ b/toolchain/semantics/testdata/basics/fail_qualifier_unsupported.carbon @@ -32,8 +32,7 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -44,13 +43,11 @@ var y: i32 = x.b; // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from to %y -// CHECK:STDOUT: assign %y, %.1 +// CHECK:STDOUT: assign %y, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/basics/parens.carbon b/toolchain/semantics/testdata/basics/parens.carbon index 5c40b9eb76d03..a4aed23c15d5a 100644 --- a/toolchain/semantics/testdata/basics/parens.carbon +++ b/toolchain/semantics/testdata/basics/parens.carbon @@ -29,8 +29,7 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+3, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -42,7 +41,6 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -50,7 +48,6 @@ var test_i32: i32 = ((1) + (2)); // CHECK:STDOUT: %test_i32: i32 = var // CHECK:STDOUT: %.loc7_23: i32 = int_literal 1 // CHECK:STDOUT: %.loc7_29: i32 = int_literal 2 -// CHECK:STDOUT: %.loc7_26.1: i32 = add %.loc7_23, %.loc7_29 -// CHECK:STDOUT: %.loc7_26.2: i32 = initialize_from %.loc7_26.1 to %test_i32 -// CHECK:STDOUT: assign %test_i32, %.loc7_26.2 +// CHECK:STDOUT: %.loc7_26: i32 = add %.loc7_23, %.loc7_29 +// CHECK:STDOUT: assign %test_i32, %.loc7_26 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index be607d2bd1b39..38e5f344edaa6 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -14,7 +14,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type3, return_slot: node+9, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type3, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -45,8 +45,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+9, type: type3}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -72,7 +71,6 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,9 +78,8 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: %.loc11 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%p: const i32**) -> %return: const i32** { +// CHECK:STDOUT: fn @F(%p: const i32**) -> const i32** { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_6.1: const i32** = value_binding %p -// CHECK:STDOUT: %.loc11_6.2: const i32** = initialize_from %.loc11_6.1 to %return -// CHECK:STDOUT: return %.loc11_6.2 +// CHECK:STDOUT: %.loc11: const i32** = value_binding %p +// CHECK:STDOUT: return %.loc11 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/fail_collapse.carbon b/toolchain/semantics/testdata/const/fail_collapse.carbon index 5cc388a1cb349..68007bac1be11 100644 --- a/toolchain/semantics/testdata/const/fail_collapse.carbon +++ b/toolchain/semantics/testdata/const/fail_collapse.carbon @@ -16,7 +16,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type5, return_slot: node+8, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type5, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -47,8 +47,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: {kind: PointerType, arg0: type4, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type5}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+8, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -72,7 +71,6 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,8 +78,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: %.loc10 = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G(%p: const i32**) -> %return: i32** { +// CHECK:STDOUT: fn @G(%p: const i32**) -> i32** { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.1: = initialize_from to %return -// CHECK:STDOUT: return %.1 +// CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index 164f1e4f2053a..315f56105d023 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -14,7 +14,7 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+5, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: {block4}}}, // CHECK:STDOUT: {name: str2, param_refs: block0, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ @@ -40,14 +40,11 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, -// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+14}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -66,24 +63,20 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -92,19 +85,16 @@ fn Main() { // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Echo(%a: {}) -> %return: {} { +// CHECK:STDOUT: fn @Echo(%a: {}) -> {} { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_9.1: {} = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: {} = initialize_from %.loc7_9.1 to %return -// CHECK:STDOUT: return %.loc7_9.2 +// CHECK:STDOUT: %.loc7: {} = value_binding %a +// CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc12_9.1: {} = struct_value () // CHECK:STDOUT: %.loc12_9.2: {} = stub_reference %.loc12_9.1 -// CHECK:STDOUT: %.loc12_7.1: {} = materialize_temporary -// CHECK:STDOUT: %.loc12_7.2: {} = call @Echo(%.loc12_9.2) to %.loc12_7.1 -// CHECK:STDOUT: assign %.loc12_7.1, %.loc12_7.2 +// CHECK:STDOUT: %.loc12_7: {} = call @Echo(%.loc12_9.2) // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index 1cf88363622ad..9da959dbacbc7 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -41,10 +41,11 @@ fn Main() { // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -64,19 +65,20 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -87,7 +89,8 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: ()) -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %.loc7: () = value_binding %a +// CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { diff --git a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon index bac503437d7b9..1edebe3077f04 100644 --- a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon @@ -15,7 +15,7 @@ fn Run() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: {name: str1, param_refs: block0, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ @@ -38,15 +38,12 @@ fn Run() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block5, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+6, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+10}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type1}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: nodeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -57,24 +54,18 @@ fn Run() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -83,19 +74,16 @@ fn Run() { // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Foo() -> %return: f64 { +// CHECK:STDOUT: fn @Foo() -> f64 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_26.1: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.loc7_26.2: f64 = initialize_from %.loc7_26.1 to %return -// CHECK:STDOUT: return %.loc7_26.2 +// CHECK:STDOUT: %.loc7: f64 = real_literal 10e-1 +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc13_19.1: f64 = materialize_temporary -// CHECK:STDOUT: %.loc13_19.2: f64 = call @Foo() to %.loc13_19.1 -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: %.loc13: f64 = call @Foo() +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index bddf807f09db4..ad8e03d9d6557 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -14,7 +14,7 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+2, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: {block4}}}, // CHECK:STDOUT: {name: str2, param_refs: block0, body: {block5}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ @@ -39,16 +39,14 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+7, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, -// CHECK:STDOUT: {kind: NoOp}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+13}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+11}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -64,26 +62,23 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -92,11 +87,10 @@ fn Main() { // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Echo(%a: i32) -> %return: i32 { +// CHECK:STDOUT: fn @Echo(%a: i32) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_9.1: i32 = value_binding %a -// CHECK:STDOUT: %.loc7_9.2: i32 = initialize_from %.loc7_9.1 to %return -// CHECK:STDOUT: return %.loc7_9.2 +// CHECK:STDOUT: %.loc7: i32 = value_binding %a +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { @@ -104,8 +98,7 @@ fn Main() { // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc12_21.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc12_21.2: i32 = stub_reference %.loc12_21.1 -// CHECK:STDOUT: no_op -// CHECK:STDOUT: %.loc12_20: i32 = call @Echo(%.loc12_21.2) to %b +// CHECK:STDOUT: %.loc12_20: i32 = call @Echo(%.loc12_21.2) // CHECK:STDOUT: assign %b, %.loc12_20 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/return_implicit.carbon b/toolchain/semantics/testdata/function/call/return_implicit.carbon index 46c8f4c53af8a..73550cdbb3486 100644 --- a/toolchain/semantics/testdata/function/call/return_implicit.carbon +++ b/toolchain/semantics/testdata/function/call/return_implicit.carbon @@ -41,7 +41,6 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -61,7 +60,6 @@ fn Main() { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -81,6 +79,5 @@ fn Main() { // CHECK:STDOUT: %.loc11_11.2: () = tuple_value () // CHECK:STDOUT: %b: () = var // CHECK:STDOUT: %.loc11_37: () = call @MakeImplicitEmptyTuple() -// CHECK:STDOUT: assign %b, %.loc11_37 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index 8474e9ca4f6e8..cffffa7ad854a 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -35,9 +35,9 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block4, block5, block6, block7}}}, -// CHECK:STDOUT: {name: str2, param_refs: block9, return_type: type1, return_slot: node+13, body: {block10, block11, block12, block13}}}, -// CHECK:STDOUT: {name: str3, param_refs: block15, return_type: type1, return_slot: node+24, body: {block16, block17, block18}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block6, block7}}}, +// CHECK:STDOUT: {name: str2, param_refs: block9, return_type: type1, body: {block10, block11, block12, block13}}}, +// CHECK:STDOUT: {name: str3, param_refs: block15, return_type: type1, body: {block16, block17, block18}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -67,30 +67,27 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+4}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+15}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+14}, // CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+13, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+22, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+20, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+22, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+26}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+24}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+29, arg1: node+24, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+30}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+27}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -106,8 +103,8 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, @@ -117,53 +114,50 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, // CHECK:STDOUT: node+26, -// CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+29, -// CHECK:STDOUT: node+30, -// CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: ], @@ -175,15 +169,14 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: %.loc27 = fn_decl @If3 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @If1(%b: bool) -> %return: i32 { +// CHECK:STDOUT: fn @If1(%b: bool) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: -// CHECK:STDOUT: %.loc9_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 to %return -// CHECK:STDOUT: return %.loc9_12.2 +// CHECK:STDOUT: %.loc9: i32 = int_literal 1 +// CHECK:STDOUT: return %.loc9 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: br !if.done @@ -191,7 +184,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: !if.done: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @If2(%b: bool) -> %return: i32 { +// CHECK:STDOUT: fn @If2(%b: bool) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc17: bool = value_binding %b // CHECK:STDOUT: if %.loc17 br !if.then else br !if.else @@ -200,22 +193,20 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: br !if.done // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.loc20_12.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc20_12.2: i32 = initialize_from %.loc20_12.1 to %return -// CHECK:STDOUT: return %.loc20_12.2 +// CHECK:STDOUT: %.loc20: i32 = int_literal 2 +// CHECK:STDOUT: return %.loc20 // CHECK:STDOUT: // CHECK:STDOUT: !if.done: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @If3(%b: bool) -> %return: i32 { +// CHECK:STDOUT: fn @If3(%b: bool) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc27: bool = value_binding %b // CHECK:STDOUT: if %.loc27 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: -// CHECK:STDOUT: %.loc29_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc29_12.2: i32 = initialize_from %.loc29_12.1 to %return -// CHECK:STDOUT: return %.loc29_12.2 +// CHECK:STDOUT: %.loc29: i32 = int_literal 1 +// CHECK:STDOUT: return %.loc29 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index 03aff65f8a522..1dc9c671971f6 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -17,7 +17,7 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block4, block5, block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 2, @@ -46,14 +46,11 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, arg1: node+7, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+10}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+9}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -81,12 +78,9 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -94,21 +88,18 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @VarScope // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @VarScope(%b: bool) -> %return: i32 { +// CHECK:STDOUT: fn @VarScope(%b: bool) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc9_18.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc9_18.2: i32 = initialize_from %.loc9_18.1 to %n -// CHECK:STDOUT: assign %n, %.loc9_18.2 -// CHECK:STDOUT: %.loc9_9.1: i32 = value_binding %n -// CHECK:STDOUT: %.loc9_9.2: i32 = initialize_from %.loc9_9.1 to %return -// CHECK:STDOUT: return %.loc9_9.2 +// CHECK:STDOUT: %.loc9_18: i32 = int_literal 2 +// CHECK:STDOUT: assign %n, %.loc9_18 +// CHECK:STDOUT: %.loc9_9: i32 = value_binding %n +// CHECK:STDOUT: return %.loc9_9 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.1: = initialize_from to %return -// CHECK:STDOUT: return %.1 +// CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index c22dc3fe8fb43..21d3be77fc63e 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -15,7 +15,7 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block4, block5, block6}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block6}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -42,11 +42,9 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+4}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -70,12 +68,10 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -83,18 +79,16 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @If // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @If(%b: bool) -> %return: i32 { +// CHECK:STDOUT: fn @If(%b: bool) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: -// CHECK:STDOUT: %.loc9_12.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc9_12.2: i32 = initialize_from %.loc9_12.1 to %return -// CHECK:STDOUT: return %.loc9_12.2 +// CHECK:STDOUT: %.loc9: i32 = int_literal 1 +// CHECK:STDOUT: return %.loc9 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: -// CHECK:STDOUT: %.loc11_12.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc11_12.2: i32 = initialize_from %.loc11_12.1 to %return -// CHECK:STDOUT: return %.loc11_12.2 +// CHECK:STDOUT: %.loc11: i32 = int_literal 2 +// CHECK:STDOUT: return %.loc11 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index 1fd3fc53cd550..2026679cca7f1 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -10,7 +10,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+6, body: {block4, block5, block6, block7}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block6, block7}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -49,8 +49,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+13}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+16}, // CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+6, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+20}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -92,7 +91,6 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -100,7 +98,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%b: bool, %n: i32, %m: i32) -> %return: i32 { +// CHECK:STDOUT: fn @F(%b: bool, %n: i32, %m: i32) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_6: bool = value_binding %b // CHECK:STDOUT: if %.loc7_6 br !if.expr.then else br !if.expr.else @@ -118,7 +116,6 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: br !if.expr.result(%.loc8_33) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: -// CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 to %return -// CHECK:STDOUT: return %.loc8_10.2 +// CHECK:STDOUT: %.loc8_10: i32 = block_arg !if.expr.result +// CHECK:STDOUT: return %.loc8_10 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/constant_condition.carbon b/toolchain/semantics/testdata/if_expression/constant_condition.carbon index 5b26f323d1c0b..026cd12d5db1a 100644 --- a/toolchain/semantics/testdata/if_expression/constant_condition.carbon +++ b/toolchain/semantics/testdata/if_expression/constant_condition.carbon @@ -17,10 +17,10 @@ fn G() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block8, block9, block12}}}, -// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, return_slot: node+28, body: {block14, block15, block16, block19}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: {block7, block8, block9, block10}}}, +// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, body: {block12, block13, block14, block15}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -44,49 +44,45 @@ fn G() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+12}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+10}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block10, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+16}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+15, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+13}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+20}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+18}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+22}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+26}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+17}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+20}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+30}, -// CHECK:STDOUT: {kind: Branch, arg0: block16}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+27}, +// CHECK:STDOUT: {kind: Branch, arg0: block14}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block17, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+33, arg1: node+34}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+33, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+30}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+31, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block18, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+37, arg1: node+38}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+37, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block19, arg1: node+36}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block19, arg1: node+40}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block19, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+43, arg1: node+28, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+44}, +// CHECK:STDOUT: {kind: Assign, arg0: node+35, arg1: node+34}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+35, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+33}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+37}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block15, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+40}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -96,88 +92,72 @@ fn G() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+26, -// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+27, // CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+30, // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+32, +// CHECK:STDOUT: node+33, +// CHECK:STDOUT: node+38, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+33, // CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, -// CHECK:STDOUT: node+41, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+37, -// CHECK:STDOUT: node+38, // CHECK:STDOUT: node+39, -// CHECK:STDOUT: node+40, -// CHECK:STDOUT: node+42, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+33, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+37, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+43, -// CHECK:STDOUT: node+44, -// CHECK:STDOUT: node+45, +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+41, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -188,66 +168,62 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc14 = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @A() -> %return: i32 { +// CHECK:STDOUT: fn @A() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 to %return -// CHECK:STDOUT: return %.loc7_24.2 +// CHECK:STDOUT: %.loc7: i32 = int_literal 1 +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @B() -> %return: i32 { +// CHECK:STDOUT: fn @B() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_24.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 to %return -// CHECK:STDOUT: return %.loc8_24.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 2 +// CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: i32 { +// CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_13: bool = bool_literal true // CHECK:STDOUT: if %.loc11_13 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc11_24.1: i32 = materialize_temporary -// CHECK:STDOUT: %.loc11_24.2: i32 = call @A() to %.loc11_24.1 -// CHECK:STDOUT: assign %.loc11_24.1, %.loc11_24.2 -// CHECK:STDOUT: %.loc11_24.3: i32 = value_binding %.loc11_24.1 +// CHECK:STDOUT: %.loc11_24.1: i32 = call @A() +// CHECK:STDOUT: %.loc11_24.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_24.2, %.loc11_24.1 +// CHECK:STDOUT: %.loc11_24.3: i32 = value_binding %.loc11_24.2 // CHECK:STDOUT: br !if.expr.result(%.loc11_24.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_33.1: i32 = materialize_temporary -// CHECK:STDOUT: %.loc11_33.2: i32 = call @B() to %.loc11_33.1 -// CHECK:STDOUT: assign %.loc11_33.1, %.loc11_33.2 -// CHECK:STDOUT: %.loc11_33.3: i32 = value_binding %.loc11_33.1 +// CHECK:STDOUT: %.loc11_33.1: i32 = call @B() +// CHECK:STDOUT: %.loc11_33.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_33.2, %.loc11_33.1 +// CHECK:STDOUT: %.loc11_33.3: i32 = value_binding %.loc11_33.2 // CHECK:STDOUT: br !if.expr.result(%.loc11_33.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: -// CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 to %return -// CHECK:STDOUT: return %.loc11_10.2 +// CHECK:STDOUT: %.loc11_10: i32 = block_arg !if.expr.result +// CHECK:STDOUT: return %.loc11_10 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() -> %return: i32 { +// CHECK:STDOUT: fn @G() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc15_13: bool = bool_literal false // CHECK:STDOUT: if %.loc15_13 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc15_25.1: i32 = materialize_temporary -// CHECK:STDOUT: %.loc15_25.2: i32 = call @A() to %.loc15_25.1 -// CHECK:STDOUT: assign %.loc15_25.1, %.loc15_25.2 -// CHECK:STDOUT: %.loc15_25.3: i32 = value_binding %.loc15_25.1 +// CHECK:STDOUT: %.loc15_25.1: i32 = call @A() +// CHECK:STDOUT: %.loc15_25.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc15_25.2, %.loc15_25.1 +// CHECK:STDOUT: %.loc15_25.3: i32 = value_binding %.loc15_25.2 // CHECK:STDOUT: br !if.expr.result(%.loc15_25.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc15_34.1: i32 = materialize_temporary -// CHECK:STDOUT: %.loc15_34.2: i32 = call @B() to %.loc15_34.1 -// CHECK:STDOUT: assign %.loc15_34.1, %.loc15_34.2 -// CHECK:STDOUT: %.loc15_34.3: i32 = value_binding %.loc15_34.1 +// CHECK:STDOUT: %.loc15_34.1: i32 = call @B() +// CHECK:STDOUT: %.loc15_34.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc15_34.2, %.loc15_34.1 +// CHECK:STDOUT: %.loc15_34.3: i32 = value_binding %.loc15_34.2 // CHECK:STDOUT: br !if.expr.result(%.loc15_34.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: -// CHECK:STDOUT: %.loc15_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc15_10.2: i32 = initialize_from %.loc15_10.1 to %return -// CHECK:STDOUT: return %.loc15_10.2 +// CHECK:STDOUT: %.loc15_10: i32 = block_arg !if.expr.result +// CHECK:STDOUT: return %.loc15_10 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index 2efd247e1e8b5..b636d2690571c 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -13,9 +13,9 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type0, return_slot: node+12, body: {block8, block9, block10, block13}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block7, return_type: type0, body: {block8, block9, block10, block11}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -39,33 +39,30 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+10, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+8, type: type1}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+14}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+18}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+17, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+15}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block12, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+22}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+20}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+24}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, arg1: node+12, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+28}, +// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+19}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+18}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+22}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block11, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+25}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -75,59 +72,50 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+21, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+28, -// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -137,41 +125,38 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: %.loc10 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @A() -> %return: i32 { +// CHECK:STDOUT: fn @A() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_24.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_24.2: i32 = initialize_from %.loc7_24.1 to %return -// CHECK:STDOUT: return %.loc7_24.2 +// CHECK:STDOUT: %.loc7: i32 = int_literal 1 +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @B() -> %return: i32 { +// CHECK:STDOUT: fn @B() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_24.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc8_24.2: i32 = initialize_from %.loc8_24.1 to %return -// CHECK:STDOUT: return %.loc8_24.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 2 +// CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%b: bool) -> %return: i32 { +// CHECK:STDOUT: fn @F(%b: bool) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc10: bool = value_binding %b // CHECK:STDOUT: if %.loc10 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc11_21.1: i32 = materialize_temporary -// CHECK:STDOUT: %.loc11_21.2: i32 = call @A() to %.loc11_21.1 -// CHECK:STDOUT: assign %.loc11_21.1, %.loc11_21.2 -// CHECK:STDOUT: %.loc11_21.3: i32 = value_binding %.loc11_21.1 +// CHECK:STDOUT: %.loc11_21.1: i32 = call @A() +// CHECK:STDOUT: %.loc11_21.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_21.2, %.loc11_21.1 +// CHECK:STDOUT: %.loc11_21.3: i32 = value_binding %.loc11_21.2 // CHECK:STDOUT: br !if.expr.result(%.loc11_21.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_30.1: i32 = materialize_temporary -// CHECK:STDOUT: %.loc11_30.2: i32 = call @B() to %.loc11_30.1 -// CHECK:STDOUT: assign %.loc11_30.1, %.loc11_30.2 -// CHECK:STDOUT: %.loc11_30.3: i32 = value_binding %.loc11_30.1 +// CHECK:STDOUT: %.loc11_30.1: i32 = call @B() +// CHECK:STDOUT: %.loc11_30.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_30.2, %.loc11_30.1 +// CHECK:STDOUT: %.loc11_30.3: i32 = value_binding %.loc11_30.2 // CHECK:STDOUT: br !if.expr.result(%.loc11_30.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: -// CHECK:STDOUT: %.loc11_10.1: i32 = block_arg !if.expr.result -// CHECK:STDOUT: %.loc11_10.2: i32 = initialize_from %.loc11_10.1 to %return -// CHECK:STDOUT: return %.loc11_10.2 +// CHECK:STDOUT: %.loc11_10: i32 = block_arg !if.expr.result +// CHECK:STDOUT: return %.loc11_10 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index 9c4863a025596..2152bd447ecd5 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -10,7 +10,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+6, body: {block4, block5, block7, block8, block9, block6, block10, block11, block12, block13}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4, block5, block7, block8, block9, block6, block10, block11, block12, block13}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -63,8 +63,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+18}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+26}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+29, arg1: node+6, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+30}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+29}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -128,7 +127,6 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+29, // CHECK:STDOUT: node+30, -// CHECK:STDOUT: node+31, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -136,7 +134,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%a: bool, %b: bool, %c: bool) -> %return: i32 { +// CHECK:STDOUT: fn @F(%a: bool, %b: bool, %c: bool) -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_6: bool = value_binding %a // CHECK:STDOUT: if %.loc7_6 br !if.expr.then.loc8_10 else br !if.expr.else.loc8_10 @@ -174,7 +172,6 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: br !if.expr.result.loc8_10(%.loc8_44) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc8_10: -// CHECK:STDOUT: %.loc8_10.1: i32 = block_arg !if.expr.result.loc8_10 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 to %return -// CHECK:STDOUT: return %.loc8_10.2 +// CHECK:STDOUT: %.loc8_10: i32 = block_arg !if.expr.result.loc8_10 +// CHECK:STDOUT: return %.loc8_10 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/array_element_access.carbon b/toolchain/semantics/testdata/index/array_element_access.carbon index 4a3653b8327a2..3b3776fca4c55 100644 --- a/toolchain/semantics/testdata/index/array_element_access.carbon +++ b/toolchain/semantics/testdata/index/array_element_access.carbon @@ -50,26 +50,22 @@ var d: i32 = a[b]; // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+9, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+11}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+10}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+13, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+14}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+16, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+20, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+18, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+23}, +// CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+18, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+20}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+25, type: type0}, -// CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+13, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+27, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+28, arg1: node+25, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+29}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+22, type: type0}, +// CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+12, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+24, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+22, arg1: node+25}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -102,10 +98,6 @@ var d: i32 = a[b]; // CHECK:STDOUT: node+24, // CHECK:STDOUT: node+25, // CHECK:STDOUT: node+26, -// CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+28, -// CHECK:STDOUT: node+29, -// CHECK:STDOUT: node+30, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -124,21 +116,17 @@ var d: i32 = a[b]; // CHECK:STDOUT: %.loc7_26.1: type = tuple_type (i32, i32) // CHECK:STDOUT: %.loc7_26.2: (i32, i32) = tuple_value (%.loc7_20.2, %.loc7_24.2) // CHECK:STDOUT: %.loc7_26.3: [i32; 2] = array_value %.loc7_26.2 -// CHECK:STDOUT: %.loc7_26.4: [i32; 2] = initialize_from %.loc7_26.3 to %a -// CHECK:STDOUT: assign %a, %.loc7_26.4 +// CHECK:STDOUT: assign %a, %.loc7_26.3 // CHECK:STDOUT: %b: i32 = var -// CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1 to %b -// CHECK:STDOUT: assign %b, %.loc8_14.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 1 +// CHECK:STDOUT: assign %b, %.loc8 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 // CHECK:STDOUT: %.loc9_17.1: i32 = array_index %a, %.loc9_16 // CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 -// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2 to %c -// CHECK:STDOUT: assign %c, %.loc9_17.3 +// CHECK:STDOUT: assign %c, %.loc9_17.2 // CHECK:STDOUT: %d: i32 = var // CHECK:STDOUT: %.loc10_17.1: i32 = array_index %a, %b // CHECK:STDOUT: %.loc10_17.2: i32 = value_binding %.loc10_17.1 -// CHECK:STDOUT: %.loc10_17.3: i32 = initialize_from %.loc10_17.2 to %d -// CHECK:STDOUT: assign %d, %.loc10_17.3 +// CHECK:STDOUT: assign %d, %.loc10_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_array_large_index.carbon b/toolchain/semantics/testdata/index/fail_array_large_index.carbon index 3795c124c01a9..7ae6fc4a62ad5 100644 --- a/toolchain/semantics/testdata/index/fail_array_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_array_large_index.carbon @@ -44,13 +44,11 @@ var b: i32 = a[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+11, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+14}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -70,8 +68,6 @@ var b: i32 = a[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -87,10 +83,8 @@ var b: i32 = a[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_value (%.loc7_20.2) // CHECK:STDOUT: %.loc7_23.3: [i32; 1] = array_value %.loc7_23.2 -// CHECK:STDOUT: %.loc7_23.4: [i32; 1] = initialize_from %.loc7_23.3 to %a -// CHECK:STDOUT: assign %a, %.loc7_23.4 +// CHECK:STDOUT: assign %a, %.loc7_23.3 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal -1 -// CHECK:STDOUT: %.1: = initialize_from to %b -// CHECK:STDOUT: assign %b, %.1 +// CHECK:STDOUT: assign %b, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_array_non_int_indexing.carbon b/toolchain/semantics/testdata/index/fail_array_non_int_indexing.carbon index 21e1e8e2c2e37..634ac04a57836 100644 --- a/toolchain/semantics/testdata/index/fail_array_non_int_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_array_non_int_indexing.carbon @@ -45,13 +45,11 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+11, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+14}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -71,8 +69,6 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -88,10 +84,8 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_value (%.loc7_20.2) // CHECK:STDOUT: %.loc7_23.3: [i32; 1] = array_value %.loc7_23.2 -// CHECK:STDOUT: %.loc7_23.4: [i32; 1] = initialize_from %.loc7_23.3 to %a -// CHECK:STDOUT: assign %a, %.loc7_23.4 +// CHECK:STDOUT: assign %a, %.loc7_23.3 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 26e-1 -// CHECK:STDOUT: %.1: = initialize_from to %b -// CHECK:STDOUT: assign %b, %.1 +// CHECK:STDOUT: assign %b, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_array_out_of_bound_access.carbon b/toolchain/semantics/testdata/index/fail_array_out_of_bound_access.carbon index c44e3b602bc5b..6594e9db2e391 100644 --- a/toolchain/semantics/testdata/index/fail_array_out_of_bound_access.carbon +++ b/toolchain/semantics/testdata/index/fail_array_out_of_bound_access.carbon @@ -44,13 +44,11 @@ var b: i32 = a[2]; // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+11, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+14}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -70,8 +68,6 @@ var b: i32 = a[2]; // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -87,10 +83,8 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_23.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc7_23.2: (i32,) = tuple_value (%.loc7_20.2) // CHECK:STDOUT: %.loc7_23.3: [i32; 1] = array_value %.loc7_23.2 -// CHECK:STDOUT: %.loc7_23.4: [i32; 1] = initialize_from %.loc7_23.3 to %a -// CHECK:STDOUT: assign %a, %.loc7_23.4 +// CHECK:STDOUT: assign %a, %.loc7_23.3 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 2 -// CHECK:STDOUT: %.1: = initialize_from to %b -// CHECK:STDOUT: assign %b, %.1 +// CHECK:STDOUT: assign %b, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_name_not_found.carbon b/toolchain/semantics/testdata/index/fail_name_not_found.carbon index a010c69a6fbbc..f212e9a41e134 100644 --- a/toolchain/semantics/testdata/index/fail_name_not_found.carbon +++ b/toolchain/semantics/testdata/index/fail_name_not_found.carbon @@ -35,8 +35,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+1, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -51,7 +50,6 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -63,7 +61,6 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 0 -// CHECK:STDOUT: %.1: = initialize_from to %b -// CHECK:STDOUT: assign %b, %.1 +// CHECK:STDOUT: assign %b, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_negative_indexing.carbon b/toolchain/semantics/testdata/index/fail_negative_indexing.carbon index 27584697658ea..9de914e4612b9 100644 --- a/toolchain/semantics/testdata/index/fail_negative_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_negative_indexing.carbon @@ -52,10 +52,9 @@ var b: i32 = a[-10]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -78,7 +77,6 @@ var b: i32 = a[-10]; // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, diff --git a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon index 15ac2a9de6b2a..d5c13fc308c8b 100644 --- a/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon +++ b/toolchain/semantics/testdata/index/fail_non_deterministic_type.carbon @@ -54,17 +54,14 @@ var c: i32 = a[b]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+16, arg1: node+14, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+15}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+19, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+19, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+21}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+17, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -90,9 +87,6 @@ var c: i32 = a[b]; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -115,14 +109,11 @@ var c: i32 = a[b]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_25.1: i32 = int_literal 3 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 -// CHECK:STDOUT: %.loc7_26.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: %.loc7_26.2: (i32, i32) = initialize_from %.loc7_26.1 to %a -// CHECK:STDOUT: assign %a, %.loc7_26.2 +// CHECK:STDOUT: %.loc7_26: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) +// CHECK:STDOUT: assign %a, %.loc7_26 // CHECK:STDOUT: %b: i32 = var -// CHECK:STDOUT: %.loc8_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_14.2: i32 = initialize_from %.loc8_14.1 to %b -// CHECK:STDOUT: assign %b, %.loc8_14.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 0 +// CHECK:STDOUT: assign %b, %.loc8 // CHECK:STDOUT: %c: i32 = var -// CHECK:STDOUT: %.1: = initialize_from to %c -// CHECK:STDOUT: assign %c, %.1 +// CHECK:STDOUT: assign %c, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon b/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon index 3687025b1efb8..c92b7b1c17f90 100644 --- a/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon @@ -48,20 +48,17 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+13, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+14}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+16, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+18, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+21}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -87,9 +84,6 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -98,7 +92,7 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -110,17 +104,14 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %a: (i32,) = var // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 -// CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 to %a -// CHECK:STDOUT: assign %a, %.loc7_21.2 +// CHECK:STDOUT: %.loc7_21: (i32,) = tuple_value (%.loc7_18.2) +// CHECK:STDOUT: assign %a, %.loc7_21 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var -// CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 to %b -// CHECK:STDOUT: assign %b, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %a +// CHECK:STDOUT: assign %b, %.loc7_5 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc12: i32 = int_literal -1 -// CHECK:STDOUT: %.1: = initialize_from to %c -// CHECK:STDOUT: assign %c, %.1 +// CHECK:STDOUT: assign %c, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_tuple_non_int_indexing.carbon b/toolchain/semantics/testdata/index/fail_tuple_non_int_indexing.carbon index 3ea591abc79f0..f1b89b65d0df1 100644 --- a/toolchain/semantics/testdata/index/fail_tuple_non_int_indexing.carbon +++ b/toolchain/semantics/testdata/index/fail_tuple_non_int_indexing.carbon @@ -53,13 +53,11 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+14, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -82,8 +80,6 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -106,11 +102,9 @@ var b: i32 = a[2.6]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_26.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 -// CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 to %a -// CHECK:STDOUT: assign %a, %.loc7_27.2 +// CHECK:STDOUT: %.loc7_27: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) +// CHECK:STDOUT: assign %a, %.loc7_27 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 26e-1 -// CHECK:STDOUT: %.1: = initialize_from to %b -// CHECK:STDOUT: assign %b, %.1 +// CHECK:STDOUT: assign %b, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_tuple_out_of_bound_access.carbon b/toolchain/semantics/testdata/index/fail_tuple_out_of_bound_access.carbon index 20829cd84c5d1..2d7a0ebb48175 100644 --- a/toolchain/semantics/testdata/index/fail_tuple_out_of_bound_access.carbon +++ b/toolchain/semantics/testdata/index/fail_tuple_out_of_bound_access.carbon @@ -52,13 +52,11 @@ var b: i32 = a[2]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+14, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -81,8 +79,6 @@ var b: i32 = a[2]; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -105,11 +101,9 @@ var b: i32 = a[2]; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_26.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_26.2: i32 = stub_reference %.loc7_26.1 -// CHECK:STDOUT: %.loc7_27.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) -// CHECK:STDOUT: %.loc7_27.2: (i32, i32) = initialize_from %.loc7_27.1 to %a -// CHECK:STDOUT: assign %a, %.loc7_27.2 +// CHECK:STDOUT: %.loc7_27: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_26.2) +// CHECK:STDOUT: assign %a, %.loc7_27 // CHECK:STDOUT: %b: i32 = var // CHECK:STDOUT: %.loc11: i32 = int_literal 2 -// CHECK:STDOUT: %.1: = initialize_from to %b -// CHECK:STDOUT: assign %b, %.1 +// CHECK:STDOUT: assign %b, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/tuple_element_access.carbon b/toolchain/semantics/testdata/index/tuple_element_access.carbon index 5307ef88c3ced..62d864a0bdcbe 100644 --- a/toolchain/semantics/testdata/index/tuple_element_access.carbon +++ b/toolchain/semantics/testdata/index/tuple_element_access.carbon @@ -45,22 +45,19 @@ var c: i32 = b[0]; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+13, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+14}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+18, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+16, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+13, arg1: node+20, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+18, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+23}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+12, arg1: node+18, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -88,9 +85,6 @@ var c: i32 = b[0]; // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -99,7 +93,7 @@ var c: i32 = b[0]; // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -111,19 +105,16 @@ var c: i32 = b[0]; // CHECK:STDOUT: %a: (i32,) = var // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 12 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 -// CHECK:STDOUT: %.loc7_21.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_21.2: (i32,) = initialize_from %.loc7_21.1 to %a -// CHECK:STDOUT: assign %a, %.loc7_21.2 +// CHECK:STDOUT: %.loc7_21: (i32,) = tuple_value (%.loc7_18.2) +// CHECK:STDOUT: assign %a, %.loc7_21 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var -// CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %a -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 to %b -// CHECK:STDOUT: assign %b, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %a +// CHECK:STDOUT: assign %b, %.loc7_5 // CHECK:STDOUT: %c: i32 = var // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 // CHECK:STDOUT: %.loc9_17.1: i32 = tuple_index %b, %.loc9_16 // CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 -// CHECK:STDOUT: %.loc9_17.3: i32 = initialize_from %.loc9_17.2 to %c -// CHECK:STDOUT: assign %c, %.loc9_17.3 +// CHECK:STDOUT: assign %c, %.loc9_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/tuple_return_value_access.carbon b/toolchain/semantics/testdata/index/tuple_return_value_access.carbon index 28df3e8e0b8f2..3631fb6c7a7aa 100644 --- a/toolchain/semantics/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/semantics/testdata/index/tuple_return_value_access.carbon @@ -12,8 +12,8 @@ fn Run() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, return_slot: node+4, body: {block4}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, return_slot: node+11, body: {block7}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: {block4}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, body: {block7}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -48,18 +48,16 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, -// CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type2}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+14}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+13, arg1: node+15, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+17, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+18, arg1: node+11, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+19}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+12}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -76,33 +74,28 @@ fn Run() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -111,23 +104,21 @@ fn Run() -> i32 { // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: (i32,) { +// CHECK:STDOUT: fn @F() -> (i32,) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_28.1: i32 = int_literal 0 // CHECK:STDOUT: %.loc7_28.2: i32 = stub_reference %.loc7_28.1 -// CHECK:STDOUT: %.loc7_30.1: (i32,) = tuple_value (%.loc7_28.2) -// CHECK:STDOUT: %.loc7_30.2: (i32,) = initialize_from %.loc7_30.1 to %return -// CHECK:STDOUT: return %.loc7_30.2 +// CHECK:STDOUT: %.loc7_30: (i32,) = tuple_value (%.loc7_28.2) +// CHECK:STDOUT: return %.loc7_30 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Run() -> %return: i32 { +// CHECK:STDOUT: fn @Run() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10_11.1: (i32,) = materialize_temporary -// CHECK:STDOUT: %.loc10_11.2: (i32,) = call @F() to %.loc10_11.1 +// CHECK:STDOUT: %.loc10_11.1: (i32,) = call @F() // CHECK:STDOUT: %.loc10_14: i32 = int_literal 0 -// CHECK:STDOUT: assign %.loc10_11.1, %.loc10_11.2 -// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11.1, %.loc10_14 +// CHECK:STDOUT: %.loc10_11.2: (i32,) = materialize_temporary +// CHECK:STDOUT: assign %.loc10_11.2, %.loc10_11.1 +// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11.2, %.loc10_14 // CHECK:STDOUT: %.loc10_15.2: i32 = value_binding %.loc10_15.1 -// CHECK:STDOUT: %.loc10_15.3: i32 = initialize_from %.loc10_15.2 to %return -// CHECK:STDOUT: return %.loc10_15.3 +// CHECK:STDOUT: return %.loc10_15.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon index e14ba5a7a08a7..9be8431ffe94c 100644 --- a/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon +++ b/toolchain/semantics/testdata/ir/duplicate_name_same_line.carbon @@ -31,16 +31,14 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block3, arg1: node+6}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block3, arg1: node+5}, // CHECK:STDOUT: {kind: Branch, arg0: block4}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+9, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+9, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+9, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+10}, // CHECK:STDOUT: {kind: Branch, arg0: block4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -58,18 +56,16 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,17 +76,15 @@ fn A() { var n: i32 = 1; if (true) { var n: i32 = 2; } } // CHECK:STDOUT: fn @A() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n.loc7_14: i32 = var -// CHECK:STDOUT: %.loc7_23.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc7_23.2: i32 = initialize_from %.loc7_23.1 to %n.loc7_14 -// CHECK:STDOUT: assign %n.loc7_14, %.loc7_23.2 +// CHECK:STDOUT: %.loc7_23: i32 = int_literal 1 +// CHECK:STDOUT: assign %n.loc7_14, %.loc7_23 // CHECK:STDOUT: %.loc7_30: bool = bool_literal true // CHECK:STDOUT: if %.loc7_30 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n.loc7_42: i32 = var -// CHECK:STDOUT: %.loc7_51.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc7_51.2: i32 = initialize_from %.loc7_51.1 to %n.loc7_42 -// CHECK:STDOUT: assign %n.loc7_42, %.loc7_51.2 +// CHECK:STDOUT: %.loc7_51: i32 = int_literal 2 +// CHECK:STDOUT: assign %n.loc7_42, %.loc7_51 // CHECK:STDOUT: br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.else: diff --git a/toolchain/semantics/testdata/operators/and.carbon b/toolchain/semantics/testdata/operators/and.carbon index 1c65d2dd18533..910c7dc441b64 100644 --- a/toolchain/semantics/testdata/operators/and.carbon +++ b/toolchain/semantics/testdata/operators/and.carbon @@ -13,9 +13,9 @@ fn And() -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block9, block10}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: {block7, block8, block9}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -35,30 +35,27 @@ fn And() -> bool { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+13}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+20}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+22}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+24, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+25}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+17}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+20}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+22}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,51 +65,42 @@ fn And() -> bool { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+24, -// CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+26, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -122,38 +110,35 @@ fn And() -> bool { // CHECK:STDOUT: %.loc10 = fn_decl @And // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: bool { +// CHECK:STDOUT: fn @F() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 to %return -// CHECK:STDOUT: return %.loc7_25.2 +// CHECK:STDOUT: %.loc7: bool = bool_literal true +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() -> %return: bool { +// CHECK:STDOUT: fn @G() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 to %return -// CHECK:STDOUT: return %.loc8_25.2 +// CHECK:STDOUT: %.loc8: bool = bool_literal true +// CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @And() -> %return: bool { +// CHECK:STDOUT: fn @And() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11.1: bool = materialize_temporary -// CHECK:STDOUT: %.loc11_11.2: bool = call @F() to %.loc11_11.1 -// CHECK:STDOUT: assign %.loc11_11.1, %.loc11_11.2 -// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.1 +// CHECK:STDOUT: %.loc11_11.1: bool = call @F() +// CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary +// CHECK:STDOUT: assign %.loc11_11.2, %.loc11_11.1 +// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 // CHECK:STDOUT: %.loc11_14.1: bool = bool_literal false // CHECK:STDOUT: if %.loc11_11.3 br !and.rhs else br !and.result(%.loc11_14.1) // CHECK:STDOUT: // CHECK:STDOUT: !and.rhs: -// CHECK:STDOUT: %.loc11_19.1: bool = materialize_temporary -// CHECK:STDOUT: %.loc11_19.2: bool = call @G() to %.loc11_19.1 -// CHECK:STDOUT: assign %.loc11_19.1, %.loc11_19.2 -// CHECK:STDOUT: %.loc11_19.3: bool = value_binding %.loc11_19.1 +// CHECK:STDOUT: %.loc11_19.1: bool = call @G() +// CHECK:STDOUT: %.loc11_19.2: bool = materialize_temporary +// CHECK:STDOUT: assign %.loc11_19.2, %.loc11_19.1 +// CHECK:STDOUT: %.loc11_19.3: bool = value_binding %.loc11_19.2 // CHECK:STDOUT: br !and.result(%.loc11_19.3) // CHECK:STDOUT: // CHECK:STDOUT: !and.result: // CHECK:STDOUT: %.loc11_14.2: bool = block_arg !and.result -// CHECK:STDOUT: %.loc11_14.3: bool = initialize_from %.loc11_14.2 to %return -// CHECK:STDOUT: return %.loc11_14.3 +// CHECK:STDOUT: return %.loc11_14.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/assignment.carbon b/toolchain/semantics/testdata/operators/assignment.carbon index c938adf632f6a..957816e1fe3c7 100644 --- a/toolchain/semantics/testdata/operators/assignment.carbon +++ b/toolchain/semantics/testdata/operators/assignment.carbon @@ -53,10 +53,10 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+35, -// CHECK:STDOUT: node+55, +// CHECK:STDOUT: node+30, +// CHECK:STDOUT: node+47, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -74,80 +74,69 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+5}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+14, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+12, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, arg1: node+14, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+21}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+18}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+23, type: type0}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+12, arg1: node+20, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+24, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+24, arg1: node+26}, +// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+22}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+28, type: type0}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+12, arg1: node+24, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, arg1: node+29, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+29, arg1: node+31}, +// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+26}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+36, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+31, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+38, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+33, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+41, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+36, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+44, arg1: node+36, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+36, arg1: node+45}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+36, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+39}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+31, arg1: member0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+48, arg1: node+47, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+47, arg1: node+49}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+36, arg1: member1, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+41, arg1: node+42}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+31, arg1: member1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+52, arg1: node+51, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+51, arg1: node+53}, +// CHECK:STDOUT: {kind: Assign, arg0: node+44, arg1: node+45}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type4}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+56, type: type4}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+48, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+58, arg1: node+56, type: type4}, -// CHECK:STDOUT: {kind: Assign, arg0: node+56, arg1: node+59}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+56, type: type4}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+61, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+48, arg1: node+50}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+48, type: type4}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+52, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+63, arg1: node+62, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+62, arg1: node+64}, +// CHECK:STDOUT: {kind: Assign, arg0: node+53, arg1: node+54}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type5}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+66}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+56}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+56, type: type4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+48, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+69}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+70}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+59}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+60}, // CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type4}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+73, type: type0}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+63, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+75, arg1: node+74, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+74, arg1: node+76}, +// CHECK:STDOUT: {kind: Assign, arg0: node+64, arg1: node+65}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -190,13 +179,13 @@ fn Main() { // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+32, // CHECK:STDOUT: node+33, -// CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, -// CHECK:STDOUT: node+37, // CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, // CHECK:STDOUT: node+41, +// CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, // CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, @@ -213,52 +202,41 @@ fn Main() { // CHECK:STDOUT: node+56, // CHECK:STDOUT: node+57, // CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+59, -// CHECK:STDOUT: node+60, -// CHECK:STDOUT: node+61, -// CHECK:STDOUT: node+62, -// CHECK:STDOUT: node+63, -// CHECK:STDOUT: node+64, -// CHECK:STDOUT: node+65, -// CHECK:STDOUT: node+66, -// CHECK:STDOUT: node+67, -// CHECK:STDOUT: node+68, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+15, // CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+33, -// CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+39, -// CHECK:STDOUT: node+42, +// CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+37, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+40, -// CHECK:STDOUT: node+43, +// CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+38, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+69, -// CHECK:STDOUT: node+71, +// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+61, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+70, -// CHECK:STDOUT: node+72, +// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+62, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+73, -// CHECK:STDOUT: node+74, -// CHECK:STDOUT: node+75, -// CHECK:STDOUT: node+76, -// CHECK:STDOUT: node+77, -// CHECK:STDOUT: node+78, +// CHECK:STDOUT: node+63, +// CHECK:STDOUT: node+64, +// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+66, +// CHECK:STDOUT: node+67, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -269,12 +247,10 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var -// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 12 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %a -// CHECK:STDOUT: assign %a, %.loc8_16.2 -// CHECK:STDOUT: %.loc9_7.1: i32 = int_literal -7 -// CHECK:STDOUT: %.loc9_7.2: i32 = initialize_from %.loc9_7.1 to %a -// CHECK:STDOUT: assign %a, %.loc9_7.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 12 +// CHECK:STDOUT: assign %a, %.loc8 +// CHECK:STDOUT: %.loc9: i32 = int_literal -7 +// CHECK:STDOUT: assign %a, %.loc9 // CHECK:STDOUT: %.loc11_11: type = stub_reference i32 // CHECK:STDOUT: %.loc11_16: type = stub_reference i32 // CHECK:STDOUT: %.loc11_19.1: type = tuple_type (type, type) @@ -285,46 +261,38 @@ fn Main() { // CHECK:STDOUT: %.loc11_24.2: i32 = stub_reference %.loc11_24.1 // CHECK:STDOUT: %.loc11_27.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc11_27.2: i32 = stub_reference %.loc11_27.1 -// CHECK:STDOUT: %.loc11_28.1: (i32, i32) = tuple_value (%.loc11_24.2, %.loc11_27.2) -// CHECK:STDOUT: %.loc11_28.2: (i32, i32) = initialize_from %.loc11_28.1 to %b -// CHECK:STDOUT: assign %b, %.loc11_28.2 +// CHECK:STDOUT: %.loc11_28: (i32, i32) = tuple_value (%.loc11_24.2, %.loc11_27.2) +// CHECK:STDOUT: assign %b, %.loc11_28 // CHECK:STDOUT: %.loc12_5: i32 = int_literal 0 // CHECK:STDOUT: %.loc12_6: i32 = tuple_index %b, %.loc12_5 -// CHECK:STDOUT: %.loc12_10.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc12_10.2: i32 = initialize_from %.loc12_10.1 to %.loc12_6 -// CHECK:STDOUT: assign %.loc12_6, %.loc12_10.2 +// CHECK:STDOUT: %.loc12_10: i32 = int_literal 3 +// CHECK:STDOUT: assign %.loc12_6, %.loc12_10 // CHECK:STDOUT: %.loc13_5: i32 = int_literal 1 // CHECK:STDOUT: %.loc13_6: i32 = tuple_index %b, %.loc13_5 -// CHECK:STDOUT: %.loc13_10.1: i32 = int_literal 4 -// CHECK:STDOUT: %.loc13_10.2: i32 = initialize_from %.loc13_10.1 to %.loc13_6 -// CHECK:STDOUT: assign %.loc13_6, %.loc13_10.2 +// 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} // CHECK:STDOUT: %c: {.a: i32, .b: i32} = var // CHECK:STDOUT: %.loc15_37: i32 = int_literal 1 // CHECK:STDOUT: %.loc15_35: i32 = stub_reference %.loc15_37 // CHECK:STDOUT: %.loc15_45: i32 = int_literal 2 // CHECK:STDOUT: %.loc15_43: i32 = stub_reference %.loc15_45 -// CHECK:STDOUT: %.loc15_46.1: {.a: i32, .b: i32} = struct_value (%.loc15_35, %.loc15_43) -// CHECK:STDOUT: %.loc15_46.2: {.a: i32, .b: i32} = initialize_from %.loc15_46.1 to %c -// CHECK:STDOUT: assign %c, %.loc15_46.2 +// CHECK:STDOUT: %.loc15_46: {.a: i32, .b: i32} = struct_value (%.loc15_35, %.loc15_43) +// CHECK:STDOUT: assign %c, %.loc15_46 // CHECK:STDOUT: %.loc16_4: i32 = struct_access %c, member0 -// CHECK:STDOUT: %.loc16_9.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc16_9.2: i32 = initialize_from %.loc16_9.1 to %.loc16_4 -// CHECK:STDOUT: assign %.loc16_4, %.loc16_9.2 +// CHECK:STDOUT: %.loc16_9: i32 = int_literal 3 +// CHECK:STDOUT: assign %.loc16_4, %.loc16_9 // CHECK:STDOUT: %.loc17_4: i32 = struct_access %c, member1 -// CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 4 -// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 to %.loc17_4 -// CHECK:STDOUT: assign %.loc17_4, %.loc17_9.2 +// 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: i32* = var -// CHECK:STDOUT: %.loc19_17.1: i32* = address_of %a -// CHECK:STDOUT: %.loc19_17.2: i32* = initialize_from %.loc19_17.1 to %p -// CHECK:STDOUT: assign %p, %.loc19_17.2 +// CHECK:STDOUT: %.loc19_17: i32* = address_of %a +// CHECK:STDOUT: assign %p, %.loc19_17 // CHECK:STDOUT: %.loc19_7.1: i32* = value_binding %p // CHECK:STDOUT: %.loc20_3: i32 = dereference %.loc19_7.1 -// CHECK:STDOUT: %.loc20_8.1: i32 = int_literal 5 -// CHECK:STDOUT: %.loc20_8.2: i32 = initialize_from %.loc20_8.1 to %.loc20_3 -// CHECK:STDOUT: assign %.loc20_3, %.loc20_8.2 +// 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: @@ -339,8 +307,7 @@ fn Main() { // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc22_5: i32* = block_arg !if.expr.result // CHECK:STDOUT: %.loc22_3: i32 = dereference %.loc22_5 -// CHECK:STDOUT: %.loc22_31.1: i32 = int_literal 10 -// CHECK:STDOUT: %.loc22_31.2: i32 = initialize_from %.loc22_31.1 to %.loc22_3 -// CHECK:STDOUT: assign %.loc22_3, %.loc22_31.2 +// CHECK:STDOUT: %.loc22_31: i32 = int_literal 10 +// CHECK:STDOUT: assign %.loc22_3, %.loc22_31 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/binary_op.carbon b/toolchain/semantics/testdata/operators/binary_op.carbon index 5817dfa5db05f..2b94f47a2b007 100644 --- a/toolchain/semantics/testdata/operators/binary_op.carbon +++ b/toolchain/semantics/testdata/operators/binary_op.carbon @@ -10,7 +10,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -32,8 +32,7 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+3, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -49,7 +48,6 @@ fn Main() -> i32 { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -57,11 +55,10 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> %return: i32 { +// CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc8_15: i32 = int_literal 34 -// CHECK:STDOUT: %.loc8_13.1: i32 = add %.loc8_10, %.loc8_15 -// CHECK:STDOUT: %.loc8_13.2: i32 = initialize_from %.loc8_13.1 to %return -// CHECK:STDOUT: return %.loc8_13.2 +// CHECK:STDOUT: %.loc8_13: i32 = add %.loc8_10, %.loc8_15 +// CHECK:STDOUT: return %.loc8_13 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon index 49bf6b3e35bd5..d4495b71a8169 100644 --- a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -47,8 +47,8 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block3, block13, block14, block15, block16, block17, block18}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0}, +// CHECK:STDOUT: {name: str1, param_refs: block0, body: {block3, block12, block13, block14, block15, block16, block17}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -82,8 +82,8 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+51, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+44, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -98,87 +98,77 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+3, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+5}, -// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block4, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+4}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+9, arg1: node+8, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+10}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+15, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+20, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+17, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+23}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+19}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+25, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+21, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, arg1: node+25, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+28}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+23}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+25, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+32, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+35, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+37, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block8, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+39, arg1: node+34, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+34, arg1: node+40}, +// CHECK:STDOUT: {kind: Assign, arg0: node+29, arg1: node+34}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+42, arg1: nodeIntegerType, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+43}, +// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+36}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+45, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+38, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+48, type: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block9, type: typeTypeType}, -// CHECK:STDOUT: {kind: StructValue, arg0: block10, type: type2}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+41, type: type0}, +// CHECK:STDOUT: {kind: StructType, arg0: block8, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructValue, arg0: block9, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+53, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+46, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+56, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block12, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+59, arg1: node+52, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+52, arg1: node+60}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+49, type: type0}, +// CHECK:STDOUT: {kind: StructValue, arg0: block11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+45, arg1: node+52}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+62}, -// CHECK:STDOUT: {kind: Branch, arg0: block14}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block12, arg1: node+54}, +// CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int15, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+65}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+66}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block15, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+57}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+58}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int16, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+70, arg1: node+69, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+69, arg1: node+71}, +// CHECK:STDOUT: {kind: Assign, arg0: node+61, arg1: node+62}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+73, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+64, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block16, arg1: node+75}, -// CHECK:STDOUT: {kind: Branch, arg0: block17}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+73, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+73, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block18, arg1: node+78}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block18, arg1: node+79}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block18, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+66}, +// CHECK:STDOUT: {kind: Branch, arg0: block16}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+64, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+64, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+69}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+70}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block17, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int17, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+83, arg1: node+82, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+82, arg1: node+84}, +// CHECK:STDOUT: {kind: Assign, arg0: node+73, arg1: node+74}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -228,97 +218,84 @@ fn Main() { // CHECK:STDOUT: node+36, // CHECK:STDOUT: node+37, // CHECK:STDOUT: node+38, -// CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, // CHECK:STDOUT: node+41, -// CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, // CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, -// CHECK:STDOUT: node+47, +// CHECK:STDOUT: node+46, // CHECK:STDOUT: node+48, -// CHECK:STDOUT: node+50, +// CHECK:STDOUT: node+49, // CHECK:STDOUT: node+51, // CHECK:STDOUT: node+52, // CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+54, // CHECK:STDOUT: node+55, // CHECK:STDOUT: node+56, -// CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+59, -// CHECK:STDOUT: node+60, -// CHECK:STDOUT: node+61, -// CHECK:STDOUT: node+62, -// CHECK:STDOUT: node+63, -// CHECK:STDOUT: node+64, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+31, // CHECK:STDOUT: node+33, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+36, -// CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+39, +// CHECK:STDOUT: node+42, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+46, -// CHECK:STDOUT: node+49, +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+43, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+47, // CHECK:STDOUT: node+50, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+51, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+57, +// CHECK:STDOUT: node+59, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+55, // CHECK:STDOUT: node+58, +// CHECK:STDOUT: node+60, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+62, +// CHECK:STDOUT: node+63, +// CHECK:STDOUT: node+64, // CHECK:STDOUT: node+65, -// CHECK:STDOUT: node+67, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+66, +// CHECK:STDOUT: node+67, // CHECK:STDOUT: node+68, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+69, -// CHECK:STDOUT: node+70, // CHECK:STDOUT: node+71, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+70, // CHECK:STDOUT: node+72, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+73, // CHECK:STDOUT: node+74, // CHECK:STDOUT: node+75, // CHECK:STDOUT: node+76, -// CHECK:STDOUT: node+77, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+78, -// CHECK:STDOUT: node+80, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+79, -// CHECK:STDOUT: node+81, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+82, -// CHECK:STDOUT: node+83, -// CHECK:STDOUT: node+84, -// CHECK:STDOUT: node+85, -// CHECK:STDOUT: node+86, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -327,19 +304,16 @@ fn Main() { // CHECK:STDOUT: %.loc9 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: i32; +// CHECK:STDOUT: fn @F() -> i32; // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc13_3: i32 = int_literal 1 -// CHECK:STDOUT: %.loc13_7.1: i32 = int_literal 2 -// CHECK:STDOUT: %.loc13_7.2: i32 = initialize_from %.loc13_7.1 to %.loc13_3 -// CHECK:STDOUT: assign %.loc13_3, %.loc13_7.2 -// CHECK:STDOUT: %.loc17_4.1: i32 = materialize_temporary -// CHECK:STDOUT: %.loc17_4.2: i32 = call @F() to %.loc17_4.1 -// CHECK:STDOUT: %.loc17_9.1: i32 = int_literal 1 -// CHECK:STDOUT: %.loc17_9.2: i32 = initialize_from %.loc17_9.1 to %.loc17_4.2 -// CHECK:STDOUT: assign %.loc17_4.2, %.loc17_9.2 +// CHECK:STDOUT: %.loc13_7: i32 = int_literal 2 +// CHECK:STDOUT: assign %.loc13_3, %.loc13_7 +// CHECK:STDOUT: %.loc17_4: i32 = call @F() +// CHECK:STDOUT: %.loc17_9: i32 = int_literal 1 +// CHECK:STDOUT: assign %.loc17_4, %.loc17_9 // CHECK:STDOUT: %.loc21_4.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc21_4.2: i32 = stub_reference %.loc21_4.1 // CHECK:STDOUT: %.loc21_7.1: i32 = int_literal 2 @@ -350,13 +324,11 @@ fn Main() { // CHECK:STDOUT: %.loc21_13.2: i32 = stub_reference %.loc21_13.1 // CHECK:STDOUT: %.loc21_16.1: i32 = int_literal 4 // CHECK:STDOUT: %.loc21_16.2: i32 = stub_reference %.loc21_16.1 -// CHECK:STDOUT: %.loc21_17.1: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) -// CHECK:STDOUT: %.loc21_17.2: (i32, i32) = initialize_from %.loc21_17.1 to %.loc21_8.2 -// CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17.2 +// CHECK:STDOUT: %.loc21_17: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) +// CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17 // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc22_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc22_16.2: i32 = initialize_from %.loc22_16.1 to %n -// CHECK:STDOUT: assign %n, %.loc22_16.2 +// CHECK:STDOUT: %.loc22_16: i32 = int_literal 0 +// CHECK:STDOUT: assign %n, %.loc22_16 // CHECK:STDOUT: %.loc22_7.1: i32 = value_binding %n // CHECK:STDOUT: %.loc26_4: i32 = stub_reference %.loc22_7.1 // CHECK:STDOUT: %.loc22_7.2: i32 = value_binding %n @@ -366,12 +338,10 @@ fn Main() { // CHECK:STDOUT: %.loc26_13.2: i32 = stub_reference %.loc26_13.1 // CHECK:STDOUT: %.loc26_16.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc26_16.2: i32 = stub_reference %.loc26_16.1 -// CHECK:STDOUT: %.loc26_17.1: (i32, i32) = tuple_value (%.loc26_13.2, %.loc26_16.2) -// CHECK:STDOUT: %.loc26_17.2: (i32, i32) = initialize_from %.loc26_17.1 to %.loc26_8 -// CHECK:STDOUT: assign %.loc26_8, %.loc26_17.2 -// CHECK:STDOUT: %.loc30_12.1: type = ptr_type i32 -// CHECK:STDOUT: %.loc30_12.2: type = initialize_from %.loc30_12.1 to i32 -// CHECK:STDOUT: assign i32, %.loc30_12.2 +// CHECK:STDOUT: %.loc26_17: (i32, i32) = tuple_value (%.loc26_13.2, %.loc26_16.2) +// CHECK:STDOUT: assign %.loc26_8, %.loc26_17 +// CHECK:STDOUT: %.loc30: type = ptr_type i32 +// CHECK:STDOUT: assign i32, %.loc30 // CHECK:STDOUT: %.loc34_9: i32 = int_literal 1 // CHECK:STDOUT: %.loc34_7: i32 = stub_reference %.loc34_9 // CHECK:STDOUT: %.loc34_17: i32 = int_literal 2 @@ -382,9 +352,8 @@ fn Main() { // CHECK:STDOUT: %.loc34_26: i32 = stub_reference %.loc34_28 // CHECK:STDOUT: %.loc34_36: i32 = int_literal 4 // CHECK:STDOUT: %.loc34_34: i32 = stub_reference %.loc34_36 -// CHECK:STDOUT: %.loc34_37.1: {.x: i32, .y: i32} = struct_value (%.loc34_26, %.loc34_34) -// CHECK:STDOUT: %.loc34_37.2: {.x: i32, .y: i32} = initialize_from %.loc34_37.1 to %.loc34_18.2 -// CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37.2 +// CHECK:STDOUT: %.loc34_37: {.x: i32, .y: i32} = struct_value (%.loc34_26, %.loc34_34) +// CHECK:STDOUT: assign %.loc34_18.2, %.loc34_37 // CHECK:STDOUT: %.loc38_7: bool = bool_literal true // CHECK:STDOUT: if %.loc38_7 br !if.expr.then.loc38 else br !if.expr.else.loc38 // CHECK:STDOUT: @@ -398,9 +367,8 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc38: // CHECK:STDOUT: %.loc38_4: i32 = block_arg !if.expr.result.loc38 -// CHECK:STDOUT: %.loc38_29.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc38_29.2: i32 = initialize_from %.loc38_29.1 to %.loc38_4 -// CHECK:STDOUT: assign %.loc38_4, %.loc38_29.2 +// CHECK:STDOUT: %.loc38_29: i32 = int_literal 3 +// CHECK:STDOUT: assign %.loc38_4, %.loc38_29 // CHECK:STDOUT: %a: i32 = var // CHECK:STDOUT: %.loc45_7: bool = bool_literal true // CHECK:STDOUT: if %.loc45_7 br !if.expr.then.loc45 else br !if.expr.else.loc45 @@ -415,8 +383,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc45: // CHECK:STDOUT: %.loc45_4: i32 = block_arg !if.expr.result.loc45 -// CHECK:STDOUT: %.loc45_29.1: i32 = int_literal 10 -// CHECK:STDOUT: %.loc45_29.2: i32 = initialize_from %.loc45_29.1 to %.loc45_4 -// CHECK:STDOUT: assign %.loc45_4, %.loc45_29.2 +// CHECK:STDOUT: %.loc45_29: i32 = int_literal 10 +// CHECK:STDOUT: assign %.loc45_4, %.loc45_29 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon index 2dde457080819..69295ea2741ac 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -36,8 +36,7 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+3, type: typeError}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+0, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -53,7 +52,6 @@ fn Main() -> i32 { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -61,11 +59,10 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> %return: i32 { +// CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc11_15: f64 = real_literal 34e-1 // CHECK:STDOUT: %.loc11_13: = add , %.loc11_15 -// CHECK:STDOUT: %.1: = initialize_from to %return -// CHECK:STDOUT: return %.1 +// CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon index 62198639cb98f..d5e2a6a7045b0 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon @@ -37,11 +37,9 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+1, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -58,8 +56,6 @@ fn Main() { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -70,11 +66,9 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %a: i32 = var -// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 3 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %a -// CHECK:STDOUT: assign %a, %.loc8_16.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 3 +// CHECK:STDOUT: assign %a, %.loc8 // CHECK:STDOUT: %.loc12: f64 = real_literal 56e-1 -// CHECK:STDOUT: %.1: = initialize_from to %a -// CHECK:STDOUT: assign %a, %.1 +// CHECK:STDOUT: assign %a, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon index 60aa2884e3ed9..efa0a68d2658c 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon @@ -15,7 +15,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -41,8 +41,7 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+3, type: typeError}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+5, type: typeError}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+0, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -60,7 +59,6 @@ fn Main() -> i32 { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -68,13 +66,12 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> %return: i32 { +// CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc13_10: i32 = int_literal 12 // CHECK:STDOUT: %.loc13_15: f64 = real_literal 34e-1 // CHECK:STDOUT: %.loc13_13: = add , %.loc13_15 // CHECK:STDOUT: %.loc13_21: i32 = int_literal 12 // CHECK:STDOUT: %.loc13_19: = add , %.loc13_21 -// CHECK:STDOUT: %.1: = initialize_from to %return -// CHECK:STDOUT: return %.1 +// CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/or.carbon b/toolchain/semantics/testdata/operators/or.carbon index 3ca153eda52d2..385080bd1e960 100644 --- a/toolchain/semantics/testdata/operators/or.carbon +++ b/toolchain/semantics/testdata/operators/or.carbon @@ -13,9 +13,9 @@ fn Or() -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, return_slot: node+5, body: {block5}}}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, return_slot: node+10, body: {block7, block9, block10}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: {block5}}}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: {block7, block8, block9}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -35,31 +35,28 @@ fn Or() -> bool { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block8, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+13}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+15, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+16}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+17}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+14}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+15}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block11, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+21}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+23}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+25, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+26}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+18}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+21}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -69,52 +66,43 @@ fn Or() -> bool { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, // CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+24, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+25, -// CHECK:STDOUT: node+26, -// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -124,39 +112,36 @@ fn Or() -> bool { // CHECK:STDOUT: %.loc10 = fn_decl @Or // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: bool { +// CHECK:STDOUT: fn @F() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc7_25.2: bool = initialize_from %.loc7_25.1 to %return -// CHECK:STDOUT: return %.loc7_25.2 +// CHECK:STDOUT: %.loc7: bool = bool_literal true +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() -> %return: bool { +// CHECK:STDOUT: fn @G() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_25.1: bool = bool_literal true -// CHECK:STDOUT: %.loc8_25.2: bool = initialize_from %.loc8_25.1 to %return -// CHECK:STDOUT: return %.loc8_25.2 +// CHECK:STDOUT: %.loc8: bool = bool_literal true +// CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Or() -> %return: bool { +// CHECK:STDOUT: fn @Or() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11.1: bool = materialize_temporary -// CHECK:STDOUT: %.loc11_11.2: bool = call @F() to %.loc11_11.1 -// CHECK:STDOUT: assign %.loc11_11.1, %.loc11_11.2 -// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.1 +// CHECK:STDOUT: %.loc11_11.1: bool = call @F() +// CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary +// CHECK:STDOUT: assign %.loc11_11.2, %.loc11_11.1 +// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 // CHECK:STDOUT: %.loc11_14.1: bool = not %.loc11_11.3 // CHECK:STDOUT: %.loc11_14.2: bool = bool_literal true // CHECK:STDOUT: if %.loc11_14.1 br !or.rhs else br !or.result(%.loc11_14.2) // CHECK:STDOUT: // CHECK:STDOUT: !or.rhs: -// CHECK:STDOUT: %.loc11_18.1: bool = materialize_temporary -// CHECK:STDOUT: %.loc11_18.2: bool = call @G() to %.loc11_18.1 -// CHECK:STDOUT: assign %.loc11_18.1, %.loc11_18.2 -// CHECK:STDOUT: %.loc11_18.3: bool = value_binding %.loc11_18.1 +// CHECK:STDOUT: %.loc11_18.1: bool = call @G() +// CHECK:STDOUT: %.loc11_18.2: bool = materialize_temporary +// CHECK:STDOUT: assign %.loc11_18.2, %.loc11_18.1 +// CHECK:STDOUT: %.loc11_18.3: bool = value_binding %.loc11_18.2 // CHECK:STDOUT: br !or.result(%.loc11_18.3) // CHECK:STDOUT: // CHECK:STDOUT: !or.result: // CHECK:STDOUT: %.loc11_14.3: bool = block_arg !or.result -// CHECK:STDOUT: %.loc11_14.4: bool = initialize_from %.loc11_14.3 to %return -// CHECK:STDOUT: return %.loc11_14.4 +// CHECK:STDOUT: return %.loc11_14.3 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/unary_op.carbon b/toolchain/semantics/testdata/operators/unary_op.carbon index 38abcf2d2652d..0c053fe2cba9d 100644 --- a/toolchain/semantics/testdata/operators/unary_op.carbon +++ b/toolchain/semantics/testdata/operators/unary_op.carbon @@ -10,7 +10,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, return_slot: node+2, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -32,8 +32,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+4, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+5, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -53,7 +52,6 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -61,10 +59,9 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: %.loc7 = fn_decl @Not // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Not(%b: bool) -> %return: bool { +// CHECK:STDOUT: fn @Not(%b: bool) -> bool { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7: bool = value_binding %b -// CHECK:STDOUT: %.loc8_10.1: bool = not %.loc7 -// CHECK:STDOUT: %.loc8_10.2: bool = initialize_from %.loc8_10.1 to %return -// CHECK:STDOUT: return %.loc8_10.2 +// CHECK:STDOUT: %.loc8: bool = not %.loc7 +// CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_deref.carbon b/toolchain/semantics/testdata/pointer/address_of_deref.carbon index 16a59c5eb4e4f..c6bc2244b6976 100644 --- a/toolchain/semantics/testdata/pointer/address_of_deref.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_deref.carbon @@ -11,7 +11,7 @@ fn F() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -24,7 +24,7 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -34,16 +34,14 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+2, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+9, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+10, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -66,8 +64,6 @@ fn F() -> i32 { // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -75,18 +71,16 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: i32 { +// CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %n -// CHECK:STDOUT: assign %n, %.loc8_16.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 0 +// CHECK:STDOUT: assign %n, %.loc8 // CHECK:STDOUT: %.loc9_13.1: type = ptr_type i32 // CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n // CHECK:STDOUT: %.loc9_12: i32 = dereference %.loc9_13.2 // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 // CHECK:STDOUT: %.loc9_10.1: i32 = dereference %.loc9_11 // CHECK:STDOUT: %.loc9_10.2: i32 = value_binding %.loc9_10.1 -// CHECK:STDOUT: %.loc9_10.3: i32 = initialize_from %.loc9_10.2 to %return -// CHECK:STDOUT: return %.loc9_10.3 +// CHECK:STDOUT: return %.loc9_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon index afe3d107a771f..2b19bf04dfba2 100644 --- a/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_lvalue.carbon @@ -51,10 +51,10 @@ fn F(param: i32) { // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+26, -// CHECK:STDOUT: node+42, -// CHECK:STDOUT: node+44, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+40, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -82,67 +82,59 @@ fn F(param: i32) { // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, arg1: node+6, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+15}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+14}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block8, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+21, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str5, arg1: node+20, type: type2}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+6, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+23, arg1: node+21, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+24}, +// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+22}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str6, arg1: node+27, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str6, arg1: node+25, type: type3}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+6, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+29, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+30, arg1: node+27, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+27, arg1: node+31}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+27, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+28}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str7, arg1: node+34, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str7, arg1: node+31, type: type3}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+6, arg1: member1, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+36, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+37, arg1: node+34, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+34, arg1: node+38}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+33, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+34}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block9, type: type4}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type5}, -// CHECK:STDOUT: {kind: BindName, arg0: str8, arg1: node+45, type: type5}, +// CHECK:STDOUT: {kind: BindName, arg0: str8, arg1: node+41, type: type5}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+47, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+43, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+49, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+45, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block10, type: type5}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+51, arg1: node+45, type: type5}, -// CHECK:STDOUT: {kind: Assign, arg0: node+45, arg1: node+52}, +// CHECK:STDOUT: {kind: Assign, arg0: node+41, arg1: node+47}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str9, arg1: node+55, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str9, arg1: node+50, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+45, arg1: node+57, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+58, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+59, arg1: node+55, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+55, arg1: node+60}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+41, arg1: node+52, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+53, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+50, arg1: node+54}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str10, arg1: node+63, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str10, arg1: node+57, type: type3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+45, arg1: node+65, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+66, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+67, arg1: node+63, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+63, arg1: node+68}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+41, arg1: node+59, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+60, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+57, arg1: node+61}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str11, arg1: node+71, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str11, arg1: node+64, type: type3}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+0, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+73, arg1: node+71, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+71, arg1: node+74}, +// CHECK:STDOUT: {kind: Assign, arg0: node+64, arg1: node+66}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -223,14 +215,6 @@ fn F(param: i32) { // CHECK:STDOUT: node+66, // CHECK:STDOUT: node+67, // CHECK:STDOUT: node+68, -// CHECK:STDOUT: node+69, -// CHECK:STDOUT: node+70, -// CHECK:STDOUT: node+71, -// CHECK:STDOUT: node+72, -// CHECK:STDOUT: node+73, -// CHECK:STDOUT: node+74, -// CHECK:STDOUT: node+75, -// CHECK:STDOUT: node+76, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, @@ -245,16 +229,16 @@ fn F(param: i32) { // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+40, -// CHECK:STDOUT: node+41, +// CHECK:STDOUT: node+36, +// CHECK:STDOUT: node+37, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+48, -// CHECK:STDOUT: node+50, +// CHECK:STDOUT: node+44, +// CHECK:STDOUT: node+46, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -270,27 +254,23 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc8_35: i32 = stub_reference %.loc8_37 // CHECK:STDOUT: %.loc8_45: i32 = int_literal 2 // CHECK:STDOUT: %.loc8_43: i32 = stub_reference %.loc8_45 -// CHECK:STDOUT: %.loc8_46.1: {.a: i32, .b: i32} = struct_value (%.loc8_35, %.loc8_43) -// CHECK:STDOUT: %.loc8_46.2: {.a: i32, .b: i32} = initialize_from %.loc8_46.1 to %s -// CHECK:STDOUT: assign %s, %.loc8_46.2 +// CHECK:STDOUT: %.loc8_46: {.a: i32, .b: i32} = struct_value (%.loc8_35, %.loc8_43) +// CHECK:STDOUT: assign %s, %.loc8_46 // 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: {.a: i32, .b: i32}* = var -// CHECK:STDOUT: %.loc10_32.1: {.a: i32, .b: i32}* = address_of %s -// CHECK:STDOUT: %.loc10_32.2: {.a: i32, .b: i32}* = initialize_from %.loc10_32.1 to %p -// CHECK:STDOUT: assign %p, %.loc10_32.2 +// CHECK:STDOUT: %.loc10_32: {.a: i32, .b: i32}* = address_of %s +// CHECK:STDOUT: assign %p, %.loc10_32 // CHECK:STDOUT: %.loc11_13: type = ptr_type i32 // CHECK:STDOUT: %q: i32* = var // CHECK:STDOUT: %.loc11_19: i32 = struct_access %s, member0 -// CHECK:STDOUT: %.loc11_17.1: i32* = address_of %.loc11_19 -// CHECK:STDOUT: %.loc11_17.2: i32* = initialize_from %.loc11_17.1 to %q -// CHECK:STDOUT: assign %q, %.loc11_17.2 +// 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: i32* = var // CHECK:STDOUT: %.loc12_19: i32 = struct_access %s, member1 -// CHECK:STDOUT: %.loc12_17.1: i32* = address_of %.loc12_19 -// CHECK:STDOUT: %.loc12_17.2: i32* = initialize_from %.loc12_17.1 to %r -// CHECK:STDOUT: assign %r, %.loc12_17.2 +// CHECK:STDOUT: %.loc12_17: i32* = address_of %.loc12_19 +// CHECK:STDOUT: assign %r, %.loc12_17 // CHECK:STDOUT: %.loc14_11: type = stub_reference i32 // CHECK:STDOUT: %.loc14_16: type = stub_reference i32 // CHECK:STDOUT: %.loc14_19.1: type = tuple_type (type, type) @@ -301,27 +281,23 @@ fn F(param: i32) { // CHECK:STDOUT: %.loc14_24.2: i32 = stub_reference %.loc14_24.1 // CHECK:STDOUT: %.loc14_27.1: i32 = int_literal 2 // CHECK:STDOUT: %.loc14_27.2: i32 = stub_reference %.loc14_27.1 -// CHECK:STDOUT: %.loc14_28.1: (i32, i32) = tuple_value (%.loc14_24.2, %.loc14_27.2) -// CHECK:STDOUT: %.loc14_28.2: (i32, i32) = initialize_from %.loc14_28.1 to %t -// CHECK:STDOUT: assign %t, %.loc14_28.2 +// CHECK:STDOUT: %.loc14_28: (i32, i32) = tuple_value (%.loc14_24.2, %.loc14_27.2) +// CHECK:STDOUT: assign %t, %.loc14_28 // CHECK:STDOUT: %.loc15_14: type = ptr_type i32 // CHECK:STDOUT: %t0: i32* = var // CHECK:STDOUT: %.loc15_21: i32 = int_literal 0 // CHECK:STDOUT: %.loc15_22: i32 = tuple_index %t, %.loc15_21 -// CHECK:STDOUT: %.loc15_18.1: i32* = address_of %.loc15_22 -// CHECK:STDOUT: %.loc15_18.2: i32* = initialize_from %.loc15_18.1 to %t0 -// CHECK:STDOUT: assign %t0, %.loc15_18.2 +// 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: i32* = var // CHECK:STDOUT: %.loc16_21: i32 = int_literal 1 // CHECK:STDOUT: %.loc16_22: i32 = tuple_index %t, %.loc16_21 -// CHECK:STDOUT: %.loc16_18.1: i32* = address_of %.loc16_22 -// CHECK:STDOUT: %.loc16_18.2: i32* = initialize_from %.loc16_18.1 to %t1 -// CHECK:STDOUT: assign %t1, %.loc16_18.2 +// CHECK:STDOUT: %.loc16_18: i32* = address_of %.loc16_22 +// CHECK:STDOUT: assign %t1, %.loc16_18 // CHECK:STDOUT: %.loc20_22: type = ptr_type i32 // CHECK:STDOUT: %param_addr: i32* = var -// CHECK:STDOUT: %.loc20_26.1: i32* = address_of %param -// CHECK:STDOUT: %.loc20_26.2: i32* = initialize_from %.loc20_26.1 to %param_addr -// CHECK:STDOUT: assign %param_addr, %.loc20_26.2 +// CHECK:STDOUT: %.loc20_26: i32* = address_of %param +// CHECK:STDOUT: assign %param_addr, %.loc20_26 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/basic.carbon b/toolchain/semantics/testdata/pointer/basic.carbon index ed125a90b3c17..03c44181f2c21 100644 --- a/toolchain/semantics/testdata/pointer/basic.carbon +++ b/toolchain/semantics/testdata/pointer/basic.carbon @@ -13,7 +13,7 @@ fn F() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -27,7 +27,7 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -37,19 +37,16 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+8, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+8, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+11}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+8, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+13, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+9}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -74,9 +71,6 @@ fn F() -> i32 { // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,20 +78,17 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F() -> %return: i32 { +// CHECK:STDOUT: fn @F() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %n: i32 = var -// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %n -// CHECK:STDOUT: assign %n, %.loc8_16.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 0 +// CHECK:STDOUT: assign %n, %.loc8 // CHECK:STDOUT: %.loc9_13: type = ptr_type i32 // CHECK:STDOUT: %p: i32* = var -// CHECK:STDOUT: %.loc9_17.1: i32* = address_of %n -// CHECK:STDOUT: %.loc9_17.2: i32* = initialize_from %.loc9_17.1 to %p -// CHECK:STDOUT: assign %p, %.loc9_17.2 +// CHECK:STDOUT: %.loc9_17: i32* = address_of %n +// CHECK:STDOUT: assign %p, %.loc9_17 // CHECK:STDOUT: %.loc9_7: i32* = value_binding %p // CHECK:STDOUT: %.loc11_10.1: i32 = dereference %.loc9_7 // CHECK:STDOUT: %.loc11_10.2: i32 = value_binding %.loc11_10.1 -// CHECK:STDOUT: %.loc11_10.3: i32 = initialize_from %.loc11_10.2 to %return -// CHECK:STDOUT: return %.loc11_10.3 +// CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon index 646e0b3c9cbdd..79f4ec2c8316d 100644 --- a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon @@ -77,13 +77,13 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, return_slot: node+4}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0}, +// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1}, // CHECK:STDOUT: {name: str3, param_refs: block0, body: {block5}}}, // CHECK:STDOUT: {name: str5, param_refs: block0, body: {block9}}}, -// CHECK:STDOUT: {name: str6, param_refs: block0, body: {block11}}}, -// CHECK:STDOUT: {name: str7, param_refs: block0, body: {block13}}}, -// CHECK:STDOUT: {name: str8, param_refs: block0, body: {block14}}}, +// CHECK:STDOUT: {name: str6, param_refs: block0, body: {block10}}}, +// CHECK:STDOUT: {name: str7, param_refs: block0, body: {block11}}}, +// CHECK:STDOUT: {name: str8, param_refs: block0, body: {block12}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -123,8 +123,8 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+25, // CHECK:STDOUT: node+31, -// CHECK:STDOUT: node+54, -// CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -172,36 +172,35 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+35, arg1: node+36, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+37, type: type2}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type1}, -// CHECK:STDOUT: {kind: Call, arg0: block10, arg1: function1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+39, arg1: node+40}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+39, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+40, arg1: node+39}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+40, arg1: member0, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+42, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, // CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+44, type: type3}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+45, type: type4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function4}, -// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, -// CHECK:STDOUT: {kind: Call, arg0: block12, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+50, type: type2}, +// CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+49, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function5}, // CHECK:STDOUT: {kind: PointerType, arg0: typeTypeType, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: nodeIntegerType, type: type12}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type13, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+57, type: type12}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+56, type: type12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+61, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+60, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+63, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block15, type: type9}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+62, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block13, type: type9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+65, arg1: node+66, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+67, type: type2}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+64, arg1: node+65, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+66, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -216,8 +215,8 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+34, // CHECK:STDOUT: node+48, -// CHECK:STDOUT: node+53, -// CHECK:STDOUT: node+60, +// CHECK:STDOUT: node+52, +// CHECK:STDOUT: node+59, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, @@ -281,26 +280,20 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+47, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+39, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+49, // CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, -// CHECK:STDOUT: node+52, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+49, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+53, // CHECK:STDOUT: node+54, // CHECK:STDOUT: node+55, // CHECK:STDOUT: node+56, // CHECK:STDOUT: node+57, // CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+59, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, // CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, @@ -309,11 +302,10 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+66, // CHECK:STDOUT: node+67, // CHECK:STDOUT: node+68, -// CHECK:STDOUT: node+69, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+62, -// CHECK:STDOUT: node+64, +// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+63, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -327,9 +319,9 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: %.loc71 = fn_decl @AddressOfTupleElementValue // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() -> %return: i32; +// CHECK:STDOUT: fn @G() -> i32; // CHECK:STDOUT: -// CHECK:STDOUT: fn @H() -> %return: {.a: i32}; +// CHECK:STDOUT: fn @H() -> {.a: i32}; // CHECK:STDOUT: // CHECK:STDOUT: fn @AddressOfLiteral() { // CHECK:STDOUT: !entry: @@ -367,10 +359,10 @@ fn AddressOfTupleElementValue() { // 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: %.loc46_5.1: {.a: i32} = materialize_temporary -// CHECK:STDOUT: %.loc46_5.2: {.a: i32} = call @H() to %.loc46_5.1 -// CHECK:STDOUT: assign %.loc46_5.1, %.loc46_5.2 -// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5.1, member0 +// CHECK:STDOUT: %.loc46_5.1: {.a: i32} = call @H() +// CHECK:STDOUT: %.loc46_5.2: {.a: i32} = materialize_temporary +// CHECK:STDOUT: assign %.loc46_5.2, %.loc46_5.1 +// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5.2, member0 // CHECK:STDOUT: %.loc46_3: i32* = address_of %.loc46_7 // CHECK:STDOUT: %.loc50_9: bool = bool_literal true // CHECK:STDOUT: %.loc50_5: bool = not %.loc50_9 @@ -380,9 +372,8 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: // CHECK:STDOUT: fn @AddressOfCall() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc57_5.1: i32 = materialize_temporary -// CHECK:STDOUT: %.loc57_5.2: i32 = call @G() to %.loc57_5.1 -// CHECK:STDOUT: %.loc57_3: i32* = address_of %.loc57_5.2 +// CHECK:STDOUT: %.loc57_5: i32 = call @G() +// CHECK:STDOUT: %.loc57_3: i32* = address_of %.loc57_5 // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon index 9cf022f3e608a..2faa2d2aaa1ad 100644 --- a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type4, return_slot: node+9, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type4, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -44,8 +44,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: {kind: ConstType, arg0: type3, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type4}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+9, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -70,7 +69,6 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -78,8 +76,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: %.loc7 = fn_decl @ConstMismatch // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> %return: const ({}*) { +// CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> const ({}*) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.1: = initialize_from to %return -// CHECK:STDOUT: return %.1 +// CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index 5fd2af701b031..d8d830c77dc4f 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -11,7 +11,7 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+8, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -47,8 +47,7 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type3}, // CHECK:STDOUT: {kind: Dereference, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, arg1: node+8, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -77,7 +76,6 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -85,13 +83,12 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: %.loc8 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> %return: const i32 { +// CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8: const (const (const i32*)*) = value_binding %p // CHECK:STDOUT: %.loc9_11.1: const (const i32*) = dereference %.loc8 // CHECK:STDOUT: %.loc9_11.2: const (const i32*) = value_binding %.loc9_11.1 // CHECK:STDOUT: %.loc9_10.1: const i32 = dereference %.loc9_11.2 // CHECK:STDOUT: %.loc9_10.2: const i32 = value_binding %.loc9_10.1 -// CHECK:STDOUT: %.loc9_10.3: const i32 = initialize_from %.loc9_10.2 to %return -// CHECK:STDOUT: return %.loc9_10.3 +// CHECK:STDOUT: return %.loc9_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index 373ac1150d0fc..e72a6375e54ab 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -14,8 +14,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+4, body: {block4}}}, -// CHECK:STDOUT: {name: str2, param_refs: block6, return_type: type3, return_slot: node+15, body: {block7}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4}}}, +// CHECK:STDOUT: {name: str2, param_refs: block6, return_type: type3, body: {block7}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -29,8 +29,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -42,19 +42,17 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, arg1: node+4, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+11, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+10, type: type3}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, arg1: node+15, type: type3}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+18}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -71,29 +69,27 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, -// CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -102,16 +98,14 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: %.loc11 = fn_decl @ConstPtr // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Ptr(%p: i32*) -> %return: i32* { +// CHECK:STDOUT: fn @Ptr(%p: i32*) -> i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7_8.1: i32* = value_binding %p -// CHECK:STDOUT: %.loc7_8.2: i32* = initialize_from %.loc7_8.1 to %return -// CHECK:STDOUT: return %.loc7_8.2 +// CHECK:STDOUT: %.loc7: i32* = value_binding %p +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> %return: const i32* { +// CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> const i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_13.1: const i32* = value_binding %p -// CHECK:STDOUT: %.loc11_13.2: const i32* = initialize_from %.loc11_13.1 to %return -// CHECK:STDOUT: return %.loc11_13.2 +// CHECK:STDOUT: %.loc11: const i32* = value_binding %p +// CHECK:STDOUT: return %.loc11 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/code_after_return.carbon b/toolchain/semantics/testdata/return/code_after_return.carbon index 8a6a931fa8fe7..8f41406739118 100644 --- a/toolchain/semantics/testdata/return/code_after_return.carbon +++ b/toolchain/semantics/testdata/return/code_after_return.carbon @@ -36,8 +36,7 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+4, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+6, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index 7f58e61301a02..89ac7e59e0a64 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -18,7 +18,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, return_slot: node+2, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -44,25 +44,23 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+7, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+12, arg1: node+7, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+13}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+11}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+17, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+15, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+20}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+18}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+22}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+20}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, // CHECK:STDOUT: {kind: Branch, arg0: unreachable}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, @@ -84,7 +82,6 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -92,9 +89,8 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F(%b: bool) -> %return: i32 { +// CHECK:STDOUT: fn @F(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_10.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 to %return -// CHECK:STDOUT: return %.loc8_10.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 0 +// CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_missing_return.carbon b/toolchain/semantics/testdata/return/fail_missing_return.carbon index e0adca0e53f36..9e24986b622a0 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return.carbon @@ -12,7 +12,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -47,6 +47,6 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> %return: i32 { +// CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon index 38195d2dc87e6..503c58e6ccfc9 100644 --- a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -33,8 +33,7 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+0, type: typeError}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -48,7 +47,6 @@ fn Main() -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -56,9 +54,8 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> %return: i32 { +// CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc11: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.1: = initialize_from to %return -// CHECK:STDOUT: return %.1 +// CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/fail_value_missing.carbon b/toolchain/semantics/testdata/return/fail_value_missing.carbon index 7777409d2c980..8fe35217e480b 100644 --- a/toolchain/semantics/testdata/return/fail_value_missing.carbon +++ b/toolchain/semantics/testdata/return/fail_value_missing.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -50,7 +50,7 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> %return: i32 { +// CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/struct.carbon b/toolchain/semantics/testdata/return/struct.carbon index 0d00694e3fe5c..9fdf393ce9793 100644 --- a/toolchain/semantics/testdata/return/struct.carbon +++ b/toolchain/semantics/testdata/return/struct.carbon @@ -10,7 +10,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type1, return_slot: node+2, body: {block4}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type1, body: {block4}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 3, @@ -36,8 +36,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block6, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -58,7 +57,6 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -72,11 +70,10 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> %return: {.a: i32} { +// CHECK:STDOUT: fn @Main() -> {.a: i32} { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_16: i32 = int_literal 3 // CHECK:STDOUT: %.loc8_14: i32 = stub_reference %.loc8_16 -// CHECK:STDOUT: %.loc8_17.1: {.a: i32} = struct_value (%.loc8_14) -// CHECK:STDOUT: %.loc8_17.2: {.a: i32} = initialize_from %.loc8_17.1 to %return -// CHECK:STDOUT: return %.loc8_17.2 +// CHECK:STDOUT: %.loc8_17: {.a: i32} = struct_value (%.loc8_14) +// CHECK:STDOUT: return %.loc8_17 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/tuple.carbon b/toolchain/semantics/testdata/return/tuple.carbon index 51122f282cf21..5d89ab215240b 100644 --- a/toolchain/semantics/testdata/return/tuple.carbon +++ b/toolchain/semantics/testdata/return/tuple.carbon @@ -50,8 +50,8 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -96,7 +96,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: %.loc9_11.2: i32 = stub_reference %.loc9_11.1 // CHECK:STDOUT: %.loc9_15.1: i32 = int_literal 35 // CHECK:STDOUT: %.loc9_15.2: i32 = stub_reference %.loc9_15.1 -// CHECK:STDOUT: %.loc9_17.1: (i32, i32) = tuple_value (%.loc9_11.2, %.loc9_15.2) -// CHECK:STDOUT: %.loc9_17.2: (i32, i32) = initialize_from %.loc9_17.1 to %return -// CHECK:STDOUT: return %.loc9_17.2 +// CHECK:STDOUT: %.loc9_17: (i32, i32) = tuple_value (%.loc9_11.2, %.loc9_15.2) +// CHECK:STDOUT: assign %return, %.loc9_17 +// CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/value.carbon b/toolchain/semantics/testdata/return/value.carbon index 73d81ca65fdc4..ae9de7cbb686a 100644 --- a/toolchain/semantics/testdata/return/value.carbon +++ b/toolchain/semantics/testdata/return/value.carbon @@ -10,7 +10,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, return_slot: node+0, body: {block3}}}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: {block3}}}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -29,8 +29,7 @@ fn Main() -> i32 { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -44,7 +43,6 @@ fn Main() -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -52,9 +50,8 @@ fn Main() -> i32 { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> %return: i32 { +// CHECK:STDOUT: fn @Main() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc8_10.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_10.2: i32 = initialize_from %.loc8_10.1 to %return -// CHECK:STDOUT: return %.loc8_10.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 0 +// CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/empty.carbon b/toolchain/semantics/testdata/struct/empty.carbon index 5349719d2f67e..000e8c9c87c42 100644 --- a/toolchain/semantics/testdata/struct/empty.carbon +++ b/toolchain/semantics/testdata/struct/empty.carbon @@ -29,14 +29,12 @@ var y: {} = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+7, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+8, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+11}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -53,8 +51,6 @@ var y: {} = x; // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -62,12 +58,10 @@ var y: {} = x; // CHECK:STDOUT: %.loc7_9.1: type = struct_type {} // CHECK:STDOUT: %.loc7_9.2: {} = struct_value () // CHECK:STDOUT: %x: {} = var -// CHECK:STDOUT: %.loc7_14.1: {} = struct_value () -// CHECK:STDOUT: %.loc7_14.2: {} = initialize_from %.loc7_14.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_14.2 +// CHECK:STDOUT: %.loc7_14: {} = struct_value () +// CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %.loc8: {} = struct_value () // CHECK:STDOUT: %y: {} = var -// CHECK:STDOUT: %.loc7_5.1: {} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {} = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: {} = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon index d489b7883235f..281bfd86a5b46 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_empty.carbon @@ -34,8 +34,7 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: StructType, arg0: block0, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+6}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -48,7 +47,6 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -60,6 +58,5 @@ var x: {.a: i32} = {}; // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc10_21.1: type = struct_type {} // CHECK:STDOUT: %.loc10_21.2: {} = struct_value () -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_nested.carbon b/toolchain/semantics/testdata/struct/fail_assign_nested.carbon index 26adc09a3a867..dc1d228861fc2 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_nested.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_nested.carbon @@ -40,8 +40,7 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+4, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+11}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -58,7 +57,6 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, @@ -80,6 +78,5 @@ var x: {.a: {}} = {.b = {}}; // CHECK:STDOUT: %.loc10_23: {} = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: {}} // CHECK:STDOUT: %.loc10_27.2: {.b: {}} = struct_value (%.loc10_23) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon index 92b3bc77ea096..8b2dee0b3499f 100644 --- a/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/struct/fail_assign_to_empty.carbon @@ -38,8 +38,7 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type1}, // CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -54,7 +53,6 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, @@ -72,6 +70,5 @@ var x: {} = {.a = 1}; // CHECK:STDOUT: %.loc10_17: i32 = stub_reference %.loc10_19 // CHECK:STDOUT: %.loc10_20.1: type = struct_type {.a: i32} // CHECK:STDOUT: %.loc10_20.2: {.a: i32} = struct_value (%.loc10_17) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon index 29d87ad71648d..4dda1d4ef089c 100644 --- a/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_name_mismatch.carbon @@ -39,8 +39,7 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -55,7 +54,6 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -75,6 +73,5 @@ var x: {.a: i32} = {.b = 1}; // CHECK:STDOUT: %.loc10_24: i32 = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_27.1: type = struct_type {.b: i32} // CHECK:STDOUT: %.loc10_27.2: {.b: i32} = struct_value (%.loc10_24) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon index f5654b033cada..6fd1d840b0160 100644 --- a/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon +++ b/toolchain/semantics/testdata/struct/fail_field_type_mismatch.carbon @@ -40,8 +40,7 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type2}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -56,7 +55,6 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -76,6 +74,5 @@ var x: {.a: i32} = {.b = 1.0}; // CHECK:STDOUT: %.loc10_24: f64 = stub_reference %.loc10_26 // CHECK:STDOUT: %.loc10_29.1: type = struct_type {.b: f64} // CHECK:STDOUT: %.loc10_29.2: {.b: f64} = struct_value (%.loc10_24) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon index 5633dda5ab0a7..1ab4b768d5c06 100644 --- a/toolchain/semantics/testdata/struct/fail_member_access_type.carbon +++ b/toolchain/semantics/testdata/struct/fail_member_access_type.carbon @@ -40,12 +40,10 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+10, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+12}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+9, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+9, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -62,8 +60,6 @@ var y: i32 = x.b; // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -81,10 +77,8 @@ var y: i32 = x.b; // CHECK:STDOUT: %x: {.a: f64} = var // CHECK:STDOUT: %.loc7_26: f64 = real_literal 40e-1 // CHECK:STDOUT: %.loc7_24: f64 = stub_reference %.loc7_26 -// CHECK:STDOUT: %.loc7_29.1: {.a: f64} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_29.2: {.a: f64} = initialize_from %.loc7_29.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_29.2 +// CHECK:STDOUT: %.loc7_29: {.a: f64} = struct_value (%.loc7_24) +// CHECK:STDOUT: assign %x, %.loc7_29 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from to %y -// CHECK:STDOUT: assign %y, %.1 +// CHECK:STDOUT: assign %y, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon index a6f03be0f2692..2eb3db738db03 100644 --- a/toolchain/semantics/testdata/struct/fail_non_member_access.carbon +++ b/toolchain/semantics/testdata/struct/fail_non_member_access.carbon @@ -39,12 +39,10 @@ var y: i32 = x.b; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+10, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+10, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+12}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+9, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+9, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -61,8 +59,6 @@ var y: i32 = x.b; // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -80,10 +76,8 @@ var y: i32 = x.b; // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_24: i32 = stub_reference %.loc7_26 -// CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_27.2 +// CHECK:STDOUT: %.loc7_27: {.a: i32} = struct_value (%.loc7_24) +// CHECK:STDOUT: assign %x, %.loc7_27 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from to %y -// CHECK:STDOUT: assign %y, %.1 +// CHECK:STDOUT: assign %y, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon index b7f32b2cfb3ba..2df9cd76595da 100644 --- a/toolchain/semantics/testdata/struct/fail_too_few_values.carbon +++ b/toolchain/semantics/testdata/struct/fail_too_few_values.carbon @@ -40,8 +40,7 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+3, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+10}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -57,7 +56,6 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -78,6 +76,5 @@ var x: {.a: i32, .b: i32} = {.a = 1}; // CHECK:STDOUT: %.loc10_33: i32 = stub_reference %.loc10_35 // CHECK:STDOUT: %.loc10_36.1: type = struct_type {.a: i32} // CHECK:STDOUT: %.loc10_36.2: {.a: i32} = struct_value (%.loc10_33) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/fail_type_assign.carbon b/toolchain/semantics/testdata/struct/fail_type_assign.carbon index 76d90ccf1fc4e..63d7e1f661af6 100644 --- a/toolchain/semantics/testdata/struct/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/struct/fail_type_assign.carbon @@ -33,8 +33,7 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block3, type: typeTypeType}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+6}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -47,7 +46,6 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -61,6 +59,5 @@ var x: {.a: i32} = {.a: i32}; // CHECK:STDOUT: %.loc10_16: type = struct_type {.a: i32} // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc10_28: type = struct_type {.a: i32} -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/member_access.carbon b/toolchain/semantics/testdata/struct/member_access.carbon index 8b65b90e87951..22b50a13e522b 100644 --- a/toolchain/semantics/testdata/struct/member_access.carbon +++ b/toolchain/semantics/testdata/struct/member_access.carbon @@ -44,19 +44,16 @@ var z: i32 = y; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+3, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+11}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+14, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+13, type: type1}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+3, arg1: member1, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, arg1: node+14, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+18}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+15, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+20, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+22, arg1: node+20, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+23}, +// CHECK:STDOUT: {kind: BindName, arg0: str4, arg1: node+18, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -82,9 +79,6 @@ var z: i32 = y; // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -107,16 +101,13 @@ var z: i32 = y; // CHECK:STDOUT: %.loc7_33: f64 = stub_reference %.loc7_35 // CHECK:STDOUT: %.loc7_45: i32 = int_literal 1 // CHECK:STDOUT: %.loc7_43: i32 = stub_reference %.loc7_45 -// CHECK:STDOUT: %.loc7_46.1: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) -// CHECK:STDOUT: %.loc7_46.2: {.a: f64, .b: i32} = initialize_from %.loc7_46.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_46.2 +// CHECK:STDOUT: %.loc7_46: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) +// CHECK:STDOUT: assign %x, %.loc7_46 // CHECK:STDOUT: %y: i32 = var // CHECK:STDOUT: %.loc8_15.1: i32 = struct_access %x, member1 // CHECK:STDOUT: %.loc8_15.2: i32 = value_binding %.loc8_15.1 -// CHECK:STDOUT: %.loc8_15.3: i32 = initialize_from %.loc8_15.2 to %y -// CHECK:STDOUT: assign %y, %.loc8_15.3 +// CHECK:STDOUT: assign %y, %.loc8_15.2 // CHECK:STDOUT: %z: i32 = var -// CHECK:STDOUT: %.loc8_5.1: i32 = value_binding %y -// CHECK:STDOUT: %.loc8_5.2: i32 = initialize_from %.loc8_5.1 to %z -// CHECK:STDOUT: assign %z, %.loc8_5.2 +// CHECK:STDOUT: %.loc8_5: i32 = value_binding %y +// CHECK:STDOUT: assign %z, %.loc8_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/one_entry.carbon b/toolchain/semantics/testdata/struct/one_entry.carbon index dd7008c2a5329..deef6e8ed71aa 100644 --- a/toolchain/semantics/testdata/struct/one_entry.carbon +++ b/toolchain/semantics/testdata/struct/one_entry.carbon @@ -35,15 +35,13 @@ var y: {.a: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+8}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+7}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+12, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+11, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+14, arg1: node+12, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+15}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+13}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -63,8 +61,6 @@ var y: {.a: i32} = x; // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -76,7 +72,7 @@ var y: {.a: i32} = x; // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -85,12 +81,10 @@ var y: {.a: i32} = x; // CHECK:STDOUT: %x: {.a: i32} = var // CHECK:STDOUT: %.loc7_26: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_24: i32 = stub_reference %.loc7_26 -// CHECK:STDOUT: %.loc7_27.1: {.a: i32} = struct_value (%.loc7_24) -// CHECK:STDOUT: %.loc7_27.2: {.a: i32} = initialize_from %.loc7_27.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_27.2 +// CHECK:STDOUT: %.loc7_27: {.a: i32} = struct_value (%.loc7_24) +// CHECK:STDOUT: assign %x, %.loc7_27 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32} // CHECK:STDOUT: %y: {.a: i32} = var -// CHECK:STDOUT: %.loc7_5.1: {.a: i32} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32} = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: {.a: i32} = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/tuple_as_element.carbon b/toolchain/semantics/testdata/struct/tuple_as_element.carbon index a631604e1af2a..03d2d4f8b9524 100644 --- a/toolchain/semantics/testdata/struct/tuple_as_element.carbon +++ b/toolchain/semantics/testdata/struct/tuple_as_element.carbon @@ -55,18 +55,16 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type2}, // CHECK:STDOUT: {kind: StructValue, arg0: block5, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+17, arg1: node+7, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+18}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+17}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block8, type: type1}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type2}, // CHECK:STDOUT: {kind: StructType, arg0: block7, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+25, type: type3}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+24, type: type3}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+27, arg1: node+25, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+28}, +// CHECK:STDOUT: {kind: Assign, arg0: node+24, arg1: node+26}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -98,8 +96,6 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: node+25, // CHECK:STDOUT: node+26, // CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+28, -// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -120,11 +116,11 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -141,14 +137,12 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc7_47.2: i32 = stub_reference %.loc7_47.1 // CHECK:STDOUT: %.loc7_49: (i32,) = tuple_value (%.loc7_47.2) // CHECK:STDOUT: %.loc7_44: (i32,) = stub_reference %.loc7_49 -// CHECK:STDOUT: %.loc7_50.1: {.a: i32, .b: (i32,)} = struct_value (%.loc7_36, %.loc7_44) -// CHECK:STDOUT: %.loc7_50.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_50.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_50.2 +// CHECK:STDOUT: %.loc7_50: {.a: i32, .b: (i32,)} = struct_value (%.loc7_36, %.loc7_44) +// CHECK:STDOUT: assign %x, %.loc7_50 // CHECK:STDOUT: %.loc8_23: type = stub_reference i32 // CHECK:STDOUT: %.loc8_27: (type,) = tuple_value (%.loc8_23) // CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} // CHECK:STDOUT: %y: {.a: i32, .b: (i32,)} = var -// CHECK:STDOUT: %.loc7_5.1: {.a: i32, .b: (i32,)} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: (i32,)} = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: {.a: i32, .b: (i32,)} = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/two_entries.carbon b/toolchain/semantics/testdata/struct/two_entries.carbon index 62970ffd2348b..0c483be5c0cd4 100644 --- a/toolchain/semantics/testdata/struct/two_entries.carbon +++ b/toolchain/semantics/testdata/struct/two_entries.carbon @@ -41,16 +41,14 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+3, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+11}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type1}, -// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+17, type: type1}, +// CHECK:STDOUT: {kind: BindName, arg0: str3, arg1: node+16, type: type1}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+17, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+20}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -74,8 +72,6 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -90,8 +86,8 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -102,12 +98,10 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: %.loc7_33: i32 = stub_reference %.loc7_35 // CHECK:STDOUT: %.loc7_43: i32 = int_literal 2 // CHECK:STDOUT: %.loc7_41: i32 = stub_reference %.loc7_43 -// CHECK:STDOUT: %.loc7_44.1: {.a: i32, .b: i32} = struct_value (%.loc7_33, %.loc7_41) -// CHECK:STDOUT: %.loc7_44.2: {.a: i32, .b: i32} = initialize_from %.loc7_44.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_44.2 +// CHECK:STDOUT: %.loc7_44: {.a: i32, .b: i32} = struct_value (%.loc7_33, %.loc7_41) +// CHECK:STDOUT: assign %x, %.loc7_44 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %y: {.a: i32, .b: i32} = var -// CHECK:STDOUT: %.loc7_5.1: {.a: i32, .b: i32} = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: {.a: i32, .b: i32} = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: {.a: i32, .b: i32} = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/empty.carbon b/toolchain/semantics/testdata/tuples/empty.carbon index fc9c52c8a95f0..dd34dc3641838 100644 --- a/toolchain/semantics/testdata/tuples/empty.carbon +++ b/toolchain/semantics/testdata/tuples/empty.carbon @@ -31,14 +31,12 @@ var y: () = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+4, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+4}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+8, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+7, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+10, arg1: node+8, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+8, arg1: node+11}, +// CHECK:STDOUT: {kind: Assign, arg0: node+7, arg1: node+9}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -55,8 +53,6 @@ var y: () = x; // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -64,12 +60,10 @@ var y: () = x; // CHECK:STDOUT: %.loc7_9.1: type = tuple_type () // CHECK:STDOUT: %.loc7_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var -// CHECK:STDOUT: %.loc7_14.1: () = tuple_value () -// CHECK:STDOUT: %.loc7_14.2: () = initialize_from %.loc7_14.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_14.2 +// CHECK:STDOUT: %.loc7_14: () = tuple_value () +// CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %.loc8: () = tuple_value () // CHECK:STDOUT: %y: () = var -// CHECK:STDOUT: %.loc7_5.1: () = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: () = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: () = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon index 02ba0c7f84177..897bc026bb458 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_empty.carbon @@ -44,8 +44,7 @@ var x: (i32,) = (); // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+4, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -60,7 +59,6 @@ var x: (i32,) = (); // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -75,6 +73,5 @@ var x: (i32,) = (); // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc10_18.1: type = tuple_type () // CHECK:STDOUT: %.loc10_18.2: () = tuple_value () -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon b/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon index 18858c6c3f08b..1ee8f776a4a9c 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_nested.carbon @@ -96,8 +96,7 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: {kind: StubReference, arg0: node+30, type: type5}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock5, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type6}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+13, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+34}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -138,7 +137,6 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: node+32, // CHECK:STDOUT: node+33, // CHECK:STDOUT: node+34, -// CHECK:STDOUT: node+35, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -202,6 +200,5 @@ var x: ((i32, i32), (i32, i32)) = ((1, 2, 3), (4, 5, 6)); // CHECK:STDOUT: %.loc10_55.2: (i32, i32, i32) = stub_reference %.loc10_55.1 // CHECK:STDOUT: %.loc10_56.1: type = tuple_type ((i32, i32, i32), (i32, i32, i32)) // CHECK:STDOUT: %.loc10_56.2: ((i32, i32, i32), (i32, i32, i32)) = tuple_value (%.loc10_44.3, %.loc10_55.2) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon index 63afbd0bfc79a..3fe51b0fbaae4 100644 --- a/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon +++ b/toolchain/semantics/testdata/tuples/fail_assign_to_empty.carbon @@ -34,8 +34,7 @@ var x: () = (66); // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -47,7 +46,6 @@ var x: () = (66); // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -56,6 +54,5 @@ var x: () = (66); // CHECK:STDOUT: %.loc10_9.2: () = tuple_value () // CHECK:STDOUT: %x: () = var // CHECK:STDOUT: %.loc10_14: i32 = int_literal 66 -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon index 3bb87941f25ab..327a3da6ab6bf 100644 --- a/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon +++ b/toolchain/semantics/testdata/tuples/fail_element_type_mismatch.carbon @@ -56,8 +56,7 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type3}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type4}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+5, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+13}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -77,7 +76,6 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -102,6 +100,5 @@ var x: (i32, i32) = (2, 65.89); // CHECK:STDOUT: %.loc10_25.2: f64 = stub_reference %.loc10_25.1 // CHECK:STDOUT: %.loc10_30.1: type = tuple_type (i32, f64) // CHECK:STDOUT: %.loc10_30.2: (i32, f64) = tuple_value (%.loc10_22.2, %.loc10_25.2) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon index a124797b9364b..cb776bcc66b4c 100644 --- a/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon +++ b/toolchain/semantics/testdata/tuples/fail_too_few_element.carbon @@ -51,8 +51,7 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type1}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock2, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type3}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+5, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -70,7 +69,6 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -92,6 +90,5 @@ var x: (i32, i32) = (2, ); // CHECK:STDOUT: %.loc10_22.2: i32 = stub_reference %.loc10_22.1 // CHECK:STDOUT: %.loc10_25.1: type = tuple_type (i32) // CHECK:STDOUT: %.loc10_25.2: (i32,) = tuple_value (%.loc10_22.2) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon index 05a84c1348f0c..1ae3ac42ad377 100644 --- a/toolchain/semantics/testdata/tuples/fail_type_assign.carbon +++ b/toolchain/semantics/testdata/tuples/fail_type_assign.carbon @@ -41,8 +41,7 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+4, type: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+4, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -57,7 +56,6 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -75,6 +73,5 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc10_19: type = stub_reference i32 // CHECK:STDOUT: %.loc10_24: (type,) = tuple_value (%.loc10_19) -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/nested_tuple.carbon b/toolchain/semantics/testdata/tuples/nested_tuple.carbon index a023b323d6b91..d6d4f89ca1b19 100644 --- a/toolchain/semantics/testdata/tuples/nested_tuple.carbon +++ b/toolchain/semantics/testdata/tuples/nested_tuple.carbon @@ -66,8 +66,7 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type2}, // CHECK:STDOUT: {kind: StubReference, arg0: node+18, type: type2}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type4}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+20, arg1: node+10, type: type4}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+21}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+20}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -95,7 +94,6 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, -// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -135,7 +133,6 @@ var x: ((i32, i32), i32) = ((12, 76), 6); // CHECK:STDOUT: %.loc7_36.2: (i32, i32) = stub_reference %.loc7_36.1 // CHECK:STDOUT: %.loc7_39.1: i32 = int_literal 6 // CHECK:STDOUT: %.loc7_39.2: i32 = stub_reference %.loc7_39.1 -// CHECK:STDOUT: %.loc7_40.1: ((i32, i32), i32) = tuple_value (%.loc7_36.2, %.loc7_39.2) -// CHECK:STDOUT: %.loc7_40.2: ((i32, i32), i32) = initialize_from %.loc7_40.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_40.2 +// CHECK:STDOUT: %.loc7_40: ((i32, i32), i32) = tuple_value (%.loc7_36.2, %.loc7_39.2) +// CHECK:STDOUT: assign %x, %.loc7_40 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/one_element.carbon b/toolchain/semantics/testdata/tuples/one_element.carbon index f1041b640030e..c8fe061d609e8 100644 --- a/toolchain/semantics/testdata/tuples/one_element.carbon +++ b/toolchain/semantics/testdata/tuples/one_element.carbon @@ -42,15 +42,13 @@ var y: (i32,) = x; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+4, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+8}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+13, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+12, type: type2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+15, arg1: node+13, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -72,8 +70,6 @@ var y: (i32,) = x; // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -82,7 +78,7 @@ var y: (i32,) = x; // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -94,13 +90,11 @@ var y: (i32,) = x; // CHECK:STDOUT: %x: (i32,) = var // CHECK:STDOUT: %.loc7_18.1: i32 = int_literal 4 // CHECK:STDOUT: %.loc7_18.2: i32 = stub_reference %.loc7_18.1 -// CHECK:STDOUT: %.loc7_20.1: (i32,) = tuple_value (%.loc7_18.2) -// CHECK:STDOUT: %.loc7_20.2: (i32,) = initialize_from %.loc7_20.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_20.2 +// CHECK:STDOUT: %.loc7_20: (i32,) = tuple_value (%.loc7_18.2) +// CHECK:STDOUT: assign %x, %.loc7_20 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %y: (i32,) = var -// CHECK:STDOUT: %.loc7_5.1: (i32,) = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: (i32,) = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/two_elements.carbon b/toolchain/semantics/testdata/tuples/two_elements.carbon index 5a1ed55ef1edf..c5b88bab233f4 100644 --- a/toolchain/semantics/testdata/tuples/two_elements.carbon +++ b/toolchain/semantics/testdata/tuples/two_elements.carbon @@ -48,16 +48,14 @@ var y: (i32, i32) = x; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+11, arg1: node+5, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+12}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, type: type2}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+17, type: type2}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+16, type: type2}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type2}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+19, arg1: node+17, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+20}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -83,8 +81,6 @@ var y: (i32, i32) = x; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+20, -// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -95,8 +91,8 @@ var y: (i32, i32) = x; // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -111,14 +107,12 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %.loc7_22.2: i32 = stub_reference %.loc7_22.1 // CHECK:STDOUT: %.loc7_25.1: i32 = int_literal 102 // CHECK:STDOUT: %.loc7_25.2: i32 = stub_reference %.loc7_25.1 -// CHECK:STDOUT: %.loc7_28.1: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) -// CHECK:STDOUT: %.loc7_28.2: (i32, i32) = initialize_from %.loc7_28.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_28.2 +// CHECK:STDOUT: %.loc7_28: (i32, i32) = tuple_value (%.loc7_22.2, %.loc7_25.2) +// CHECK:STDOUT: assign %x, %.loc7_28 // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_14: type = stub_reference i32 // CHECK:STDOUT: %.loc8_17: (type, type) = tuple_value (%.loc8_9, %.loc8_14) // CHECK:STDOUT: %y: (i32, i32) = var -// CHECK:STDOUT: %.loc7_5.1: (i32, i32) = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: (i32, i32) = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: (i32, i32) = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/decl_with_init.carbon b/toolchain/semantics/testdata/var/decl_with_init.carbon index 6e1248d9dd7e5..f17fb393b3b23 100644 --- a/toolchain/semantics/testdata/var/decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/decl_with_init.carbon @@ -31,8 +31,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -47,7 +46,6 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -58,8 +56,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %x -// CHECK:STDOUT: assign %x, %.loc8_16.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 0 +// CHECK:STDOUT: assign %x, %.loc8 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon index be1c0e016cbd4..109cdfb680d5f 100644 --- a/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon +++ b/toolchain/semantics/testdata/var/fail_duplicate_decl.carbon @@ -40,13 +40,11 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+6, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+6, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -65,8 +63,6 @@ fn Main() { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -77,12 +73,10 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x.loc9: i32 = var -// CHECK:STDOUT: %.loc9_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_16.2: i32 = initialize_from %.loc9_16.1 to %x.loc9 -// CHECK:STDOUT: assign %x.loc9, %.loc9_16.2 +// CHECK:STDOUT: %.loc9: i32 = int_literal 0 +// CHECK:STDOUT: assign %x.loc9, %.loc9 // CHECK:STDOUT: %x.loc16: i32 = var -// CHECK:STDOUT: %.loc16_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc16_16.2: i32 = initialize_from %.loc16_16.1 to %x.loc16 -// CHECK:STDOUT: assign %x.loc16, %.loc16_16.2 +// CHECK:STDOUT: %.loc16: i32 = int_literal 0 +// CHECK:STDOUT: assign %x.loc16, %.loc16 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon index 095345fd00a3f..ad18a8d01ef37 100644 --- a/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon +++ b/toolchain/semantics/testdata/var/fail_init_type_mismatch.carbon @@ -35,8 +35,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+1, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -51,7 +50,6 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -63,7 +61,6 @@ fn Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var // CHECK:STDOUT: %.loc11: f64 = real_literal 10e-1 -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_init_with_self.carbon b/toolchain/semantics/testdata/var/fail_init_with_self.carbon index bd080f7908c35..35521e4842ee6 100644 --- a/toolchain/semantics/testdata/var/fail_init_with_self.carbon +++ b/toolchain/semantics/testdata/var/fail_init_with_self.carbon @@ -32,8 +32,7 @@ fn Main() { // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+1, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -47,7 +46,6 @@ fn Main() { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -58,7 +56,6 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon index 9e0e4cb2b59cb..79e6380bea2af 100644 --- a/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon +++ b/toolchain/semantics/testdata/var/fail_lookup_outside_scope.carbon @@ -38,8 +38,7 @@ var y: i32 = x; // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+4, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+4, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+6}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -49,7 +48,6 @@ var y: i32 = x; // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, @@ -61,8 +59,7 @@ var y: i32 = x; // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.1: = initialize_from to %y -// CHECK:STDOUT: assign %y, %.1 +// CHECK:STDOUT: assign %y, // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { diff --git a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon index dac4b99379099..c39bd8140ca6e 100644 --- a/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon +++ b/toolchain/semantics/testdata/var/fail_storage_is_literal.carbon @@ -36,8 +36,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: typeError}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+2, type: typeError}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: nodeError, arg1: node+2, type: typeError}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+5}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: nodeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -53,7 +52,6 @@ fn Main() { // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -66,7 +64,6 @@ fn Main() { // CHECK:STDOUT: %.loc11_10: i32 = int_literal 1 // CHECK:STDOUT: %x: = var // CHECK:STDOUT: %.loc11_14: i32 = int_literal 1 -// CHECK:STDOUT: %.1: = initialize_from to %x -// CHECK:STDOUT: assign %x, %.1 +// CHECK:STDOUT: assign %x, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_decl_with_init.carbon b/toolchain/semantics/testdata/var/global_decl_with_init.carbon index 429cbffb73904..99932570d46c4 100644 --- a/toolchain/semantics/testdata/var/global_decl_with_init.carbon +++ b/toolchain/semantics/testdata/var/global_decl_with_init.carbon @@ -26,8 +26,7 @@ var x: i32 = 0; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -37,13 +36,11 @@ var x: i32 = 0; // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_14.2 +// CHECK:STDOUT: %.loc7: i32 = int_literal 0 +// CHECK:STDOUT: assign %x, %.loc7 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup.carbon b/toolchain/semantics/testdata/var/global_lookup.carbon index 5d5cc6c601869..d8ca5cec7f9f7 100644 --- a/toolchain/semantics/testdata/var/global_lookup.carbon +++ b/toolchain/semantics/testdata/var/global_lookup.carbon @@ -28,13 +28,11 @@ var y: i32 = x; // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+5, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+4, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+7, arg1: node+5, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+6}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -48,18 +46,14 @@ var y: i32 = x; // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_14.2 +// CHECK:STDOUT: %.loc7_14: i32 = int_literal 0 +// CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.loc7_5.1: i32 = value_binding %x -// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7_5: i32 = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon index fb771ebfd9388..3c2f7f407d462 100644 --- a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon +++ b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon @@ -33,14 +33,12 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str0, arg1: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+2, arg1: node+0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, type: type0}, -// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+6, type: type0}, +// CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+5, type: type0}, // CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+8, arg1: node+6, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+7}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -52,31 +50,27 @@ fn Main() { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc7_14.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc7_14.2: i32 = initialize_from %.loc7_14.1 to %x -// CHECK:STDOUT: assign %x, %.loc7_14.2 +// CHECK:STDOUT: %.loc7: i32 = int_literal 0 +// CHECK:STDOUT: assign %x, %.loc7 // CHECK:STDOUT: %.loc9 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %y: i32 = var -// CHECK:STDOUT: %.loc7_5.1: i32 = value_binding package.%x -// CHECK:STDOUT: %.loc7_5.2: i32 = initialize_from %.loc7_5.1 to %y -// CHECK:STDOUT: assign %y, %.loc7_5.2 +// CHECK:STDOUT: %.loc7: i32 = value_binding package.%x +// CHECK:STDOUT: assign %y, %.loc7 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/lookup.carbon b/toolchain/semantics/testdata/var/lookup.carbon index 006011f350998..986c27f12e050 100644 --- a/toolchain/semantics/testdata/var/lookup.carbon +++ b/toolchain/semantics/testdata/var/lookup.carbon @@ -32,8 +32,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, type: type0}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+1, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: InitializeFrom, arg0: node+3, arg1: node+1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+3}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -48,7 +47,6 @@ fn Main() { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -59,8 +57,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %x: i32 = var -// CHECK:STDOUT: %.loc8_16.1: i32 = int_literal 0 -// CHECK:STDOUT: %.loc8_16.2: i32 = initialize_from %.loc8_16.1 to %x -// CHECK:STDOUT: assign %x, %.loc8_16.2 +// CHECK:STDOUT: %.loc8: i32 = int_literal 0 +// CHECK:STDOUT: assign %x, %.loc8 // CHECK:STDOUT: return // CHECK:STDOUT: } From f213f177d11d54ce120ea6618aa641795db06686 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 15:36:17 -0700 Subject: [PATCH 12/21] Remove unused node InitializeFrom. --- .../lowering/lowering_handle_expression_category.cpp | 8 -------- toolchain/semantics/semantics_context.cpp | 6 ------ toolchain/semantics/semantics_ir.cpp | 4 ---- toolchain/semantics/semantics_ir_formatter.cpp | 10 ---------- toolchain/semantics/semantics_node.h | 4 ---- toolchain/semantics/semantics_node_kind.def | 2 -- 6 files changed, 34 deletions(-) diff --git a/toolchain/lowering/lowering_handle_expression_category.cpp b/toolchain/lowering/lowering_handle_expression_category.cpp index 36aaa6402040b..6b1d8b5f09132 100644 --- a/toolchain/lowering/lowering_handle_expression_category.cpp +++ b/toolchain/lowering/lowering_handle_expression_category.cpp @@ -6,14 +6,6 @@ namespace Carbon { -auto LoweringHandleInitializeFrom(LoweringFunctionContext& context, - SemanticsNodeId node_id, SemanticsNode node) - -> void { - // TODO: If the value representation is indirect, perform the copy. - auto [init_value_id, target_id] = node.GetAsInitializeFrom(); - context.SetLocal(node_id, context.GetLocal(init_value_id)); -} - auto LoweringHandleMaterializeTemporary(LoweringFunctionContext& context, SemanticsNodeId node_id, SemanticsNode node) -> void { diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 42c3199fd1ce8..8b2f9a3c569f6 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -391,9 +391,6 @@ auto SemanticsContext::FinalizeTemporary(SemanticsNodeId init_id, } return temporary_id; } - - case SemanticsNodeKind::InitializeFrom: - CARBON_FATAL() << init << " should be created with a destination"; } } } @@ -441,9 +438,6 @@ auto SemanticsContext::MarkInitializerFor(SemanticsNodeId init_id, } return; } - - case SemanticsNodeKind::InitializeFrom: - CARBON_FATAL() << init << " should be created with a destination"; } } } diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index aedba80df8c14..930909b3aabc6 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -235,7 +235,6 @@ static auto GetTypePrecedence(SemanticsNodeKind kind) -> int { case SemanticsNodeKind::Call: case SemanticsNodeKind::Dereference: case SemanticsNodeKind::FunctionDeclaration: - case SemanticsNodeKind::InitializeFrom: case SemanticsNodeKind::IntegerLiteral: case SemanticsNodeKind::Invalid: case SemanticsNodeKind::MaterializeTemporary: @@ -396,7 +395,6 @@ auto SemanticsIR::StringifyType(SemanticsTypeId type_id, case SemanticsNodeKind::CrossReference: case SemanticsNodeKind::Dereference: case SemanticsNodeKind::FunctionDeclaration: - case SemanticsNodeKind::InitializeFrom: case SemanticsNodeKind::IntegerLiteral: case SemanticsNodeKind::MaterializeTemporary: case SemanticsNodeKind::Namespace: @@ -520,7 +518,6 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, return SemanticsExpressionCategory::Value; case SemanticsNodeKind::Call: - case SemanticsNodeKind::InitializeFrom: return SemanticsExpressionCategory::Initializing; case SemanticsNodeKind::Dereference: @@ -554,7 +551,6 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, case SemanticsNodeKind::Call: case SemanticsNodeKind::Dereference: case SemanticsNodeKind::FunctionDeclaration: - case SemanticsNodeKind::InitializeFrom: case SemanticsNodeKind::IntegerLiteral: case SemanticsNodeKind::Invalid: case SemanticsNodeKind::MaterializeTemporary: diff --git a/toolchain/semantics/semantics_ir_formatter.cpp b/toolchain/semantics/semantics_ir_formatter.cpp index 20c08ab201c90..97608ddaa5577 100644 --- a/toolchain/semantics/semantics_ir_formatter.cpp +++ b/toolchain/semantics/semantics_ir_formatter.cpp @@ -639,16 +639,6 @@ class SemanticsIRFormatter { out_ << " " << xref_id << "." << node_id; } - template <> - auto FormatInstructionRHS(SemanticsNode node) - -> void { - auto [init_id, target_id] = node.GetAsInitializeFrom(); - out_ << " "; - FormatArg(init_id); - out_ << " to "; - FormatArg(target_id); - } - // StructTypeFields are formatted as part of their StructType. template <> auto FormatInstruction( diff --git a/toolchain/semantics/semantics_node.h b/toolchain/semantics/semantics_node.h index c031084a08a3f..d654ba8674865 100644 --- a/toolchain/semantics/semantics_node.h +++ b/toolchain/semantics/semantics_node.h @@ -398,10 +398,6 @@ class SemanticsNode { FactoryNoType; - using InitializeFrom = - Factory; - using IntegerLiteral = Factory; diff --git a/toolchain/semantics/semantics_node_kind.def b/toolchain/semantics/semantics_node_kind.def index 949efc83cdb55..94924effde023 100644 --- a/toolchain/semantics/semantics_node_kind.def +++ b/toolchain/semantics/semantics_node_kind.def @@ -64,8 +64,6 @@ CARBON_SEMANTICS_NODE_KIND_IMPL(Dereference, "dereference", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(FunctionDeclaration, "fn_decl", Untyped, NotTerminator) -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(MaterializeTemporary, "materialize_temporary", From f7c1f85b1b2d3d68eaf11b30e9326239f7e97d10 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 15:56:29 -0700 Subject: [PATCH 13/21] Fix cases where we'd make use of the return value of a function that returns in-place. --- .../testdata/array/assign_return_value.carbon | 15 ++++--- toolchain/lowering/testdata/array/base.carbon | 24 +++++----- .../call/implicit_empty_tuple_as_arg.carbon | 2 +- .../testdata/function/call/var_param.carbon | 3 +- .../index/array_element_access.carbon | 45 ++++++++++--------- toolchain/semantics/semantics_context.cpp | 7 ++- .../testdata/array/assign_return_value.carbon | 17 +++++-- .../testdata/array/assign_var.carbon | 11 +++-- 8 files changed, 71 insertions(+), 53 deletions(-) diff --git a/toolchain/lowering/testdata/array/assign_return_value.carbon b/toolchain/lowering/testdata/array/assign_return_value.carbon index 9fb77ec823fb0..c5a8e1f5beecb 100644 --- a/toolchain/lowering/testdata/array/assign_return_value.carbon +++ b/toolchain/lowering/testdata/array/assign_return_value.carbon @@ -28,12 +28,15 @@ fn Run() { // CHECK:STDOUT: %var = alloca [2 x i32], align 4 // CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 // CHECK:STDOUT: call void @F(ptr %temp) +// CHECK:STDOUT: %1 = load { i32, i32 }, ptr %temp, align 4 // CHECK:STDOUT: %array = alloca [2 x i32], align 4 -// CHECK:STDOUT: %1 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 -// CHECK:STDOUT: store i32 undef, ptr %1, align 4 -// CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 -// CHECK:STDOUT: store i32 undef, ptr %2, align 4 -// CHECK:STDOUT: %3 = load [2 x i32], ptr %array, align 4 -// CHECK:STDOUT: store [2 x i32] %3, ptr %var, align 4 +// CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %1, 0 +// CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 +// CHECK:STDOUT: store i32 %array.element, ptr %2, align 4 +// CHECK:STDOUT: %array.element1 = extractvalue { i32, i32 } %1, 1 +// CHECK:STDOUT: %3 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 +// CHECK:STDOUT: store i32 %array.element1, ptr %3, align 4 +// CHECK:STDOUT: %4 = load [2 x i32], ptr %array, align 4 +// CHECK:STDOUT: store [2 x i32] %4, ptr %var, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/array/base.carbon b/toolchain/lowering/testdata/array/base.carbon index ad1b146265737..bd87168a5a821 100644 --- a/toolchain/lowering/testdata/array/base.carbon +++ b/toolchain/lowering/testdata/array/base.carbon @@ -105,20 +105,18 @@ fn Run() { // CHECK:STDOUT: %34 = load { i32, i32, i32 }, ptr %tuple22, align 4 // CHECK:STDOUT: store { i32, i32, i32 } %34, ptr %var21, align 4 // CHECK:STDOUT: %var23 = alloca [3 x i32], align 4 +// CHECK:STDOUT: %35 = load { i32, i32, i32 }, ptr %var21, align 4 // CHECK:STDOUT: %array24 = alloca [3 x i32], align 4 -// CHECK:STDOUT: %array.element25 = getelementptr inbounds { i32, i32, i32 }, ptr %var21, i32 0, i32 0 -// CHECK:STDOUT: %35 = load i32, ptr %array.element25, align 4 +// CHECK:STDOUT: %array.element25 = extractvalue { i32, i32, i32 } %35, 0 // CHECK:STDOUT: %36 = getelementptr inbounds [3 x i32], ptr %array24, i32 0, i32 0 -// CHECK:STDOUT: store i32 %35, ptr %36, align 4 -// CHECK:STDOUT: %array.element26 = getelementptr inbounds { i32, i32, i32 }, ptr %var21, i32 0, i32 1 -// CHECK:STDOUT: %37 = load i32, ptr %array.element26, align 4 -// CHECK:STDOUT: %38 = getelementptr inbounds [3 x i32], ptr %array24, i32 0, i32 1 -// CHECK:STDOUT: store i32 %37, ptr %38, align 4 -// CHECK:STDOUT: %array.element27 = getelementptr inbounds { i32, i32, i32 }, ptr %var21, i32 0, i32 2 -// CHECK:STDOUT: %39 = load i32, ptr %array.element27, align 4 -// CHECK:STDOUT: %40 = getelementptr inbounds [3 x i32], ptr %array24, i32 0, i32 2 -// CHECK:STDOUT: store i32 %39, ptr %40, align 4 -// CHECK:STDOUT: %41 = load [3 x i32], ptr %array24, align 4 -// CHECK:STDOUT: store [3 x i32] %41, ptr %var23, align 4 +// CHECK:STDOUT: store i32 %array.element25, ptr %36, align 4 +// CHECK:STDOUT: %array.element26 = extractvalue { i32, i32, i32 } %35, 1 +// CHECK:STDOUT: %37 = getelementptr inbounds [3 x i32], ptr %array24, i32 0, i32 1 +// CHECK:STDOUT: store i32 %array.element26, ptr %37, align 4 +// CHECK:STDOUT: %array.element27 = extractvalue { i32, i32, i32 } %35, 2 +// CHECK:STDOUT: %38 = getelementptr inbounds [3 x i32], ptr %array24, i32 0, i32 2 +// CHECK:STDOUT: store i32 %array.element27, ptr %38, align 4 +// CHECK:STDOUT: %39 = load [3 x i32], ptr %array24, align 4 +// CHECK:STDOUT: store [3 x i32] %39, ptr %var23, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon index 1c2daceb12d1b..137e5b62dd84e 100644 --- a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon +++ b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon @@ -30,6 +30,6 @@ fn Main() { // CHECK:STDOUT: call void @Foo() // CHECK:STDOUT: %temp = alloca {}, align 8 // CHECK:STDOUT: %1 = load {}, ptr %temp, align 1 -// CHECK:STDOUT: call void @Bar({} undef) +// CHECK:STDOUT: call void @Bar({} %1) // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/var_param.carbon b/toolchain/lowering/testdata/function/call/var_param.carbon index 17009102c7cbc..3cc234bdde8ff 100644 --- a/toolchain/lowering/testdata/function/call/var_param.carbon +++ b/toolchain/lowering/testdata/function/call/var_param.carbon @@ -22,7 +22,6 @@ fn Main() { // CHECK:STDOUT: %var = alloca i32, align 4 // CHECK:STDOUT: store i32 0, ptr %var, align 4 // CHECK:STDOUT: %1 = load i32, ptr %var, align 4 -// CHECK:STDOUT: %2 = load i32, ptr %var, align 4 -// CHECK:STDOUT: call void @DoNothing(i32 %2) +// CHECK:STDOUT: call void @DoNothing(i32 %1) // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/index/array_element_access.carbon b/toolchain/lowering/testdata/index/array_element_access.carbon index 22e5bffb69371..489284b6090c7 100644 --- a/toolchain/lowering/testdata/index/array_element_access.carbon +++ b/toolchain/lowering/testdata/index/array_element_access.carbon @@ -52,29 +52,32 @@ fn Run() { // CHECK:STDOUT: %var = alloca [2 x i32], align 4 // CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 // CHECK:STDOUT: call void @A(ptr %temp) +// CHECK:STDOUT: %1 = load { i32, i32 }, ptr %temp, align 4 // CHECK:STDOUT: %array = alloca [2 x i32], align 4 -// CHECK:STDOUT: %1 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 -// CHECK:STDOUT: store i32 undef, ptr %1, align 4 -// CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 -// CHECK:STDOUT: store i32 undef, ptr %2, align 4 -// CHECK:STDOUT: %3 = load [2 x i32], ptr %array, align 4 -// CHECK:STDOUT: store [2 x i32] %3, ptr %var, align 4 -// CHECK:STDOUT: %var1 = alloca i32, align 4 -// CHECK:STDOUT: %temp2 = alloca { i32, i32 }, align 8 -// CHECK:STDOUT: call void @A(ptr %temp2) -// CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp2, i32 0, i32 0 -// CHECK:STDOUT: %4 = load i32, ptr %tuple.index, align 4 -// CHECK:STDOUT: store i32 %4, ptr %var1, align 4 -// CHECK:STDOUT: %var3 = alloca i32, align 4 -// CHECK:STDOUT: %5 = load i32, ptr %var1, align 4 -// CHECK:STDOUT: %array.index = getelementptr inbounds [2 x i32], ptr %var, i32 %5 -// CHECK:STDOUT: %6 = load i32, ptr %array.index, align 4 -// CHECK:STDOUT: store i32 %6, ptr %var3, align 4 +// CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %1, 0 +// CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 +// CHECK:STDOUT: store i32 %array.element, ptr %2, align 4 +// CHECK:STDOUT: %array.element1 = extractvalue { i32, i32 } %1, 1 +// CHECK:STDOUT: %3 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 +// CHECK:STDOUT: store i32 %array.element1, ptr %3, align 4 +// CHECK:STDOUT: %4 = load [2 x i32], ptr %array, align 4 +// CHECK:STDOUT: store [2 x i32] %4, ptr %var, align 4 +// CHECK:STDOUT: %var2 = alloca i32, align 4 +// CHECK:STDOUT: %temp3 = alloca { i32, i32 }, align 8 +// CHECK:STDOUT: call void @A(ptr %temp3) +// CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp3, i32 0, i32 0 +// CHECK:STDOUT: %5 = load i32, ptr %tuple.index, align 4 +// CHECK:STDOUT: store i32 %5, ptr %var2, align 4 // CHECK:STDOUT: %var4 = alloca i32, align 4 -// CHECK:STDOUT: %temp5 = alloca [2 x i32], align 4 -// CHECK:STDOUT: call void @B(ptr %temp5) -// CHECK:STDOUT: %array.index6 = getelementptr inbounds [2 x i32], ptr %temp5, i32 0, i32 1 -// CHECK:STDOUT: %7 = load i32, ptr %array.index6, align 4 +// CHECK:STDOUT: %6 = load i32, ptr %var2, align 4 +// CHECK:STDOUT: %array.index = getelementptr inbounds [2 x i32], ptr %var, i32 %6 +// CHECK:STDOUT: %7 = load i32, ptr %array.index, align 4 // CHECK:STDOUT: store i32 %7, ptr %var4, align 4 +// CHECK:STDOUT: %var5 = alloca i32, align 4 +// CHECK:STDOUT: %temp6 = alloca [2 x i32], align 4 +// CHECK:STDOUT: call void @B(ptr %temp6) +// CHECK:STDOUT: %array.index7 = getelementptr inbounds [2 x i32], ptr %temp6, i32 0, i32 1 +// CHECK:STDOUT: %8 = load i32, ptr %array.index7, align 4 +// CHECK:STDOUT: store i32 %8, ptr %var5, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 8b2f9a3c569f6..9d969cfc738b9 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -465,8 +465,8 @@ auto SemanticsContext::ImplicitAsForArgs( return true; } - auto arg_refs = semantics_ir_->GetNodeBlock(arg_refs_id); - auto param_refs = semantics_ir_->GetNodeBlock(param_refs_id); + auto &arg_refs = semantics_ir_->GetNodeBlock(arg_refs_id); + const auto ¶m_refs = semantics_ir_->GetNodeBlock(param_refs_id); // If sizes mismatch, fail early. if (arg_refs.size() != param_refs.size()) { @@ -582,6 +582,9 @@ auto SemanticsContext::ImplicitAsImpl(SemanticsNodeId value_id, std::all_of(type_block.begin(), type_block.end(), [&](auto type) { return type == element_type; })) { if (output_value_id != nullptr) { + // TODO: We should convert an initializing expression of tuple type + // to an initializing expression of array type. + value_id = ConvertToValueExpression(value_id); *output_value_id = AddNode(SemanticsNode::ArrayValue::Make( value.parse_node(), as_type_id, value_id)); } diff --git a/toolchain/semantics/testdata/array/assign_return_value.carbon b/toolchain/semantics/testdata/array/assign_return_value.carbon index a0b6891ce2590..ebd26b8593f6a 100644 --- a/toolchain/semantics/testdata/array/assign_return_value.carbon +++ b/toolchain/semantics/testdata/array/assign_return_value.carbon @@ -57,8 +57,11 @@ fn Run() { // CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: BindName, arg0: str2, arg1: node+13, type: type3}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+15, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+16}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+15}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type2}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+18, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+19}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -96,6 +99,9 @@ fn Run() { // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -118,7 +124,10 @@ fn Run() { // CHECK:STDOUT: %.loc10_17: type = array_type %.loc10_16, i32 // CHECK:STDOUT: %t: [i32; 1] = var // CHECK:STDOUT: %.loc10_22.1: (i32,) = call @F() -// CHECK:STDOUT: %.loc10_22.2: [i32; 1] = array_value %.loc10_22.1 -// CHECK:STDOUT: assign %t, %.loc10_22.2 +// CHECK:STDOUT: %.loc10_22.2: (i32,) = materialize_temporary +// CHECK:STDOUT: assign %.loc10_22.2, %.loc10_22.1 +// CHECK:STDOUT: %.loc10_22.3: (i32,) = value_binding %.loc10_22.2 +// CHECK:STDOUT: %.loc10_22.4: [i32; 1] = array_value %.loc10_22.3 +// CHECK:STDOUT: assign %t, %.loc10_22.4 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/assign_var.carbon b/toolchain/semantics/testdata/array/assign_var.carbon index 0e0c16061a24b..a6af3388c1763 100644 --- a/toolchain/semantics/testdata/array/assign_var.carbon +++ b/toolchain/semantics/testdata/array/assign_var.carbon @@ -61,8 +61,9 @@ var b: [i32; 3] = a; // CHECK:STDOUT: {kind: ArrayType, arg0: node+16, arg1: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, type: type3}, // CHECK:STDOUT: {kind: BindName, arg0: str1, arg1: node+18, type: type3}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+6, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+20}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type2}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+20, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -90,6 +91,7 @@ var b: [i32; 3] = a; // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -122,6 +124,7 @@ 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: [i32; 3] = var -// CHECK:STDOUT: %.loc7_5: [i32; 3] = array_value %a -// CHECK:STDOUT: assign %b, %.loc7_5 +// CHECK:STDOUT: %.loc7_5.1: (i32, i32, i32) = value_binding %a +// CHECK:STDOUT: %.loc7_5.2: [i32; 3] = array_value %.loc7_5.1 +// CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: } From c5c137dbe164580af17623850ac5ce036592b430 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 16:22:28 -0700 Subject: [PATCH 14/21] Fix up and regenerate test expectations after merge. --- .../testdata/array/assign_return_value.carbon | 25 +-- toolchain/lowering/testdata/array/base.carbon | 24 ++- .../function/call/empty_struct.carbon | 8 +- .../testdata/function/call/empty_tuple.carbon | 7 +- .../call/implicit_empty_tuple_as_arg.carbon | 11 +- .../function/call/return_implicit.carbon | 3 - .../index/array_element_access.carbon | 54 +++--- .../index/tuple_return_value_access.carbon | 13 +- .../semantics/semantics_handle_function.cpp | 7 +- toolchain/semantics/semantics_ir.cpp | 6 - .../testdata/array/assign_return_value.carbon | 50 +++-- .../testdata/array/assign_var.carbon | 11 +- .../semantics/testdata/const/collapse.carbon | 26 +-- .../testdata/const/fail_collapse.carbon | 15 +- .../function/call/empty_struct.carbon | 31 ++-- .../testdata/function/call/empty_tuple.carbon | 31 ++-- .../call/fail_return_type_mismatch.carbon | 19 +- .../testdata/function/call/i32.carbon | 30 +-- .../function/call/return_implicit.carbon | 3 - toolchain/semantics/testdata/if/else.carbon | 17 +- .../if/fail_reachable_fallthrough.carbon | 72 +++++--- .../semantics/testdata/if/fail_scope.carbon | 35 ++-- .../semantics/testdata/if/no_else.carbon | 13 +- .../if/unreachable_fallthrough.carbon | 22 ++- .../testdata/if_expression/basic.carbon | 50 +++-- .../if_expression/constant_condition.carbon | 129 +++++++++---- .../if_expression/control_flow.carbon | 82 ++++++--- .../testdata/if_expression/nested.carbon | 68 ++++--- .../index/array_element_access.carbon | 18 +- .../index/fail_tuple_large_index.carbon | 9 +- .../index/tuple_element_access.carbon | 18 +- .../index/tuple_return_value_access.carbon | 50 +++-- .../semantics/testdata/operators/and.carbon | 73 +++++--- .../testdata/operators/assignment.carbon | 30 +-- .../testdata/operators/binary_op.carbon | 11 +- .../fail_assigment_to_non_assignable.carbon | 173 ++++++++++-------- .../operators/fail_type_mismatch.carbon | 9 +- .../fail_type_mismatch_assignment.carbon | 4 +- .../operators/fail_type_mismatch_once.carbon | 11 +- .../semantics/testdata/operators/or.carbon | 77 +++++--- .../testdata/operators/unary_op.carbon | 16 +- .../testdata/pointer/address_of_deref.carbon | 30 +-- .../semantics/testdata/pointer/basic.carbon | 33 ++-- .../pointer/fail_address_of_value.carbon | 152 ++++++++------- .../fail_dereference_not_pointer.carbon | 15 +- .../pointer/fail_type_mismatch.carbon | 18 +- .../testdata/pointer/nested_const.carbon | 33 ++-- .../semantics/testdata/pointer/types.carbon | 50 ++--- .../return/code_after_return_value.carbon | 24 ++- .../return/fail_missing_return.carbon | 7 +- .../fail_missing_return_empty_tuple.carbon | 11 +- .../testdata/return/fail_type_mismatch.carbon | 7 +- .../testdata/return/fail_value_missing.carbon | 7 +- .../semantics/testdata/return/struct.carbon | 22 ++- .../semantics/testdata/return/tuple.carbon | 33 ++-- .../semantics/testdata/return/value.carbon | 9 +- .../semantics/testdata/struct/empty.carbon | 7 +- .../testdata/struct/member_access.carbon | 16 +- .../testdata/struct/one_entry.carbon | 7 +- .../testdata/struct/tuple_as_element.carbon | 7 +- .../testdata/struct/two_entries.carbon | 7 +- .../semantics/testdata/tuples/empty.carbon | 7 +- .../testdata/tuples/one_element.carbon | 7 +- .../testdata/tuples/two_elements.carbon | 7 +- .../testdata/var/global_lookup.carbon | 11 +- .../var/global_lookup_in_scope.carbon | 7 +- 66 files changed, 1172 insertions(+), 723 deletions(-) diff --git a/toolchain/lowering/testdata/array/assign_return_value.carbon b/toolchain/lowering/testdata/array/assign_return_value.carbon index 2c280ed42ae29..a9ec9f19942ab 100644 --- a/toolchain/lowering/testdata/array/assign_return_value.carbon +++ b/toolchain/lowering/testdata/array/assign_return_value.carbon @@ -13,27 +13,30 @@ fn Run() { // CHECK:STDOUT: ; ModuleID = 'assign_return_value.carbon' // CHECK:STDOUT: source_filename = "assign_return_value.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define { i32, i32 } @F() { +// CHECK:STDOUT: define void @F(ptr sret({ i32, i32 }) %return) { // CHECK:STDOUT: %tuple = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %1 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 0 // CHECK:STDOUT: store i32 12, ptr %1, align 4 // CHECK:STDOUT: %2 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 1 // CHECK:STDOUT: store i32 24, ptr %2, align 4 // CHECK:STDOUT: %3 = load { i32, i32 }, ptr %tuple, align 4 -// CHECK:STDOUT: ret { i32, i32 } %3 +// CHECK:STDOUT: store { i32, i32 } %3, ptr %return, align 4 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %t = alloca [2 x i32], align 4 -// CHECK:STDOUT: %F = call { i32, i32 } @F() +// CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 +// CHECK:STDOUT: call void @F(ptr %temp) +// CHECK:STDOUT: %1 = load { i32, i32 }, ptr %temp, align 4 // CHECK:STDOUT: %array = alloca [2 x i32], align 4 -// CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %F, 0 -// CHECK:STDOUT: %1 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 -// CHECK:STDOUT: store i32 %array.element, ptr %1, align 4 -// CHECK:STDOUT: %array.element1 = extractvalue { i32, i32 } %F, 1 -// CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 -// CHECK:STDOUT: store i32 %array.element1, ptr %2, align 4 -// CHECK:STDOUT: %3 = load [2 x i32], ptr %array, align 4 -// CHECK:STDOUT: store [2 x i32] %3, ptr %t, align 4 +// CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %1, 0 +// CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 +// CHECK:STDOUT: store i32 %array.element, ptr %2, align 4 +// CHECK:STDOUT: %array.element1 = extractvalue { i32, i32 } %1, 1 +// CHECK:STDOUT: %3 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 +// CHECK:STDOUT: store i32 %array.element1, ptr %3, align 4 +// CHECK:STDOUT: %4 = load [2 x i32], ptr %array, align 4 +// CHECK:STDOUT: store [2 x i32] %4, ptr %t, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/array/base.carbon b/toolchain/lowering/testdata/array/base.carbon index 7535f326707b5..4c14d9588aff2 100644 --- a/toolchain/lowering/testdata/array/base.carbon +++ b/toolchain/lowering/testdata/array/base.carbon @@ -105,20 +105,18 @@ fn Run() { // CHECK:STDOUT: %34 = load { i32, i32, i32 }, ptr %tuple19, align 4 // CHECK:STDOUT: store { i32, i32, i32 } %34, ptr %d, align 4 // CHECK:STDOUT: %e = alloca [3 x i32], align 4 +// CHECK:STDOUT: %35 = load { i32, i32, i32 }, ptr %d, align 4 // CHECK:STDOUT: %array20 = alloca [3 x i32], align 4 -// CHECK:STDOUT: %array.element21 = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 0 -// CHECK:STDOUT: %35 = load i32, ptr %array.element21, align 4 +// CHECK:STDOUT: %array.element21 = extractvalue { i32, i32, i32 } %35, 0 // CHECK:STDOUT: %36 = getelementptr inbounds [3 x i32], ptr %array20, i32 0, i32 0 -// CHECK:STDOUT: store i32 %35, ptr %36, align 4 -// CHECK:STDOUT: %array.element22 = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 1 -// CHECK:STDOUT: %37 = load i32, ptr %array.element22, align 4 -// CHECK:STDOUT: %38 = getelementptr inbounds [3 x i32], ptr %array20, i32 0, i32 1 -// CHECK:STDOUT: store i32 %37, ptr %38, align 4 -// CHECK:STDOUT: %array.element23 = getelementptr inbounds { i32, i32, i32 }, ptr %d, i32 0, i32 2 -// CHECK:STDOUT: %39 = load i32, ptr %array.element23, align 4 -// CHECK:STDOUT: %40 = getelementptr inbounds [3 x i32], ptr %array20, i32 0, i32 2 -// CHECK:STDOUT: store i32 %39, ptr %40, align 4 -// CHECK:STDOUT: %41 = load [3 x i32], ptr %array20, align 4 -// CHECK:STDOUT: store [3 x i32] %41, ptr %e, align 4 +// CHECK:STDOUT: store i32 %array.element21, ptr %36, align 4 +// CHECK:STDOUT: %array.element22 = extractvalue { i32, i32, i32 } %35, 1 +// CHECK:STDOUT: %37 = getelementptr inbounds [3 x i32], ptr %array20, i32 0, i32 1 +// CHECK:STDOUT: store i32 %array.element22, ptr %37, align 4 +// CHECK:STDOUT: %array.element23 = extractvalue { i32, i32, i32 } %35, 2 +// CHECK:STDOUT: %38 = getelementptr inbounds [3 x i32], ptr %array20, i32 0, i32 2 +// CHECK:STDOUT: store i32 %array.element23, ptr %38, align 4 +// CHECK:STDOUT: %39 = load [3 x i32], ptr %array20, align 4 +// CHECK:STDOUT: store [3 x i32] %39, ptr %e, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/empty_struct.carbon b/toolchain/lowering/testdata/function/call/empty_struct.carbon index 8fc7bbbf4f687..6b2521185adca 100644 --- a/toolchain/lowering/testdata/function/call/empty_struct.carbon +++ b/toolchain/lowering/testdata/function/call/empty_struct.carbon @@ -15,10 +15,9 @@ fn Main() { // CHECK:STDOUT: ; ModuleID = 'empty_struct.carbon' // CHECK:STDOUT: source_filename = "empty_struct.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define {} @Echo({} %a) { +// CHECK:STDOUT: define void @Echo({} %a) { // CHECK:STDOUT: %struct = alloca {}, align 8 -// CHECK:STDOUT: %1 = load {}, ptr %struct, align 1 -// CHECK:STDOUT: ret {} %1 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { @@ -26,7 +25,6 @@ fn Main() { // CHECK:STDOUT: %b = alloca {}, align 8 // CHECK:STDOUT: %struct1 = alloca {}, align 8 // CHECK:STDOUT: %1 = load {}, ptr %struct1, align 1 -// CHECK:STDOUT: %Echo = call {} @Echo({} %1) -// CHECK:STDOUT: store {} %Echo, ptr %b, align 1 +// CHECK:STDOUT: call void @Echo({} %1) // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/empty_tuple.carbon b/toolchain/lowering/testdata/function/call/empty_tuple.carbon index 365751a58c4fa..a4e86ef3e1e76 100644 --- a/toolchain/lowering/testdata/function/call/empty_tuple.carbon +++ b/toolchain/lowering/testdata/function/call/empty_tuple.carbon @@ -15,8 +15,8 @@ fn Main() { // CHECK:STDOUT: ; ModuleID = 'empty_tuple.carbon' // CHECK:STDOUT: source_filename = "empty_tuple.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define {} @Echo({} %a) { -// CHECK:STDOUT: ret {} %a +// CHECK:STDOUT: define void @Echo({} %a) { +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { @@ -24,7 +24,6 @@ fn Main() { // CHECK:STDOUT: %b = alloca {}, align 8 // CHECK:STDOUT: %tuple1 = alloca {}, align 8 // CHECK:STDOUT: %1 = load {}, ptr %tuple1, align 1 -// CHECK:STDOUT: %Echo = call {} @Echo({} %1) -// CHECK:STDOUT: store {} %Echo, ptr %b, align 1 +// CHECK:STDOUT: call void @Echo({} %1) // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon index 6720acfde74d3..01cdb08d82fa3 100644 --- a/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon +++ b/toolchain/lowering/testdata/function/call/implicit_empty_tuple_as_arg.carbon @@ -20,17 +20,16 @@ fn Main() { // CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: define {} @Bar({} %a) { -// CHECK:STDOUT: ret {} %a +// CHECK:STDOUT: define void @Bar({} %a) { +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Main() { // CHECK:STDOUT: %tuple = alloca {}, align 8 // CHECK:STDOUT: %x = alloca {}, align 8 // CHECK:STDOUT: call void @Foo() -// CHECK:STDOUT: %call.result = alloca {}, align 8 -// CHECK:STDOUT: %1 = load {}, ptr %call.result, align 1 -// CHECK:STDOUT: %Bar = call {} @Bar({} %1) -// CHECK:STDOUT: store {} %Bar, ptr %x, align 1 +// CHECK:STDOUT: %temp = alloca {}, align 8 +// CHECK:STDOUT: %1 = load {}, ptr %temp, align 1 +// CHECK:STDOUT: call void @Bar({} %1) // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/function/call/return_implicit.carbon b/toolchain/lowering/testdata/function/call/return_implicit.carbon index 7346a5808751e..a82f5c0e081f5 100644 --- a/toolchain/lowering/testdata/function/call/return_implicit.carbon +++ b/toolchain/lowering/testdata/function/call/return_implicit.carbon @@ -23,8 +23,5 @@ fn Main() { // CHECK:STDOUT: %tuple = alloca {}, align 8 // CHECK:STDOUT: %b = alloca {}, align 8 // CHECK:STDOUT: call void @MakeImplicitEmptyTuple() -// CHECK:STDOUT: %call.result = alloca {}, align 8 -// CHECK:STDOUT: %1 = load {}, ptr %call.result, align 1 -// CHECK:STDOUT: store {} %1, ptr %b, align 1 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/index/array_element_access.carbon b/toolchain/lowering/testdata/index/array_element_access.carbon index b90963cf88133..14d5f53957804 100644 --- a/toolchain/lowering/testdata/index/array_element_access.carbon +++ b/toolchain/lowering/testdata/index/array_element_access.carbon @@ -17,17 +17,18 @@ fn Run() { // CHECK:STDOUT: ; ModuleID = 'array_element_access.carbon' // CHECK:STDOUT: source_filename = "array_element_access.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define { i32, i32 } @A() { +// CHECK:STDOUT: define void @A(ptr sret({ i32, i32 }) %return) { // CHECK:STDOUT: %tuple = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %1 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 0 // CHECK:STDOUT: store i32 1, ptr %1, align 4 // CHECK:STDOUT: %2 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 1 // CHECK:STDOUT: store i32 2, ptr %2, align 4 // CHECK:STDOUT: %3 = load { i32, i32 }, ptr %tuple, align 4 -// CHECK:STDOUT: ret { i32, i32 } %3 +// CHECK:STDOUT: store { i32, i32 } %3, ptr %return, align 4 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: define [2 x i32] @B() { +// CHECK:STDOUT: define void @B(ptr sret([2 x i32]) %return) { // CHECK:STDOUT: %tuple = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %1 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 0 // CHECK:STDOUT: store i32 1, ptr %1, align 4 @@ -43,33 +44,40 @@ fn Run() { // CHECK:STDOUT: %6 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 // CHECK:STDOUT: store i32 %5, ptr %6, align 4 // CHECK:STDOUT: %7 = load [2 x i32], ptr %array, align 4 -// CHECK:STDOUT: ret [2 x i32] %7 +// CHECK:STDOUT: store [2 x i32] %7, ptr %return, align 4 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %a = alloca [2 x i32], align 4 -// CHECK:STDOUT: %A = call { i32, i32 } @A() +// CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 +// CHECK:STDOUT: call void @A(ptr %temp) +// CHECK:STDOUT: %1 = load { i32, i32 }, ptr %temp, align 4 // CHECK:STDOUT: %array = alloca [2 x i32], align 4 -// CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %A, 0 -// CHECK:STDOUT: %1 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 -// CHECK:STDOUT: store i32 %array.element, ptr %1, align 4 -// CHECK:STDOUT: %array.element1 = extractvalue { i32, i32 } %A, 1 -// CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 -// CHECK:STDOUT: store i32 %array.element1, ptr %2, align 4 -// CHECK:STDOUT: %3 = load [2 x i32], ptr %array, align 4 -// CHECK:STDOUT: store [2 x i32] %3, ptr %a, align 4 +// CHECK:STDOUT: %array.element = extractvalue { i32, i32 } %1, 0 +// CHECK:STDOUT: %2 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 0 +// CHECK:STDOUT: store i32 %array.element, ptr %2, align 4 +// CHECK:STDOUT: %array.element1 = extractvalue { i32, i32 } %1, 1 +// CHECK:STDOUT: %3 = getelementptr inbounds [2 x i32], ptr %array, i32 0, i32 1 +// CHECK:STDOUT: store i32 %array.element1, ptr %3, align 4 +// CHECK:STDOUT: %4 = load [2 x i32], ptr %array, align 4 +// CHECK:STDOUT: store [2 x i32] %4, ptr %a, align 4 // CHECK:STDOUT: %b = alloca i32, align 4 -// CHECK:STDOUT: %A2 = call { i32, i32 } @A() -// CHECK:STDOUT: %tuple.index = extractvalue { i32, i32 } %A2, 0 -// CHECK:STDOUT: store i32 %tuple.index, ptr %b, align 4 +// CHECK:STDOUT: %temp2 = alloca { i32, i32 }, align 8 +// CHECK:STDOUT: call void @A(ptr %temp2) +// CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp2, i32 0, i32 0 +// CHECK:STDOUT: %5 = load i32, ptr %tuple.index, align 4 +// CHECK:STDOUT: store i32 %5, ptr %b, align 4 // CHECK:STDOUT: %c = alloca i32, align 4 -// CHECK:STDOUT: %4 = load i32, ptr %b, align 4 -// CHECK:STDOUT: %array.index = getelementptr inbounds [2 x i32], ptr %a, i32 %4 -// CHECK:STDOUT: %5 = load i32, ptr %array.index, align 4 -// CHECK:STDOUT: store i32 %5, ptr %c, align 4 +// CHECK:STDOUT: %6 = load i32, ptr %b, align 4 +// CHECK:STDOUT: %array.index = getelementptr inbounds [2 x i32], ptr %a, i32 %6 +// CHECK:STDOUT: %7 = load i32, ptr %array.index, align 4 +// CHECK:STDOUT: store i32 %7, ptr %c, align 4 // CHECK:STDOUT: %d = alloca i32, align 4 -// CHECK:STDOUT: %B = call [2 x i32] @B() -// CHECK:STDOUT: %array.index3 = extractvalue [2 x i32] %B, 1 -// CHECK:STDOUT: store i32 %array.index3, ptr %d, align 4 +// CHECK:STDOUT: %temp3 = alloca [2 x i32], align 4 +// CHECK:STDOUT: call void @B(ptr %temp3) +// CHECK:STDOUT: %array.index4 = getelementptr inbounds [2 x i32], ptr %temp3, i32 0, i32 1 +// CHECK:STDOUT: %8 = load i32, ptr %array.index4, align 4 +// CHECK:STDOUT: store i32 %8, ptr %d, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/lowering/testdata/index/tuple_return_value_access.carbon b/toolchain/lowering/testdata/index/tuple_return_value_access.carbon index ad2ddc83fbad1..d0698776764e0 100644 --- a/toolchain/lowering/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/lowering/testdata/index/tuple_return_value_access.carbon @@ -13,20 +13,23 @@ fn Run() { // CHECK:STDOUT: ; ModuleID = 'tuple_return_value_access.carbon' // CHECK:STDOUT: source_filename = "tuple_return_value_access.carbon" // CHECK:STDOUT: -// CHECK:STDOUT: define { i32, i32 } @F() { +// CHECK:STDOUT: define void @F(ptr sret({ i32, i32 }) %return) { // CHECK:STDOUT: %tuple = alloca { i32, i32 }, align 8 // CHECK:STDOUT: %1 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 0 // CHECK:STDOUT: store i32 12, ptr %1, align 4 // CHECK:STDOUT: %2 = getelementptr inbounds { i32, i32 }, ptr %tuple, i32 0, i32 1 // CHECK:STDOUT: store i32 24, ptr %2, align 4 // CHECK:STDOUT: %3 = load { i32, i32 }, ptr %tuple, align 4 -// CHECK:STDOUT: ret { i32, i32 } %3 +// CHECK:STDOUT: store { i32, i32 } %3, ptr %return, align 4 +// CHECK:STDOUT: ret void // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: define void @Run() { // CHECK:STDOUT: %t = alloca i32, align 4 -// CHECK:STDOUT: %F = call { i32, i32 } @F() -// CHECK:STDOUT: %tuple.index = extractvalue { i32, i32 } %F, 1 -// CHECK:STDOUT: store i32 %tuple.index, ptr %t, align 4 +// CHECK:STDOUT: %temp = alloca { i32, i32 }, align 8 +// CHECK:STDOUT: call void @F(ptr %temp) +// CHECK:STDOUT: %tuple.index = getelementptr inbounds { i32, i32 }, ptr %temp, i32 0, i32 1 +// CHECK:STDOUT: %1 = load i32, ptr %tuple.index, align 4 +// CHECK:STDOUT: store i32 %1, ptr %t, align 4 // CHECK:STDOUT: ret void // CHECK:STDOUT: } diff --git a/toolchain/semantics/semantics_handle_function.cpp b/toolchain/semantics/semantics_handle_function.cpp index d6932aa79ceb5..b15039055a087 100644 --- a/toolchain/semantics/semantics_handle_function.cpp +++ b/toolchain/semantics/semantics_handle_function.cpp @@ -137,8 +137,11 @@ auto SemanticsHandleReturnType(SemanticsContext& context, auto [type_parse_node, type_node_id] = context.node_stack().PopExpressionWithParseNode(); auto type_id = context.ExpressionAsType(type_parse_node, type_node_id); - context.AddNodeAndPush(parse_node, - SemanticsNode::VarStorage::Make(parse_node, type_id)); + // TODO: Use a dedicated node rather than VarStorage here. + context.AddNodeAndPush( + parse_node, + SemanticsNode::VarStorage::Make( + parse_node, type_id, context.semantics_ir().AddString("return"))); return true; } diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index 7e9893cdc9b91..872976a5afd49 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -569,12 +569,6 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, continue; } - case SemanticsNodeKind::BindName: { - auto [name_id, value_id] = node.GetAsBindName(); - node_id = value_id; - continue; - } - case SemanticsNodeKind::StubReference: { node_id = node.GetAsStubReference(); continue; diff --git a/toolchain/semantics/testdata/array/assign_return_value.carbon b/toolchain/semantics/testdata/array/assign_return_value.carbon index 04ce03c41ed40..9aee43b25b99c 100644 --- a/toolchain/semantics/testdata/array/assign_return_value.carbon +++ b/toolchain/semantics/testdata/array/assign_return_value.carbon @@ -12,8 +12,8 @@ fn Run() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block3]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: [block5]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block4]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: [block6]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -23,6 +23,7 @@ fn Run() { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, +// CHECK:STDOUT: return, // CHECK:STDOUT: Run, // CHECK:STDOUT: t, // CHECK:STDOUT: ] @@ -30,7 +31,7 @@ fn Run() { // CHECK:STDOUT: node+1, // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -45,18 +46,22 @@ fn Run() { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: ArrayType, arg0: node+10, arg1: type1, type: typeTypeType}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, +// CHECK:STDOUT: {kind: ArrayType, arg0: node+11, arg1: type1, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type3}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+13, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+14}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+14}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+17, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+18}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -68,37 +73,39 @@ fn Run() { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12: type = stub_reference i32 -// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_16.2: (type,) = tuple_value (%.loc7_12) -// CHECK:STDOUT: %.loc7_16.3: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: @@ -116,7 +123,10 @@ fn Run() { // CHECK:STDOUT: %.loc10_17: type = array_type %.loc10_16, i32 // CHECK:STDOUT: %t: [i32; 1] = var "t" // CHECK:STDOUT: %.loc10_22.1: (i32,) = call @F() -// CHECK:STDOUT: %.loc10_22.2: [i32; 1] = array_value %.loc10_22.1 -// CHECK:STDOUT: assign %t, %.loc10_22.2 +// CHECK:STDOUT: %.loc10_22.2: (i32,) = materialize_temporary +// CHECK:STDOUT: assign %.loc10_22.2, %.loc10_22.1 +// CHECK:STDOUT: %.loc10_22.3: (i32,) = value_binding %.loc10_22.2 +// CHECK:STDOUT: %.loc10_22.4: [i32; 1] = array_value %.loc10_22.3 +// CHECK:STDOUT: assign %t, %.loc10_22.4 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/array/assign_var.carbon b/toolchain/semantics/testdata/array/assign_var.carbon index e9f7ebb4efced..b2d615038e6a9 100644 --- a/toolchain/semantics/testdata/array/assign_var.carbon +++ b/toolchain/semantics/testdata/array/assign_var.carbon @@ -59,8 +59,9 @@ var b: [i32; 3] = a; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, // CHECK:STDOUT: {kind: ArrayType, arg0: node+15, arg1: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type3}, -// CHECK:STDOUT: {kind: ArrayValue, arg0: node+6, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+18}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type2}, +// CHECK:STDOUT: {kind: ArrayValue, arg0: node+18, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+19}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -86,6 +87,7 @@ var b: [i32; 3] = a; // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -118,6 +120,7 @@ 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: [i32; 3] = var "b" -// CHECK:STDOUT: %.loc7_5: [i32; 3] = array_value %a -// CHECK:STDOUT: assign %b, %.loc7_5 +// CHECK:STDOUT: %.loc7_5.1: (i32, i32, i32) = value_binding %a +// CHECK:STDOUT: %.loc7_5.2: [i32; 3] = array_value %.loc7_5.1 +// CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index 05b7f2d03c8d6..844e2dcf18323 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -23,6 +23,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, // CHECK:STDOUT: p, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -41,8 +42,10 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: {kind: ConstType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -52,11 +55,6 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, @@ -64,19 +62,23 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc11_32: type = const_type i32 -// CHECK:STDOUT: %.loc11_25: type = const_type const i32 -// CHECK:STDOUT: %.loc11_42: type = ptr_type const i32 -// CHECK:STDOUT: %.loc11_43: type = ptr_type const i32* -// CHECK:STDOUT: %.loc11_1 = fn_decl @F +// CHECK:STDOUT: %.loc11 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const i32**) -> const i32** { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %p +// CHECK:STDOUT: %.loc11: const i32** = value_binding %p +// CHECK:STDOUT: return %.loc11 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/fail_collapse.carbon b/toolchain/semantics/testdata/const/fail_collapse.carbon index 824fdb1b30c0c..c5f0f720942da 100644 --- a/toolchain/semantics/testdata/const/fail_collapse.carbon +++ b/toolchain/semantics/testdata/const/fail_collapse.carbon @@ -25,6 +25,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: G, // CHECK:STDOUT: p, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -44,6 +45,7 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type3}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type4, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type5}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] @@ -56,24 +58,23 @@ fn G(p: const (const i32)**) -> i32** { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc10_36: type = ptr_type i32 -// CHECK:STDOUT: %.loc10_37: type = ptr_type i32* -// CHECK:STDOUT: %.loc10_1 = fn_decl @G +// CHECK:STDOUT: %.loc10 = fn_decl @G // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @G(%p: const i32**) -> i32** { diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index b3ea739a688ee..4f814f747bb11 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -15,7 +15,7 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: [block4]}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block0, body: [block5]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -24,6 +24,7 @@ fn Main() { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Echo, // CHECK:STDOUT: a, +// CHECK:STDOUT: return, // CHECK:STDOUT: Main, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ @@ -36,11 +37,13 @@ fn Main() { // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -51,38 +54,40 @@ fn Main() { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_20: {} = struct_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @Echo +// CHECK:STDOUT: %.loc7 = fn_decl @Echo // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: {}) -> {} { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %.loc7: {} = value_binding %a +// CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index 49ba22edfdedf..e3043fca472a7 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -15,7 +15,7 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: [block4]}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block0, body: [block5]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -24,6 +24,7 @@ fn Main() { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Echo, // CHECK:STDOUT: a, +// CHECK:STDOUT: return, // CHECK:STDOUT: Main, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ @@ -38,11 +39,13 @@ fn Main() { // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -53,38 +56,40 @@ fn Main() { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_20: () = tuple_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @Echo +// CHECK:STDOUT: %.loc7 = fn_decl @Echo // CHECK:STDOUT: %.loc11 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: ()) -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %.loc7: () = value_binding %a +// CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { diff --git a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon index 6b0c49b693c55..70c6a2ec5cbaf 100644 --- a/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/semantics/testdata/function/call/fail_return_type_mismatch.carbon @@ -15,8 +15,8 @@ fn Run() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: [block3]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: [block4]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -25,6 +25,7 @@ fn Run() { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Foo, +// CHECK:STDOUT: return, // CHECK:STDOUT: Run, // CHECK:STDOUT: x, // CHECK:STDOUT: ] @@ -35,13 +36,14 @@ fn Run() { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: nodeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: nodeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -49,17 +51,20 @@ fn Run() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index d4389cd5663af..cf27c2a2ade91 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -15,7 +15,7 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: [block4]}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block0, body: [block5]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -25,6 +25,7 @@ fn Main() { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Echo, // CHECK:STDOUT: a, +// CHECK:STDOUT: return, // CHECK:STDOUT: Main, // CHECK:STDOUT: b, // CHECK:STDOUT: ] @@ -35,14 +36,16 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+9}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,27 +53,29 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -81,7 +86,8 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: i32) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %a +// CHECK:STDOUT: %.loc7: i32 = value_binding %a +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() { diff --git a/toolchain/semantics/testdata/function/call/return_implicit.carbon b/toolchain/semantics/testdata/function/call/return_implicit.carbon index 6b5c6e7f7208d..acd7ef4879f4a 100644 --- a/toolchain/semantics/testdata/function/call/return_implicit.carbon +++ b/toolchain/semantics/testdata/function/call/return_implicit.carbon @@ -40,7 +40,6 @@ fn Main() { // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+6}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -59,7 +58,6 @@ fn Main() { // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -79,6 +77,5 @@ fn Main() { // CHECK:STDOUT: %.loc11_11.2: () = tuple_value () // CHECK:STDOUT: %b: () = var "b" // CHECK:STDOUT: %.loc11_37: () = call @MakeImplicitEmptyTuple() -// CHECK:STDOUT: assign %b, %.loc11_37 // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/if/else.carbon b/toolchain/semantics/testdata/if/else.carbon index 06d51ba96eca1..ba6961247c264 100644 --- a/toolchain/semantics/testdata/if/else.carbon +++ b/toolchain/semantics/testdata/if/else.carbon @@ -37,7 +37,7 @@ fn If(b: bool) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -52,7 +52,8 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+6}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+8}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, @@ -89,19 +90,20 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -129,7 +131,8 @@ 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: %.loc11: bool = value_binding %b +// CHECK:STDOUT: if %.loc11 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc13_6.1: type = tuple_type () diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index 4651e633b5588..790e728e73c17 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -36,8 +36,8 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: [block4, block5, block6, block7]}, -// CHECK:STDOUT: {name: str2, param_refs: block9, return_type: type1, body: [block10, block11, block12, block13]}, -// CHECK:STDOUT: {name: str3, param_refs: block15, return_type: type1, body: [block16, block17, block18]}, +// CHECK:STDOUT: {name: str3, param_refs: block9, return_type: type1, body: [block10, block11, block12, block13]}, +// CHECK:STDOUT: {name: str4, param_refs: block15, return_type: type1, body: [block16, block17, block18]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -49,6 +49,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: If1, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: If2, // CHECK:STDOUT: If3, // CHECK:STDOUT: ] @@ -60,25 +61,31 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, // CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+7}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+15}, // CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+14}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+21}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+18}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -86,60 +93,66 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+18, -// CHECK:STDOUT: node+19, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: ], @@ -153,7 +166,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: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc9: i32 = int_literal 1 @@ -167,7 +181,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: %.loc17: bool = value_binding %b +// CHECK:STDOUT: if %.loc17 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: br !if.done @@ -181,7 +196,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: %.loc27: bool = value_binding %b +// CHECK:STDOUT: if %.loc27 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc29: i32 = int_literal 1 diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index aee59cde3a55d..3a0856700af1f 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -27,6 +27,7 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: VarScope, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: n, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ @@ -37,13 +38,16 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+5}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] @@ -52,25 +56,28 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -80,13 +87,15 @@ 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: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n: i32 = var "n" -// CHECK:STDOUT: %.loc9: i32 = int_literal 2 -// CHECK:STDOUT: assign %n, %.loc9 -// CHECK:STDOUT: return %n +// CHECK:STDOUT: %.loc9_18: i32 = int_literal 2 +// CHECK:STDOUT: assign %n, %.loc9_18 +// CHECK:STDOUT: %.loc9_9: i32 = value_binding %n +// CHECK:STDOUT: return %.loc9_9 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: return diff --git a/toolchain/semantics/testdata/if/no_else.carbon b/toolchain/semantics/testdata/if/no_else.carbon index 49d04ca6bbb3f..87a4a12ee19ae 100644 --- a/toolchain/semantics/testdata/if/no_else.carbon +++ b/toolchain/semantics/testdata/if/no_else.carbon @@ -32,7 +32,7 @@ fn If(b: bool) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -45,7 +45,8 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+6}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, @@ -76,15 +77,16 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -106,7 +108,8 @@ 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: %.loc10: bool = value_binding %b +// CHECK:STDOUT: if %.loc10 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc12_6.1: type = tuple_type () diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index 7e7a920c04e83..863a587b2dc40 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -26,6 +26,7 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: If, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, @@ -35,31 +36,31 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], @@ -67,6 +68,10 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -75,7 +80,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: %.loc7: bool = value_binding %b +// CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc9: i32 = int_literal 1 diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index 4a704e8056b56..f45a960ee1c76 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -21,6 +21,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: b, // CHECK:STDOUT: n, // CHECK:STDOUT: m, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, @@ -32,15 +33,21 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+5}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+1, arg1: node+2, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+1, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+6}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+7}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+8, arg1: node+9, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+11, arg1: node+12, type: type1}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+10}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+13}, // CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -49,6 +56,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -56,23 +64,28 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -82,14 +95,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: %.loc7_6: bool = value_binding %b +// CHECK:STDOUT: if %.loc7_6 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: %.loc7_15.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc7_23.1: i32 = value_binding %m +// CHECK:STDOUT: %.loc8_22: i32 = add %.loc7_15.1, %.loc7_23.1 // 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: %.loc7_23.2: i32 = value_binding %m +// CHECK:STDOUT: %.loc7_15.2: i32 = value_binding %n +// CHECK:STDOUT: %.loc8_33: i32 = add %.loc7_23.2, %.loc7_15.2 // CHECK:STDOUT: br !if.expr.result(%.loc8_33) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: diff --git a/toolchain/semantics/testdata/if_expression/constant_condition.carbon b/toolchain/semantics/testdata/if_expression/constant_condition.carbon index cad918d6b5556..8009f0c81c7c6 100644 --- a/toolchain/semantics/testdata/if_expression/constant_condition.carbon +++ b/toolchain/semantics/testdata/if_expression/constant_condition.carbon @@ -17,10 +17,10 @@ fn G() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: [block3]}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: [block4, block5, block6, block7]}, -// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, body: [block8, block9, block10, block11]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, body: [block7, block8, block9, block10]}, +// CHECK:STDOUT: {name: str4, param_refs: block0, return_type: type0, body: [block12, block13, block14, block15]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -30,6 +30,7 @@ fn G() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: A, +// CHECK:STDOUT: return, // CHECK:STDOUT: B, // CHECK:STDOUT: F, // CHECK:STDOUT: G, @@ -41,84 +42,124 @@ fn G() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, -// CHECK:STDOUT: {kind: Branch, arg0: block6}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+10}, +// CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+13}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+10}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+11}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+17}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+20}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+17}, -// CHECK:STDOUT: {kind: Branch, arg0: block10}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block13, arg1: node+27}, +// CHECK:STDOUT: {kind: Branch, arg0: block14}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+30}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+31, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+20}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+21}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block11, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+35, arg1: node+34}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+35, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+33}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+37}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block15, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+40}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+17, // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+20, // CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+21, // CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+24, // CHECK:STDOUT: node+25, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+28, +// CHECK:STDOUT: node+29, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+30, +// CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+32, +// CHECK:STDOUT: node+33, +// CHECK:STDOUT: node+38, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+35, +// CHECK:STDOUT: node+36, +// CHECK:STDOUT: node+37, +// CHECK:STDOUT: node+39, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+41, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -146,12 +187,18 @@ 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: %.loc11_24: i32 = call @A() -// CHECK:STDOUT: br !if.expr.result(%.loc11_24) +// CHECK:STDOUT: %.loc11_24.1: i32 = call @A() +// CHECK:STDOUT: %.loc11_24.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_24.2, %.loc11_24.1 +// CHECK:STDOUT: %.loc11_24.3: i32 = value_binding %.loc11_24.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_24.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_33: i32 = call @B() -// CHECK:STDOUT: br !if.expr.result(%.loc11_33) +// CHECK:STDOUT: %.loc11_33.1: i32 = call @B() +// CHECK:STDOUT: %.loc11_33.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_33.2, %.loc11_33.1 +// CHECK:STDOUT: %.loc11_33.3: i32 = value_binding %.loc11_33.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_33.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_10: i32 = block_arg !if.expr.result @@ -164,12 +211,18 @@ 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: %.loc15_25: i32 = call @A() -// CHECK:STDOUT: br !if.expr.result(%.loc15_25) +// CHECK:STDOUT: %.loc15_25.1: i32 = call @A() +// CHECK:STDOUT: %.loc15_25.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc15_25.2, %.loc15_25.1 +// CHECK:STDOUT: %.loc15_25.3: i32 = value_binding %.loc15_25.2 +// CHECK:STDOUT: br !if.expr.result(%.loc15_25.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc15_34: i32 = call @B() -// CHECK:STDOUT: br !if.expr.result(%.loc15_34) +// CHECK:STDOUT: %.loc15_34.1: i32 = call @B() +// CHECK:STDOUT: %.loc15_34.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc15_34.2, %.loc15_34.1 +// CHECK:STDOUT: %.loc15_34.3: i32 = value_binding %.loc15_34.2 +// CHECK:STDOUT: br !if.expr.result(%.loc15_34.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc15_10: i32 = block_arg !if.expr.result diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index aa4f67b157267..4eddea5ba9cf0 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -13,9 +13,9 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: [block3]}, -// CHECK:STDOUT: {name: str2, param_refs: block5, return_type: type0, body: [block6, block7, block8, block9]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block7, return_type: type0, body: [block8, block9, block10, block11]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -25,6 +25,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: A, +// CHECK:STDOUT: return, // CHECK:STDOUT: B, // CHECK:STDOUT: F, // CHECK:STDOUT: b, @@ -36,60 +37,84 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+6}, -// CHECK:STDOUT: {kind: Branch, arg0: block8}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+11}, +// CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+14}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+15, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+10}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+11}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+18}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+17}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+21}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block11, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+24}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -113,15 +138,22 @@ 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: %.loc10: bool = value_binding %b +// CHECK:STDOUT: if %.loc10 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc11_21: i32 = call @A() -// CHECK:STDOUT: br !if.expr.result(%.loc11_21) +// CHECK:STDOUT: %.loc11_21.1: i32 = call @A() +// CHECK:STDOUT: %.loc11_21.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_21.2, %.loc11_21.1 +// CHECK:STDOUT: %.loc11_21.3: i32 = value_binding %.loc11_21.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_21.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_30: i32 = call @B() -// CHECK:STDOUT: br !if.expr.result(%.loc11_30) +// CHECK:STDOUT: %.loc11_30.1: i32 = call @B() +// CHECK:STDOUT: %.loc11_30.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_30.2, %.loc11_30.1 +// CHECK:STDOUT: %.loc11_30.3: i32 = value_binding %.loc11_30.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_30.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_10: i32 = block_arg !if.expr.result diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index ded985573b484..bf9f5b10096b7 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -25,6 +25,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: a, // CHECK:STDOUT: b, // CHECK:STDOUT: c, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, @@ -36,27 +37,31 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+5}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+8}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+8}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+9}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+11}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+12}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+16}, // CHECK:STDOUT: {kind: Branch, arg0: block11}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+16}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+20}, // CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+12}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+15}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+23}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+22}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+26}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -65,6 +70,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -72,47 +78,50 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+17, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+20, // CHECK:STDOUT: node+22, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -122,10 +131,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: %.loc7_6: bool = value_binding %a +// CHECK:STDOUT: if %.loc7_6 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: %.loc7_15: bool = value_binding %b +// CHECK:STDOUT: if %.loc7_15 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 @@ -140,7 +151,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: %.loc7_24: bool = value_binding %c +// CHECK:STDOUT: if %.loc7_24 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/semantics/testdata/index/array_element_access.carbon b/toolchain/semantics/testdata/index/array_element_access.carbon index 71a78d140d755..3c4e649d96773 100644 --- a/toolchain/semantics/testdata/index/array_element_access.carbon +++ b/toolchain/semantics/testdata/index/array_element_access.carbon @@ -56,10 +56,12 @@ var d: i32 = a[b]; // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+15, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+16}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, // CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+11, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+19}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -86,6 +88,8 @@ var d: i32 = a[b]; // CHECK:STDOUT: node+18, // CHECK:STDOUT: node+19, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, @@ -110,9 +114,11 @@ var d: i32 = a[b]; // CHECK:STDOUT: assign %b, %.loc8 // CHECK:STDOUT: %c: i32 = var "c" // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_17: i32 = array_index %a, %.loc9_16 -// CHECK:STDOUT: assign %c, %.loc9_17 +// CHECK:STDOUT: %.loc9_17.1: i32 = array_index %a, %.loc9_16 +// CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 +// CHECK:STDOUT: assign %c, %.loc9_17.2 // CHECK:STDOUT: %d: i32 = var "d" -// CHECK:STDOUT: %.loc10: i32 = array_index %a, %b -// CHECK:STDOUT: assign %d, %.loc10 +// CHECK:STDOUT: %.loc10_17.1: i32 = array_index %a, %b +// CHECK:STDOUT: %.loc10_17.2: i32 = value_binding %.loc10_17.1 +// CHECK:STDOUT: assign %d, %.loc10_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon b/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon index 737fa17e8dea3..90aa5dec0854a 100644 --- a/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon @@ -51,10 +51,11 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: nodeError}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -76,6 +77,7 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -101,7 +103,8 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var "b" -// CHECK:STDOUT: assign %b, %a +// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %a +// CHECK:STDOUT: assign %b, %.loc7_5 // CHECK:STDOUT: %c: i32 = var "c" // CHECK:STDOUT: %.loc12: i32 = int_literal -1 // CHECK:STDOUT: assign %c, diff --git a/toolchain/semantics/testdata/index/tuple_element_access.carbon b/toolchain/semantics/testdata/index/tuple_element_access.carbon index 4cba2ec1be7cf..cc5a68aea1ec1 100644 --- a/toolchain/semantics/testdata/index/tuple_element_access.carbon +++ b/toolchain/semantics/testdata/index/tuple_element_access.carbon @@ -48,11 +48,13 @@ var c: i32 = b[0]; // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+11, arg1: node+14, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+15}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+11, arg1: node+15, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -75,6 +77,8 @@ var c: i32 = b[0]; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -100,9 +104,11 @@ var c: i32 = b[0]; // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var "b" -// CHECK:STDOUT: assign %b, %a +// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %a +// CHECK:STDOUT: assign %b, %.loc7_5 // CHECK:STDOUT: %c: i32 = var "c" // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 -// CHECK:STDOUT: %.loc9_17: i32 = tuple_index %b, %.loc9_16 -// CHECK:STDOUT: assign %c, %.loc9_17 +// CHECK:STDOUT: %.loc9_17.1: i32 = tuple_index %b, %.loc9_16 +// CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 +// CHECK:STDOUT: assign %c, %.loc9_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/tuple_return_value_access.carbon b/toolchain/semantics/testdata/index/tuple_return_value_access.carbon index 158b7314bf901..8ca2ba7c0386d 100644 --- a/toolchain/semantics/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/semantics/testdata/index/tuple_return_value_access.carbon @@ -12,8 +12,8 @@ fn Run() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block3]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1, body: [block5]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block4]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type1, body: [block7]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -23,6 +23,7 @@ fn Run() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, +// CHECK:STDOUT: return, // CHECK:STDOUT: Run, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ @@ -43,16 +44,21 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+10, arg1: node+11, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+12}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+13, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -63,34 +69,39 @@ fn Run() -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12: type = stub_reference i32 -// CHECK:STDOUT: %.loc7_16.1: type = tuple_type (type) -// CHECK:STDOUT: %.loc7_16.2: (type,) = tuple_value (%.loc7_12) -// CHECK:STDOUT: %.loc7_16.3: type = tuple_type (i32) -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: %.loc9 = fn_decl @Run // CHECK:STDOUT: } // CHECK:STDOUT: @@ -104,8 +115,11 @@ fn Run() -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @Run() -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10_11: (i32,) = call @F() +// CHECK:STDOUT: %.loc10_11.1: (i32,) = call @F() // CHECK:STDOUT: %.loc10_14: i32 = int_literal 0 -// CHECK:STDOUT: %.loc10_15: i32 = tuple_index %.loc10_11, %.loc10_14 -// CHECK:STDOUT: return %.loc10_15 +// CHECK:STDOUT: %.loc10_11.2: (i32,) = materialize_temporary +// CHECK:STDOUT: assign %.loc10_11.2, %.loc10_11.1 +// CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11.2, %.loc10_14 +// CHECK:STDOUT: %.loc10_15.2: i32 = value_binding %.loc10_15.1 +// CHECK:STDOUT: return %.loc10_15.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/and.carbon b/toolchain/semantics/testdata/operators/and.carbon index 48ec3b2076651..1096494e20df6 100644 --- a/toolchain/semantics/testdata/operators/and.carbon +++ b/toolchain/semantics/testdata/operators/and.carbon @@ -13,9 +13,9 @@ fn And() -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: [block3]}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: [block4, block5, block6]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, body: [block7, block8, block9]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -23,6 +23,7 @@ fn And() -> bool { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, +// CHECK:STDOUT: return, // CHECK:STDOUT: G, // CHECK:STDOUT: And, // CHECK:STDOUT: ] @@ -32,51 +33,75 @@ fn And() -> bool { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+7}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+8}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+11}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+17}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+20}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+22}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: node+23, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -100,13 +125,19 @@ fn And() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @And() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11: bool = call @F() +// CHECK:STDOUT: %.loc11_11.1: bool = call @F() +// CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary +// CHECK:STDOUT: assign %.loc11_11.2, %.loc11_11.1 +// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 // CHECK:STDOUT: %.loc11_14.1: bool = bool_literal false -// CHECK:STDOUT: if %.loc11_11 br !and.rhs else br !and.result(%.loc11_14.1) +// CHECK:STDOUT: if %.loc11_11.3 br !and.rhs else br !and.result(%.loc11_14.1) // CHECK:STDOUT: // CHECK:STDOUT: !and.rhs: -// CHECK:STDOUT: %.loc11_19: bool = call @G() -// CHECK:STDOUT: br !and.result(%.loc11_19) +// CHECK:STDOUT: %.loc11_19.1: bool = call @G() +// CHECK:STDOUT: %.loc11_19.2: bool = materialize_temporary +// CHECK:STDOUT: assign %.loc11_19.2, %.loc11_19.1 +// CHECK:STDOUT: %.loc11_19.3: bool = value_binding %.loc11_19.2 +// CHECK:STDOUT: br !and.result(%.loc11_19.3) // CHECK:STDOUT: // CHECK:STDOUT: !and.result: // CHECK:STDOUT: %.loc11_14.2: bool = block_arg !and.result diff --git a/toolchain/semantics/testdata/operators/assignment.carbon b/toolchain/semantics/testdata/operators/assignment.carbon index 24da4f75b78bd..d971581c28259 100644 --- a/toolchain/semantics/testdata/operators/assignment.carbon +++ b/toolchain/semantics/testdata/operators/assignment.carbon @@ -118,19 +118,21 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, // CHECK:STDOUT: {kind: Assign, arg0: node+45, arg1: node+46}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+45, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+45, type: type4}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+48, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+48, arg1: node+49}, +// CHECK:STDOUT: {kind: Assign, arg0: node+49, arg1: node+50}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type5}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+51}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+52}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+45, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+45}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+54}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+55}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+56}, // CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type4}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+57, type: type0}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+59, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+58, arg1: node+59}, +// CHECK:STDOUT: {kind: Assign, arg0: node+60, arg1: node+61}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -191,6 +193,7 @@ fn Main() { // CHECK:STDOUT: node+51, // CHECK:STDOUT: node+52, // CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+54, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, @@ -214,17 +217,18 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+55, +// CHECK:STDOUT: node+57, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+54, // CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+58, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+57, -// CHECK:STDOUT: node+58, // CHECK:STDOUT: node+59, // CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+62, +// CHECK:STDOUT: node+63, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -277,14 +281,16 @@ fn Main() { // CHECK:STDOUT: %p: i32* = var "p" // CHECK:STDOUT: %.loc19_17: i32* = address_of %a // CHECK:STDOUT: assign %p, %.loc19_17 -// CHECK:STDOUT: %.loc20_3: i32 = dereference %p +// CHECK:STDOUT: %.loc19_7.1: i32* = value_binding %p +// CHECK:STDOUT: %.loc20_3: i32 = dereference %.loc19_7.1 // 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: br !if.expr.result(%p) +// CHECK:STDOUT: %.loc19_7.2: i32* = value_binding %p +// CHECK:STDOUT: br !if.expr.result(%.loc19_7.2) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: // CHECK:STDOUT: %.loc22_25: i32* = address_of %a diff --git a/toolchain/semantics/testdata/operators/binary_op.carbon b/toolchain/semantics/testdata/operators/binary_op.carbon index 3521c082a20b3..7e2617cf3b034 100644 --- a/toolchain/semantics/testdata/operators/binary_op.carbon +++ b/toolchain/semantics/testdata/operators/binary_op.carbon @@ -10,7 +10,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -20,6 +20,7 @@ fn Main() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -27,11 +28,12 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+1, arg1: node+2, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+3, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -41,9 +43,12 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon index 6c0a6d55b68b2..f14b1859f6c7a 100644 --- a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -48,7 +48,7 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0}, -// CHECK:STDOUT: {name: str1, param_refs: block0, body: [block2, block11, block12, block13, block14, block15, block16]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, body: [block3, block12, block13, block14, block15, block16, block17]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -74,6 +74,7 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, +// CHECK:STDOUT: return, // CHECK:STDOUT: Main, // CHECK:STDOUT: n, // CHECK:STDOUT: x, @@ -82,8 +83,8 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+40, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+43, // CHECK:STDOUT: nodeBoolType, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ @@ -93,75 +94,80 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+4}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+6}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block3, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+15, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+16, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+18}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+20, arg1: node+21}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+20, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type1}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+19}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+22}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+24, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+26, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+28, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+25, arg1: node+30}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+29, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int9, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+31, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block7, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+28, arg1: node+33}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+32}, +// CHECK:STDOUT: {kind: Assign, arg0: nodeIntegerType, arg1: node+35}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int10, type: type0}, -// CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+34, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+37, type: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block7, type: typeTypeType}, -// CHECK:STDOUT: {kind: StructValue, arg0: block8, type: type2}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int11, type: type0}, +// CHECK:STDOUT: {kind: StructTypeField, arg0: str5, arg1: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+40, type: type0}, +// CHECK:STDOUT: {kind: StructType, arg0: block8, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructValue, arg0: block9, type: type2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, -// CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+42, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str4, arg1: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+45, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block10, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+41, arg1: node+48}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int13, type: type0}, +// CHECK:STDOUT: {kind: StructTypeField, arg0: str5, arg1: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+48, type: type0}, +// CHECK:STDOUT: {kind: StructValue, arg0: block11, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+44, arg1: node+51}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+50}, -// CHECK:STDOUT: {kind: Branch, arg0: block12}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block12, arg1: node+53}, +// CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int15, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+53}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+54}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+56}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block14, arg1: node+57}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block14, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int16, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+57, arg1: node+58}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str5, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+60, arg1: node+61}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str6, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block14, arg1: node+61}, -// CHECK:STDOUT: {kind: Branch, arg0: block15}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+60}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block16, arg1: node+60}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block16, type: type0}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+64}, +// CHECK:STDOUT: {kind: Branch, arg0: block16}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+63, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+63, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+67}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+68}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block17, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int17, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+66, arg1: node+67}, +// CHECK:STDOUT: {kind: Assign, arg0: node+71, arg1: node+72}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -169,10 +175,12 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, @@ -205,82 +213,87 @@ fn Main() { // CHECK:STDOUT: node+32, // CHECK:STDOUT: node+33, // CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, // CHECK:STDOUT: node+37, // CHECK:STDOUT: node+39, // CHECK:STDOUT: node+40, -// CHECK:STDOUT: node+41, // CHECK:STDOUT: node+42, +// CHECK:STDOUT: node+43, // CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, // CHECK:STDOUT: node+47, // CHECK:STDOUT: node+48, -// CHECK:STDOUT: node+49, // CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, // CHECK:STDOUT: node+52, +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+27, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+29, +// CHECK:STDOUT: node+30, +// CHECK:STDOUT: node+32, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+35, // CHECK:STDOUT: node+38, +// CHECK:STDOUT: node+41, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+36, // CHECK:STDOUT: node+39, +// CHECK:STDOUT: node+42, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+43, // CHECK:STDOUT: node+46, +// CHECK:STDOUT: node+49, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+44, // CHECK:STDOUT: node+47, +// CHECK:STDOUT: node+50, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+53, -// CHECK:STDOUT: node+55, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+54, // CHECK:STDOUT: node+56, +// CHECK:STDOUT: node+58, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+57, -// CHECK:STDOUT: node+58, // CHECK:STDOUT: node+59, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, // CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+64, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+66, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+66, // CHECK:STDOUT: node+67, -// CHECK:STDOUT: node+68, // CHECK:STDOUT: node+69, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+68, +// CHECK:STDOUT: node+70, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+71, +// CHECK:STDOUT: node+72, +// CHECK:STDOUT: node+73, +// CHECK:STDOUT: node+74, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { @@ -311,10 +324,12 @@ fn Main() { // CHECK:STDOUT: %.loc21_17: (i32, i32) = tuple_value (%.loc21_13.2, %.loc21_16.2) // CHECK:STDOUT: assign %.loc21_8.2, %.loc21_17 // CHECK:STDOUT: %n: i32 = var "n" -// CHECK:STDOUT: %.loc22: i32 = int_literal 0 -// CHECK:STDOUT: assign %n, %.loc22 -// CHECK:STDOUT: %.loc26_4: i32 = stub_reference %n -// CHECK:STDOUT: %.loc26_7: i32 = stub_reference %n +// CHECK:STDOUT: %.loc22_16: i32 = int_literal 0 +// CHECK:STDOUT: assign %n, %.loc22_16 +// CHECK:STDOUT: %.loc22_7.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc26_4: i32 = stub_reference %.loc22_7.1 +// CHECK:STDOUT: %.loc22_7.2: i32 = value_binding %n +// CHECK:STDOUT: %.loc26_7: i32 = stub_reference %.loc22_7.2 // CHECK:STDOUT: %.loc26_8: (i32, i32) = tuple_value (%.loc26_4, %.loc26_7) // CHECK:STDOUT: %.loc26_13.1: i32 = int_literal 1 // CHECK:STDOUT: %.loc26_13.2: i32 = stub_reference %.loc26_13.1 @@ -356,10 +371,12 @@ 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: br !if.expr.result.loc45(%a) +// CHECK:STDOUT: %.loc41_7.1: i32 = value_binding %a +// CHECK:STDOUT: br !if.expr.result.loc45(%.loc41_7.1) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else.loc45: -// CHECK:STDOUT: br !if.expr.result.loc45(%a) +// CHECK:STDOUT: %.loc41_7.2: i32 = value_binding %a +// CHECK:STDOUT: br !if.expr.result.loc45(%.loc41_7.2) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc45: // CHECK:STDOUT: %.loc45_4: i32 = block_arg !if.expr.result.loc45 diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon index eeaeaacb08b2b..5888b33a6ed06 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -23,6 +23,7 @@ fn Main() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -31,10 +32,11 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+2, type: typeError}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+3, type: typeError}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -45,9 +47,12 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon index d17df6a636dac..cc7474f8a1dcd 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_assignment.carbon @@ -38,7 +38,7 @@ fn Main() { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+2}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: nodeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -67,6 +67,6 @@ fn Main() { // CHECK:STDOUT: %.loc8: i32 = int_literal 3 // CHECK:STDOUT: assign %a, %.loc8 // CHECK:STDOUT: %.loc12: f64 = real_literal 56e-1 -// CHECK:STDOUT: assign %a, %.loc12 +// CHECK:STDOUT: assign %a, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon index 08b62c947b831..a8afd2926fd7f 100644 --- a/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon +++ b/toolchain/semantics/testdata/operators/fail_type_mismatch_once.carbon @@ -15,7 +15,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 12, @@ -26,6 +26,7 @@ fn Main() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -34,12 +35,13 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+2, type: typeError}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+3, type: typeError}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+4, type: typeError}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: nodeError, arg1: node+5, type: typeError}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,11 +52,14 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/operators/or.carbon b/toolchain/semantics/testdata/operators/or.carbon index 6f18d26860fe3..bc6b6be790093 100644 --- a/toolchain/semantics/testdata/operators/or.carbon +++ b/toolchain/semantics/testdata/operators/or.carbon @@ -13,9 +13,9 @@ fn Or() -> bool { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: [block3]}, -// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: [block4, block5, block6]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block0, return_type: type0, body: [block7, block8, block9]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -23,6 +23,7 @@ fn Or() -> bool { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, +// CHECK:STDOUT: return, // CHECK:STDOUT: G, // CHECK:STDOUT: Or, // CHECK:STDOUT: ] @@ -32,53 +33,77 @@ fn Or() -> bool { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+7, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+10}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+8}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+9}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+14}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+15}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block6, arg1: node+12}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block6, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+18}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+21}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -102,14 +127,20 @@ fn Or() -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @Or() -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11_11: bool = call @F() -// CHECK:STDOUT: %.loc11_14.1: bool = not %.loc11_11 +// CHECK:STDOUT: %.loc11_11.1: bool = call @F() +// CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary +// CHECK:STDOUT: assign %.loc11_11.2, %.loc11_11.1 +// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 +// CHECK:STDOUT: %.loc11_14.1: bool = not %.loc11_11.3 // CHECK:STDOUT: %.loc11_14.2: bool = bool_literal true // CHECK:STDOUT: if %.loc11_14.1 br !or.rhs else br !or.result(%.loc11_14.2) // CHECK:STDOUT: // CHECK:STDOUT: !or.rhs: -// CHECK:STDOUT: %.loc11_18: bool = call @G() -// CHECK:STDOUT: br !or.result(%.loc11_18) +// CHECK:STDOUT: %.loc11_18.1: bool = call @G() +// CHECK:STDOUT: %.loc11_18.2: bool = materialize_temporary +// CHECK:STDOUT: assign %.loc11_18.2, %.loc11_18.1 +// CHECK:STDOUT: %.loc11_18.3: bool = value_binding %.loc11_18.2 +// CHECK:STDOUT: br !or.result(%.loc11_18.3) // CHECK:STDOUT: // CHECK:STDOUT: !or.result: // CHECK:STDOUT: %.loc11_14.3: bool = block_arg !or.result diff --git a/toolchain/semantics/testdata/operators/unary_op.carbon b/toolchain/semantics/testdata/operators/unary_op.carbon index 45231fbc5a1a2..0022fb1e41bd8 100644 --- a/toolchain/semantics/testdata/operators/unary_op.carbon +++ b/toolchain/semantics/testdata/operators/unary_op.carbon @@ -19,6 +19,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Not, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, @@ -27,25 +28,29 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+3, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -55,6 +60,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: %.loc7: bool = value_binding %b +// CHECK:STDOUT: %.loc8: bool = not %.loc7 // CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_deref.carbon b/toolchain/semantics/testdata/pointer/address_of_deref.carbon index 3afa7d4d2c64e..6f2bf16c3a8d4 100644 --- a/toolchain/semantics/testdata/pointer/address_of_deref.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_deref.carbon @@ -11,7 +11,7 @@ fn F() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -20,25 +20,28 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, +// CHECK:STDOUT: return, // CHECK:STDOUT: n, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ -// CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+5, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+6, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+7, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+7, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -48,6 +51,8 @@ fn F() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, @@ -56,6 +61,8 @@ fn F() -> i32 { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -72,6 +79,7 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc9_13.2: i32* = address_of %n // CHECK:STDOUT: %.loc9_12: i32 = dereference %.loc9_13.2 // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 -// CHECK:STDOUT: %.loc9_10: i32 = dereference %.loc9_11 -// CHECK:STDOUT: return %.loc9_10 +// CHECK:STDOUT: %.loc9_10.1: i32 = dereference %.loc9_11 +// CHECK:STDOUT: %.loc9_10.2: i32 = value_binding %.loc9_10.1 +// CHECK:STDOUT: return %.loc9_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/basic.carbon b/toolchain/semantics/testdata/pointer/basic.carbon index ad640649470e3..57e89b56a166a 100644 --- a/toolchain/semantics/testdata/pointer/basic.carbon +++ b/toolchain/semantics/testdata/pointer/basic.carbon @@ -13,7 +13,7 @@ fn F() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -22,26 +22,30 @@ fn F() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, +// CHECK:STDOUT: return, // CHECK:STDOUT: n, // CHECK:STDOUT: p, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ -// CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+1, arg1: node+2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+6}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+5, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -51,6 +55,8 @@ fn F() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, @@ -59,6 +65,9 @@ fn F() -> i32 { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -75,6 +84,8 @@ fn F() -> i32 { // CHECK:STDOUT: %p: i32* = var "p" // CHECK:STDOUT: %.loc9_17: i32* = address_of %n // CHECK:STDOUT: assign %p, %.loc9_17 -// CHECK:STDOUT: %.loc11: i32 = dereference %p -// CHECK:STDOUT: return %.loc11 +// CHECK:STDOUT: %.loc9_7: i32* = value_binding %p +// CHECK:STDOUT: %.loc11_10.1: i32 = dereference %.loc9_7 +// CHECK:STDOUT: %.loc11_10.2: i32 = value_binding %.loc11_10.1 +// CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon index 530772b09ef97..077e09013c97e 100644 --- a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon @@ -40,7 +40,7 @@ fn AddressOfOperator() { // CHECK:STDERR: &(1 + 1); // CHECK:STDERR: ^ &(1 + 1); - // CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+3]]:3: Cannot take the address of non-reference expression. + // CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+3]]:3: Cannot take the address of a temporary object. // CHECK:STDERR: &H().a; // CHECK:STDERR: ^ &H().a; @@ -78,12 +78,12 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1}, -// CHECK:STDOUT: {name: str3, param_refs: block0, body: [block3]}, -// CHECK:STDOUT: {name: str5, param_refs: block0, body: [block7]}, -// CHECK:STDOUT: {name: str6, param_refs: block0, body: [block8]}, -// CHECK:STDOUT: {name: str7, param_refs: block0, body: [block9]}, -// CHECK:STDOUT: {name: str8, param_refs: block0, body: [block10]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type1}, +// CHECK:STDOUT: {name: str4, param_refs: block0, body: [block5]}, +// CHECK:STDOUT: {name: str6, param_refs: block0, body: [block9]}, +// CHECK:STDOUT: {name: str7, param_refs: block0, body: [block10]}, +// CHECK:STDOUT: {name: str8, param_refs: block0, body: [block11]}, +// CHECK:STDOUT: {name: str9, param_refs: block0, body: [block12]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -101,6 +101,7 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: G, +// CHECK:STDOUT: return, // CHECK:STDOUT: H, // CHECK:STDOUT: a, // CHECK:STDOUT: AddressOfLiteral, @@ -112,19 +113,19 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: nodeFloatingPointType, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: nodeStringType, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+29, -// CHECK:STDOUT: node+49, -// CHECK:STDOUT: node+51, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -133,70 +134,74 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, +// CHECK:STDOUT: {kind: StructType, arg0: block4, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+5, type: type2}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+7, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, // CHECK:STDOUT: {kind: PointerType, arg0: type3, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+8, type: type4}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+10, type: type4}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type5}, // CHECK:STDOUT: {kind: PointerType, arg0: type5, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+11, type: type6}, -// CHECK:STDOUT: {kind: StringLiteral, arg0: str4, type: type7}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+13, type: type6}, +// CHECK:STDOUT: {kind: StringLiteral, arg0: str5, type: type7}, // CHECK:STDOUT: {kind: PointerType, arg0: type7, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+14, type: type8}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+16, type: type8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+21, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type9}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type9}, // CHECK:STDOUT: {kind: PointerType, arg0: type9, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+22, type: type10}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+24, type: type10}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+25, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block6, type: type1}, +// CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: StructValue, arg0: block8, type: type1}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+28, type: type11}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+30, type: type11}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+33, arg1: node+34, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+35, type: type2}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+35, arg1: node+36, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+37, type: type2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+37, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+38, type: type2}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+40, arg1: node+39}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+40, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+42, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+40, type: type3}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+41, type: type4}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+44, type: type3}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+45, type: type4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function4}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+45, type: type2}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+49, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function5}, // CHECK:STDOUT: {kind: PointerType, arg0: typeTypeType, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: nodeIntegerType, type: type12}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type13, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+52, type: type12}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+56, type: type12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+56, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+60, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+58, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block11, type: type9}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+62, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block13, type: type9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+60, arg1: node+61, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+62, type: type2}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+64, arg1: node+65, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+66, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -204,21 +209,25 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+52, +// CHECK:STDOUT: node+59, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+32, -// CHECK:STDOUT: node+44, -// CHECK:STDOUT: node+48, -// CHECK:STDOUT: node+55, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, @@ -238,25 +247,25 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, // CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+28, // CHECK:STDOUT: node+29, // CHECK:STDOUT: node+30, // CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+32, +// CHECK:STDOUT: node+33, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+33, -// CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, // CHECK:STDOUT: node+37, @@ -266,8 +275,7 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+41, // CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ +// CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, // CHECK:STDOUT: node+46, // CHECK:STDOUT: node+47, @@ -276,31 +284,35 @@ fn AddressOfTupleElementValue() { // CHECK:STDOUT: node+49, // CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, -// CHECK:STDOUT: node+52, -// CHECK:STDOUT: node+53, -// CHECK:STDOUT: node+54, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: node+56, // CHECK:STDOUT: node+57, // CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+59, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, // CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, // CHECK:STDOUT: node+64, +// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+66, +// CHECK:STDOUT: node+67, +// CHECK:STDOUT: node+68, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+57, -// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+63, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @G -// CHECK:STDOUT: %.loc9_19: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc9_1 = fn_decl @H +// CHECK:STDOUT: %.loc9 = fn_decl @H // CHECK:STDOUT: %.loc11 = fn_decl @AddressOfLiteral // CHECK:STDOUT: %.loc38 = fn_decl @AddressOfOperator // CHECK:STDOUT: %.loc53 = fn_decl @AddressOfCall @@ -348,8 +360,10 @@ fn AddressOfTupleElementValue() { // 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: %.loc46_5: {.a: i32} = call @H() -// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5, member0 +// CHECK:STDOUT: %.loc46_5.1: {.a: i32} = call @H() +// CHECK:STDOUT: %.loc46_5.2: {.a: i32} = materialize_temporary +// CHECK:STDOUT: assign %.loc46_5.2, %.loc46_5.1 +// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5.2, member0 // CHECK:STDOUT: %.loc46_3: i32* = address_of %.loc46_7 // CHECK:STDOUT: %.loc50_9: bool = bool_literal true // CHECK:STDOUT: %.loc50_5: bool = not %.loc50_9 diff --git a/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon b/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon index 38c63ba558be3..8d220891c484e 100644 --- a/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon +++ b/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon @@ -33,8 +33,8 @@ fn Deref(n: i32) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -43,13 +43,14 @@ fn Deref(n: i32) { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+0, type: typeError}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+2, type: typeError}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+4, type: typeError}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+5, type: typeError}, // CHECK:STDOUT: {kind: StructType, arg0: block0, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type2}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+7, type: typeError}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: typeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -73,6 +74,7 @@ fn Deref(n: i32) { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -82,7 +84,8 @@ fn Deref(n: i32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Deref(%n: i32) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: = dereference %n +// CHECK:STDOUT: %.loc7: i32 = value_binding %n +// CHECK:STDOUT: %.loc11: = dereference %.loc7 // CHECK:STDOUT: %.loc15_5.1: type = tuple_type () // CHECK:STDOUT: %.loc15_5.2: () = tuple_value () // CHECK:STDOUT: %.loc15_3: = dereference %.loc15_5.2 diff --git a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon index c33edf29183cd..89ab0c3cf75bd 100644 --- a/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/pointer/fail_type_mismatch.carbon @@ -22,6 +22,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: ConstMismatch, // CHECK:STDOUT: p, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: node+0, @@ -41,6 +42,7 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: ConstType, arg0: type3, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type4}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] @@ -53,26 +55,24 @@ fn ConstMismatch(p: const {}*) -> const ({}*) { // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+4, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_43: {} = struct_value () -// CHECK:STDOUT: %.loc7_44: type = ptr_type {} -// CHECK:STDOUT: %.loc7_35: type = const_type {}* -// CHECK:STDOUT: %.loc7_1 = fn_decl @ConstMismatch +// CHECK:STDOUT: %.loc7 = fn_decl @ConstMismatch // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstMismatch(%p: const {}*) -> const ({}*) { diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index 38d2f82b26e09..2e45ab172b847 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -20,6 +20,7 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, // CHECK:STDOUT: p, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -39,10 +40,14 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: {kind: ConstType, arg0: type4, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type5}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+5, type: type3}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type5}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type3}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type3}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -54,29 +59,35 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc8_41: type = const_type i32 -// CHECK:STDOUT: %.loc8_1 = fn_decl @F +// CHECK:STDOUT: %.loc8 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc9_11: const (const i32*) = dereference %p -// CHECK:STDOUT: %.loc9_10: const i32 = dereference %.loc9_11 -// CHECK:STDOUT: return %.loc9_10 +// CHECK:STDOUT: %.loc8: const (const (const i32*)*) = value_binding %p +// CHECK:STDOUT: %.loc9_11.1: const (const i32*) = dereference %.loc8 +// CHECK:STDOUT: %.loc9_11.2: const (const i32*) = value_binding %.loc9_11.1 +// CHECK:STDOUT: %.loc9_10.1: const i32 = dereference %.loc9_11.2 +// CHECK:STDOUT: %.loc9_10.2: const i32 = value_binding %.loc9_10.1 +// CHECK:STDOUT: return %.loc9_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index badae1405adec..085103830a479 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -15,7 +15,7 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: [block4]}, -// CHECK:STDOUT: {name: str2, param_refs: block6, return_type: type3, body: [block7]}, +// CHECK:STDOUT: {name: str3, param_refs: block6, return_type: type3, body: [block7]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -24,13 +24,14 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Ptr, // CHECK:STDOUT: p, +// CHECK:STDOUT: return, // CHECK:STDOUT: ConstPtr, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -38,15 +39,19 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type1}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type3}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+9, type: type3}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -54,47 +59,50 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+9, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+14, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_23: type = ptr_type i32 -// CHECK:STDOUT: %.loc7_1 = fn_decl @Ptr -// CHECK:STDOUT: %.loc11_32: type = const_type i32 -// CHECK:STDOUT: %.loc11_42: type = ptr_type const i32 -// CHECK:STDOUT: %.loc11_1 = fn_decl @ConstPtr +// CHECK:STDOUT: %.loc7 = fn_decl @Ptr +// CHECK:STDOUT: %.loc11 = fn_decl @ConstPtr // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Ptr(%p: i32*) -> i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %p +// CHECK:STDOUT: %.loc7: i32* = value_binding %p +// CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> const i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: return %p +// CHECK:STDOUT: %.loc11: const i32* = value_binding %p +// CHECK:STDOUT: return %.loc11 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index 70e6c77319d9d..2b418b6cf5a0f 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -30,6 +30,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: n, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ @@ -40,38 +41,45 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+9}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+16}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+18}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, // CHECK:STDOUT: {kind: Branch, arg0: unreachable}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/return/fail_missing_return.carbon b/toolchain/semantics/testdata/return/fail_missing_return.carbon index 82921fd481c8e..8816595db0ae6 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return.carbon @@ -12,7 +12,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -20,6 +20,7 @@ fn Main() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -27,6 +28,7 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -36,6 +38,9 @@ fn Main() -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon index a8f73e128e0cc..504f4bd0eb148 100644 --- a/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon +++ b/toolchain/semantics/testdata/return/fail_missing_return_empty_tuple.carbon @@ -12,7 +12,7 @@ fn F() -> () { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -20,6 +20,7 @@ fn F() -> () { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: node+0, @@ -31,6 +32,7 @@ fn F() -> () { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -42,13 +44,14 @@ fn F() -> () { // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_12.1: type = tuple_type () -// CHECK:STDOUT: %.loc7_12.2: () = tuple_value () -// CHECK:STDOUT: %.loc7_1 = fn_decl @F +// CHECK:STDOUT: %.loc7 = fn_decl @F // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F() -> () { diff --git a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon index 2463cae4a7a87..8824310c2c11f 100644 --- a/toolchain/semantics/testdata/return/fail_type_mismatch.carbon +++ b/toolchain/semantics/testdata/return/fail_type_mismatch.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -22,6 +22,7 @@ fn Main() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -30,6 +31,7 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, @@ -42,7 +44,10 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/return/fail_value_missing.carbon b/toolchain/semantics/testdata/return/fail_value_missing.carbon index 8d54678cf171e..3955478b27b22 100644 --- a/toolchain/semantics/testdata/return/fail_value_missing.carbon +++ b/toolchain/semantics/testdata/return/fail_value_missing.carbon @@ -13,7 +13,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: ] @@ -21,6 +21,7 @@ fn Main() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -28,6 +29,7 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -40,6 +42,9 @@ fn Main() -> i32 { // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { diff --git a/toolchain/semantics/testdata/return/struct.carbon b/toolchain/semantics/testdata/return/struct.carbon index 2d575afe1d614..c09f30339cc7e 100644 --- a/toolchain/semantics/testdata/return/struct.carbon +++ b/toolchain/semantics/testdata/return/struct.carbon @@ -10,7 +10,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type1, body: [block3]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type1, body: [block4]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 3, @@ -20,6 +20,7 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, // CHECK:STDOUT: a, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -30,12 +31,13 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+3, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block5, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: StructValue, arg0: block6, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -50,21 +52,23 @@ fn Main() -> {.a: i32} { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, // CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc7_22: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc7_1 = fn_decl @Main +// CHECK:STDOUT: %.loc7 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Main() -> {.a: i32} { diff --git a/toolchain/semantics/testdata/return/tuple.carbon b/toolchain/semantics/testdata/return/tuple.carbon index 507c43449be20..739f98f3fe6f4 100644 --- a/toolchain/semantics/testdata/return/tuple.carbon +++ b/toolchain/semantics/testdata/return/tuple.carbon @@ -11,7 +11,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, body: [block3]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type2, return_slot: node+5, body: [block4]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 15, @@ -21,6 +21,7 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: node+2, @@ -43,13 +44,15 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block2, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock1, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+7, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type1}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type2}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type1}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block5, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+11}, +// CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -68,33 +71,33 @@ fn Main() -> (i32, i32) { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { -// CHECK:STDOUT: %.loc8_15: type = stub_reference i32 -// CHECK:STDOUT: %.loc8_20: type = stub_reference i32 -// CHECK:STDOUT: %.loc8_23.1: type = tuple_type (type, type) -// CHECK:STDOUT: %.loc8_23.2: (type, type) = tuple_value (%.loc8_15, %.loc8_20) -// CHECK:STDOUT: %.loc8_23.3: type = tuple_type (i32, i32) -// CHECK:STDOUT: %.loc8_1 = fn_decl @Main +// CHECK:STDOUT: %.loc8 = fn_decl @Main // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @Main() -> (i32, i32) { +// CHECK:STDOUT: fn @Main() -> %return: (i32, i32) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc9_11.1: i32 = int_literal 15 // CHECK:STDOUT: %.loc9_11.2: i32 = stub_reference %.loc9_11.1 // CHECK:STDOUT: %.loc9_15.1: i32 = int_literal 35 // CHECK:STDOUT: %.loc9_15.2: i32 = stub_reference %.loc9_15.1 // CHECK:STDOUT: %.loc9_17: (i32, i32) = tuple_value (%.loc9_11.2, %.loc9_15.2) -// CHECK:STDOUT: return %.loc9_17 +// CHECK:STDOUT: assign %return, %.loc9_17 +// CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/value.carbon b/toolchain/semantics/testdata/return/value.carbon index c2e24a33de045..76119ad5abaeb 100644 --- a/toolchain/semantics/testdata/return/value.carbon +++ b/toolchain/semantics/testdata/return/value.carbon @@ -10,7 +10,7 @@ fn Main() -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -19,6 +19,7 @@ fn Main() -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Main, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, @@ -26,9 +27,10 @@ fn Main() -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -38,7 +40,10 @@ fn Main() -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/struct/empty.carbon b/toolchain/semantics/testdata/struct/empty.carbon index 60098f2c5879b..ac1f7b9b2d081 100644 --- a/toolchain/semantics/testdata/struct/empty.carbon +++ b/toolchain/semantics/testdata/struct/empty.carbon @@ -31,7 +31,8 @@ var y: {} = x; // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -45,6 +46,7 @@ var y: {} = x; // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -56,5 +58,6 @@ var y: {} = x; // CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %.loc8: {} = struct_value () // CHECK:STDOUT: %y: {} = var "y" -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5: {} = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/member_access.carbon b/toolchain/semantics/testdata/struct/member_access.carbon index f692738c8debf..09bdd9d1d017a 100644 --- a/toolchain/semantics/testdata/struct/member_access.carbon +++ b/toolchain/semantics/testdata/struct/member_access.carbon @@ -46,9 +46,11 @@ var z: i32 = y; // CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+10}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+3, arg1: member1, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+13}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+14}, // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+12}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -69,6 +71,8 @@ var z: i32 = y; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -94,8 +98,10 @@ var z: i32 = y; // CHECK:STDOUT: %.loc7_46: {.a: f64, .b: i32} = struct_value (%.loc7_33, %.loc7_43) // CHECK:STDOUT: assign %x, %.loc7_46 // CHECK:STDOUT: %y: i32 = var "y" -// CHECK:STDOUT: %.loc8: i32 = struct_access %x, member1 -// CHECK:STDOUT: assign %y, %.loc8 +// CHECK:STDOUT: %.loc8_15.1: i32 = struct_access %x, member1 +// CHECK:STDOUT: %.loc8_15.2: i32 = value_binding %.loc8_15.1 +// CHECK:STDOUT: assign %y, %.loc8_15.2 // CHECK:STDOUT: %z: i32 = var "z" -// CHECK:STDOUT: assign %z, %y +// CHECK:STDOUT: %.loc8_5: i32 = value_binding %y +// CHECK:STDOUT: assign %z, %.loc8_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/one_entry.carbon b/toolchain/semantics/testdata/struct/one_entry.carbon index 1d9a231b66b4e..949694deb9b71 100644 --- a/toolchain/semantics/testdata/struct/one_entry.carbon +++ b/toolchain/semantics/testdata/struct/one_entry.carbon @@ -38,7 +38,8 @@ var y: {.a: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -55,6 +56,7 @@ var y: {.a: i32} = x; // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -79,5 +81,6 @@ var y: {.a: i32} = x; // CHECK:STDOUT: assign %x, %.loc7_27 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32} // CHECK:STDOUT: %y: {.a: i32} = var "y" -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5: {.a: i32} = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/tuple_as_element.carbon b/toolchain/semantics/testdata/struct/tuple_as_element.carbon index 140591769c0c1..26e240478169d 100644 --- a/toolchain/semantics/testdata/struct/tuple_as_element.carbon +++ b/toolchain/semantics/testdata/struct/tuple_as_element.carbon @@ -61,7 +61,8 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type2}, // CHECK:STDOUT: {kind: StructType, arg0: block7, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type3}, -// CHECK:STDOUT: {kind: Assign, arg0: node+23, arg1: node+7}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type3}, +// CHECK:STDOUT: {kind: Assign, arg0: node+23, arg1: node+24}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -90,6 +91,7 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: node+22, // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, +// CHECK:STDOUT: node+25, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -137,5 +139,6 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc8_27: (type,) = tuple_value (%.loc8_23) // CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} // CHECK:STDOUT: %y: {.a: i32, .b: (i32,)} = var "y" -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5: {.a: i32, .b: (i32,)} = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/two_entries.carbon b/toolchain/semantics/testdata/struct/two_entries.carbon index 9db4bf7af52be..6c9ee31a7dbcb 100644 --- a/toolchain/semantics/testdata/struct/two_entries.carbon +++ b/toolchain/semantics/testdata/struct/two_entries.carbon @@ -45,7 +45,8 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+3}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -66,6 +67,7 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -96,5 +98,6 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: assign %x, %.loc7_44 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %y: {.a: i32, .b: i32} = var "y" -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5: {.a: i32, .b: i32} = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/empty.carbon b/toolchain/semantics/testdata/tuples/empty.carbon index 974dccf692277..2615a1388473b 100644 --- a/toolchain/semantics/testdata/tuples/empty.carbon +++ b/toolchain/semantics/testdata/tuples/empty.carbon @@ -33,7 +33,8 @@ var y: () = x; // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+2}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -47,6 +48,7 @@ var y: () = x; // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -58,5 +60,6 @@ var y: () = x; // CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %.loc8: () = tuple_value () // CHECK:STDOUT: %y: () = var "y" -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5: () = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/one_element.carbon b/toolchain/semantics/testdata/tuples/one_element.carbon index 03d7ab7e19c44..9623f95c5bd40 100644 --- a/toolchain/semantics/testdata/tuples/one_element.carbon +++ b/toolchain/semantics/testdata/tuples/one_element.carbon @@ -45,7 +45,8 @@ var y: (i32,) = x; // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+4}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -64,6 +65,7 @@ var y: (i32,) = x; // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -89,5 +91,6 @@ var y: (i32,) = x; // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %y: (i32,) = var "y" -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/two_elements.carbon b/toolchain/semantics/testdata/tuples/two_elements.carbon index 8ea69a1789fd9..3da5a7308d30a 100644 --- a/toolchain/semantics/testdata/tuples/two_elements.carbon +++ b/toolchain/semantics/testdata/tuples/two_elements.carbon @@ -52,7 +52,8 @@ var y: (i32, i32) = x; // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+5}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -75,6 +76,7 @@ var y: (i32, i32) = x; // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, // CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -107,5 +109,6 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %.loc8_14: type = stub_reference i32 // CHECK:STDOUT: %.loc8_17: (type, type) = tuple_value (%.loc8_9, %.loc8_14) // CHECK:STDOUT: %y: (i32, i32) = var "y" -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5: (i32, i32) = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup.carbon b/toolchain/semantics/testdata/var/global_lookup.carbon index 87196da70f28c..ca9742f2014de 100644 --- a/toolchain/semantics/testdata/var/global_lookup.carbon +++ b/toolchain/semantics/testdata/var/global_lookup.carbon @@ -29,7 +29,8 @@ var y: i32 = x; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+1}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -40,13 +41,15 @@ var y: i32 = x; // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, +// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %x: i32 = var "x" -// CHECK:STDOUT: %.loc7: i32 = int_literal 0 -// CHECK:STDOUT: assign %x, %.loc7 +// CHECK:STDOUT: %.loc7_14: i32 = int_literal 0 +// CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %y: i32 = var "y" -// CHECK:STDOUT: assign %y, %x +// CHECK:STDOUT: %.loc7_5: i32 = value_binding %x +// CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon index afb1eea5eeb8f..ca3fcc391b79b 100644 --- a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon +++ b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon @@ -35,7 +35,8 @@ fn Main() { // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+0}, +// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+5}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -51,6 +52,7 @@ fn Main() { // CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -64,6 +66,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %y: i32 = var "y" -// CHECK:STDOUT: assign %y, package.%x +// CHECK:STDOUT: %.loc7: i32 = value_binding package.%x +// CHECK:STDOUT: assign %y, %.loc7 // CHECK:STDOUT: return // CHECK:STDOUT: } From b8f6d4d6dff3efc94864b90fa8f3e391fd0d3318 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 16:23:26 -0700 Subject: [PATCH 15/21] clang-format --- toolchain/semantics/semantics_context.cpp | 4 ++-- toolchain/semantics/semantics_ir.cpp | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 9d969cfc738b9..9660120769789 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -465,8 +465,8 @@ auto SemanticsContext::ImplicitAsForArgs( return true; } - auto &arg_refs = semantics_ir_->GetNodeBlock(arg_refs_id); - const auto ¶m_refs = semantics_ir_->GetNodeBlock(param_refs_id); + auto& arg_refs = semantics_ir_->GetNodeBlock(arg_refs_id); + const auto& param_refs = semantics_ir_->GetNodeBlock(param_refs_id); // If sizes mismatch, fail early. if (arg_refs.size() != param_refs.size()) { diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index 872976a5afd49..6f41a695c0eba 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -649,17 +649,17 @@ auto GetSemanticsInitializingRepresentation(const SemanticsIR& semantics_ir, -> SemanticsInitializingRepresentation { auto value_rep = GetSemanticsValueRepresentation(semantics_ir, type_id); switch (value_rep.kind) { - case SemanticsValueRepresentation::None: - return {.kind = SemanticsInitializingRepresentation::None}; + case SemanticsValueRepresentation::None: + return {.kind = SemanticsInitializingRepresentation::None}; - case SemanticsValueRepresentation::Copy: - // TODO: Use in-place initialization for types that have a non-trivial - // destructor. - return {.kind = SemanticsInitializingRepresentation::ByCopy}; + case SemanticsValueRepresentation::Copy: + // TODO: Use in-place initialization for types that have a non-trivial + // destructor. + return {.kind = SemanticsInitializingRepresentation::ByCopy}; - case SemanticsValueRepresentation::Pointer: - case SemanticsValueRepresentation::Custom: - return {.kind = SemanticsInitializingRepresentation::InPlace}; + case SemanticsValueRepresentation::Pointer: + case SemanticsValueRepresentation::Custom: + return {.kind = SemanticsInitializingRepresentation::InPlace}; } } From 6f4a45075a7009e1fc67ed6ae14aeeb0c810f04f Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 16:28:22 -0700 Subject: [PATCH 16/21] Update TODO to match discussion in #3133. --- toolchain/semantics/semantics_ir.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index 6f41a695c0eba..da7d86a83bf90 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -653,8 +653,8 @@ auto GetSemanticsInitializingRepresentation(const SemanticsIR& semantics_ir, return {.kind = SemanticsInitializingRepresentation::None}; case SemanticsValueRepresentation::Copy: - // TODO: Use in-place initialization for types that have a non-trivial - // destructor. + // TODO: Use in-place initialization for types that have non-trivial + // destructive move. return {.kind = SemanticsInitializingRepresentation::ByCopy}; case SemanticsValueRepresentation::Pointer: From ac1e73d51f60be3a8391dec721b12c122fb40d0c Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 22 Aug 2023 16:32:01 -0700 Subject: [PATCH 17/21] Rename value_binding -> bind_value. --- .../lowering_handle_expression_category.cpp | 12 +++++------ toolchain/semantics/semantics_context.cpp | 6 +++--- toolchain/semantics/semantics_ir.cpp | 8 ++++---- toolchain/semantics/semantics_node.h | 6 +++--- toolchain/semantics/semantics_node_kind.def | 3 +-- .../testdata/array/assign_return_value.carbon | 4 ++-- .../testdata/array/assign_var.carbon | 4 ++-- .../semantics/testdata/const/collapse.carbon | 4 ++-- .../function/call/empty_struct.carbon | 4 ++-- .../testdata/function/call/empty_tuple.carbon | 4 ++-- .../testdata/function/call/i32.carbon | 4 ++-- toolchain/semantics/testdata/if/else.carbon | 4 ++-- .../if/fail_reachable_fallthrough.carbon | 12 +++++------ .../semantics/testdata/if/fail_scope.carbon | 8 ++++---- .../semantics/testdata/if/no_else.carbon | 4 ++-- .../if/unreachable_fallthrough.carbon | 4 ++-- .../testdata/if_expression/basic.carbon | 20 +++++++++---------- .../if_expression/constant_condition.carbon | 16 +++++++-------- .../if_expression/control_flow.carbon | 12 +++++------ .../testdata/if_expression/nested.carbon | 12 +++++------ .../index/array_element_access.carbon | 8 ++++---- .../index/fail_tuple_large_index.carbon | 4 ++-- .../index/tuple_element_access.carbon | 8 ++++---- .../index/tuple_return_value_access.carbon | 4 ++-- .../semantics/testdata/operators/and.carbon | 8 ++++---- .../testdata/operators/assignment.carbon | 8 ++++---- .../fail_assigment_to_non_assignable.carbon | 16 +++++++-------- .../semantics/testdata/operators/or.carbon | 8 ++++---- .../testdata/operators/unary_op.carbon | 4 ++-- .../testdata/pointer/address_of_deref.carbon | 4 ++-- .../semantics/testdata/pointer/basic.carbon | 8 ++++---- .../fail_dereference_not_pointer.carbon | 4 ++-- .../testdata/pointer/nested_const.carbon | 12 +++++------ .../semantics/testdata/pointer/types.carbon | 8 ++++---- .../return/code_after_return_value.carbon | 10 +++++----- .../semantics/testdata/struct/empty.carbon | 4 ++-- .../testdata/struct/member_access.carbon | 8 ++++---- .../testdata/struct/one_entry.carbon | 4 ++-- .../testdata/struct/tuple_as_element.carbon | 4 ++-- .../testdata/struct/two_entries.carbon | 4 ++-- .../semantics/testdata/tuples/empty.carbon | 4 ++-- .../testdata/tuples/one_element.carbon | 4 ++-- .../testdata/tuples/two_elements.carbon | 4 ++-- .../testdata/var/global_lookup.carbon | 4 ++-- .../var/global_lookup_in_scope.carbon | 4 ++-- 45 files changed, 154 insertions(+), 155 deletions(-) diff --git a/toolchain/lowering/lowering_handle_expression_category.cpp b/toolchain/lowering/lowering_handle_expression_category.cpp index 6b1d8b5f09132..d41e6dd931634 100644 --- a/toolchain/lowering/lowering_handle_expression_category.cpp +++ b/toolchain/lowering/lowering_handle_expression_category.cpp @@ -6,6 +6,12 @@ namespace Carbon { +auto LoweringHandleBindValue(LoweringFunctionContext& context, + SemanticsNodeId node_id, SemanticsNode node) + -> void { + context.SetLocal(node_id, context.GetLocalLoaded(node.GetAsBindValue())); +} + auto LoweringHandleMaterializeTemporary(LoweringFunctionContext& context, SemanticsNodeId node_id, SemanticsNode node) -> void { @@ -14,10 +20,4 @@ auto LoweringHandleMaterializeTemporary(LoweringFunctionContext& context, nullptr, "temp")); } -auto LoweringHandleValueBinding(LoweringFunctionContext& context, - SemanticsNodeId node_id, SemanticsNode node) - -> void { - context.SetLocal(node_id, context.GetLocalLoaded(node.GetAsValueBinding())); -} - } // namespace Carbon diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 9660120769789..2d464e5e6e83e 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -290,7 +290,7 @@ auto SemanticsContext::Initialize(ParseTree::Node parse_node, // // TODO: Determine whether this is observably different from the design, // and change either the toolchain or the design so they match. - expr_id = AddNode(SemanticsNode::ValueBinding::Make( + expr_id = AddNode(SemanticsNode::BindValue::Make( expr.parse_node(), expr.type_id(), expr_id)); [[fallthrough]]; @@ -327,8 +327,8 @@ auto SemanticsContext::ConvertToValueExpression(SemanticsNodeId expr_id) case SemanticsExpressionCategory::EphemeralReference: { // TODO: Support types with custom value representations. SemanticsNode expr = semantics_ir().GetNode(expr_id); - return AddNode(SemanticsNode::ValueBinding::Make( - expr.parse_node(), expr.type_id(), expr_id)); + return AddNode(SemanticsNode::BindValue::Make(expr.parse_node(), + expr.type_id(), expr_id)); } case SemanticsExpressionCategory::Value: diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index da7d86a83bf90..1b2a38e8cbe1a 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -226,6 +226,7 @@ static auto GetTypePrecedence(SemanticsNodeKind kind) -> int { case SemanticsNodeKind::ArrayValue: case SemanticsNodeKind::Assign: case SemanticsNodeKind::BinaryOperatorAdd: + case SemanticsNodeKind::BindValue: case SemanticsNodeKind::BlockArg: case SemanticsNodeKind::BoolLiteral: case SemanticsNodeKind::Branch: @@ -250,7 +251,6 @@ static auto GetTypePrecedence(SemanticsNodeKind kind) -> int { case SemanticsNodeKind::TupleIndex: case SemanticsNodeKind::TupleValue: case SemanticsNodeKind::UnaryOperatorNot: - case SemanticsNodeKind::ValueBinding: case SemanticsNodeKind::VarStorage: CARBON_FATAL() << "GetTypePrecedence for non-type node kind " << kind; } @@ -383,6 +383,7 @@ auto SemanticsIR::StringifyType(SemanticsTypeId type_id, case SemanticsNodeKind::ArrayValue: case SemanticsNodeKind::Assign: case SemanticsNodeKind::BinaryOperatorAdd: + case SemanticsNodeKind::BindValue: case SemanticsNodeKind::BlockArg: case SemanticsNodeKind::BoolLiteral: case SemanticsNodeKind::Branch: @@ -407,7 +408,6 @@ auto SemanticsIR::StringifyType(SemanticsTypeId type_id, case SemanticsNodeKind::TupleIndex: case SemanticsNodeKind::TupleValue: case SemanticsNodeKind::UnaryOperatorNot: - case SemanticsNodeKind::ValueBinding: case SemanticsNodeKind::VarStorage: // We don't need to handle stringification for nodes that don't show up // in errors, but make it clear what's going on so that it's clearer @@ -463,6 +463,7 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, case SemanticsNodeKind::AddressOf: case SemanticsNodeKind::ArrayType: case SemanticsNodeKind::BinaryOperatorAdd: + case SemanticsNodeKind::BindValue: case SemanticsNodeKind::BlockArg: case SemanticsNodeKind::BoolLiteral: case SemanticsNodeKind::Builtin: @@ -474,7 +475,6 @@ auto GetSemanticsExpressionCategory(const SemanticsIR& semantics_ir, case SemanticsNodeKind::StructType: case SemanticsNodeKind::TupleType: case SemanticsNodeKind::UnaryOperatorNot: - case SemanticsNodeKind::ValueBinding: return SemanticsExpressionCategory::Value; case SemanticsNodeKind::ArrayIndex: { @@ -535,6 +535,7 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, case SemanticsNodeKind::ArrayValue: case SemanticsNodeKind::Assign: case SemanticsNodeKind::BinaryOperatorAdd: + case SemanticsNodeKind::BindValue: case SemanticsNodeKind::BlockArg: case SemanticsNodeKind::BoolLiteral: case SemanticsNodeKind::Branch: @@ -558,7 +559,6 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, case SemanticsNodeKind::TupleIndex: case SemanticsNodeKind::TupleValue: case SemanticsNodeKind::UnaryOperatorNot: - case SemanticsNodeKind::ValueBinding: case SemanticsNodeKind::VarStorage: CARBON_FATAL() << "Type refers to non-type node " << node; diff --git a/toolchain/semantics/semantics_node.h b/toolchain/semantics/semantics_node.h index 6f367ebf679c2..4a116eb1aedbd 100644 --- a/toolchain/semantics/semantics_node.h +++ b/toolchain/semantics/semantics_node.h @@ -331,6 +331,9 @@ class SemanticsNode { SemanticsNodeId /*lhs_id*/, SemanticsNodeId /*rhs_id*/>; + using BindValue = + Factory; + using BlockArg = Factory; @@ -448,9 +451,6 @@ class SemanticsNode { using UnaryOperatorNot = Factory; - using ValueBinding = - Factory; - using VarStorage = Factory; diff --git a/toolchain/semantics/semantics_node_kind.def b/toolchain/semantics/semantics_node_kind.def index 6992e9d6e0d43..0a557a4677d9c 100644 --- a/toolchain/semantics/semantics_node_kind.def +++ b/toolchain/semantics/semantics_node_kind.def @@ -51,6 +51,7 @@ CARBON_SEMANTICS_NODE_KIND_IMPL(ArrayType, "array_type", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(ArrayValue, "array_value", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(Assign, "assign", None, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(BinaryOperatorAdd, "add", Typed, NotTerminator) +CARBON_SEMANTICS_NODE_KIND_IMPL(BindValue, "bind_value", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(BlockArg, "block_arg", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(BoolLiteral, "bool_literal", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(Branch, "br", None, Terminator) @@ -89,8 +90,6 @@ CARBON_SEMANTICS_NODE_KIND_IMPL(TupleIndex, "tuple_index", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(TupleType, "tuple_type", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(TupleValue, "tuple_value", Typed, NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(UnaryOperatorNot, "not", Typed, NotTerminator) -CARBON_SEMANTICS_NODE_KIND_IMPL(ValueBinding, "value_binding", Typed, - NotTerminator) CARBON_SEMANTICS_NODE_KIND_IMPL(VarStorage, "var", Typed, NotTerminator) #undef CARBON_SEMANTICS_NODE_KIND diff --git a/toolchain/semantics/testdata/array/assign_return_value.carbon b/toolchain/semantics/testdata/array/assign_return_value.carbon index 9aee43b25b99c..45345f8db3c32 100644 --- a/toolchain/semantics/testdata/array/assign_return_value.carbon +++ b/toolchain/semantics/testdata/array/assign_return_value.carbon @@ -59,7 +59,7 @@ fn Run() { // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type2}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+14}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+15, type: type2}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+15, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+17, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+13, arg1: node+18}, // CHECK:STDOUT: {kind: Return}, @@ -125,7 +125,7 @@ fn Run() { // CHECK:STDOUT: %.loc10_22.1: (i32,) = call @F() // CHECK:STDOUT: %.loc10_22.2: (i32,) = materialize_temporary // CHECK:STDOUT: assign %.loc10_22.2, %.loc10_22.1 -// CHECK:STDOUT: %.loc10_22.3: (i32,) = value_binding %.loc10_22.2 +// CHECK:STDOUT: %.loc10_22.3: (i32,) = bind_value %.loc10_22.2 // CHECK:STDOUT: %.loc10_22.4: [i32; 1] = array_value %.loc10_22.3 // CHECK:STDOUT: assign %t, %.loc10_22.4 // CHECK:STDOUT: return diff --git a/toolchain/semantics/testdata/array/assign_var.carbon b/toolchain/semantics/testdata/array/assign_var.carbon index b2d615038e6a9..55c771fabc0ec 100644 --- a/toolchain/semantics/testdata/array/assign_var.carbon +++ b/toolchain/semantics/testdata/array/assign_var.carbon @@ -59,7 +59,7 @@ var b: [i32; 3] = a; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, // CHECK:STDOUT: {kind: ArrayType, arg0: node+15, arg1: type1, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type3}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type2}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+6, type: type2}, // CHECK:STDOUT: {kind: ArrayValue, arg0: node+18, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+17, arg1: node+19}, // CHECK:STDOUT: ] @@ -120,7 +120,7 @@ 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: [i32; 3] = var "b" -// CHECK:STDOUT: %.loc7_5.1: (i32, i32, i32) = value_binding %a +// CHECK:STDOUT: %.loc7_5.1: (i32, i32, i32) = bind_value %a // CHECK:STDOUT: %.loc7_5.2: [i32; 3] = array_value %.loc7_5.1 // CHECK:STDOUT: assign %b, %.loc7_5.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index 844e2dcf18323..f67e6c1902e74 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -44,7 +44,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type3}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+3, type: type3}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -79,6 +79,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: %.loc11: const i32** = value_binding %p +// CHECK:STDOUT: %.loc11: const i32** = bind_value %p // CHECK:STDOUT: return %.loc11 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index 4f814f747bb11..a04bad82fd8d8 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -39,7 +39,7 @@ fn Main() { // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, @@ -86,7 +86,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: {}) -> {} { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: {} = value_binding %a +// CHECK:STDOUT: %.loc7: {} = bind_value %a // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index e3043fca472a7..568e7a7961186 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -41,7 +41,7 @@ fn Main() { // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, @@ -88,7 +88,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: ()) -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: () = value_binding %a +// CHECK:STDOUT: %.loc7: () = bind_value %a // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index cf27c2a2ade91..ff1a81c2bb65f 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -38,7 +38,7 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type0}, @@ -86,7 +86,7 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: i32) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = value_binding %a +// CHECK:STDOUT: %.loc7: i32 = bind_value %a // CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/if/else.carbon b/toolchain/semantics/testdata/if/else.carbon index ba6961247c264..0a4d2e2a2787c 100644 --- a/toolchain/semantics/testdata/if/else.carbon +++ b/toolchain/semantics/testdata/if/else.carbon @@ -52,7 +52,7 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+6, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+8}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, @@ -131,7 +131,7 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: bool = value_binding %b +// CHECK:STDOUT: %.loc11: bool = bind_value %b // CHECK:STDOUT: if %.loc11 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index 790e728e73c17..d79e513b27061 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -63,7 +63,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, @@ -72,7 +72,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+12}, // CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, @@ -81,7 +81,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+21}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, @@ -166,7 +166,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If1(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: bool = value_binding %b +// CHECK:STDOUT: %.loc7: bool = bind_value %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: @@ -181,7 +181,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If2(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc17: bool = value_binding %b +// CHECK:STDOUT: %.loc17: bool = bind_value %b // CHECK:STDOUT: if %.loc17 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: @@ -196,7 +196,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If3(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc27: bool = value_binding %b +// CHECK:STDOUT: %.loc27: bool = bind_value %b // CHECK:STDOUT: if %.loc27 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index 3a0856700af1f..6e1da9df8fe72 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -40,13 +40,13 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+9}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, @@ -87,14 +87,14 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @VarScope(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: bool = value_binding %b +// CHECK:STDOUT: %.loc7: bool = bind_value %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n: i32 = var "n" // CHECK:STDOUT: %.loc9_18: i32 = int_literal 2 // CHECK:STDOUT: assign %n, %.loc9_18 -// CHECK:STDOUT: %.loc9_9: i32 = value_binding %n +// CHECK:STDOUT: %.loc9_9: i32 = bind_value %n // CHECK:STDOUT: return %.loc9_9 // CHECK:STDOUT: // CHECK:STDOUT: !if.else: diff --git a/toolchain/semantics/testdata/if/no_else.carbon b/toolchain/semantics/testdata/if/no_else.carbon index 87a4a12ee19ae..a80d216848250 100644 --- a/toolchain/semantics/testdata/if/no_else.carbon +++ b/toolchain/semantics/testdata/if/no_else.carbon @@ -45,7 +45,7 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+4, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+6}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, @@ -108,7 +108,7 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10: bool = value_binding %b +// CHECK:STDOUT: %.loc10: bool = bind_value %b // CHECK:STDOUT: if %.loc10 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index 863a587b2dc40..9688cf66e5be3 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -38,7 +38,7 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+3}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, @@ -80,7 +80,7 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: bool = value_binding %b +// CHECK:STDOUT: %.loc7: bool = bind_value %b // CHECK:STDOUT: if %.loc7 br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index f45a960ee1c76..f09f6f5ddd8cc 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -35,14 +35,14 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+5}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+1, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type1}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+8, arg1: node+9, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+1, type: type1}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+11, arg1: node+12, type: type1}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+10}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+13}, @@ -95,18 +95,18 @@ 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: %.loc7_6: bool = value_binding %b +// CHECK:STDOUT: %.loc7_6: bool = bind_value %b // CHECK:STDOUT: if %.loc7_6 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc7_15.1: i32 = value_binding %n -// CHECK:STDOUT: %.loc7_23.1: i32 = value_binding %m +// CHECK:STDOUT: %.loc7_15.1: i32 = bind_value %n +// CHECK:STDOUT: %.loc7_23.1: i32 = bind_value %m // CHECK:STDOUT: %.loc8_22: i32 = add %.loc7_15.1, %.loc7_23.1 // CHECK:STDOUT: br !if.expr.result(%.loc8_22) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc7_23.2: i32 = value_binding %m -// CHECK:STDOUT: %.loc7_15.2: i32 = value_binding %n +// CHECK:STDOUT: %.loc7_23.2: i32 = bind_value %m +// CHECK:STDOUT: %.loc7_15.2: i32 = bind_value %n // CHECK:STDOUT: %.loc8_33: i32 = add %.loc7_23.2, %.loc7_15.2 // CHECK:STDOUT: br !if.expr.result(%.loc8_33) // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/if_expression/constant_condition.carbon b/toolchain/semantics/testdata/if_expression/constant_condition.carbon index 8009f0c81c7c6..28dde1ebbc203 100644 --- a/toolchain/semantics/testdata/if_expression/constant_condition.carbon +++ b/toolchain/semantics/testdata/if_expression/constant_condition.carbon @@ -58,11 +58,11 @@ fn G() -> i32 { // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+13}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+14, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+14, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+17}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+16}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+20}, // CHECK:STDOUT: {kind: BlockArg, arg0: block10, type: type0}, @@ -75,11 +75,11 @@ fn G() -> i32 { // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+31, arg1: node+30}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+31, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+31, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+35, arg1: node+34}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+35, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+35, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+33}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block15, arg1: node+37}, // CHECK:STDOUT: {kind: BlockArg, arg0: block15, type: type0}, @@ -190,14 +190,14 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc11_24.1: i32 = call @A() // CHECK:STDOUT: %.loc11_24.2: i32 = materialize_temporary // CHECK:STDOUT: assign %.loc11_24.2, %.loc11_24.1 -// CHECK:STDOUT: %.loc11_24.3: i32 = value_binding %.loc11_24.2 +// CHECK:STDOUT: %.loc11_24.3: i32 = bind_value %.loc11_24.2 // CHECK:STDOUT: br !if.expr.result(%.loc11_24.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: // CHECK:STDOUT: %.loc11_33.1: i32 = call @B() // CHECK:STDOUT: %.loc11_33.2: i32 = materialize_temporary // CHECK:STDOUT: assign %.loc11_33.2, %.loc11_33.1 -// CHECK:STDOUT: %.loc11_33.3: i32 = value_binding %.loc11_33.2 +// CHECK:STDOUT: %.loc11_33.3: i32 = bind_value %.loc11_33.2 // CHECK:STDOUT: br !if.expr.result(%.loc11_33.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: @@ -214,14 +214,14 @@ fn G() -> i32 { // CHECK:STDOUT: %.loc15_25.1: i32 = call @A() // CHECK:STDOUT: %.loc15_25.2: i32 = materialize_temporary // CHECK:STDOUT: assign %.loc15_25.2, %.loc15_25.1 -// CHECK:STDOUT: %.loc15_25.3: i32 = value_binding %.loc15_25.2 +// CHECK:STDOUT: %.loc15_25.3: i32 = bind_value %.loc15_25.2 // CHECK:STDOUT: br !if.expr.result(%.loc15_25.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: // CHECK:STDOUT: %.loc15_34.1: i32 = call @B() // CHECK:STDOUT: %.loc15_34.2: i32 = materialize_temporary // CHECK:STDOUT: assign %.loc15_34.2, %.loc15_34.1 -// CHECK:STDOUT: %.loc15_34.3: i32 = value_binding %.loc15_34.2 +// CHECK:STDOUT: %.loc15_34.3: i32 = bind_value %.loc15_34.2 // CHECK:STDOUT: br !if.expr.result(%.loc15_34.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index 4eddea5ba9cf0..9f35eea52c906 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -48,17 +48,17 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+8, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+8, type: type1}, // CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+11}, // CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+14}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+15, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+15, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+18}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+19, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+17}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+21}, // CHECK:STDOUT: {kind: BlockArg, arg0: block11, type: type0}, @@ -138,21 +138,21 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%b: bool) -> i32 { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10: bool = value_binding %b +// CHECK:STDOUT: %.loc10: bool = bind_value %b // CHECK:STDOUT: if %.loc10 br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: // CHECK:STDOUT: %.loc11_21.1: i32 = call @A() // CHECK:STDOUT: %.loc11_21.2: i32 = materialize_temporary // CHECK:STDOUT: assign %.loc11_21.2, %.loc11_21.1 -// CHECK:STDOUT: %.loc11_21.3: i32 = value_binding %.loc11_21.2 +// CHECK:STDOUT: %.loc11_21.3: i32 = bind_value %.loc11_21.2 // CHECK:STDOUT: br !if.expr.result(%.loc11_21.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: // CHECK:STDOUT: %.loc11_30.1: i32 = call @B() // CHECK:STDOUT: %.loc11_30.2: i32 = materialize_temporary // CHECK:STDOUT: assign %.loc11_30.2, %.loc11_30.1 -// CHECK:STDOUT: %.loc11_30.3: i32 = value_binding %.loc11_30.2 +// CHECK:STDOUT: %.loc11_30.3: i32 = bind_value %.loc11_30.2 // CHECK:STDOUT: br !if.expr.result(%.loc11_30.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index bf9f5b10096b7..e7dd441b66e86 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -39,10 +39,10 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+5}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+1, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+8}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, @@ -50,7 +50,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+11}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+12}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+16}, // CHECK:STDOUT: {kind: Branch, arg0: block11}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, @@ -131,11 +131,11 @@ 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: %.loc7_6: bool = value_binding %a +// CHECK:STDOUT: %.loc7_6: bool = bind_value %a // CHECK:STDOUT: if %.loc7_6 br !if.expr.then.loc8_10 else br !if.expr.else.loc8_10 // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc8_10: -// CHECK:STDOUT: %.loc7_15: bool = value_binding %b +// CHECK:STDOUT: %.loc7_15: bool = bind_value %b // CHECK:STDOUT: if %.loc7_15 br !if.expr.then.loc8_20 else br !if.expr.else.loc8_20 // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc8_20: @@ -151,7 +151,7 @@ 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: %.loc7_24: bool = value_binding %c +// CHECK:STDOUT: %.loc7_24: bool = bind_value %c // CHECK:STDOUT: if %.loc7_24 br !if.expr.then.loc8_44 else br !if.expr.else.loc8_44 // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then.loc8_44: diff --git a/toolchain/semantics/testdata/index/array_element_access.carbon b/toolchain/semantics/testdata/index/array_element_access.carbon index 3c4e649d96773..d6d1c6b107ecc 100644 --- a/toolchain/semantics/testdata/index/array_element_access.carbon +++ b/toolchain/semantics/testdata/index/array_element_access.carbon @@ -56,11 +56,11 @@ var d: i32 = a[b]; // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+15, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+16, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, // CHECK:STDOUT: {kind: ArrayIndex, arg0: node+2, arg1: node+11, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+20, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+20, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+21}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -115,10 +115,10 @@ var d: i32 = a[b]; // CHECK:STDOUT: %c: i32 = var "c" // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 // CHECK:STDOUT: %.loc9_17.1: i32 = array_index %a, %.loc9_16 -// CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 +// CHECK:STDOUT: %.loc9_17.2: i32 = bind_value %.loc9_17.1 // CHECK:STDOUT: assign %c, %.loc9_17.2 // CHECK:STDOUT: %d: i32 = var "d" // CHECK:STDOUT: %.loc10_17.1: i32 = array_index %a, %b -// CHECK:STDOUT: %.loc10_17.2: i32 = value_binding %.loc10_17.1 +// CHECK:STDOUT: %.loc10_17.2: i32 = bind_value %.loc10_17.1 // CHECK:STDOUT: assign %d, %.loc10_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon b/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon index 90aa5dec0854a..12ae96d9724f0 100644 --- a/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon +++ b/toolchain/semantics/testdata/index/fail_tuple_large_index.carbon @@ -51,7 +51,7 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+4, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, @@ -103,7 +103,7 @@ var c: i32 = b[0xFFFFFFFFFFFFFFFFF]; // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var "b" -// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %a +// CHECK:STDOUT: %.loc7_5: (i32,) = bind_value %a // CHECK:STDOUT: assign %b, %.loc7_5 // CHECK:STDOUT: %c: i32 = var "c" // CHECK:STDOUT: %.loc12: i32 = int_literal -1 diff --git a/toolchain/semantics/testdata/index/tuple_element_access.carbon b/toolchain/semantics/testdata/index/tuple_element_access.carbon index cc5a68aea1ec1..22bca63bb0473 100644 --- a/toolchain/semantics/testdata/index/tuple_element_access.carbon +++ b/toolchain/semantics/testdata/index/tuple_element_access.carbon @@ -48,12 +48,12 @@ var c: i32 = b[0]; // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+4, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+12}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: TupleIndex, arg0: node+11, arg1: node+15, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+16, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -104,11 +104,11 @@ var c: i32 = b[0]; // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %b: (i32,) = var "b" -// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %a +// CHECK:STDOUT: %.loc7_5: (i32,) = bind_value %a // CHECK:STDOUT: assign %b, %.loc7_5 // CHECK:STDOUT: %c: i32 = var "c" // CHECK:STDOUT: %.loc9_16: i32 = int_literal 0 // CHECK:STDOUT: %.loc9_17.1: i32 = tuple_index %b, %.loc9_16 -// CHECK:STDOUT: %.loc9_17.2: i32 = value_binding %.loc9_17.1 +// CHECK:STDOUT: %.loc9_17.2: i32 = bind_value %.loc9_17.1 // CHECK:STDOUT: assign %c, %.loc9_17.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/index/tuple_return_value_access.carbon b/toolchain/semantics/testdata/index/tuple_return_value_access.carbon index 8ca2ba7c0386d..8ee9d5fb18c2c 100644 --- a/toolchain/semantics/testdata/index/tuple_return_value_access.carbon +++ b/toolchain/semantics/testdata/index/tuple_return_value_access.carbon @@ -57,7 +57,7 @@ fn Run() -> i32 { // CHECK:STDOUT: {kind: MaterializeTemporary, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+12}, // CHECK:STDOUT: {kind: TupleIndex, arg0: node+14, arg1: node+13, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+16, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+16, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -120,6 +120,6 @@ fn Run() -> i32 { // CHECK:STDOUT: %.loc10_11.2: (i32,) = materialize_temporary // CHECK:STDOUT: assign %.loc10_11.2, %.loc10_11.1 // CHECK:STDOUT: %.loc10_15.1: i32 = tuple_index %.loc10_11.2, %.loc10_14 -// CHECK:STDOUT: %.loc10_15.2: i32 = value_binding %.loc10_15.1 +// CHECK:STDOUT: %.loc10_15.2: i32 = bind_value %.loc10_15.1 // CHECK:STDOUT: return %.loc10_15.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/operators/and.carbon b/toolchain/semantics/testdata/operators/and.carbon index 1096494e20df6..f9bd5bb09f1b9 100644 --- a/toolchain/semantics/testdata/operators/and.carbon +++ b/toolchain/semantics/testdata/operators/and.carbon @@ -46,14 +46,14 @@ fn And() -> bool { // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+10}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+13}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+14}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+17}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+18, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+20}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+22}, @@ -128,7 +128,7 @@ fn And() -> bool { // CHECK:STDOUT: %.loc11_11.1: bool = call @F() // CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary // CHECK:STDOUT: assign %.loc11_11.2, %.loc11_11.1 -// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 +// CHECK:STDOUT: %.loc11_11.3: bool = bind_value %.loc11_11.2 // CHECK:STDOUT: %.loc11_14.1: bool = bool_literal false // CHECK:STDOUT: if %.loc11_11.3 br !and.rhs else br !and.result(%.loc11_14.1) // CHECK:STDOUT: @@ -136,7 +136,7 @@ fn And() -> bool { // CHECK:STDOUT: %.loc11_19.1: bool = call @G() // CHECK:STDOUT: %.loc11_19.2: bool = materialize_temporary // CHECK:STDOUT: assign %.loc11_19.2, %.loc11_19.1 -// CHECK:STDOUT: %.loc11_19.3: bool = value_binding %.loc11_19.2 +// CHECK:STDOUT: %.loc11_19.3: bool = bind_value %.loc11_19.2 // CHECK:STDOUT: br !and.result(%.loc11_19.3) // CHECK:STDOUT: // CHECK:STDOUT: !and.result: diff --git a/toolchain/semantics/testdata/operators/assignment.carbon b/toolchain/semantics/testdata/operators/assignment.carbon index d971581c28259..1f7d5648ec59e 100644 --- a/toolchain/semantics/testdata/operators/assignment.carbon +++ b/toolchain/semantics/testdata/operators/assignment.carbon @@ -118,14 +118,14 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, // CHECK:STDOUT: {kind: Assign, arg0: node+45, arg1: node+46}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+45, type: type4}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+45, type: type4}, // CHECK:STDOUT: {kind: Dereference, arg0: node+48, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int12, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+49, arg1: node+50}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type5}, // CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+52}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+45, type: type4}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+45, type: type4}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+1, type: type4}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+55}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block10, arg1: node+56}, @@ -281,7 +281,7 @@ fn Main() { // CHECK:STDOUT: %p: i32* = var "p" // CHECK:STDOUT: %.loc19_17: i32* = address_of %a // CHECK:STDOUT: assign %p, %.loc19_17 -// CHECK:STDOUT: %.loc19_7.1: i32* = value_binding %p +// CHECK:STDOUT: %.loc19_7.1: i32* = bind_value %p // CHECK:STDOUT: %.loc20_3: i32 = dereference %.loc19_7.1 // CHECK:STDOUT: %.loc20_8: i32 = int_literal 5 // CHECK:STDOUT: assign %.loc20_3, %.loc20_8 @@ -289,7 +289,7 @@ fn Main() { // 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* = value_binding %p +// CHECK:STDOUT: %.loc19_7.2: i32* = bind_value %p // CHECK:STDOUT: br !if.expr.result(%.loc19_7.2) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: diff --git a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon index f14b1859f6c7a..6877b3dece3b4 100644 --- a/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon +++ b/toolchain/semantics/testdata/operators/fail_assigment_to_non_assignable.carbon @@ -118,9 +118,9 @@ fn Main() { // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+21, arg1: node+22}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+21, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+24, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+21, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+21, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+26, type: type0}, // CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, @@ -161,8 +161,8 @@ fn Main() { // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, // CHECK:STDOUT: {kind: BranchIf, arg0: block15, arg1: node+64}, // CHECK:STDOUT: {kind: Branch, arg0: block16}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+63, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+63, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+63, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+63, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+67}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block17, arg1: node+68}, // CHECK:STDOUT: {kind: BlockArg, arg0: block17, type: type0}, @@ -326,9 +326,9 @@ fn Main() { // CHECK:STDOUT: %n: i32 = var "n" // CHECK:STDOUT: %.loc22_16: i32 = int_literal 0 // CHECK:STDOUT: assign %n, %.loc22_16 -// CHECK:STDOUT: %.loc22_7.1: i32 = value_binding %n +// CHECK:STDOUT: %.loc22_7.1: i32 = bind_value %n // CHECK:STDOUT: %.loc26_4: i32 = stub_reference %.loc22_7.1 -// CHECK:STDOUT: %.loc22_7.2: i32 = value_binding %n +// CHECK:STDOUT: %.loc22_7.2: i32 = bind_value %n // CHECK:STDOUT: %.loc26_7: i32 = stub_reference %.loc22_7.2 // CHECK:STDOUT: %.loc26_8: (i32, i32) = tuple_value (%.loc26_4, %.loc26_7) // CHECK:STDOUT: %.loc26_13.1: i32 = int_literal 1 @@ -371,11 +371,11 @@ 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 = value_binding %a +// CHECK:STDOUT: %.loc41_7.1: i32 = bind_value %a // CHECK:STDOUT: br !if.expr.result.loc45(%.loc41_7.1) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else.loc45: -// CHECK:STDOUT: %.loc41_7.2: i32 = value_binding %a +// CHECK:STDOUT: %.loc41_7.2: i32 = bind_value %a // CHECK:STDOUT: br !if.expr.result.loc45(%.loc41_7.2) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result.loc45: diff --git a/toolchain/semantics/testdata/operators/or.carbon b/toolchain/semantics/testdata/operators/or.carbon index bc6b6be790093..c18b825333ca3 100644 --- a/toolchain/semantics/testdata/operators/or.carbon +++ b/toolchain/semantics/testdata/operators/or.carbon @@ -46,7 +46,7 @@ fn Or() -> bool { // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+10}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+11, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+11, type: type0}, // CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+14}, @@ -54,7 +54,7 @@ fn Or() -> bool { // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, // CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+19, arg1: node+18}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+19, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+21}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, @@ -130,7 +130,7 @@ fn Or() -> bool { // CHECK:STDOUT: %.loc11_11.1: bool = call @F() // CHECK:STDOUT: %.loc11_11.2: bool = materialize_temporary // CHECK:STDOUT: assign %.loc11_11.2, %.loc11_11.1 -// CHECK:STDOUT: %.loc11_11.3: bool = value_binding %.loc11_11.2 +// CHECK:STDOUT: %.loc11_11.3: bool = bind_value %.loc11_11.2 // CHECK:STDOUT: %.loc11_14.1: bool = not %.loc11_11.3 // CHECK:STDOUT: %.loc11_14.2: bool = bool_literal true // CHECK:STDOUT: if %.loc11_14.1 br !or.rhs else br !or.result(%.loc11_14.2) @@ -139,7 +139,7 @@ fn Or() -> bool { // CHECK:STDOUT: %.loc11_18.1: bool = call @G() // CHECK:STDOUT: %.loc11_18.2: bool = materialize_temporary // CHECK:STDOUT: assign %.loc11_18.2, %.loc11_18.1 -// CHECK:STDOUT: %.loc11_18.3: bool = value_binding %.loc11_18.2 +// CHECK:STDOUT: %.loc11_18.3: bool = bind_value %.loc11_18.2 // CHECK:STDOUT: br !or.result(%.loc11_18.3) // CHECK:STDOUT: // CHECK:STDOUT: !or.result: diff --git a/toolchain/semantics/testdata/operators/unary_op.carbon b/toolchain/semantics/testdata/operators/unary_op.carbon index 0022fb1e41bd8..b929b7a121293 100644 --- a/toolchain/semantics/testdata/operators/unary_op.carbon +++ b/toolchain/semantics/testdata/operators/unary_op.carbon @@ -30,7 +30,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+3, type: type0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, // CHECK:STDOUT: ] @@ -60,7 +60,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: // CHECK:STDOUT: fn @Not(%b: bool) -> bool { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: bool = value_binding %b +// CHECK:STDOUT: %.loc7: bool = bind_value %b // CHECK:STDOUT: %.loc8: bool = not %.loc7 // CHECK:STDOUT: return %.loc8 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/address_of_deref.carbon b/toolchain/semantics/testdata/pointer/address_of_deref.carbon index 6f2bf16c3a8d4..546f11a54bca2 100644 --- a/toolchain/semantics/testdata/pointer/address_of_deref.carbon +++ b/toolchain/semantics/testdata/pointer/address_of_deref.carbon @@ -40,7 +40,7 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: Dereference, arg0: node+6, type: type0}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+7, type: type1}, // CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+9, type: type0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -80,6 +80,6 @@ fn F() -> i32 { // CHECK:STDOUT: %.loc9_12: i32 = dereference %.loc9_13.2 // CHECK:STDOUT: %.loc9_11: i32* = address_of %.loc9_12 // CHECK:STDOUT: %.loc9_10.1: i32 = dereference %.loc9_11 -// CHECK:STDOUT: %.loc9_10.2: i32 = value_binding %.loc9_10.1 +// CHECK:STDOUT: %.loc9_10.2: i32 = bind_value %.loc9_10.1 // CHECK:STDOUT: return %.loc9_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/basic.carbon b/toolchain/semantics/testdata/pointer/basic.carbon index 57e89b56a166a..7aecece551571 100644 --- a/toolchain/semantics/testdata/pointer/basic.carbon +++ b/toolchain/semantics/testdata/pointer/basic.carbon @@ -42,9 +42,9 @@ fn F() -> i32 { // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: AddressOf, arg0: node+2, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+6, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+6, type: type1}, // CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+10, type: type0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -84,8 +84,8 @@ fn F() -> i32 { // CHECK:STDOUT: %p: i32* = var "p" // CHECK:STDOUT: %.loc9_17: i32* = address_of %n // CHECK:STDOUT: assign %p, %.loc9_17 -// CHECK:STDOUT: %.loc9_7: i32* = value_binding %p +// CHECK:STDOUT: %.loc9_7: i32* = bind_value %p // CHECK:STDOUT: %.loc11_10.1: i32 = dereference %.loc9_7 -// CHECK:STDOUT: %.loc11_10.2: i32 = value_binding %.loc11_10.1 +// CHECK:STDOUT: %.loc11_10.2: i32 = bind_value %.loc11_10.1 // CHECK:STDOUT: return %.loc11_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon b/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon index 8d220891c484e..a23b635151292 100644 --- a/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon +++ b/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon @@ -43,7 +43,7 @@ fn Deref(n: i32) { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: Dereference, arg0: node+2, type: typeError}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type1}, @@ -84,7 +84,7 @@ fn Deref(n: i32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Deref(%n: i32) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = value_binding %n +// CHECK:STDOUT: %.loc7: i32 = bind_value %n // CHECK:STDOUT: %.loc11: = dereference %.loc7 // CHECK:STDOUT: %.loc15_5.1: type = tuple_type () // CHECK:STDOUT: %.loc15_5.2: () = tuple_value () diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index 2e45ab172b847..c7c85557cb858 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -42,11 +42,11 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type5}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+5, type: type5}, // CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type3}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+10, type: type3}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+10, type: type3}, // CHECK:STDOUT: {kind: Dereference, arg0: node+11, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -84,10 +84,10 @@ 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: %.loc8: const (const (const i32*)*) = value_binding %p +// CHECK:STDOUT: %.loc8: const (const (const i32*)*) = bind_value %p // CHECK:STDOUT: %.loc9_11.1: const (const i32*) = dereference %.loc8 -// CHECK:STDOUT: %.loc9_11.2: const (const i32*) = value_binding %.loc9_11.1 +// CHECK:STDOUT: %.loc9_11.2: const (const i32*) = bind_value %.loc9_11.1 // CHECK:STDOUT: %.loc9_10.1: const i32 = dereference %.loc9_11.2 -// CHECK:STDOUT: %.loc9_10.2: const i32 = value_binding %.loc9_10.1 +// CHECK:STDOUT: %.loc9_10.2: const i32 = bind_value %.loc9_10.1 // CHECK:STDOUT: return %.loc9_10.2 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index 085103830a479..b3e447f04be44 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -41,7 +41,7 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+1, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+1, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, @@ -50,7 +50,7 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+9, type: type3}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+9, type: type3}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -97,12 +97,12 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: // CHECK:STDOUT: fn @Ptr(%p: i32*) -> i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32* = value_binding %p +// CHECK:STDOUT: %.loc7: i32* = bind_value %p // CHECK:STDOUT: return %.loc7 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> const i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: const i32* = value_binding %p +// CHECK:STDOUT: %.loc11: const i32* = bind_value %p // CHECK:STDOUT: return %.loc11 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index 2b418b6cf5a0f..dc08b855758d6 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -46,23 +46,23 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+9}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+13, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+16}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+18}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, // CHECK:STDOUT: {kind: Branch, arg0: unreachable}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ diff --git a/toolchain/semantics/testdata/struct/empty.carbon b/toolchain/semantics/testdata/struct/empty.carbon index ac1f7b9b2d081..f4725011831d3 100644 --- a/toolchain/semantics/testdata/struct/empty.carbon +++ b/toolchain/semantics/testdata/struct/empty.carbon @@ -31,7 +31,7 @@ var y: {} = x; // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -58,6 +58,6 @@ var y: {} = x; // CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %.loc8: {} = struct_value () // CHECK:STDOUT: %y: {} = var "y" -// CHECK:STDOUT: %.loc7_5: {} = value_binding %x +// CHECK:STDOUT: %.loc7_5: {} = bind_value %x // CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/member_access.carbon b/toolchain/semantics/testdata/struct/member_access.carbon index 09bdd9d1d017a..6190bcd7aa4e0 100644 --- a/toolchain/semantics/testdata/struct/member_access.carbon +++ b/toolchain/semantics/testdata/struct/member_access.carbon @@ -46,10 +46,10 @@ var z: i32 = y; // CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+10}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: StructAccess, arg0: node+3, arg1: member1, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+13, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+13, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+12, arg1: node+14}, // CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+12, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+12, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+16, arg1: node+17}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -99,9 +99,9 @@ var z: i32 = y; // CHECK:STDOUT: assign %x, %.loc7_46 // CHECK:STDOUT: %y: i32 = var "y" // CHECK:STDOUT: %.loc8_15.1: i32 = struct_access %x, member1 -// CHECK:STDOUT: %.loc8_15.2: i32 = value_binding %.loc8_15.1 +// CHECK:STDOUT: %.loc8_15.2: i32 = bind_value %.loc8_15.1 // CHECK:STDOUT: assign %y, %.loc8_15.2 // CHECK:STDOUT: %z: i32 = var "z" -// CHECK:STDOUT: %.loc8_5: i32 = value_binding %y +// CHECK:STDOUT: %.loc8_5: i32 = bind_value %y // CHECK:STDOUT: assign %z, %.loc8_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/one_entry.carbon b/toolchain/semantics/testdata/struct/one_entry.carbon index 949694deb9b71..1b94973c81ccb 100644 --- a/toolchain/semantics/testdata/struct/one_entry.carbon +++ b/toolchain/semantics/testdata/struct/one_entry.carbon @@ -38,7 +38,7 @@ var y: {.a: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str1, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+10, arg1: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -81,6 +81,6 @@ var y: {.a: i32} = x; // CHECK:STDOUT: assign %x, %.loc7_27 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32} // CHECK:STDOUT: %y: {.a: i32} = var "y" -// CHECK:STDOUT: %.loc7_5: {.a: i32} = value_binding %x +// CHECK:STDOUT: %.loc7_5: {.a: i32} = bind_value %x // CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/tuple_as_element.carbon b/toolchain/semantics/testdata/struct/tuple_as_element.carbon index 26e240478169d..303c73dbb51bf 100644 --- a/toolchain/semantics/testdata/struct/tuple_as_element.carbon +++ b/toolchain/semantics/testdata/struct/tuple_as_element.carbon @@ -61,7 +61,7 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type2}, // CHECK:STDOUT: {kind: StructType, arg0: block7, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type3}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+7, type: type3}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+7, type: type3}, // CHECK:STDOUT: {kind: Assign, arg0: node+23, arg1: node+24}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -139,6 +139,6 @@ var y: {.a: i32, .b: (i32,)} = x; // CHECK:STDOUT: %.loc8_27: (type,) = tuple_value (%.loc8_23) // CHECK:STDOUT: %.loc8_28: type = struct_type {.a: i32, .b: (i32,)} // CHECK:STDOUT: %y: {.a: i32, .b: (i32,)} = var "y" -// CHECK:STDOUT: %.loc7_5: {.a: i32, .b: (i32,)} = value_binding %x +// CHECK:STDOUT: %.loc7_5: {.a: i32, .b: (i32,)} = bind_value %x // CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/struct/two_entries.carbon b/toolchain/semantics/testdata/struct/two_entries.carbon index 6c9ee31a7dbcb..ba506a668464e 100644 --- a/toolchain/semantics/testdata/struct/two_entries.carbon +++ b/toolchain/semantics/testdata/struct/two_entries.carbon @@ -45,7 +45,7 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, // CHECK:STDOUT: {kind: StructType, arg0: block5, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+3, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+3, type: type1}, // CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -98,6 +98,6 @@ var y: {.a: i32, .b: i32} = x; // CHECK:STDOUT: assign %x, %.loc7_44 // CHECK:STDOUT: %.loc8: type = struct_type {.a: i32, .b: i32} // CHECK:STDOUT: %y: {.a: i32, .b: i32} = var "y" -// CHECK:STDOUT: %.loc7_5: {.a: i32, .b: i32} = value_binding %x +// CHECK:STDOUT: %.loc7_5: {.a: i32, .b: i32} = bind_value %x // CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/empty.carbon b/toolchain/semantics/testdata/tuples/empty.carbon index 2615a1388473b..928ada3447190 100644 --- a/toolchain/semantics/testdata/tuples/empty.carbon +++ b/toolchain/semantics/testdata/tuples/empty.carbon @@ -33,7 +33,7 @@ var y: () = x; // CHECK:STDOUT: {kind: Assign, arg0: node+2, arg1: node+3}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+2, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+6, arg1: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -60,6 +60,6 @@ var y: () = x; // CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %.loc8: () = tuple_value () // CHECK:STDOUT: %y: () = var "y" -// CHECK:STDOUT: %.loc7_5: () = value_binding %x +// CHECK:STDOUT: %.loc7_5: () = bind_value %x // CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/one_element.carbon b/toolchain/semantics/testdata/tuples/one_element.carbon index 9623f95c5bd40..1d1bf1e636a7b 100644 --- a/toolchain/semantics/testdata/tuples/one_element.carbon +++ b/toolchain/semantics/testdata/tuples/one_element.carbon @@ -45,7 +45,7 @@ var y: (i32,) = x; // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+4, type: type2}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+4, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+11, arg1: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -91,6 +91,6 @@ var y: (i32,) = x; // CHECK:STDOUT: %.loc8_9: type = stub_reference i32 // CHECK:STDOUT: %.loc8_13: (type,) = tuple_value (%.loc8_9) // CHECK:STDOUT: %y: (i32,) = var "y" -// CHECK:STDOUT: %.loc7_5: (i32,) = value_binding %x +// CHECK:STDOUT: %.loc7_5: (i32,) = bind_value %x // CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/tuples/two_elements.carbon b/toolchain/semantics/testdata/tuples/two_elements.carbon index 3da5a7308d30a..d73440067438d 100644 --- a/toolchain/semantics/testdata/tuples/two_elements.carbon +++ b/toolchain/semantics/testdata/tuples/two_elements.carbon @@ -52,7 +52,7 @@ var y: (i32, i32) = x; // CHECK:STDOUT: {kind: StubReference, arg0: nodeIntegerType, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type2}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+5, type: type2}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+5, type: type2}, // CHECK:STDOUT: {kind: Assign, arg0: node+15, arg1: node+16}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -109,6 +109,6 @@ var y: (i32, i32) = x; // CHECK:STDOUT: %.loc8_14: type = stub_reference i32 // CHECK:STDOUT: %.loc8_17: (type, type) = tuple_value (%.loc8_9, %.loc8_14) // CHECK:STDOUT: %y: (i32, i32) = var "y" -// CHECK:STDOUT: %.loc7_5: (i32, i32) = value_binding %x +// CHECK:STDOUT: %.loc7_5: (i32, i32) = bind_value %x // CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup.carbon b/toolchain/semantics/testdata/var/global_lookup.carbon index ca9742f2014de..79091c708fca8 100644 --- a/toolchain/semantics/testdata/var/global_lookup.carbon +++ b/toolchain/semantics/testdata/var/global_lookup.carbon @@ -29,7 +29,7 @@ var y: i32 = x; // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+1}, // CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+3, arg1: node+4}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,6 +50,6 @@ var y: i32 = x; // CHECK:STDOUT: %.loc7_14: i32 = int_literal 0 // CHECK:STDOUT: assign %x, %.loc7_14 // CHECK:STDOUT: %y: i32 = var "y" -// CHECK:STDOUT: %.loc7_5: i32 = value_binding %x +// CHECK:STDOUT: %.loc7_5: i32 = bind_value %x // CHECK:STDOUT: assign %y, %.loc7_5 // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon index ca3fcc391b79b..5287f2f0e65c0 100644 --- a/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon +++ b/toolchain/semantics/testdata/var/global_lookup_in_scope.carbon @@ -35,7 +35,7 @@ fn Main() { // CHECK:STDOUT: {kind: Assign, arg0: node+0, arg1: node+1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, -// CHECK:STDOUT: {kind: ValueBinding, arg0: node+0, type: type0}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+5}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -66,7 +66,7 @@ fn Main() { // CHECK:STDOUT: fn @Main() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %y: i32 = var "y" -// CHECK:STDOUT: %.loc7: i32 = value_binding package.%x +// CHECK:STDOUT: %.loc7: i32 = bind_value package.%x // CHECK:STDOUT: assign %y, %.loc7 // CHECK:STDOUT: return // CHECK:STDOUT: } From e172f4eb79df2e4404c45758549916a9a87df1a4 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 23 Aug 2023 13:54:30 -0700 Subject: [PATCH 18/21] Autoupdate --- toolchain/semantics/semantics_ir.cpp | 1 + .../semantics/testdata/const/collapse.carbon | 7 +- .../function/call/empty_struct.carbon | 11 +- .../testdata/function/call/empty_tuple.carbon | 11 +- .../testdata/function/call/i32.carbon | 21 ++- toolchain/semantics/testdata/if/else.carbon | 17 +- .../if/fail_reachable_fallthrough.carbon | 49 ++--- .../semantics/testdata/if/fail_scope.carbon | 26 ++- .../semantics/testdata/if/no_else.carbon | 13 +- .../if/unreachable_fallthrough.carbon | 15 +- .../testdata/if_expression/basic.carbon | 17 +- .../if_expression/control_flow.carbon | 79 +++++--- .../testdata/if_expression/nested.carbon | 37 ++-- .../testdata/operators/unary_op.carbon | 9 +- .../pointer/fail_address_of_value.carbon | 176 ++++++++++-------- .../fail_dereference_not_pointer.carbon | 15 +- .../testdata/pointer/nested_const.carbon | 15 +- .../semantics/testdata/pointer/types.carbon | 24 +-- .../return/code_after_return_value.carbon | 15 +- 19 files changed, 303 insertions(+), 255 deletions(-) diff --git a/toolchain/semantics/semantics_ir.cpp b/toolchain/semantics/semantics_ir.cpp index 27f3e5f950b5d..0f50028fa3580 100644 --- a/toolchain/semantics/semantics_ir.cpp +++ b/toolchain/semantics/semantics_ir.cpp @@ -551,6 +551,7 @@ auto GetSemanticsValueRepresentation(const SemanticsIR& semantics_ir, case SemanticsNodeKind::MaterializeTemporary: case SemanticsNodeKind::Namespace: case SemanticsNodeKind::NoOp: + case SemanticsNodeKind::Parameter: case SemanticsNodeKind::RealLiteral: case SemanticsNodeKind::Return: case SemanticsNodeKind::ReturnExpression: diff --git a/toolchain/semantics/testdata/const/collapse.carbon b/toolchain/semantics/testdata/const/collapse.carbon index 92902a57e623c..2a6523259f612 100644 --- a/toolchain/semantics/testdata/const/collapse.carbon +++ b/toolchain/semantics/testdata/const/collapse.carbon @@ -44,8 +44,7 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+3, type: type3}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -69,7 +68,6 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -79,6 +77,5 @@ fn F(p: const i32**) -> const (const i32)** { // CHECK:STDOUT: // CHECK:STDOUT: fn @F(%p: const i32**) -> const i32** { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: const i32** = bind_value %p -// CHECK:STDOUT: return %.loc11 +// CHECK:STDOUT: return %p // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/function/call/empty_struct.carbon b/toolchain/semantics/testdata/function/call/empty_struct.carbon index eefd9213d9915..0a837380c142f 100644 --- a/toolchain/semantics/testdata/function/call/empty_struct.carbon +++ b/toolchain/semantics/testdata/function/call/empty_struct.carbon @@ -39,11 +39,10 @@ fn Main() { // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -62,20 +61,19 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -86,7 +84,6 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: {}) -> {} { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: {} = bind_value %a // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/empty_tuple.carbon b/toolchain/semantics/testdata/function/call/empty_tuple.carbon index 41d421b57564c..7cdd796a7a474 100644 --- a/toolchain/semantics/testdata/function/call/empty_tuple.carbon +++ b/toolchain/semantics/testdata/function/call/empty_tuple.carbon @@ -41,11 +41,10 @@ fn Main() { // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+2, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+9, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+8, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] @@ -64,20 +63,19 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -88,7 +86,6 @@ fn Main() { // CHECK:STDOUT: // CHECK:STDOUT: fn @Echo(%a: ()) -> () { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: () = bind_value %a // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/function/call/i32.carbon b/toolchain/semantics/testdata/function/call/i32.carbon index 20859a081931b..2cd392ebe07f5 100644 --- a/toolchain/semantics/testdata/function/call/i32.carbon +++ b/toolchain/semantics/testdata/function/call/i32.carbon @@ -15,7 +15,7 @@ fn Main() { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type0, body: [block4]}, -// CHECK:STDOUT: {name: str2, param_refs: block0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block0, body: [block5]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -25,6 +25,7 @@ fn Main() { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Echo, // CHECK:STDOUT: a, +// CHECK:STDOUT: return, // CHECK:STDOUT: Main, // CHECK:STDOUT: b, // CHECK:STDOUT: ] @@ -35,14 +36,15 @@ fn Main() { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: node+0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+5, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+6, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block6, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -50,27 +52,28 @@ fn Main() { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/if/else.carbon b/toolchain/semantics/testdata/if/else.carbon index 27e08f4995e1f..617a5aea866ee 100644 --- a/toolchain/semantics/testdata/if/else.carbon +++ b/toolchain/semantics/testdata/if/else.carbon @@ -37,7 +37,7 @@ fn If(b: bool) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -52,8 +52,7 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: Parameter, arg0: str4, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+6, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+8}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block8, arg1: node+6}, // CHECK:STDOUT: {kind: Branch, arg0: block9}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, @@ -90,20 +89,19 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+15, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+16, -// CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -131,8 +129,7 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: bool = bind_value %b -// CHECK:STDOUT: if %.loc11 br !if.then else br !if.else +// CHECK:STDOUT: if %b br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc13_6.1: type = tuple_type () diff --git a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon index a9ba66dfa36eb..c0c1ae2355083 100644 --- a/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/fail_reachable_fallthrough.carbon @@ -36,8 +36,8 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block2, return_type: type1, body: [block4, block5, block6, block7]}, -// CHECK:STDOUT: {name: str2, param_refs: block9, return_type: type1, body: [block10, block11, block12, block13]}, -// CHECK:STDOUT: {name: str3, param_refs: block15, return_type: type1, body: [block16, block17, block18]}, +// CHECK:STDOUT: {name: str3, param_refs: block9, return_type: type1, body: [block10, block11, block12, block13]}, +// CHECK:STDOUT: {name: str4, param_refs: block15, return_type: type1, body: [block16, block17, block18]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -49,6 +49,7 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: If1, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: If2, // CHECK:STDOUT: If3, // CHECK:STDOUT: ] @@ -60,25 +61,28 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: {kind: Branch, arg0: block7}, // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+7}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block11, arg1: node+8}, // CHECK:STDOUT: {kind: Branch, arg0: block12}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, // CHECK:STDOUT: {kind: Branch, arg0: block13}, // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+14}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block17, arg1: node+16}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+18}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+21}, // CHECK:STDOUT: {kind: Branch, arg0: block18}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -86,60 +90,63 @@ fn If3(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+17, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: ], diff --git a/toolchain/semantics/testdata/if/fail_scope.carbon b/toolchain/semantics/testdata/if/fail_scope.carbon index 4ed6ad5e4392a..fef77d4a4de75 100644 --- a/toolchain/semantics/testdata/if/fail_scope.carbon +++ b/toolchain/semantics/testdata/if/fail_scope.carbon @@ -27,6 +27,7 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: VarScope, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: n, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ @@ -37,13 +38,15 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+5}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+6}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+5, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: ReturnExpression, arg0: nodeError}, // CHECK:STDOUT: ] @@ -52,25 +55,27 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, +// CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,9 +89,10 @@ fn VarScope(b: bool) -> i32 { // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %n: i32 = var "n" -// CHECK:STDOUT: %.loc9: i32 = int_literal 2 -// CHECK:STDOUT: assign %n, %.loc9 -// CHECK:STDOUT: return %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: // CHECK:STDOUT: !if.else: // CHECK:STDOUT: return diff --git a/toolchain/semantics/testdata/if/no_else.carbon b/toolchain/semantics/testdata/if/no_else.carbon index a786478c249ce..7911683e9bf14 100644 --- a/toolchain/semantics/testdata/if/no_else.carbon +++ b/toolchain/semantics/testdata/if/no_else.carbon @@ -32,7 +32,7 @@ fn If(b: bool) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -45,8 +45,7 @@ fn If(b: bool) { // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: Parameter, arg0: str3, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+4, type: type0}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+6}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+4}, // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type1}, @@ -77,16 +76,15 @@ fn If(b: bool) { // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -108,8 +106,7 @@ fn If(b: bool) { // CHECK:STDOUT: // CHECK:STDOUT: fn @If(%b: bool) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc10: bool = bind_value %b -// CHECK:STDOUT: if %.loc10 br !if.then else br !if.else +// CHECK:STDOUT: if %b br !if.then else br !if.else // CHECK:STDOUT: // CHECK:STDOUT: !if.then: // CHECK:STDOUT: %.loc12_6.1: type = tuple_type () diff --git a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon index aea3b81a4e8d1..fde5e7a4e18f8 100644 --- a/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon +++ b/toolchain/semantics/testdata/if/unreachable_fallthrough.carbon @@ -26,6 +26,7 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: If, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, @@ -35,37 +36,39 @@ fn If(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+7}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/if_expression/basic.carbon b/toolchain/semantics/testdata/if_expression/basic.carbon index 49e03b6d23f15..36327f2efa3e5 100644 --- a/toolchain/semantics/testdata/if_expression/basic.carbon +++ b/toolchain/semantics/testdata/if_expression/basic.carbon @@ -21,6 +21,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: b, // CHECK:STDOUT: n, // CHECK:STDOUT: m, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, @@ -32,15 +33,16 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: Parameter, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: Parameter, arg0: str3, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+1, arg1: node+2, type: type1}, // CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+2, arg1: node+1, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+6}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+7}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block7, arg1: node+8}, // CHECK:STDOUT: {kind: BlockArg, arg0: block7, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+10}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+11}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -49,6 +51,7 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -56,23 +59,23 @@ fn F(b: bool, n: i32, m: i32) -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+5, // CHECK:STDOUT: node+6, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+8, // CHECK:STDOUT: node+10, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+11, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/if_expression/control_flow.carbon b/toolchain/semantics/testdata/if_expression/control_flow.carbon index 57225db55a62a..f5137b744d4e6 100644 --- a/toolchain/semantics/testdata/if_expression/control_flow.carbon +++ b/toolchain/semantics/testdata/if_expression/control_flow.carbon @@ -13,9 +13,9 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ -// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block2]}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type0, body: [block3]}, -// CHECK:STDOUT: {name: str2, param_refs: block5, return_type: type0, body: [block6, block7, block8, block9]}, +// CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0, body: [block3]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type0, body: [block5]}, +// CHECK:STDOUT: {name: str3, param_refs: block7, return_type: type0, body: [block8, block9, block10, block11]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 1, @@ -25,6 +25,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: A, +// CHECK:STDOUT: return, // CHECK:STDOUT: B, // CHECK:STDOUT: F, // CHECK:STDOUT: b, @@ -36,60 +37,82 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+4}, -// CHECK:STDOUT: {kind: Parameter, arg0: str3, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+6}, +// CHECK:STDOUT: {kind: Parameter, arg0: str4, type: type1}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, -// CHECK:STDOUT: {kind: BranchIf, arg0: block7, arg1: node+6}, -// CHECK:STDOUT: {kind: Branch, arg0: block8}, +// CHECK:STDOUT: {kind: BranchIf, arg0: block9, arg1: node+8}, +// CHECK:STDOUT: {kind: Branch, arg0: block10}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+14, arg1: node+13}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+14, type: type0}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+10}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+11}, -// CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type0}, +// CHECK:STDOUT: {kind: Assign, arg0: node+18, arg1: node+17}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+18, type: type0}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+16}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block11, arg1: node+20}, +// CHECK:STDOUT: {kind: BlockArg, arg0: block11, type: type0}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, -// CHECK:STDOUT: node+3, -// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+1, -// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+7, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+10, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, // CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+16, +// CHECK:STDOUT: node+21, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+18, +// CHECK:STDOUT: node+19, +// CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+22, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ +// CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -116,12 +139,18 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: if %b br !if.expr.then else br !if.expr.else // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.then: -// CHECK:STDOUT: %.loc11_21: i32 = call @A() -// CHECK:STDOUT: br !if.expr.result(%.loc11_21) +// CHECK:STDOUT: %.loc11_21.1: i32 = call @A() +// CHECK:STDOUT: %.loc11_21.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_21.2, %.loc11_21.1 +// CHECK:STDOUT: %.loc11_21.3: i32 = bind_value %.loc11_21.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_21.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.else: -// CHECK:STDOUT: %.loc11_30: i32 = call @B() -// CHECK:STDOUT: br !if.expr.result(%.loc11_30) +// CHECK:STDOUT: %.loc11_30.1: i32 = call @B() +// CHECK:STDOUT: %.loc11_30.2: i32 = materialize_temporary +// CHECK:STDOUT: assign %.loc11_30.2, %.loc11_30.1 +// CHECK:STDOUT: %.loc11_30.3: i32 = bind_value %.loc11_30.2 +// CHECK:STDOUT: br !if.expr.result(%.loc11_30.3) // CHECK:STDOUT: // CHECK:STDOUT: !if.expr.result: // CHECK:STDOUT: %.loc11_10: i32 = block_arg !if.expr.result diff --git a/toolchain/semantics/testdata/if_expression/nested.carbon b/toolchain/semantics/testdata/if_expression/nested.carbon index 69620e4e3dda1..470c82c40ae31 100644 --- a/toolchain/semantics/testdata/if_expression/nested.carbon +++ b/toolchain/semantics/testdata/if_expression/nested.carbon @@ -25,6 +25,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: a, // CHECK:STDOUT: b, // CHECK:STDOUT: c, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, @@ -36,6 +37,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: Parameter, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: Parameter, arg0: str3, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str4, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: BranchIf, arg0: block5, arg1: node+0}, // CHECK:STDOUT: {kind: Branch, arg0: block6}, @@ -43,20 +45,20 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: {kind: Branch, arg0: block8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+8}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+9}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block9, arg1: node+10}, // CHECK:STDOUT: {kind: BlockArg, arg0: block9, type: type1}, // CHECK:STDOUT: {kind: BranchIf, arg0: block10, arg1: node+2}, // CHECK:STDOUT: {kind: Branch, arg0: block11}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+15}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+16}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block12, arg1: node+17}, // CHECK:STDOUT: {kind: BlockArg, arg0: block12, type: type1}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+12}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+19}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: block13, arg1: node+20}, // CHECK:STDOUT: {kind: BlockArg, arg0: block13, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+22}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+23}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -65,6 +67,7 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: node+0, // CHECK:STDOUT: node+1, // CHECK:STDOUT: node+2, +// CHECK:STDOUT: node+3, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, @@ -72,47 +75,47 @@ fn F(a: bool, b: bool, c: bool) -> i32 { // CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+4, // CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+13, // CHECK:STDOUT: node+14, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ -// CHECK:STDOUT: node+8, -// CHECK:STDOUT: node+10, +// CHECK:STDOUT: node+15, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+11, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+10, // CHECK:STDOUT: node+12, -// CHECK:STDOUT: node+20, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+17, +// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+16, // CHECK:STDOUT: node+18, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+17, // CHECK:STDOUT: node+19, -// CHECK:STDOUT: node+21, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+20, // CHECK:STDOUT: node+22, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+23, +// CHECK:STDOUT: node+24, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/operators/unary_op.carbon b/toolchain/semantics/testdata/operators/unary_op.carbon index a9ef7aebd75c6..4687ebb2fdd53 100644 --- a/toolchain/semantics/testdata/operators/unary_op.carbon +++ b/toolchain/semantics/testdata/operators/unary_op.carbon @@ -19,6 +19,7 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: Not, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeBoolType, @@ -27,25 +28,27 @@ fn Not(b: bool) -> bool { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: diff --git a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon index 576ade41cbe97..9ee135d089921 100644 --- a/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon +++ b/toolchain/semantics/testdata/pointer/fail_address_of_value.carbon @@ -40,7 +40,7 @@ fn AddressOfOperator() { // CHECK:STDERR: &(1 + 1); // CHECK:STDERR: ^ &(1 + 1); - // CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+3]]:3: Cannot take the address of non-reference expression. + // CHECK:STDERR: fail_address_of_value.carbon:[[@LINE+3]]:3: Cannot take the address of a temporary object. // CHECK:STDERR: &H().a; // CHECK:STDERR: ^ &H().a; @@ -85,13 +85,13 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: cross_reference_irs_size: 1 // CHECK:STDOUT: functions: [ // CHECK:STDOUT: {name: str0, param_refs: block0, return_type: type0}, -// CHECK:STDOUT: {name: str1, param_refs: block0, return_type: type1}, -// CHECK:STDOUT: {name: str3, param_refs: block0, body: [block3]}, -// CHECK:STDOUT: {name: str5, param_refs: block0, body: [block7]}, -// CHECK:STDOUT: {name: str6, param_refs: block0, body: [block8]}, -// CHECK:STDOUT: {name: str7, param_refs: block0, body: [block9]}, -// CHECK:STDOUT: {name: str8, param_refs: block0, body: [block10]}, -// CHECK:STDOUT: {name: str9, param_refs: block13, body: [block14]}, +// CHECK:STDOUT: {name: str2, param_refs: block0, return_type: type1}, +// CHECK:STDOUT: {name: str4, param_refs: block0, body: [block5]}, +// CHECK:STDOUT: {name: str6, param_refs: block0, body: [block9]}, +// CHECK:STDOUT: {name: str7, param_refs: block0, body: [block10]}, +// CHECK:STDOUT: {name: str8, param_refs: block0, body: [block11]}, +// CHECK:STDOUT: {name: str9, param_refs: block0, body: [block12]}, +// CHECK:STDOUT: {name: str10, param_refs: block15, body: [block16]}, // CHECK:STDOUT: ] // CHECK:STDOUT: integer_literals: [ // CHECK:STDOUT: 0, @@ -109,6 +109,7 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: ] // CHECK:STDOUT: strings: [ // CHECK:STDOUT: G, +// CHECK:STDOUT: return, // CHECK:STDOUT: H, // CHECK:STDOUT: a, // CHECK:STDOUT: AddressOfLiteral, @@ -123,19 +124,19 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+2, -// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: nodeBoolType, -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+11, // CHECK:STDOUT: nodeFloatingPointType, -// CHECK:STDOUT: node+12, +// CHECK:STDOUT: node+14, // CHECK:STDOUT: nodeStringType, -// CHECK:STDOUT: node+15, -// CHECK:STDOUT: node+21, +// CHECK:STDOUT: node+17, // CHECK:STDOUT: node+23, -// CHECK:STDOUT: node+29, -// CHECK:STDOUT: node+49, -// CHECK:STDOUT: node+51, +// CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -144,77 +145,81 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StructType, arg0: block2, type: typeTypeType}, +// CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, +// CHECK:STDOUT: {kind: StructType, arg0: block4, type: typeTypeType}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str1, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function2}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type0}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+5, type: type2}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+7, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, // CHECK:STDOUT: {kind: PointerType, arg0: type3, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+8, type: type4}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+10, type: type4}, // CHECK:STDOUT: {kind: RealLiteral, arg0: real0, type: type5}, // CHECK:STDOUT: {kind: PointerType, arg0: type5, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+11, type: type6}, -// CHECK:STDOUT: {kind: StringLiteral, arg0: str4, type: type7}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+13, type: type6}, +// CHECK:STDOUT: {kind: StringLiteral, arg0: str5, type: type7}, // CHECK:STDOUT: {kind: PointerType, arg0: type7, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+14, type: type8}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+16, type: type8}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+17, type: type0}, -// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, // CHECK:STDOUT: {kind: StubReference, arg0: node+19, type: type0}, +// CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+21, type: type0}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block4, type: type9}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block6, type: type9}, // CHECK:STDOUT: {kind: PointerType, arg0: type9, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+22, type: type10}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+24, type: type10}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int3, type: type0}, -// CHECK:STDOUT: {kind: StructTypeField, arg0: str2, arg1: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+25, type: type0}, -// CHECK:STDOUT: {kind: StructValue, arg0: block6, type: type1}, +// CHECK:STDOUT: {kind: StructTypeField, arg0: str3, arg1: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+27, type: type0}, +// CHECK:STDOUT: {kind: StructValue, arg0: block8, type: type1}, // CHECK:STDOUT: {kind: PointerType, arg0: type1, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+28, type: type11}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+30, type: type11}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function3}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int4, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int5, type: type0}, -// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+33, arg1: node+34, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+35, type: type2}, +// CHECK:STDOUT: {kind: BinaryOperatorAdd, arg0: node+35, arg1: node+36, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+37, type: type2}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function1, type: type1}, -// CHECK:STDOUT: {kind: StructAccess, arg0: node+37, arg1: member0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+38, type: type2}, +// CHECK:STDOUT: {kind: MaterializeTemporary, type: type1}, +// CHECK:STDOUT: {kind: Assign, arg0: node+40, arg1: node+39}, +// CHECK:STDOUT: {kind: StructAccess, arg0: node+40, arg1: member0, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+42, type: type2}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type3}, -// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+40, type: type3}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+41, type: type4}, +// CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+44, type: type3}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+45, type: type4}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function4}, // CHECK:STDOUT: {kind: Call, arg0: block0, arg1: function0, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+45, type: type2}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+49, type: type2}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function5}, // CHECK:STDOUT: {kind: PointerType, arg0: typeTypeType, type: typeTypeType}, // CHECK:STDOUT: {kind: AddressOf, arg0: nodeIntegerType, type: type12}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type13, type: typeTypeType}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+52, type: type12}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+56, type: type12}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function6}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int6, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+56, type: type0}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+60, type: type0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int7, type: type0}, -// CHECK:STDOUT: {kind: StubReference, arg0: node+58, type: type0}, -// CHECK:STDOUT: {kind: TupleValue, arg0: block11, type: type9}, +// CHECK:STDOUT: {kind: StubReference, arg0: node+62, type: type0}, +// CHECK:STDOUT: {kind: TupleValue, arg0: block13, type: type9}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int8, type: type0}, -// CHECK:STDOUT: {kind: TupleIndex, arg0: node+60, arg1: node+61, type: type0}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+62, type: type2}, +// CHECK:STDOUT: {kind: TupleIndex, arg0: node+64, arg1: node+65, type: type0}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+66, type: type2}, // CHECK:STDOUT: {kind: Return}, -// CHECK:STDOUT: {kind: Parameter, arg0: str10, type: type0}, +// CHECK:STDOUT: {kind: Parameter, arg0: str11, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function7}, // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str11, type: type2}, -// CHECK:STDOUT: {kind: AddressOf, arg0: node+65, type: type2}, -// CHECK:STDOUT: {kind: Assign, arg0: node+68, arg1: node+69}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str12, type: type2}, +// CHECK:STDOUT: {kind: AddressOf, arg0: node+69, type: type2}, +// CHECK:STDOUT: {kind: Assign, arg0: node+72, arg1: node+73}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -222,22 +227,26 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+5, +// CHECK:STDOUT: node+6, +// CHECK:STDOUT: node+34, +// CHECK:STDOUT: node+48, +// CHECK:STDOUT: node+52, +// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+70, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+32, -// CHECK:STDOUT: node+44, -// CHECK:STDOUT: node+48, -// CHECK:STDOUT: node+55, -// CHECK:STDOUT: node+66, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, @@ -257,25 +266,25 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: node+23, // CHECK:STDOUT: node+24, // CHECK:STDOUT: node+25, +// CHECK:STDOUT: node+26, // CHECK:STDOUT: node+27, -// CHECK:STDOUT: node+28, // CHECK:STDOUT: node+29, // CHECK:STDOUT: node+30, // CHECK:STDOUT: node+31, +// CHECK:STDOUT: node+32, +// CHECK:STDOUT: node+33, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+18, // CHECK:STDOUT: node+20, +// CHECK:STDOUT: node+22, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+26, +// CHECK:STDOUT: node+28, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+27, +// CHECK:STDOUT: node+29, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+33, -// CHECK:STDOUT: node+34, // CHECK:STDOUT: node+35, // CHECK:STDOUT: node+36, // CHECK:STDOUT: node+37, @@ -285,8 +294,7 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: node+41, // CHECK:STDOUT: node+42, // CHECK:STDOUT: node+43, -// CHECK:STDOUT: ], -// CHECK:STDOUT: [ +// CHECK:STDOUT: node+44, // CHECK:STDOUT: node+45, // CHECK:STDOUT: node+46, // CHECK:STDOUT: node+47, @@ -295,44 +303,48 @@ fn AddressOfParameter(param: i32) { // CHECK:STDOUT: node+49, // CHECK:STDOUT: node+50, // CHECK:STDOUT: node+51, -// CHECK:STDOUT: node+52, -// CHECK:STDOUT: node+53, -// CHECK:STDOUT: node+54, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+53, +// CHECK:STDOUT: node+54, +// CHECK:STDOUT: node+55, // CHECK:STDOUT: node+56, // CHECK:STDOUT: node+57, // CHECK:STDOUT: node+58, -// CHECK:STDOUT: node+59, +// CHECK:STDOUT: ], +// CHECK:STDOUT: [ // CHECK:STDOUT: node+60, // CHECK:STDOUT: node+61, // CHECK:STDOUT: node+62, // CHECK:STDOUT: node+63, // CHECK:STDOUT: node+64, +// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+66, +// CHECK:STDOUT: node+67, +// CHECK:STDOUT: node+68, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+57, -// CHECK:STDOUT: node+59, +// CHECK:STDOUT: node+61, +// CHECK:STDOUT: node+63, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+69, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+65, +// CHECK:STDOUT: node+69, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+67, -// CHECK:STDOUT: node+68, -// CHECK:STDOUT: node+69, -// CHECK:STDOUT: node+70, // CHECK:STDOUT: node+71, +// CHECK:STDOUT: node+72, +// CHECK:STDOUT: node+73, +// CHECK:STDOUT: node+74, +// CHECK:STDOUT: node+75, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: // CHECK:STDOUT: package { // CHECK:STDOUT: %.loc7 = fn_decl @G -// CHECK:STDOUT: %.loc9_19: type = struct_type {.a: i32} -// CHECK:STDOUT: %.loc9_1 = fn_decl @H +// CHECK:STDOUT: %.loc9 = fn_decl @H // CHECK:STDOUT: %.loc11 = fn_decl @AddressOfLiteral // CHECK:STDOUT: %.loc38 = fn_decl @AddressOfOperator // CHECK:STDOUT: %.loc53 = fn_decl @AddressOfCall @@ -381,8 +393,10 @@ 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: %.loc46_5: {.a: i32} = call @H() -// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5, member0 +// CHECK:STDOUT: %.loc46_5.1: {.a: i32} = call @H() +// CHECK:STDOUT: %.loc46_5.2: {.a: i32} = materialize_temporary +// CHECK:STDOUT: assign %.loc46_5.2, %.loc46_5.1 +// CHECK:STDOUT: %.loc46_7: i32 = struct_access %.loc46_5.2, member0 // CHECK:STDOUT: %.loc46_3: i32* = address_of %.loc46_7 // CHECK:STDOUT: %.loc50_9: bool = bool_literal true // CHECK:STDOUT: %.loc50_5: bool = not %.loc50_9 diff --git a/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon b/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon index 41b89b1a8b49c..0a1fa9af20899 100644 --- a/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon +++ b/toolchain/semantics/testdata/pointer/fail_dereference_not_pointer.carbon @@ -33,8 +33,8 @@ fn Deref(n: i32) { // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, -// CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+7, +// CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: [ @@ -43,14 +43,13 @@ fn Deref(n: i32) { // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+0, type: type0}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+2, type: typeError}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+0, type: typeError}, // CHECK:STDOUT: {kind: TupleType, arg0: typeBlock0, type: typeTypeType}, // CHECK:STDOUT: {kind: TupleValue, arg0: block0, type: type1}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+5, type: typeError}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+4, type: typeError}, // CHECK:STDOUT: {kind: StructType, arg0: block0, type: typeTypeType}, // CHECK:STDOUT: {kind: StructValue, arg0: block0, type: type2}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+8, type: typeError}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+7, type: typeError}, // CHECK:STDOUT: {kind: Return}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ @@ -74,7 +73,6 @@ fn Deref(n: i32) { // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, -// CHECK:STDOUT: node+10, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,8 +82,7 @@ fn Deref(n: i32) { // CHECK:STDOUT: // CHECK:STDOUT: fn @Deref(%n: i32) { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32 = bind_value %n -// CHECK:STDOUT: %.loc11: = dereference %.loc7 +// CHECK:STDOUT: %.loc11: = dereference %n // CHECK:STDOUT: %.loc15_5.1: type = tuple_type () // CHECK:STDOUT: %.loc15_5.2: () = tuple_value () // CHECK:STDOUT: %.loc15_3: = dereference %.loc15_5.2 diff --git a/toolchain/semantics/testdata/pointer/nested_const.carbon b/toolchain/semantics/testdata/pointer/nested_const.carbon index 3950cf2adb4b7..e4e731db59637 100644 --- a/toolchain/semantics/testdata/pointer/nested_const.carbon +++ b/toolchain/semantics/testdata/pointer/nested_const.carbon @@ -42,12 +42,11 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+5, type: type5}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+9, type: type3}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+10, type: type3}, -// CHECK:STDOUT: {kind: Dereference, arg0: node+11, type: type1}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+12, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+13}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+5, type: type3}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+9, type: type3}, +// CHECK:STDOUT: {kind: Dereference, arg0: node+10, type: type1}, +// CHECK:STDOUT: {kind: BindValue, arg0: node+11, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+12}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -74,7 +73,6 @@ fn F(p: const (const (const i32*)*)) -> const i32 { // CHECK:STDOUT: node+11, // CHECK:STDOUT: node+12, // CHECK:STDOUT: node+13, -// CHECK:STDOUT: node+14, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -84,8 +82,7 @@ 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: %.loc8: const (const (const i32*)*) = bind_value %p -// CHECK:STDOUT: %.loc9_11.1: const (const i32*) = dereference %.loc8 +// CHECK:STDOUT: %.loc9_11.1: const (const i32*) = dereference %p // CHECK:STDOUT: %.loc9_11.2: const (const i32*) = bind_value %.loc9_11.1 // CHECK:STDOUT: %.loc9_10.1: const i32 = dereference %.loc9_11.2 // CHECK:STDOUT: %.loc9_10.2: const i32 = bind_value %.loc9_10.1 diff --git a/toolchain/semantics/testdata/pointer/types.carbon b/toolchain/semantics/testdata/pointer/types.carbon index 799cf17b351ec..7caa6bad2f87d 100644 --- a/toolchain/semantics/testdata/pointer/types.carbon +++ b/toolchain/semantics/testdata/pointer/types.carbon @@ -30,8 +30,8 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: types: [ // CHECK:STDOUT: nodeIntegerType, // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, -// CHECK:STDOUT: node+8, // CHECK:STDOUT: ] // CHECK:STDOUT: type_blocks: [ // CHECK:STDOUT: ] @@ -41,8 +41,7 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: {kind: PointerType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+1, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+5}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+1}, // CHECK:STDOUT: {kind: ConstType, arg0: type0, type: typeTypeType}, // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type3}, @@ -50,8 +49,7 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: {kind: PointerType, arg0: type2, type: typeTypeType}, // CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type3}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function1}, -// CHECK:STDOUT: {kind: BindValue, arg0: node+9, type: type3}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+14}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+8}, // CHECK:STDOUT: ] // CHECK:STDOUT: node_blocks: [ // CHECK:STDOUT: [ @@ -67,26 +65,24 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+4, -// CHECK:STDOUT: node+13, +// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+5, -// CHECK:STDOUT: node+6, // CHECK:STDOUT: ], // CHECK:STDOUT: [ +// CHECK:STDOUT: node+6, // CHECK:STDOUT: node+7, // CHECK:STDOUT: node+8, // CHECK:STDOUT: node+9, // CHECK:STDOUT: node+10, // CHECK:STDOUT: node+11, -// CHECK:STDOUT: node+12, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+9, +// CHECK:STDOUT: node+8, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+14, -// CHECK:STDOUT: node+15, +// CHECK:STDOUT: node+13, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: @@ -97,12 +93,10 @@ fn ConstPtr(p: const i32*) -> (const i32)* { // CHECK:STDOUT: // CHECK:STDOUT: fn @Ptr(%p: i32*) -> i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc7: i32* = bind_value %p -// CHECK:STDOUT: return %.loc7 +// CHECK:STDOUT: return %p // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @ConstPtr(%p: const i32*) -> const i32* { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %.loc11: const i32* = bind_value %p -// CHECK:STDOUT: return %.loc11 +// CHECK:STDOUT: return %p // CHECK:STDOUT: } diff --git a/toolchain/semantics/testdata/return/code_after_return_value.carbon b/toolchain/semantics/testdata/return/code_after_return_value.carbon index 512eb61fdb70e..6e06871b253b2 100644 --- a/toolchain/semantics/testdata/return/code_after_return_value.carbon +++ b/toolchain/semantics/testdata/return/code_after_return_value.carbon @@ -30,6 +30,7 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: strings: [ // CHECK:STDOUT: F, // CHECK:STDOUT: b, +// CHECK:STDOUT: return, // CHECK:STDOUT: n, // CHECK:STDOUT: ] // CHECK:STDOUT: types: [ @@ -40,20 +41,21 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: ] // CHECK:STDOUT: nodes: [ // CHECK:STDOUT: {kind: Parameter, arg0: str1, type: type0}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, // CHECK:STDOUT: {kind: FunctionDeclaration, arg0: function0}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int0, type: type1}, -// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+2}, -// CHECK:STDOUT: {kind: VarStorage, arg0: str2, type: type1}, +// CHECK:STDOUT: {kind: ReturnExpression, arg0: node+3}, +// CHECK:STDOUT: {kind: VarStorage, arg0: str3, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int1, type: type1}, // CHECK:STDOUT: {kind: IntegerLiteral, arg0: int2, type: type1}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type1}, -// CHECK:STDOUT: {kind: Assign, arg0: node+4, arg1: node+7}, +// CHECK:STDOUT: {kind: Assign, arg0: node+5, arg1: node+8}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: false, type: type0}, // CHECK:STDOUT: {kind: UnaryOperatorNot, arg0: node+0, type: type0}, // CHECK:STDOUT: {kind: BoolLiteral, arg0: true, type: type0}, // CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+0}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, -// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+13}, +// CHECK:STDOUT: {kind: BranchWithArg, arg0: unreachable, arg1: node+14}, // CHECK:STDOUT: {kind: BlockArg, arg0: unreachable, type: type0}, // CHECK:STDOUT: {kind: Branch, arg0: unreachable}, // CHECK:STDOUT: ] @@ -62,16 +64,17 @@ fn F(b: bool) -> i32 { // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, +// CHECK:STDOUT: node+1, // CHECK:STDOUT: ], // CHECK:STDOUT: [ // CHECK:STDOUT: node+0, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+1, +// CHECK:STDOUT: node+2, // CHECK:STDOUT: ], // CHECK:STDOUT: [ -// CHECK:STDOUT: node+2, // CHECK:STDOUT: node+3, +// CHECK:STDOUT: node+4, // CHECK:STDOUT: ], // CHECK:STDOUT: ] // CHECK:STDOUT: From dc447a230fbb3027f48b50d973cc0e2360147ef1 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 23 Aug 2023 17:05:49 -0700 Subject: [PATCH 19/21] Fix typo from merging the big namespace change. --- toolchain/semantics/semantics_ir.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolchain/semantics/semantics_ir.h b/toolchain/semantics/semantics_ir.h index c1f5b8585d342..523a396ad7b1e 100644 --- a/toolchain/semantics/semantics_ir.h +++ b/toolchain/semantics/semantics_ir.h @@ -391,7 +391,7 @@ struct ValueRepresentation { }; // Returns information about the value representation to use for a type. -auto GetValueRepresentation(const File& file, File type_id) +auto GetValueRepresentation(const File& file, TypeId type_id) -> ValueRepresentation; // The initializing representation to use when returning by value. From 13c31568af2b0a86c1954ca7df45167bbe070f95 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 24 Aug 2023 12:16:49 -0700 Subject: [PATCH 20/21] Remove redundant braces. Co-authored-by: Chandler Carruth --- toolchain/semantics/semantics_context.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 423013d3af8ea..6548b172e51cf 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -306,13 +306,12 @@ auto Context::ConvertToValueExpression(SemIR::NodeId expr_id) -> SemIR::NodeId { << semantics_ir().GetNode(expr_id) << " to value expression"; - case SemIR::ExpressionCategory::Initializing: { + case SemIR::ExpressionCategory::Initializing: // Commit to using a temporary for this initializing expression. // TODO: Don't create a temporary if the initializing representation is // already a value representation. expr_id = FinalizeTemporary(expr_id, /*discarded=*/false); [[fallthrough]]; - } case SemIR::ExpressionCategory::DurableReference: case SemIR::ExpressionCategory::EphemeralReference: { From 1dee9130949a200fd2d8fcda81e4f5c3c89c9d59 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 24 Aug 2023 12:17:12 -0700 Subject: [PATCH 21/21] Remove redundant braces. Co-authored-by: Chandler Carruth --- toolchain/semantics/semantics_context.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/toolchain/semantics/semantics_context.cpp b/toolchain/semantics/semantics_context.cpp index 6548b172e51cf..bfe071797c527 100644 --- a/toolchain/semantics/semantics_context.cpp +++ b/toolchain/semantics/semantics_context.cpp @@ -399,10 +399,9 @@ auto Context::MarkInitializerFor(SemIR::NodeId init_id, SemIR::NodeId target_id) case SemIR::NodeKind::TupleValue: CARBON_FATAL() << init << " is not modeled as initializing yet"; - case SemIR::NodeKind::StubReference: { + case SemIR::NodeKind::StubReference: init_id = init.GetAsStubReference(); continue; - } case SemIR::NodeKind::Call: { // If the callee has a return slot, point it at our target.