From 2c1d02d991aaebb8b142f161b46e55935dd69484 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 11 Nov 2024 13:32:33 -0800 Subject: [PATCH] Don't eagerly materialize an initializing expression used as the object in a compound member access. (#4496) Instead, wait until we know whether it is used as a value or reference expression. This allows us to avoid materializing a temporary if it is used as a value and the initializing representation holds a copy of a value representation. --- toolchain/check/member_access.cpp | 2 - .../testdata/as/adapter_conversion.carbon | 7 +- toolchain/check/testdata/as/overloaded.carbon | 4 +- .../testdata/class/fail_incomplete.carbon | 70 +++++++++++++++++++ .../testdata/class/generic/import.carbon | 5 +- .../class/generic/member_access.carbon | 5 +- .../check/testdata/class/init_adapt.carbon | 12 ++-- toolchain/check/testdata/class/self.carbon | 13 +--- .../call/fail_return_type_mismatch.carbon | 2 - .../impl/fail_todo_impl_assoc_const.carbon | 4 +- .../check/testdata/let/fail_generic.carbon | 2 +- .../operators/overloaded/implicit_as.carbon | 31 ++++---- .../testdata/struct/fail_value_as_type.carbon | 5 +- toolchain/check/testdata/struct/import.carbon | 5 +- .../testdata/tuple/fail_type_assign.carbon | 2 - toolchain/check/testdata/tuple/import.carbon | 5 +- .../testdata/where_expr/constraints.carbon | 5 +- .../builtins/overloaded_operator.carbon | 5 +- 18 files changed, 110 insertions(+), 74 deletions(-) diff --git a/toolchain/check/member_access.cpp b/toolchain/check/member_access.cpp index a62383b5e648..149953506485 100644 --- a/toolchain/check/member_access.cpp +++ b/toolchain/check/member_access.cpp @@ -462,8 +462,6 @@ auto PerformCompoundMemberAccess( Context& context, SemIR::LocId loc_id, SemIR::InstId base_id, SemIR::InstId member_expr_id, Context::BuildDiagnosticFn missing_impl_diagnoser) -> SemIR::InstId { - // Materialize a temporary for the base expression if necessary. - base_id = ConvertToValueOrRefExpr(context, base_id); auto base_type_id = context.insts().Get(base_id).type_id(); auto base_type_const_id = context.types().GetConstantId(base_type_id); diff --git a/toolchain/check/testdata/as/adapter_conversion.carbon b/toolchain/check/testdata/as/adapter_conversion.carbon index e4c8bfcde38f..5e49ce4a2480 100644 --- a/toolchain/check/testdata/as/adapter_conversion.carbon +++ b/toolchain/check/testdata/as/adapter_conversion.carbon @@ -541,7 +541,6 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: %.9: type = assoc_entity_type %As.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.10: %.9 = assoc_entity element0, imports.%import_ref.6 [template] // CHECK:STDOUT: %.11: %.7 = assoc_entity element0, imports.%import_ref.7 [symbolic] -// CHECK:STDOUT: %struct: %.2 = struct_value (%.6) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -629,11 +628,9 @@ var b: B = {.x = 1} as B; // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc21_18: i32 = int_value 1 [template = constants.%.6] -// CHECK:STDOUT: %.loc21_19.1: %.2 = struct_literal (%.loc21_18) +// CHECK:STDOUT: %.loc21_19: %.2 = struct_literal (%.loc21_18) // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B] -// CHECK:STDOUT: %struct: %.2 = struct_value (%.loc21_18) [template = constants.%struct] -// CHECK:STDOUT: %.loc21_19.2: %.2 = converted %.loc21_19.1, %struct [template = constants.%struct] -// CHECK:STDOUT: %.loc21_21: %B = converted %.loc21_19.1, [template = ] +// CHECK:STDOUT: %.loc21_21: %B = converted %.loc21_19, [template = ] // CHECK:STDOUT: assign file.%b.var, // CHECK:STDOUT: return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/as/overloaded.carbon b/toolchain/check/testdata/as/overloaded.carbon index 67ec457be4ec..6e08c056428e 100644 --- a/toolchain/check/testdata/as/overloaded.carbon +++ b/toolchain/check/testdata/as/overloaded.carbon @@ -235,9 +235,9 @@ let n: i32 = ((4 as i32) as X) as i32; // CHECK:STDOUT: %int.make_type_32.loc23_35: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc23_35.1: type = value_of_initializer %int.make_type_32.loc23_35 [template = i32] // CHECK:STDOUT: %.loc23_35.2: type = converted %int.make_type_32.loc23_35, %.loc23_35.1 [template = i32] -// CHECK:STDOUT: %.loc23_26.5: ref %X = temporary %.loc23_26.3, %.loc23_26.4 // CHECK:STDOUT: %.loc23_32.1: %Convert.type.5 = interface_witness_access constants.%.12, element0 [template = constants.%Convert.4] -// CHECK:STDOUT: %.loc23_32.2: = bound_method %.loc23_26.5, %.loc23_32.1 +// CHECK:STDOUT: %.loc23_32.2: = bound_method %.loc23_26.4, %.loc23_32.1 +// CHECK:STDOUT: %.loc23_26.5: ref %X = temporary %.loc23_26.3, %.loc23_26.4 // CHECK:STDOUT: %.loc23_26.6: %X = bind_value %.loc23_26.5 // CHECK:STDOUT: %Convert.call.loc23_32: init i32 = call %.loc23_32.2(%.loc23_26.6) // CHECK:STDOUT: %.loc23_32.3: i32 = value_of_initializer %Convert.call.loc23_32 diff --git a/toolchain/check/testdata/class/fail_incomplete.carbon b/toolchain/check/testdata/class/fail_incomplete.carbon index 45fb5aa2902b..eba65ecb9f5a 100644 --- a/toolchain/check/testdata/class/fail_incomplete.carbon +++ b/toolchain/check/testdata/class/fail_incomplete.carbon @@ -140,6 +140,25 @@ fn CallReturnIncomplete() { ReturnIncomplete(); } +class IncompleteAddrSelf { + fn F[addr self: Class*](); +} + +fn CallIncompleteAddrSelf(p: Class*) { + // TODO: Should this be valid? + // CHECK:STDERR: fail_forward_decl.carbon:[[@LINE+10]]:3: error: invalid use of incomplete type `Class` [IncompleteTypeInConversion] + // CHECK:STDERR: p->(IncompleteAddrSelf.F)(); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ + // CHECK:STDERR: fail_forward_decl.carbon:[[@LINE-137]]:1: note: class was forward declared here [ClassForwardDeclaredHere] + // CHECK:STDERR: class Class; + // CHECK:STDERR: ^~~~~~~~~~~~ + // CHECK:STDERR: fail_forward_decl.carbon:[[@LINE-11]]:8: note: initializing function parameter [InCallToFunctionParam] + // CHECK:STDERR: fn F[addr self: Class*](); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~ + // CHECK:STDERR: + p->(IncompleteAddrSelf.F)(); +} + // --- fail_in_definition.carbon library "[[@TEST_NAME]]"; @@ -185,6 +204,13 @@ class C { // CHECK:STDOUT: %CallTakeIncomplete: %CallTakeIncomplete.type = struct_value () [template] // CHECK:STDOUT: %CallReturnIncomplete.type: type = fn_type @CallReturnIncomplete [template] // CHECK:STDOUT: %CallReturnIncomplete: %CallReturnIncomplete.type = struct_value () [template] +// CHECK:STDOUT: %IncompleteAddrSelf: type = class_type @IncompleteAddrSelf [template] +// CHECK:STDOUT: %F.type: type = fn_type @F [template] +// CHECK:STDOUT: %F: %F.type = struct_value () [template] +// CHECK:STDOUT: %.4: = complete_type_witness %.2 [template] +// CHECK:STDOUT: %CallIncompleteAddrSelf.type: type = fn_type @CallIncompleteAddrSelf [template] +// CHECK:STDOUT: %CallIncompleteAddrSelf: %CallIncompleteAddrSelf.type = struct_value () [template] +// CHECK:STDOUT: %.5: type = ptr_type %.2 [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -211,6 +237,8 @@ class C { // CHECK:STDOUT: .ReturnIncomplete = %ReturnIncomplete.decl // CHECK:STDOUT: .CallTakeIncomplete = %CallTakeIncomplete.decl // CHECK:STDOUT: .CallReturnIncomplete = %CallReturnIncomplete.decl +// CHECK:STDOUT: .IncompleteAddrSelf = %IncompleteAddrSelf.decl +// CHECK:STDOUT: .CallIncompleteAddrSelf = %CallIncompleteAddrSelf.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Class.decl: type = class_decl @Class [template = constants.%Class] {} {} @@ -308,10 +336,38 @@ class C { // CHECK:STDOUT: %p: %.3 = bind_name p, %p.param // CHECK:STDOUT: } // CHECK:STDOUT: %CallReturnIncomplete.decl: %CallReturnIncomplete.type = fn_decl @CallReturnIncomplete [template = constants.%CallReturnIncomplete] {} {} +// CHECK:STDOUT: %IncompleteAddrSelf.decl: type = class_decl @IncompleteAddrSelf [template = constants.%IncompleteAddrSelf] {} {} +// CHECK:STDOUT: %CallIncompleteAddrSelf.decl: %CallIncompleteAddrSelf.type = fn_decl @CallIncompleteAddrSelf [template = constants.%CallIncompleteAddrSelf] { +// CHECK:STDOUT: %p.patt: %.3 = binding_pattern p +// CHECK:STDOUT: %p.param_patt: %.3 = value_param_pattern %p.patt, runtime_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] +// CHECK:STDOUT: %.loc136: type = ptr_type %Class [template = constants.%.3] +// CHECK:STDOUT: %p.param: %.3 = value_param runtime_param0 +// CHECK:STDOUT: %p: %.3 = bind_name p, %p.param +// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @Class; // CHECK:STDOUT: +// CHECK:STDOUT: class @IncompleteAddrSelf { +// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] { +// CHECK:STDOUT: %self.patt: %.3 = binding_pattern self +// CHECK:STDOUT: %self.param_patt: %.3 = value_param_pattern %self.patt, runtime_param0 +// CHECK:STDOUT: %.loc133_8: auto = addr_pattern %self.param_patt +// CHECK:STDOUT: } { +// CHECK:STDOUT: %Class.ref: type = name_ref Class, file.%Class.decl [template = constants.%Class] +// CHECK:STDOUT: %.loc133_24: type = ptr_type %Class [template = constants.%.3] +// CHECK:STDOUT: %self.param: %.3 = value_param runtime_param0 +// CHECK:STDOUT: %self: %.3 = bind_name self, %self.param +// CHECK:STDOUT: } +// CHECK:STDOUT: %.loc134: = complete_type_witness %.2 [template = constants.%.4] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%IncompleteAddrSelf +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: fn @.1() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return @@ -385,6 +441,20 @@ class C { // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: fn @F[addr %self.param_patt: %.3](); +// CHECK:STDOUT: +// CHECK:STDOUT: fn @CallIncompleteAddrSelf(%p.param_patt: %.3) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %p.ref: %.3 = name_ref p, %p +// CHECK:STDOUT: %IncompleteAddrSelf.ref: type = name_ref IncompleteAddrSelf, file.%IncompleteAddrSelf.decl [template = constants.%IncompleteAddrSelf] +// CHECK:STDOUT: %F.ref: %F.type = name_ref F, @IncompleteAddrSelf.%F.decl [template = constants.%F] +// CHECK:STDOUT: %.loc148_4.1: ref %Class = deref %p.ref +// CHECK:STDOUT: %.loc148_4.2: = bound_method %.loc148_4.1, %F.ref +// CHECK:STDOUT: %.1: = addr_of [template = ] +// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc148_4.2() +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: // CHECK:STDOUT: --- fail_in_definition.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { diff --git a/toolchain/check/testdata/class/generic/import.carbon b/toolchain/check/testdata/class/generic/import.carbon index a0f296031ea1..23600aec1ea9 100644 --- a/toolchain/check/testdata/class/generic/import.carbon +++ b/toolchain/check/testdata/class/generic/import.carbon @@ -728,9 +728,8 @@ class Class(U:! type) { // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var // CHECK:STDOUT: %F.ref: %F.type.3 = name_ref F, imports.%import_ref.3 [template = constants.%F.3] -// CHECK:STDOUT: %.loc14_33.1: ref %CompleteClass.4 = temporary_storage -// CHECK:STDOUT: %F.call: init %CompleteClass.4 = call %F.ref() to %.loc14_33.1 -// CHECK:STDOUT: %.loc14_33.2: ref %CompleteClass.4 = temporary %.loc14_33.1, %F.call +// CHECK:STDOUT: %.loc14_33: ref %CompleteClass.4 = temporary_storage +// CHECK:STDOUT: %F.call: init %CompleteClass.4 = call %F.ref() to %.loc14_33 // CHECK:STDOUT: %.loc14_35: %CompleteClass.3 = converted %F.call, [template = ] // CHECK:STDOUT: assign %v.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/class/generic/member_access.carbon b/toolchain/check/testdata/class/generic/member_access.carbon index 8257c226793f..623e555a258a 100644 --- a/toolchain/check/testdata/class/generic/member_access.carbon +++ b/toolchain/check/testdata/class/generic/member_access.carbon @@ -546,9 +546,8 @@ fn StaticMemberFunctionCall(T:! type) -> Class(T) { // CHECK:STDOUT: %.loc15_18.1: @StaticMemberFunctionCall.%Make.type (%Make.type) = specific_constant @Class.%Make.decl, @Class(constants.%T) [symbolic = %Make (constants.%Make)] // CHECK:STDOUT: %Make.ref: @StaticMemberFunctionCall.%Make.type (%Make.type) = name_ref Make, %.loc15_18.1 [symbolic = %Make (constants.%Make)] // CHECK:STDOUT: %.loc15_18.2: = specific_function %Make.ref, @Make(constants.%T) [symbolic = %.loc15_18.3 (constants.%.4)] -// CHECK:STDOUT: %.loc15_23.1: ref @StaticMemberFunctionCall.%Class.loc8_47.2 (%Class.2) = temporary_storage -// CHECK:STDOUT: %Make.call: init @StaticMemberFunctionCall.%Class.loc8_47.2 (%Class.2) = call %.loc15_18.2() to %.loc15_23.1 -// CHECK:STDOUT: %.loc15_23.2: ref @StaticMemberFunctionCall.%Class.loc8_47.2 (%Class.2) = temporary %.loc15_23.1, %Make.call +// CHECK:STDOUT: %.loc15_23: ref @StaticMemberFunctionCall.%Class.loc8_47.2 (%Class.2) = temporary_storage +// CHECK:STDOUT: %Make.call: init @StaticMemberFunctionCall.%Class.loc8_47.2 (%Class.2) = call %.loc15_18.2() to %.loc15_23 // CHECK:STDOUT: %.loc15_25: @StaticMemberFunctionCall.%Class.loc8_47.2 (%Class.2) = converted %Make.call, [template = ] // CHECK:STDOUT: return to %return // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/class/init_adapt.carbon b/toolchain/check/testdata/class/init_adapt.carbon index 0e4150a8b562..bc21ffdde903 100644 --- a/toolchain/check/testdata/class/init_adapt.carbon +++ b/toolchain/check/testdata/class/init_adapt.carbon @@ -64,7 +64,7 @@ let b: AdaptC = a; // CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+7]]:1: error: cannot implicitly convert from `AdaptC` to `C` [ImplicitAsConversionFailure] // CHECK:STDERR: let c: C = b; // CHECK:STDERR: ^~~~~~~~~~~~~ -// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+4]]:1: note: type `` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] +// CHECK:STDERR: fail_not_implicit.carbon:[[@LINE+4]]:1: note: type `AdaptC` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] // CHECK:STDERR: let c: C = b; // CHECK:STDERR: ^~~~~~~~~~~~~ // CHECK:STDERR: @@ -424,15 +424,13 @@ var e: C = MakeAdaptC(); // CHECK:STDOUT: %.loc33: %C = converted %b.ref, [template = ] // CHECK:STDOUT: %c: %C = bind_name c, // CHECK:STDOUT: %MakeC.ref: %MakeC.type = name_ref MakeC, file.%MakeC.decl [template = constants.%MakeC] -// CHECK:STDOUT: %.loc46_22.1: ref %C = temporary_storage -// CHECK:STDOUT: %MakeC.call: init %C = call %MakeC.ref() to %.loc46_22.1 -// CHECK:STDOUT: %.loc46_22.2: ref %C = temporary %.loc46_22.1, %MakeC.call +// CHECK:STDOUT: %.loc46_22: ref %C = temporary_storage +// CHECK:STDOUT: %MakeC.call: init %C = call %MakeC.ref() to %.loc46_22 // CHECK:STDOUT: %.loc46_24: %AdaptC = converted %MakeC.call, [template = ] // CHECK:STDOUT: assign file.%d.var, // CHECK:STDOUT: %MakeAdaptC.ref: %MakeAdaptC.type = name_ref MakeAdaptC, file.%MakeAdaptC.decl [template = constants.%MakeAdaptC] -// CHECK:STDOUT: %.loc54_22.1: ref %AdaptC = temporary_storage -// CHECK:STDOUT: %MakeAdaptC.call: init %AdaptC = call %MakeAdaptC.ref() to %.loc54_22.1 -// CHECK:STDOUT: %.loc54_22.2: ref %AdaptC = temporary %.loc54_22.1, %MakeAdaptC.call +// CHECK:STDOUT: %.loc54_22: ref %AdaptC = temporary_storage +// CHECK:STDOUT: %MakeAdaptC.call: init %AdaptC = call %MakeAdaptC.ref() to %.loc54_22 // CHECK:STDOUT: %.loc54_24: %C = converted %MakeAdaptC.call, [template = ] // CHECK:STDOUT: assign file.%e.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/class/self.carbon b/toolchain/check/testdata/class/self.carbon index cc6047d9864c..53334e030648 100644 --- a/toolchain/check/testdata/class/self.carbon +++ b/toolchain/check/testdata/class/self.carbon @@ -32,17 +32,10 @@ fn Class.G[addr self: Self*]() -> i32 { library "[[@TEST_NAME]]"; class Class { - // CHECK:STDERR: fail_return_self_value.carbon:[[@LINE+13]]:25: error: invalid use of incomplete type `Class` [IncompleteTypeInConversion] - // CHECK:STDERR: fn F[self: Self]() -> self; - // CHECK:STDERR: ^~~~ - // CHECK:STDERR: fail_return_self_value.carbon:[[@LINE-4]]:1: note: class is incomplete within its definition [ClassIncompleteWithinDefinition] - // CHECK:STDERR: class Class { - // CHECK:STDERR: ^~~~~~~~~~~~~ - // CHECK:STDERR: // CHECK:STDERR: fail_return_self_value.carbon:[[@LINE+6]]:25: error: cannot implicitly convert from `Class` to `type` [ImplicitAsConversionFailure] // CHECK:STDERR: fn F[self: Self]() -> self; // CHECK:STDERR: ^~~~ - // CHECK:STDERR: fail_return_self_value.carbon:[[@LINE+3]]:25: note: type `` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] + // CHECK:STDERR: fail_return_self_value.carbon:[[@LINE+3]]:25: note: type `Class` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] // CHECK:STDERR: fn F[self: Self]() -> self; // CHECK:STDERR: ^~~~ fn F[self: Self]() -> self; @@ -263,13 +256,13 @@ class Class { // CHECK:STDOUT: } { // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Class [template = constants.%Class] // CHECK:STDOUT: %self.ref: %Class = name_ref self, %self -// CHECK:STDOUT: %.loc18: type = converted %self.ref, [template = ] +// CHECK:STDOUT: %.loc11: type = converted %self.ref, [template = ] // CHECK:STDOUT: %self.param: %Class = value_param runtime_param0 // CHECK:STDOUT: %self: %Class = bind_name self, %self.param // CHECK:STDOUT: %return.param: ref = out_param runtime_param1 // CHECK:STDOUT: %return: ref = return_slot %return.param // CHECK:STDOUT: } -// CHECK:STDOUT: %.loc19: = complete_type_witness %.6 [template = constants.%.7] +// CHECK:STDOUT: %.loc12: = complete_type_witness %.6 [template = constants.%.7] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%Class diff --git a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon index b34dd07ac9da..0194abe0682b 100644 --- a/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon +++ b/toolchain/check/testdata/function/call/fail_return_type_mismatch.carbon @@ -129,8 +129,6 @@ fn Run() { // CHECK:STDOUT: %x: ref i32 = bind_name x, %x.var // CHECK:STDOUT: %Foo.ref: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo] // CHECK:STDOUT: %Foo.call: init f64 = call %Foo.ref() -// CHECK:STDOUT: %.loc20_19.1: ref f64 = temporary_storage -// CHECK:STDOUT: %.loc20_19.2: ref f64 = temporary %.loc20_19.1, %Foo.call // CHECK:STDOUT: %.loc20_21: i32 = converted %Foo.call, [template = ] // CHECK:STDOUT: assign %x.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon b/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon index eac0903539d0..dec466b53d13 100644 --- a/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon +++ b/toolchain/check/testdata/impl/fail_todo_impl_assoc_const.carbon @@ -85,9 +85,7 @@ impl bool as I where .T = bool {} // CHECK:STDOUT: %.Self.ref: %I.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %T.ref: %.1 = name_ref T, @I.%.loc11 [template = constants.%.2] // CHECK:STDOUT: %bool.make_type.loc23_27: init type = call constants.%Bool() [template = bool] -// CHECK:STDOUT: %.loc23_27.1: ref type = temporary_storage -// CHECK:STDOUT: %.loc23_27.2: ref type = temporary %.loc23_27.1, %bool.make_type.loc23_27 -// CHECK:STDOUT: %.loc23_27.3: %.1 = converted %bool.make_type.loc23_27, [template = ] +// CHECK:STDOUT: %.loc23_27: %.1 = converted %bool.make_type.loc23_27, [template = ] // CHECK:STDOUT: %.loc23_16: type = where_expr %.Self [template = constants.%I.type.2] { // CHECK:STDOUT: requirement_rewrite %T.ref, // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/let/fail_generic.carbon b/toolchain/check/testdata/let/fail_generic.carbon index 1ff21f02a35f..f9a2fa7f13fe 100644 --- a/toolchain/check/testdata/let/fail_generic.carbon +++ b/toolchain/check/testdata/let/fail_generic.carbon @@ -22,7 +22,7 @@ fn F(a: i32) -> i32 { // CHECK:STDERR: fail_generic.carbon:[[@LINE+6]]:3: error: cannot implicitly convert from `T` to `i32` [ImplicitAsConversionFailure] // CHECK:STDERR: return x; // CHECK:STDERR: ^~~~~~~~~ - // CHECK:STDERR: fail_generic.carbon:[[@LINE+3]]:3: note: type `` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] + // CHECK:STDERR: fail_generic.carbon:[[@LINE+3]]:3: note: type `T` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] // CHECK:STDERR: return x; // CHECK:STDERR: ^~~~~~~~~ return x; diff --git a/toolchain/check/testdata/operators/overloaded/implicit_as.carbon b/toolchain/check/testdata/operators/overloaded/implicit_as.carbon index 947117ab687a..34dd6a813bad 100644 --- a/toolchain/check/testdata/operators/overloaded/implicit_as.carbon +++ b/toolchain/check/testdata/operators/overloaded/implicit_as.carbon @@ -302,11 +302,11 @@ fn Test() { // CHECK:STDOUT: %.loc30_12: = specific_function %Source.ref.loc30, @Source(constants.%X) [template = constants.%.14] // CHECK:STDOUT: %.loc30_18.1: ref %X = temporary_storage // CHECK:STDOUT: %Source.call.loc30: init %X = call %.loc30_12() to %.loc30_18.1 -// CHECK:STDOUT: %.loc30_18.2: ref %X = temporary %.loc30_18.1, %Source.call.loc30 -// CHECK:STDOUT: %.loc30_18.3: %Convert.type.5 = interface_witness_access constants.%.12, element0 [template = constants.%Convert.4] -// CHECK:STDOUT: %.loc30_18.4: = bound_method %.loc30_18.2, %.loc30_18.3 -// CHECK:STDOUT: %.loc30_18.5: %X = bind_value %.loc30_18.2 -// CHECK:STDOUT: %Convert.call.loc30: init i32 = call %.loc30_18.4(%.loc30_18.5) +// CHECK:STDOUT: %.loc30_18.2: %Convert.type.5 = interface_witness_access constants.%.12, element0 [template = constants.%Convert.4] +// CHECK:STDOUT: %.loc30_18.3: = bound_method %Source.call.loc30, %.loc30_18.2 +// CHECK:STDOUT: %.loc30_18.4: ref %X = temporary %.loc30_18.1, %Source.call.loc30 +// CHECK:STDOUT: %.loc30_18.5: %X = bind_value %.loc30_18.4 +// CHECK:STDOUT: %Convert.call.loc30: init i32 = call %.loc30_18.3(%.loc30_18.5) // CHECK:STDOUT: %.loc30_18.6: i32 = value_of_initializer %Convert.call.loc30 // CHECK:STDOUT: %.loc30_18.7: i32 = converted %Source.call.loc30, %.loc30_18.6 // CHECK:STDOUT: %Sink_i32.call: init %empty_tuple.type = call %Sink_i32.ref(%.loc30_18.7) @@ -317,17 +317,16 @@ fn Test() { // CHECK:STDOUT: %.loc31_16.2: type = converted %int.make_type_32, %.loc31_16.1 [template = i32] // CHECK:STDOUT: %.loc31_10: = specific_function %Source.ref.loc31, @Source(i32) [template = constants.%.16] // CHECK:STDOUT: %Source.call.loc31: init i32 = call %.loc31_10() -// CHECK:STDOUT: %.loc31_16.3: ref i32 = temporary_storage -// CHECK:STDOUT: %.loc31_16.4: ref i32 = temporary %.loc31_16.3, %Source.call.loc31 -// CHECK:STDOUT: %.loc31_16.5: %Convert.type.3 = interface_witness_access constants.%.8, element0 [template = constants.%Convert.2] -// CHECK:STDOUT: %.loc31_16.6: = bound_method %.loc31_16.4, %.loc31_16.5 -// CHECK:STDOUT: %.loc31_16.7: ref %X = temporary_storage -// CHECK:STDOUT: %.loc31_16.8: i32 = bind_value %.loc31_16.4 -// CHECK:STDOUT: %Convert.call.loc31: init %X = call %.loc31_16.6(%.loc31_16.8) to %.loc31_16.7 -// CHECK:STDOUT: %.loc31_16.9: init %X = converted %Source.call.loc31, %Convert.call.loc31 -// CHECK:STDOUT: %.loc31_16.10: ref %X = temporary %.loc31_16.7, %.loc31_16.9 -// CHECK:STDOUT: %.loc31_16.11: %X = bind_value %.loc31_16.10 -// CHECK:STDOUT: %Sink_X.call: init %empty_tuple.type = call %Sink_X.ref(%.loc31_16.11) +// CHECK:STDOUT: %.loc31_16.3: %Convert.type.3 = interface_witness_access constants.%.8, element0 [template = constants.%Convert.2] +// CHECK:STDOUT: %.loc31_16.4: = bound_method %Source.call.loc31, %.loc31_16.3 +// CHECK:STDOUT: %.loc31_16.5: ref %X = temporary_storage +// CHECK:STDOUT: %.loc31_16.6: i32 = value_of_initializer %Source.call.loc31 +// CHECK:STDOUT: %.loc31_16.7: i32 = converted %Source.call.loc31, %.loc31_16.6 +// CHECK:STDOUT: %Convert.call.loc31: init %X = call %.loc31_16.4(%.loc31_16.7) to %.loc31_16.5 +// CHECK:STDOUT: %.loc31_16.8: init %X = converted %Source.call.loc31, %Convert.call.loc31 +// CHECK:STDOUT: %.loc31_16.9: ref %X = temporary %.loc31_16.5, %.loc31_16.8 +// CHECK:STDOUT: %.loc31_16.10: %X = bind_value %.loc31_16.9 +// CHECK:STDOUT: %Sink_X.call: init %empty_tuple.type = call %Sink_X.ref(%.loc31_16.10) // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: diff --git a/toolchain/check/testdata/struct/fail_value_as_type.carbon b/toolchain/check/testdata/struct/fail_value_as_type.carbon index 21b1dbd269d8..5083386ec70e 100644 --- a/toolchain/check/testdata/struct/fail_value_as_type.carbon +++ b/toolchain/check/testdata/struct/fail_value_as_type.carbon @@ -39,7 +39,6 @@ var x: {.a = 1}; // CHECK:STDOUT: %.5: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: %.7: %.3 = assoc_entity element0, imports.%import_ref.6 [symbolic] -// CHECK:STDOUT: %struct: %.2 = struct_value (%.1) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -64,9 +63,7 @@ var x: {.a = 1}; // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %.loc17_14: i32 = int_value 1 [template = constants.%.1] // CHECK:STDOUT: %.loc17_15.1: %.2 = struct_literal (%.loc17_14) -// CHECK:STDOUT: %struct: %.2 = struct_value (%.loc17_14) [template = constants.%struct] -// CHECK:STDOUT: %.loc17_15.2: %.2 = converted %.loc17_15.1, %struct [template = constants.%struct] -// CHECK:STDOUT: %.loc17_15.3: type = converted %.loc17_15.1, [template = ] +// CHECK:STDOUT: %.loc17_15.2: type = converted %.loc17_15.1, [template = ] // CHECK:STDOUT: %x.var: ref = var x // CHECK:STDOUT: %x: ref = bind_name x, %x.var // CHECK:STDOUT: } diff --git a/toolchain/check/testdata/struct/import.carbon b/toolchain/check/testdata/struct/import.carbon index e8bad0c0debc..3e1da518c103 100644 --- a/toolchain/check/testdata/struct/import.carbon +++ b/toolchain/check/testdata/struct/import.carbon @@ -592,9 +592,8 @@ var c_bad: C({.a = 3, .b = 4}) = F(); // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.4 [template = constants.%F] -// CHECK:STDOUT: %.loc9_35.1: ref %C.4 = temporary_storage -// CHECK:STDOUT: %F.call: init %C.4 = call %F.ref() to %.loc9_35.1 -// CHECK:STDOUT: %.loc9_35.2: ref %C.4 = temporary %.loc9_35.1, %F.call +// CHECK:STDOUT: %.loc9_35: ref %C.4 = temporary_storage +// CHECK:STDOUT: %F.call: init %C.4 = call %F.ref() to %.loc9_35 // CHECK:STDOUT: %.loc9_37: %C.3 = converted %F.call, [template = ] // CHECK:STDOUT: assign file.%c_bad.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/tuple/fail_type_assign.carbon b/toolchain/check/testdata/tuple/fail_type_assign.carbon index 359f445016df..12a767e75fb3 100644 --- a/toolchain/check/testdata/tuple/fail_type_assign.carbon +++ b/toolchain/check/testdata/tuple/fail_type_assign.carbon @@ -108,8 +108,6 @@ var x: (i32, ) = (i32, ); // CHECK:STDOUT: !entry: // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc17_24.1: %tuple.type.1 = tuple_literal (%int.make_type_32) -// CHECK:STDOUT: %.loc17_19.1: ref type = temporary_storage -// CHECK:STDOUT: %.loc17_19.2: ref type = temporary %.loc17_19.1, %int.make_type_32 // CHECK:STDOUT: %.loc17_24.2: i32 = converted %int.make_type_32, [template = ] // CHECK:STDOUT: assign file.%x.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/tuple/import.carbon b/toolchain/check/testdata/tuple/import.carbon index b37ba60cc0f9..fcf349937f5f 100644 --- a/toolchain/check/testdata/tuple/import.carbon +++ b/toolchain/check/testdata/tuple/import.carbon @@ -633,9 +633,8 @@ var c_bad: C((3, 4)) = F(); // CHECK:STDOUT: fn @__global_init() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%import_ref.4 [template = constants.%F] -// CHECK:STDOUT: %.loc10_25.1: ref %C.4 = temporary_storage -// CHECK:STDOUT: %F.call: init %C.4 = call %F.ref() to %.loc10_25.1 -// CHECK:STDOUT: %.loc10_25.2: ref %C.4 = temporary %.loc10_25.1, %F.call +// CHECK:STDOUT: %.loc10_25: ref %C.4 = temporary_storage +// CHECK:STDOUT: %F.call: init %C.4 = call %F.ref() to %.loc10_25 // CHECK:STDOUT: %.loc10_27: %C.3 = converted %F.call, [template = ] // CHECK:STDOUT: assign file.%c_bad.var, // CHECK:STDOUT: return diff --git a/toolchain/check/testdata/where_expr/constraints.carbon b/toolchain/check/testdata/where_expr/constraints.carbon index aa311a278458..ce18b6548a0b 100644 --- a/toolchain/check/testdata/where_expr/constraints.carbon +++ b/toolchain/check/testdata/where_expr/constraints.carbon @@ -363,7 +363,6 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.6: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.5 [template] // CHECK:STDOUT: %.8: %.4 = assoc_entity element0, imports.%import_ref.6 [symbolic] -// CHECK:STDOUT: %struct: %.3 = struct_value () [template] // CHECK:STDOUT: %N.type.2: type = facet_type <@N where TODO> [template] // CHECK:STDOUT: %T: %N.type.2 = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %T.patt: %N.type.2 = symbolic_binding_pattern T, 0 [symbolic] @@ -402,9 +401,7 @@ let B: type where .Self impls A = D; // CHECK:STDOUT: %.Self.ref: %N.type.1 = name_ref .Self, %.Self [symbolic = constants.%.Self] // CHECK:STDOUT: %P.ref: %.1 = name_ref P, @N.%.loc5 [template = constants.%.2] // CHECK:STDOUT: %.loc15_28.1: %.3 = struct_literal () -// CHECK:STDOUT: %struct: %.3 = struct_value () [template = constants.%struct] -// CHECK:STDOUT: %.loc15_28.2: %.3 = converted %.loc15_28.1, %struct [template = constants.%struct] -// CHECK:STDOUT: %.loc15_28.3: %.1 = converted %.loc15_28.1, [template = ] +// CHECK:STDOUT: %.loc15_28.2: %.1 = converted %.loc15_28.1, [template = ] // CHECK:STDOUT: %.loc15_16: type = where_expr %.Self [template = constants.%N.type.2] { // CHECK:STDOUT: requirement_rewrite %P.ref, // CHECK:STDOUT: } diff --git a/toolchain/lower/testdata/builtins/overloaded_operator.carbon b/toolchain/lower/testdata/builtins/overloaded_operator.carbon index 3b9064f1ea49..effca71ed97a 100644 --- a/toolchain/lower/testdata/builtins/overloaded_operator.carbon +++ b/toolchain/lower/testdata/builtins/overloaded_operator.carbon @@ -24,10 +24,7 @@ fn AddThreeIntegers(a: i32, b: i32, c: i32) -> i32 { // CHECK:STDOUT: define i32 @_CAddThreeIntegers.Main(i32 %a, i32 %b, i32 %c) !dbg !4 { // CHECK:STDOUT: entry: // CHECK:STDOUT: %int.sadd.loc18_12 = add i32 %a, %b, !dbg !7 -// CHECK:STDOUT: %.loc18_12.3.temp = alloca i32, align 4, !dbg !7 -// CHECK:STDOUT: store i32 %int.sadd.loc18_12, ptr %.loc18_12.3.temp, align 4, !dbg !7 -// CHECK:STDOUT: %.loc18_12.5 = load i32, ptr %.loc18_12.3.temp, align 4, !dbg !7 -// CHECK:STDOUT: %int.sadd.loc18_16 = add i32 %.loc18_12.5, %c, !dbg !7 +// CHECK:STDOUT: %int.sadd.loc18_16 = add i32 %int.sadd.loc18_12, %c, !dbg !7 // CHECK:STDOUT: ret i32 %int.sadd.loc18_16, !dbg !8 // CHECK:STDOUT: } // CHECK:STDOUT: