From 81ed4d829d62a018aa66812a98ed0baa07e60aef Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Thu, 2 Apr 2026 16:39:25 -0700 Subject: [PATCH] Perform CppThunkRef conversion as part of category conversion. (#7020) Instead of recursing back into Convert, make CppThunkRef conversion just add an extra step to category conversion, performing a copy conversion followed by an ephemeral reference binding conversion. --- toolchain/check/convert.cpp | 36 +++++++++---------- .../interop/cpp/class/constructor.carbon | 2 +- .../function/arithmetic_types_bridged.carbon | 32 ++++++++--------- .../interop/cpp/function/full_semir.carbon | 2 +- .../interop/cpp/function/inline.carbon | 4 +-- .../interop/cpp/function/overloads.carbon | 16 ++++----- .../lower/testdata/interop/cpp/nullptr.carbon | 2 +- 7 files changed, 46 insertions(+), 48 deletions(-) diff --git a/toolchain/check/convert.cpp b/toolchain/check/convert.cpp index 26affe566eed..489f2eec7e62 100644 --- a/toolchain/check/convert.cpp +++ b/toolchain/check/convert.cpp @@ -1558,9 +1558,10 @@ static auto PerformCopy(Context& context, SemIR::InstId expr_id, return copy_id; } -// Convert a value expression so that it can be used to initialize a C++ thunk -// parameter. -static auto ConvertValueForCppThunkRef(Context& context, SemIR::InstId expr_id) +// Tries to form a `ValueAsRef` conversion that extracts the pointer value from +// a value expression with a pointer value representation. Returns the converted +// expression, or None if the conversion was not applicable. +static auto TryMakeValueAsRef(Context& context, SemIR::InstId expr_id) -> SemIR::InstId { auto expr = context.insts().Get(expr_id); @@ -1573,15 +1574,7 @@ static auto ConvertValueForCppThunkRef(Context& context, SemIR::InstId expr_id) {.type_id = expr.type_id(), .value_id = expr_id}); } - // Otherwise, we need a temporary to pass as the thunk argument. Create a copy - // and initialize a temporary from it. - auto temporary_id = AddInst( - context, SemIR::LocId(expr_id), {.type_id = expr.type_id()}); - expr_id = Initialize(context, SemIR::LocId(expr_id), temporary_id, expr_id); - return AddInstWithCleanup(context, SemIR::LocId(expr_id), - {.type_id = expr.type_id(), - .storage_id = temporary_id, - .init_id = expr_id}); + return SemIR::InstId::None; } // Returns the Core interface name to use for a given kind of conversion. @@ -1808,8 +1801,19 @@ auto CategoryConverter::DoStep(const SemIR::InstId expr_id, return Done{SemIR::ErrorInst::InstId}; } + // When initializing a C++ thunk parameter, try to pass a value "by + // reference". + if (target_.kind == ConversionTarget::CppThunkRef) { + if (auto result_id = TryMakeValueAsRef(context_, expr_id); + result_id.has_value()) { + return Done{result_id}; + } + // Otherwise, fall through to make a copy. + } + // When initializing from a value, perform a copy. - if (target_.is_initializer()) { + if (target_.is_initializer() || + target_.kind == ConversionTarget::CppThunkRef) { auto copy_id = PerformCopy(context_, expr_id, target_); if (copy_id == SemIR::ErrorInst::InstId) { return Done{SemIR::ErrorInst::InstId}; @@ -1818,12 +1822,6 @@ auto CategoryConverter::DoStep(const SemIR::InstId expr_id, .category = SemIR::GetExprCategory(sem_ir_, copy_id)}; } - // When initializing a C++ thunk parameter, form a reference, creating a - // temporary if needed. - if (target_.kind == ConversionTarget::CppThunkRef) { - return Done{ConvertValueForCppThunkRef(context_, expr_id)}; - } - return Done{expr_id}; } } diff --git a/toolchain/check/testdata/interop/cpp/class/constructor.carbon b/toolchain/check/testdata/interop/cpp/class/constructor.carbon index dcade5a0a3e2..a5965c2ad217 100644 --- a/toolchain/check/testdata/interop/cpp/class/constructor.carbon +++ b/toolchain/check/testdata/interop/cpp/class/constructor.carbon @@ -871,10 +871,10 @@ fn F() { // CHECK:STDOUT: %C.ref.loc9_31: %C.C.cpp_overload_set.type = name_ref C, imports.%C.C.cpp_overload_set.value [concrete = constants.%C.C.cpp_overload_set.value] // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true] // CHECK:STDOUT: %.loc9_3: ref %C = splice_block %c2.var {} -// CHECK:STDOUT: %.loc9_34.1: ref bool = temporary_storage // CHECK:STDOUT: %impl.elem0.loc9: %.86d = impl_witness_access constants.%Copy.impl_witness.348, element0 [concrete = constants.%bool.as.Copy.impl.Op] // CHECK:STDOUT: %bound_method.loc9: = bound_method %true, %impl.elem0.loc9 [concrete = constants.%bool.as.Copy.impl.Op.bound] // CHECK:STDOUT: %bool.as.Copy.impl.Op.call: init bool = call %bound_method.loc9(%true) [concrete = constants.%true] +// CHECK:STDOUT: %.loc9_34.1: ref bool = temporary_storage // CHECK:STDOUT: %.loc9_34.2: ref bool = temporary %.loc9_34.1, %bool.as.Copy.impl.Op.call [concrete = constants.%.e3b] // CHECK:STDOUT: %addr.loc9_38.1: %ptr.bb2 = addr_of %.loc9_34.2 [concrete = constants.%addr] // CHECK:STDOUT: %addr.loc9_38.2: %ptr.d9e = addr_of %.loc9_3 diff --git a/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon b/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon index f379435473a4..d58c37443471 100644 --- a/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon +++ b/toolchain/check/testdata/interop/cpp/function/arithmetic_types_bridged.carbon @@ -597,10 +597,10 @@ fn F() { // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %foo.ref: %foo.cpp_overload_set.type = name_ref foo, imports.%foo.cpp_overload_set.value [concrete = constants.%foo.cpp_overload_set.value] // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true] -// CHECK:STDOUT: %.loc8_11.1: ref bool = temporary_storage // CHECK:STDOUT: %impl.elem0: %.86d = impl_witness_access constants.%Copy.impl_witness.348, element0 [concrete = constants.%bool.as.Copy.impl.Op] // CHECK:STDOUT: %bound_method: = bound_method %true, %impl.elem0 [concrete = constants.%bool.as.Copy.impl.Op.bound] // CHECK:STDOUT: %bool.as.Copy.impl.Op.call: init bool = call %bound_method(%true) [concrete = constants.%true] +// CHECK:STDOUT: %.loc8_11.1: ref bool = temporary_storage // CHECK:STDOUT: %.loc8_11.2: ref bool = temporary %.loc8_11.1, %bool.as.Copy.impl.Op.call [concrete = constants.%.e3b] // CHECK:STDOUT: %addr: %ptr.bb2 = addr_of %.loc8_11.2 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -651,10 +651,10 @@ fn F() { // CHECK:STDOUT: %Cpp.ref: = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp] // CHECK:STDOUT: %foo.ref: %foo.cpp_overload_set.type = name_ref foo, imports.%foo.cpp_overload_set.value [concrete = constants.%foo.cpp_overload_set.value] // CHECK:STDOUT: %false: bool = bool_literal false [concrete = constants.%false] -// CHECK:STDOUT: %.loc8_11.1: ref bool = temporary_storage // CHECK:STDOUT: %impl.elem0: %.86d = impl_witness_access constants.%Copy.impl_witness.348, element0 [concrete = constants.%bool.as.Copy.impl.Op] // CHECK:STDOUT: %bound_method: = bound_method %false, %impl.elem0 [concrete = constants.%bool.as.Copy.impl.Op.bound] // CHECK:STDOUT: %bool.as.Copy.impl.Op.call: init bool = call %bound_method(%false) [concrete = constants.%false] +// CHECK:STDOUT: %.loc8_11.1: ref bool = temporary_storage // CHECK:STDOUT: %.loc8_11.2: ref bool = temporary %.loc8_11.1, %bool.as.Copy.impl.Op.call [concrete = constants.%.48c] // CHECK:STDOUT: %addr: %ptr.bb2 = addr_of %.loc8_11.2 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -756,12 +756,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i8 = call %bound_method.loc8_11.3(%.loc8_11.2) [concrete = constants.%int_-1.416] // CHECK:STDOUT: %.loc8_11.3: %i8 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_-1.416] // CHECK:STDOUT: %.loc8_11.4: %i8 = converted %Core.IntLiteral.as.Negate.impl.Op.call, %.loc8_11.3 [concrete = constants.%int_-1.416] -// CHECK:STDOUT: %.loc8_11.5: ref %i8 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_11.2: %.bf0 = impl_witness_access constants.%Copy.impl_witness.75f, element0 [concrete = constants.%Int.as.Copy.impl.Op.817] // CHECK:STDOUT: %bound_method.loc8_11.4: = bound_method %.loc8_11.4, %impl.elem0.loc8_11.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_11.2: = specific_function %impl.elem0.loc8_11.2, @Int.as.Copy.impl.Op(constants.%int_8) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_11.5: = bound_method %.loc8_11.4, %specific_fn.loc8_11.2 [concrete = constants.%bound_method.81a] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i8 = call %bound_method.loc8_11.5(%.loc8_11.4) [concrete = constants.%int_-1.416] +// CHECK:STDOUT: %.loc8_11.5: ref %i8 = temporary_storage // CHECK:STDOUT: %.loc8_11.6: ref %i8 = temporary %.loc8_11.5, %Int.as.Copy.impl.Op.call [concrete = constants.%.702] // CHECK:STDOUT: %addr: %ptr.5c1 = addr_of %.loc8_11.6 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -852,12 +852,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %u8 = call %bound_method.loc8_11.2(%int_1) [concrete = constants.%int_1.e80] // CHECK:STDOUT: %.loc8_11.1: %u8 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.e80] // CHECK:STDOUT: %.loc8_11.2: %u8 = converted %int_1, %.loc8_11.1 [concrete = constants.%int_1.e80] -// CHECK:STDOUT: %.loc8_11.3: ref %u8 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_11.2: %.9da = impl_witness_access constants.%Copy.impl_witness.c60, element0 [concrete = constants.%UInt.as.Copy.impl.Op.ccb] // CHECK:STDOUT: %bound_method.loc8_11.3: = bound_method %.loc8_11.2, %impl.elem0.loc8_11.2 [concrete = constants.%UInt.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_11.2: = specific_function %impl.elem0.loc8_11.2, @UInt.as.Copy.impl.Op(constants.%int_8) [concrete = constants.%UInt.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_11.4: = bound_method %.loc8_11.2, %specific_fn.loc8_11.2 [concrete = constants.%bound_method.98f] // CHECK:STDOUT: %UInt.as.Copy.impl.Op.call: init %u8 = call %bound_method.loc8_11.4(%.loc8_11.2) [concrete = constants.%int_1.e80] +// CHECK:STDOUT: %.loc8_11.3: ref %u8 = temporary_storage // CHECK:STDOUT: %.loc8_11.4: ref %u8 = temporary %.loc8_11.3, %UInt.as.Copy.impl.Op.call [concrete = constants.%.84f] // CHECK:STDOUT: %addr: %ptr.3e8 = addr_of %.loc8_11.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -936,10 +936,10 @@ fn F() { // CHECK:STDOUT: %Core.CharLiteral.as.ImplicitAs.impl.Convert.call: init %char = call %bound_method.loc8_11.1(%.loc8_11.1) [concrete = constants.%int_88] // CHECK:STDOUT: %.loc8_11.2: %char = value_of_initializer %Core.CharLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_88] // CHECK:STDOUT: %.loc8_11.3: %char = converted %.loc8_11.1, %.loc8_11.2 [concrete = constants.%int_88] -// CHECK:STDOUT: %.loc8_11.4: ref %char = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_11.2: %.bf3 = impl_witness_access constants.%Copy.impl_witness.bd9, element0 [concrete = constants.%char.as.Copy.impl.Op] // CHECK:STDOUT: %bound_method.loc8_11.2: = bound_method %.loc8_11.3, %impl.elem0.loc8_11.2 [concrete = constants.%char.as.Copy.impl.Op.bound] // CHECK:STDOUT: %char.as.Copy.impl.Op.call: init %char = call %bound_method.loc8_11.2(%.loc8_11.3) [concrete = constants.%int_88] +// CHECK:STDOUT: %.loc8_11.4: ref %char = temporary_storage // CHECK:STDOUT: %.loc8_11.5: ref %char = temporary %.loc8_11.4, %char.as.Copy.impl.Op.call [concrete = constants.%.3df] // CHECK:STDOUT: %addr: %ptr.fb0 = addr_of %.loc8_11.5 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1161,12 +1161,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_13.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc8_13.3: = bound_method %.loc8_13.2, %impl.elem0.loc8_13.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_13.2: = specific_function %impl.elem0.loc8_13.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_13.4: = bound_method %.loc8_13.2, %specific_fn.loc8_13.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc8_13.4(%.loc8_13.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc8_13.4: ref %i16 = temporary %.loc8_13.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.dde] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc8_13.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1257,12 +1257,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i16 = call %bound_method.loc8_11.2(%int_32767) [concrete = constants.%int_32767.faa] // CHECK:STDOUT: %.loc8_11.1: %i16 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_32767.faa] // CHECK:STDOUT: %.loc8_11.2: %i16 = converted %int_32767, %.loc8_11.1 [concrete = constants.%int_32767.faa] -// CHECK:STDOUT: %.loc8_11.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_11.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc8_11.3: = bound_method %.loc8_11.2, %impl.elem0.loc8_11.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_11.2: = specific_function %impl.elem0.loc8_11.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_11.4: = bound_method %.loc8_11.2, %specific_fn.loc8_11.2 [concrete = constants.%bound_method.964] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc8_11.4(%.loc8_11.2) [concrete = constants.%int_32767.faa] +// CHECK:STDOUT: %.loc8_11.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc8_11.4: ref %i16 = temporary %.loc8_11.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.436] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc8_11.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1370,12 +1370,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i16 = call %bound_method.loc8_11.3(%.loc8_11.2) [concrete = constants.%int_-32768.7e5] // CHECK:STDOUT: %.loc8_11.3: %i16 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_-32768.7e5] // CHECK:STDOUT: %.loc8_11.4: %i16 = converted %Core.IntLiteral.as.Negate.impl.Op.call, %.loc8_11.3 [concrete = constants.%int_-32768.7e5] -// CHECK:STDOUT: %.loc8_11.5: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_11.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc8_11.4: = bound_method %.loc8_11.4, %impl.elem0.loc8_11.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_11.2: = specific_function %impl.elem0.loc8_11.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_11.5: = bound_method %.loc8_11.4, %specific_fn.loc8_11.2 [concrete = constants.%bound_method.971] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc8_11.5(%.loc8_11.4) [concrete = constants.%int_-32768.7e5] +// CHECK:STDOUT: %.loc8_11.5: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc8_11.6: ref %i16 = temporary %.loc8_11.5, %Int.as.Copy.impl.Op.call [concrete = constants.%.81f] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc8_11.6 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1467,12 +1467,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_13.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc8_13.3: = bound_method %.loc8_13.2, %impl.elem0.loc8_13.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_13.2: = specific_function %impl.elem0.loc8_13.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_13.4: = bound_method %.loc8_13.2, %specific_fn.loc8_13.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc8_13.4(%.loc8_13.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc8_13.4: ref %i16 = temporary %.loc8_13.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.dde] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc8_13.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1564,12 +1564,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_13.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc8_13.3: = bound_method %.loc8_13.2, %impl.elem0.loc8_13.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_13.2: = specific_function %impl.elem0.loc8_13.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_13.4: = bound_method %.loc8_13.2, %specific_fn.loc8_13.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc8_13.4(%.loc8_13.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc8_13.4: ref %i16 = temporary %.loc8_13.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.dde] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc8_13.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1661,12 +1661,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_13.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc8_13.3: = bound_method %.loc8_13.2, %impl.elem0.loc8_13.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_13.2: = specific_function %impl.elem0.loc8_13.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_13.4: = bound_method %.loc8_13.2, %specific_fn.loc8_13.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc8_13.4(%.loc8_13.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc8_13.4: ref %i16 = temporary %.loc8_13.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.dde] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc8_13.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1758,12 +1758,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_13.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc8_13.3: = bound_method %.loc8_13.2, %impl.elem0.loc8_13.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_13.2: = specific_function %impl.elem0.loc8_13.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_13.4: = bound_method %.loc8_13.2, %specific_fn.loc8_13.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc8_13.4(%.loc8_13.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc8_13.4: ref %i16 = temporary %.loc8_13.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.dde] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc8_13.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1854,12 +1854,12 @@ fn F() { // CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call: init %f16.a6a = call %bound_method.loc8_15.2(%float) [concrete = constants.%float.032] // CHECK:STDOUT: %.loc8_15.1: %f16.a6a = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call [concrete = constants.%float.032] // CHECK:STDOUT: %.loc8_15.2: %f16.a6a = converted %float, %.loc8_15.1 [concrete = constants.%float.032] -// CHECK:STDOUT: %.loc8_15.3: ref %f16.a6a = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_15.2: %.8eb = impl_witness_access constants.%Copy.impl_witness.9fb, element0 [concrete = constants.%Float.as.Copy.impl.Op.d96] // CHECK:STDOUT: %bound_method.loc8_15.3: = bound_method %.loc8_15.2, %impl.elem0.loc8_15.2 [concrete = constants.%Float.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_15.2: = specific_function %impl.elem0.loc8_15.2, @Float.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Float.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_15.4: = bound_method %.loc8_15.2, %specific_fn.loc8_15.2 [concrete = constants.%bound_method.670] // CHECK:STDOUT: %Float.as.Copy.impl.Op.call: init %f16.a6a = call %bound_method.loc8_15.4(%.loc8_15.2) [concrete = constants.%float.032] +// CHECK:STDOUT: %.loc8_15.3: ref %f16.a6a = temporary_storage // CHECK:STDOUT: %.loc8_15.4: ref %f16.a6a = temporary %.loc8_15.3, %Float.as.Copy.impl.Op.call [concrete = constants.%.9d1] // CHECK:STDOUT: %addr: %ptr.823 = addr_of %.loc8_15.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1950,12 +1950,12 @@ fn F() { // CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call: init %f32.97e = call %bound_method.loc8_15.2(%float) [concrete = constants.%float.4cb] // CHECK:STDOUT: %.loc8_15.1: %f32.97e = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call [concrete = constants.%float.4cb] // CHECK:STDOUT: %.loc8_15.2: %f32.97e = converted %float, %.loc8_15.1 [concrete = constants.%float.4cb] -// CHECK:STDOUT: %.loc8_15.3: ref %f32.97e = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_15.2: %.509 = impl_witness_access constants.%Copy.impl_witness.f95, element0 [concrete = constants.%Float.as.Copy.impl.Op.27a] // CHECK:STDOUT: %bound_method.loc8_15.3: = bound_method %.loc8_15.2, %impl.elem0.loc8_15.2 [concrete = constants.%Float.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_15.2: = specific_function %impl.elem0.loc8_15.2, @Float.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Float.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_15.4: = bound_method %.loc8_15.2, %specific_fn.loc8_15.2 [concrete = constants.%bound_method.d87] // CHECK:STDOUT: %Float.as.Copy.impl.Op.call: init %f32.97e = call %bound_method.loc8_15.4(%.loc8_15.2) [concrete = constants.%float.4cb] +// CHECK:STDOUT: %.loc8_15.3: ref %f32.97e = temporary_storage // CHECK:STDOUT: %.loc8_15.4: ref %f32.97e = temporary %.loc8_15.3, %Float.as.Copy.impl.Op.call [concrete = constants.%.404] // CHECK:STDOUT: %addr: %ptr.0bc = addr_of %.loc8_15.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -2046,12 +2046,12 @@ fn F() { // CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call: init %f64.d77 = call %bound_method.loc8_15.2(%float) [concrete = constants.%float.0fc] // CHECK:STDOUT: %.loc8_15.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call [concrete = constants.%float.0fc] // CHECK:STDOUT: %.loc8_15.2: %f64.d77 = converted %float, %.loc8_15.1 [concrete = constants.%float.0fc] -// CHECK:STDOUT: %.loc8_15.3: ref %f64.d77 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_15.2: %.59b = impl_witness_access constants.%Copy.impl_witness.1e3, element0 [concrete = constants.%Float.as.Copy.impl.Op.f05] // CHECK:STDOUT: %bound_method.loc8_15.3: = bound_method %.loc8_15.2, %impl.elem0.loc8_15.2 [concrete = constants.%Float.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_15.2: = specific_function %impl.elem0.loc8_15.2, @Float.as.Copy.impl.Op(constants.%int_64) [concrete = constants.%Float.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_15.4: = bound_method %.loc8_15.2, %specific_fn.loc8_15.2 [concrete = constants.%bound_method.36b] // CHECK:STDOUT: %Float.as.Copy.impl.Op.call: init %f64.d77 = call %bound_method.loc8_15.4(%.loc8_15.2) [concrete = constants.%float.0fc] +// CHECK:STDOUT: %.loc8_15.3: ref %f64.d77 = temporary_storage // CHECK:STDOUT: %.loc8_15.4: ref %f64.d77 = temporary %.loc8_15.3, %Float.as.Copy.impl.Op.call [concrete = constants.%.39a] // CHECK:STDOUT: %addr: %ptr.bcc = addr_of %.loc8_15.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -2142,12 +2142,12 @@ fn F() { // CHECK:STDOUT: %Core.FloatLiteral.as.As.impl.Convert.call: init %f128.b8c = call %bound_method.loc8_15.2(%float) [concrete = constants.%float.709] // CHECK:STDOUT: %.loc8_15.1: %f128.b8c = value_of_initializer %Core.FloatLiteral.as.As.impl.Convert.call [concrete = constants.%float.709] // CHECK:STDOUT: %.loc8_15.2: %f128.b8c = converted %float, %.loc8_15.1 [concrete = constants.%float.709] -// CHECK:STDOUT: %.loc8_15.3: ref %f128.b8c = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_15.2: %.c96 = impl_witness_access constants.%Copy.impl_witness.775, element0 [concrete = constants.%Float.as.Copy.impl.Op.021] // CHECK:STDOUT: %bound_method.loc8_15.3: = bound_method %.loc8_15.2, %impl.elem0.loc8_15.2 [concrete = constants.%Float.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_15.2: = specific_function %impl.elem0.loc8_15.2, @Float.as.Copy.impl.Op(constants.%int_128) [concrete = constants.%Float.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_15.4: = bound_method %.loc8_15.2, %specific_fn.loc8_15.2 [concrete = constants.%bound_method.6ed] // CHECK:STDOUT: %Float.as.Copy.impl.Op.call: init %f128.b8c = call %bound_method.loc8_15.4(%.loc8_15.2) [concrete = constants.%float.709] +// CHECK:STDOUT: %.loc8_15.3: ref %f128.b8c = temporary_storage // CHECK:STDOUT: %.loc8_15.4: ref %f128.b8c = temporary %.loc8_15.3, %Float.as.Copy.impl.Op.call [concrete = constants.%.1c5] // CHECK:STDOUT: %addr: %ptr.402 = addr_of %.loc8_15.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) diff --git a/toolchain/check/testdata/interop/cpp/function/full_semir.carbon b/toolchain/check/testdata/interop/cpp/function/full_semir.carbon index 54eab6c9935e..8249b21ada02 100644 --- a/toolchain/check/testdata/interop/cpp/function/full_semir.carbon +++ b/toolchain/check/testdata/interop/cpp/function/full_semir.carbon @@ -182,12 +182,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc7_13.2(%int_1) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc7_13.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc7_13.2: %i16 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc7_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc7_13.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc7_13.3: = bound_method %.loc7_13.2, %impl.elem0.loc7_13.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc7_13.2: = specific_function %impl.elem0.loc7_13.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc7_13.4: = bound_method %.loc7_13.2, %specific_fn.loc7_13.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc7_13.4(%.loc7_13.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc7_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc7_13.4: ref %i16 = temporary %.loc7_13.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.dde] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc7_13.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) diff --git a/toolchain/check/testdata/interop/cpp/function/inline.carbon b/toolchain/check/testdata/interop/cpp/function/inline.carbon index d0275243b2aa..8d199d312b6b 100644 --- a/toolchain/check/testdata/interop/cpp/function/inline.carbon +++ b/toolchain/check/testdata/interop/cpp/function/inline.carbon @@ -288,12 +288,12 @@ fn MyF() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14: init %i16 = call %bound_method.loc14_39.2(%int_1.loc14) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc14_39.1: %i16 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14 [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc14_39.2: %i16 = converted %int_1.loc14, %.loc14_39.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc14_39.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc14_39.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc14_39.3: = bound_method %.loc14_39.2, %impl.elem0.loc14_39.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc14_39.2: = specific_function %impl.elem0.loc14_39.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc14_39.4: = bound_method %.loc14_39.2, %specific_fn.loc14_39.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc14: init %i16 = call %bound_method.loc14_39.4(%.loc14_39.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc14_39.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc14_39.4: ref %i16 = temporary %.loc14_39.3, %Int.as.Copy.impl.Op.call.loc14 [concrete = constants.%.dde] // CHECK:STDOUT: %addr.loc14: %ptr.251 = addr_of %.loc14_39.4 [concrete = constants.%addr] // CHECK:STDOUT: %ThunkOnArg__carbon_thunk.call: init %i32 = call imports.%ThunkOnArg__carbon_thunk.decl(%addr.loc14) @@ -335,12 +335,12 @@ fn MyF() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16: init %i16 = call %bound_method.loc16_40.2(%int_1.loc16) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc16_40.1: %i16 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16 [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc16_40.2: %i16 = converted %int_1.loc16, %.loc16_40.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc16_40.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc16_40.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc16_40.3: = bound_method %.loc16_40.2, %impl.elem0.loc16_40.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc16_40.2: = specific_function %impl.elem0.loc16_40.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc16_40.4: = bound_method %.loc16_40.2, %specific_fn.loc16_40.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc16: init %i16 = call %bound_method.loc16_40.4(%.loc16_40.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc16_40.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc16_40.4: ref %i16 = temporary %.loc16_40.3, %Int.as.Copy.impl.Op.call.loc16 [concrete = constants.%.dde] // CHECK:STDOUT: %addr.loc16_41.1: %ptr.251 = addr_of %.loc16_40.4 [concrete = constants.%addr] // CHECK:STDOUT: %.loc16_41.1: ref %i16 = temporary_storage diff --git a/toolchain/check/testdata/interop/cpp/function/overloads.carbon b/toolchain/check/testdata/interop/cpp/function/overloads.carbon index d750faa0c622..65ad992c35d8 100644 --- a/toolchain/check/testdata/interop/cpp/function/overloads.carbon +++ b/toolchain/check/testdata/interop/cpp/function/overloads.carbon @@ -907,12 +907,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i16 = call %bound_method.loc7_13.2(%int_1) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc7_13.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc7_13.2: %i16 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc7_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc7_13.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc7_13.3: = bound_method %.loc7_13.2, %impl.elem0.loc7_13.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc7_13.2: = specific_function %impl.elem0.loc7_13.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc7_13.4: = bound_method %.loc7_13.2, %specific_fn.loc7_13.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc7_13.4(%.loc7_13.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc7_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc7_13.4: ref %i16 = temporary %.loc7_13.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.dde] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc7_13.4 [concrete = constants.%addr] // CHECK:STDOUT: %bar__carbon_thunk.call: init %empty_tuple.type = call imports.%bar__carbon_thunk.decl(%addr) @@ -1184,12 +1184,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call.loc8: init %i16 = call %bound_method.loc8_13.2(%int_1.loc8) [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call.loc8 [concrete = constants.%int_1.f90] // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1.loc8, %.loc8_13.1 [concrete = constants.%int_1.f90] -// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc8_13.2: %.eb3 = impl_witness_access constants.%Copy.impl_witness.e99, element0 [concrete = constants.%Int.as.Copy.impl.Op.0da] // CHECK:STDOUT: %bound_method.loc8_13.3: = bound_method %.loc8_13.2, %impl.elem0.loc8_13.2 [concrete = constants.%Int.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc8_13.2: = specific_function %impl.elem0.loc8_13.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc8_13.4: = bound_method %.loc8_13.2, %specific_fn.loc8_13.2 [concrete = constants.%bound_method.a48] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i16 = call %bound_method.loc8_13.4(%.loc8_13.2) [concrete = constants.%int_1.f90] +// CHECK:STDOUT: %.loc8_13.3: ref %i16 = temporary_storage // CHECK:STDOUT: %.loc8_13.4: ref %i16 = temporary %.loc8_13.3, %Int.as.Copy.impl.Op.call [concrete = constants.%.dde] // CHECK:STDOUT: %addr: %ptr.251 = addr_of %.loc8_13.4 [concrete = constants.%addr] // CHECK:STDOUT: %foo__carbon_thunk.call: init %empty_tuple.type = call imports.%foo__carbon_thunk.decl(%addr) @@ -1660,12 +1660,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc22: init %i128 = call %bound_method.loc22_32.2(%int_9223372036854775808) [concrete = constants.%int_9223372036854775808.f14] // CHECK:STDOUT: %.loc22_32.1: %i128 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc22 [concrete = constants.%int_9223372036854775808.f14] // CHECK:STDOUT: %.loc22_32.2: %i128 = converted %int_9223372036854775808, %.loc22_32.1 [concrete = constants.%int_9223372036854775808.f14] -// CHECK:STDOUT: %.loc22_32.3: ref %i128 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc22_32.2: %.0e6 = impl_witness_access constants.%Copy.impl_witness.a35, element0 [concrete = constants.%Int.as.Copy.impl.Op.bc1] // CHECK:STDOUT: %bound_method.loc22_32.3: = bound_method %.loc22_32.2, %impl.elem0.loc22_32.2 [concrete = constants.%Int.as.Copy.impl.Op.bound.def] // CHECK:STDOUT: %specific_fn.loc22_32.2: = specific_function %impl.elem0.loc22_32.2, @Int.as.Copy.impl.Op(constants.%int_128) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc22_32.4: = bound_method %.loc22_32.2, %specific_fn.loc22_32.2 [concrete = constants.%bound_method.b4e] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc22: init %i128 = call %bound_method.loc22_32.4(%.loc22_32.2) [concrete = constants.%int_9223372036854775808.f14] +// CHECK:STDOUT: %.loc22_32.3: ref %i128 = temporary_storage // CHECK:STDOUT: %.loc22_32.4: ref %i128 = temporary %.loc22_32.3, %Int.as.Copy.impl.Op.call.loc22 [concrete = constants.%.5bc] // CHECK:STDOUT: %addr.loc22_51.1: %ptr.974 = addr_of %.loc22_32.4 [concrete = constants.%addr.e72] // CHECK:STDOUT: %.loc22_51.1: ref %i128 = temporary_storage @@ -1689,12 +1689,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc25: init %i128 = call %bound_method.loc25_32.2(%int_18446744073709551615) [concrete = constants.%int_18446744073709551615.f56] // CHECK:STDOUT: %.loc25_32.1: %i128 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc25 [concrete = constants.%int_18446744073709551615.f56] // CHECK:STDOUT: %.loc25_32.2: %i128 = converted %int_18446744073709551615, %.loc25_32.1 [concrete = constants.%int_18446744073709551615.f56] -// CHECK:STDOUT: %.loc25_32.3: ref %i128 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc25_32.2: %.0e6 = impl_witness_access constants.%Copy.impl_witness.a35, element0 [concrete = constants.%Int.as.Copy.impl.Op.bc1] // CHECK:STDOUT: %bound_method.loc25_32.3: = bound_method %.loc25_32.2, %impl.elem0.loc25_32.2 [concrete = constants.%Int.as.Copy.impl.Op.bound.cf0] // CHECK:STDOUT: %specific_fn.loc25_32.2: = specific_function %impl.elem0.loc25_32.2, @Int.as.Copy.impl.Op(constants.%int_128) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc25_32.4: = bound_method %.loc25_32.2, %specific_fn.loc25_32.2 [concrete = constants.%bound_method.2cb] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc25: init %i128 = call %bound_method.loc25_32.4(%.loc25_32.2) [concrete = constants.%int_18446744073709551615.f56] +// CHECK:STDOUT: %.loc25_32.3: ref %i128 = temporary_storage // CHECK:STDOUT: %.loc25_32.4: ref %i128 = temporary %.loc25_32.3, %Int.as.Copy.impl.Op.call.loc25 [concrete = constants.%.2ee] // CHECK:STDOUT: %addr.loc25_52.1: %ptr.974 = addr_of %.loc25_32.4 [concrete = constants.%addr.9bf] // CHECK:STDOUT: %.loc25_52.1: ref %i128 = temporary_storage @@ -1718,12 +1718,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc28: init %i128 = call %bound_method.loc28_32.2(%int_18446744073709551616) [concrete = constants.%int_18446744073709551616.92b] // CHECK:STDOUT: %.loc28_32.1: %i128 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc28 [concrete = constants.%int_18446744073709551616.92b] // CHECK:STDOUT: %.loc28_32.2: %i128 = converted %int_18446744073709551616, %.loc28_32.1 [concrete = constants.%int_18446744073709551616.92b] -// CHECK:STDOUT: %.loc28_32.3: ref %i128 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc28_32.2: %.0e6 = impl_witness_access constants.%Copy.impl_witness.a35, element0 [concrete = constants.%Int.as.Copy.impl.Op.bc1] // CHECK:STDOUT: %bound_method.loc28_32.3: = bound_method %.loc28_32.2, %impl.elem0.loc28_32.2 [concrete = constants.%Int.as.Copy.impl.Op.bound.bcd] // CHECK:STDOUT: %specific_fn.loc28_32.2: = specific_function %impl.elem0.loc28_32.2, @Int.as.Copy.impl.Op(constants.%int_128) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc28_32.4: = bound_method %.loc28_32.2, %specific_fn.loc28_32.2 [concrete = constants.%bound_method.6a9] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc28: init %i128 = call %bound_method.loc28_32.4(%.loc28_32.2) [concrete = constants.%int_18446744073709551616.92b] +// CHECK:STDOUT: %.loc28_32.3: ref %i128 = temporary_storage // CHECK:STDOUT: %.loc28_32.4: ref %i128 = temporary %.loc28_32.3, %Int.as.Copy.impl.Op.call.loc28 [concrete = constants.%.4db] // CHECK:STDOUT: %addr.loc28_52.1: %ptr.974 = addr_of %.loc28_32.4 [concrete = constants.%addr.84d] // CHECK:STDOUT: %.loc28_52.1: ref %i128 = temporary_storage @@ -1747,12 +1747,12 @@ fn F() { // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc31: init %i128 = call %bound_method.loc31_32.2(%int_170141183460469231731687303715884105727) [concrete = constants.%int_170141183460469231731687303715884105727.ff5] // CHECK:STDOUT: %.loc31_32.1: %i128 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc31 [concrete = constants.%int_170141183460469231731687303715884105727.ff5] // CHECK:STDOUT: %.loc31_32.2: %i128 = converted %int_170141183460469231731687303715884105727, %.loc31_32.1 [concrete = constants.%int_170141183460469231731687303715884105727.ff5] -// CHECK:STDOUT: %.loc31_32.3: ref %i128 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc31_32.2: %.0e6 = impl_witness_access constants.%Copy.impl_witness.a35, element0 [concrete = constants.%Int.as.Copy.impl.Op.bc1] // CHECK:STDOUT: %bound_method.loc31_32.3: = bound_method %.loc31_32.2, %impl.elem0.loc31_32.2 [concrete = constants.%Int.as.Copy.impl.Op.bound.78b] // CHECK:STDOUT: %specific_fn.loc31_32.2: = specific_function %impl.elem0.loc31_32.2, @Int.as.Copy.impl.Op(constants.%int_128) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc31_32.4: = bound_method %.loc31_32.2, %specific_fn.loc31_32.2 [concrete = constants.%bound_method.2fb] // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc31: init %i128 = call %bound_method.loc31_32.4(%.loc31_32.2) [concrete = constants.%int_170141183460469231731687303715884105727.ff5] +// CHECK:STDOUT: %.loc31_32.3: ref %i128 = temporary_storage // CHECK:STDOUT: %.loc31_32.4: ref %i128 = temporary %.loc31_32.3, %Int.as.Copy.impl.Op.call.loc31 [concrete = constants.%.7df] // CHECK:STDOUT: %addr.loc31_71.1: %ptr.974 = addr_of %.loc31_32.4 [concrete = constants.%addr.6a2] // CHECK:STDOUT: %.loc31_71.1: ref %i128 = temporary_storage @@ -2205,12 +2205,12 @@ fn F() { // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc7_31.2(%float) [concrete = constants.%float.d20] // CHECK:STDOUT: %.loc7_31.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%float.d20] // CHECK:STDOUT: %.loc7_31.2: %f64.d77 = converted %float, %.loc7_31.1 [concrete = constants.%float.d20] -// CHECK:STDOUT: %.loc7_31.3: ref %f64.d77 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc7_31.2: %.59b = impl_witness_access constants.%Copy.impl_witness.1e3, element0 [concrete = constants.%Float.as.Copy.impl.Op.f05] // CHECK:STDOUT: %bound_method.loc7_31.3: = bound_method %.loc7_31.2, %impl.elem0.loc7_31.2 [concrete = constants.%Float.as.Copy.impl.Op.bound] // CHECK:STDOUT: %specific_fn.loc7_31.2: = specific_function %impl.elem0.loc7_31.2, @Float.as.Copy.impl.Op(constants.%int_64) [concrete = constants.%Float.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc7_31.4: = bound_method %.loc7_31.2, %specific_fn.loc7_31.2 [concrete = constants.%bound_method.9b6] // CHECK:STDOUT: %Float.as.Copy.impl.Op.call: init %f64.d77 = call %bound_method.loc7_31.4(%.loc7_31.2) [concrete = constants.%float.d20] +// CHECK:STDOUT: %.loc7_31.3: ref %f64.d77 = temporary_storage // CHECK:STDOUT: %.loc7_31.4: ref %f64.d77 = temporary %.loc7_31.3, %Float.as.Copy.impl.Op.call [concrete = constants.%.4f3] // CHECK:STDOUT: %addr.loc7_34.1: %ptr.bcc = addr_of %.loc7_31.4 [concrete = constants.%addr] // CHECK:STDOUT: %.loc7_34.1: ref %f64.d77 = temporary_storage @@ -2357,12 +2357,12 @@ fn F() { // CHECK:STDOUT: %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call: init %f64.d77 = call %bound_method.loc15_11.2(%float) [concrete = ] // CHECK:STDOUT: %.loc15_11.1: %f64.d77 = value_of_initializer %Core.FloatLiteral.as.ImplicitAs.impl.Convert.call [concrete = ] // CHECK:STDOUT: %.loc15_11.2: %f64.d77 = converted %float, %.loc15_11.1 [concrete = ] -// CHECK:STDOUT: %.loc15_11.3: ref %f64.d77 = temporary_storage // CHECK:STDOUT: %impl.elem0.loc15_11.2: %.59b = impl_witness_access constants.%Copy.impl_witness.1e3, element0 [concrete = constants.%Float.as.Copy.impl.Op.f05] // CHECK:STDOUT: %bound_method.loc15_11.3: = bound_method %.loc15_11.2, %impl.elem0.loc15_11.2 [concrete = ] // CHECK:STDOUT: %specific_fn.loc15_11.2: = specific_function %impl.elem0.loc15_11.2, @Float.as.Copy.impl.Op(constants.%int_64) [concrete = constants.%Float.as.Copy.impl.Op.specific_fn] // CHECK:STDOUT: %bound_method.loc15_11.4: = bound_method %.loc15_11.2, %specific_fn.loc15_11.2 [concrete = ] // CHECK:STDOUT: %Float.as.Copy.impl.Op.call: init %f64.d77 = call %bound_method.loc15_11.4(%.loc15_11.2) [concrete = ] +// CHECK:STDOUT: %.loc15_11.3: ref %f64.d77 = temporary_storage // CHECK:STDOUT: %.loc15_11.4: ref %f64.d77 = temporary %.loc15_11.3, %Float.as.Copy.impl.Op.call [concrete = ] // CHECK:STDOUT: %addr.loc15_19.1: %ptr.bcc = addr_of %.loc15_11.4 [concrete = ] // CHECK:STDOUT: %.loc15_19.1: ref %f64.d77 = temporary_storage diff --git a/toolchain/lower/testdata/interop/cpp/nullptr.carbon b/toolchain/lower/testdata/interop/cpp/nullptr.carbon index 98602c087ceb..a4e0bfe98c7b 100644 --- a/toolchain/lower/testdata/interop/cpp/nullptr.carbon +++ b/toolchain/lower/testdata/interop/cpp/nullptr.carbon @@ -89,8 +89,8 @@ fn ConvertNullptrConstant() -> Core.Optional(i32*) { // CHECK:STDOUT: store ptr %Cpp.nullptr_t.as.ImplicitAs.impl.Convert.call, ptr %.loc12_18.2.temp, align 8, !dbg !19 // CHECK:STDOUT: %.loc12_18.4 = load ptr, ptr %.loc12_18.2.temp, align 8, !dbg !19 // CHECK:STDOUT: call void @_Z7TakePtrPi(ptr %.loc12_18.4), !dbg !21 -// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc14_22.1.temp), !dbg !20 // CHECK:STDOUT: %Cpp.nullptr_t.as.Copy.impl.Op.call = call ptr @"_COp.NullptrT.CppCompat.Core:Copy.Core"(ptr poison), !dbg !20 +// CHECK:STDOUT: call void @llvm.lifetime.start.p0(ptr %.loc14_22.1.temp), !dbg !20 // CHECK:STDOUT: store ptr %Cpp.nullptr_t.as.Copy.impl.Op.call, ptr %.loc14_22.1.temp, align 8, !dbg !20 // CHECK:STDOUT: call void @_Z11TakeNullptrDn.carbon_thunk(ptr %.loc14_22.1.temp), !dbg !22 // CHECK:STDOUT: call void @"_COp.705e422c84320121:core.Destroy.Core"(ptr %.loc14_22.1.temp), !dbg !20