Support pass-by-move when calling a C++ function taking by value. (#7135)

Previously, we picked a single Carbon parameter pattern for each C++
parameter pattern. This doesn't work well in cases where the Carbon
semantics and the C++ semantics are not perfectly aligned. In
particular, when a parameter is passed by value in C++, that might mean
either pass-by-move (which in Carbon would best be modeled by a `var`
pattern, as no other form of parameter would perform a move) or
pass-by-copy (which in Carbon would best be modeled by a value
parameter, as a `var` parameter would force an extra copy).

After this change, we compute a passing mode for each parameter based on
the implicit conversion sequence from the argument to the parameter as
determined by C++ overload resolution, and use that to determine the
Carbon pattern corresponding to each C++ parameter. This results in
potentially generating multiple different thunks for the same C++
function if it's called in different ways, but we already did that to
handle default arguments and list-initialization. The passing modes are
included in the thunk mangling.

Add a new value store for clang decl signatures, which capture the
information about parameter passing mode as well as the other existing
information about different ways that a C++ function might be imported
to Carbon.

Most of the rules for computing passing modes are the same as before:
const references use pass by value, non-const lvalue references use
pass-by-ref, non-const rvalue references use pass-by-var. But for C++
non-reference parameters, pick between pass-by-value and pass-by-var
based on whether the implicit conversion sequence was effectively
performing a copy. Prefer pass-by-value if either would work and they'd
do the same thing. We still use pass-by-value for const references, even
when the argument is an lvalue and we could pass a reference; we may
want to change this in future.

For virtual functions, we try to pick a worst-case passing mode, as we
can only pick a single signature for what goes in the vtable. Calls to
virtual functions will still use a thunk to C++, allowing variance in
the calling convention at call sites. We don't allow variance in the
overriders as we don't implement support for thunks for virtual
functions yet. We currently use pass-by-value for const reference
parameters here, but that should probably change at some point.

Assisted-by: Gemini via Antigravity
This commit is contained in:
Richard Smith
2026-05-13 01:44:07 +00:00
committed by GitHub
parent 10b2b71847
commit 71ba07239f
50 changed files with 1654 additions and 524 deletions
@@ -1128,14 +1128,14 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
// CHECK:STDOUT: %.0d7: type = fn_type_with_self_type %Negate.WithSelf.Op.type.899, %Negate.facet.758 [symbolic]
// CHECK:STDOUT: %impl.elem1.ec8: %.0d7 = impl_witness_access %Negate.lookup_impl_witness.783, element1 [symbolic]
// CHECK:STDOUT: %specific_impl_fn.f22: <specific function> = specific_impl_function %impl.elem1.ec8, @Negate.WithSelf.Op(%Negate.facet.758) [symbolic]
// CHECK:STDOUT: %Int32.cpp_operator.type.49e401.16: type = fn_type @Int32.cpp_operator.16 [concrete]
// CHECK:STDOUT: %Int32.cpp_operator.0010d3.16: %Int32.cpp_operator.type.49e401.16 = struct_value () [concrete]
// CHECK:STDOUT: %custom_witness.934: <witness> = custom_witness (%Int32.cpp_operator.0010d3.16), @Inc [concrete]
// CHECK:STDOUT: %Inc.facet.390: %Inc.type = facet_value %Int32, (%custom_witness.934) [concrete]
// CHECK:STDOUT: %Int32.cpp_operator.type.49e401.17: type = fn_type @Int32.cpp_operator.17 [concrete]
// CHECK:STDOUT: %Int32.cpp_operator.0010d3.17: %Int32.cpp_operator.type.49e401.17 = struct_value () [concrete]
// CHECK:STDOUT: %custom_witness.99f: <witness> = custom_witness (%Int32.cpp_operator.0010d3.17), @Dec [concrete]
// CHECK:STDOUT: %Dec.facet.961: %Dec.type = facet_value %Int32, (%custom_witness.99f) [concrete]
// CHECK:STDOUT: %Int32.Op.type.68b858.18: type = fn_type @Int32.Op.18 [concrete]
// CHECK:STDOUT: %Int32.Op.6afff1.18: %Int32.Op.type.68b858.18 = struct_value () [concrete]
// CHECK:STDOUT: %custom_witness.50d: <witness> = custom_witness (%Int32.Op.6afff1.18), @Inc [concrete]
// CHECK:STDOUT: %Inc.facet.9db: %Inc.type = facet_value %Int32, (%custom_witness.50d) [concrete]
// CHECK:STDOUT: %Int32.Op.type.68b858.19: type = fn_type @Int32.Op.19 [concrete]
// CHECK:STDOUT: %Int32.Op.6afff1.19: %Int32.Op.type.68b858.19 = struct_value () [concrete]
// CHECK:STDOUT: %custom_witness.e76: <witness> = custom_witness (%Int32.Op.6afff1.19), @Dec [concrete]
// CHECK:STDOUT: %Dec.facet.bed: %Dec.type = facet_value %Int32, (%custom_witness.e76) [concrete]
// CHECK:STDOUT: %facet_type.89a: type = facet_type <@Destroy & @Negate where %impl.elem0.f00 = %Int64> [concrete]
// CHECK:STDOUT: %Int16.Op.type.180c8b.18: type = fn_type @Int16.Op.18 [concrete]
// CHECK:STDOUT: %Int16.Op.c3e49c.18: %Int16.Op.type.180c8b.18 = struct_value () [concrete]
@@ -1143,9 +1143,9 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
// CHECK:STDOUT: %facet_value.70a: %facet_type.89a = facet_value %Int16, (%custom_witness.e5b, %custom_witness.e58) [concrete]
// CHECK:STDOUT: %pattern_type.c49: type = pattern_type %facet_type.89a [concrete]
// CHECK:STDOUT: %facet_type.d5d: type = facet_type <@Destroy & @Negate where %impl.elem0.f00 = %Int32> [concrete]
// CHECK:STDOUT: %Int32.Op.type.68b858.18: type = fn_type @Int32.Op.18 [concrete]
// CHECK:STDOUT: %Int32.Op.6afff1.18: %Int32.Op.type.68b858.18 = struct_value () [concrete]
// CHECK:STDOUT: %custom_witness.e8a: <witness> = custom_witness (%Int32, %Int32.Op.6afff1.18), @Negate [concrete]
// CHECK:STDOUT: %Int32.Op.type.68b858.20: type = fn_type @Int32.Op.20 [concrete]
// CHECK:STDOUT: %Int32.Op.6afff1.20: %Int32.Op.type.68b858.20 = struct_value () [concrete]
// CHECK:STDOUT: %custom_witness.e8a: <witness> = custom_witness (%Int32, %Int32.Op.6afff1.20), @Negate [concrete]
// CHECK:STDOUT: %facet_value.396: %facet_type.d5d = facet_value %Int32, (%custom_witness.ce1, %custom_witness.e8a) [concrete]
// CHECK:STDOUT: %pattern_type.0ec: type = pattern_type %facet_type.d5d [concrete]
// CHECK:STDOUT: %complete_type.f1c: <witness> = complete_type_witness %AddWith.type.344 [concrete]
@@ -1313,10 +1313,10 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
// CHECK:STDOUT: %.384: type = fn_type_with_self_type %DivAssignWith.WithSelf.Op.type.646, %DivAssignWith.facet.d3b [concrete]
// CHECK:STDOUT: %ModAssignWith.WithSelf.Op.type.a34: type = fn_type @ModAssignWith.WithSelf.Op, @ModAssignWith.WithSelf(%Int32, %ModAssignWith.facet.1c6) [concrete]
// CHECK:STDOUT: %.ee0: type = fn_type_with_self_type %ModAssignWith.WithSelf.Op.type.a34, %ModAssignWith.facet.1c6 [concrete]
// CHECK:STDOUT: %Inc.WithSelf.Op.type.eaa: type = fn_type @Inc.WithSelf.Op, @Inc.WithSelf(%Inc.facet.390) [concrete]
// CHECK:STDOUT: %.696: type = fn_type_with_self_type %Inc.WithSelf.Op.type.eaa, %Inc.facet.390 [concrete]
// CHECK:STDOUT: %Dec.WithSelf.Op.type.6fb: type = fn_type @Dec.WithSelf.Op, @Dec.WithSelf(%Dec.facet.961) [concrete]
// CHECK:STDOUT: %.cdd: type = fn_type_with_self_type %Dec.WithSelf.Op.type.6fb, %Dec.facet.961 [concrete]
// CHECK:STDOUT: %Inc.WithSelf.Op.type.755: type = fn_type @Inc.WithSelf.Op, @Inc.WithSelf(%Inc.facet.9db) [concrete]
// CHECK:STDOUT: %.cfd3: type = fn_type_with_self_type %Inc.WithSelf.Op.type.755, %Inc.facet.9db [concrete]
// CHECK:STDOUT: %Dec.WithSelf.Op.type.e71: type = fn_type @Dec.WithSelf.Op, @Dec.WithSelf(%Dec.facet.bed) [concrete]
// CHECK:STDOUT: %.b6e: type = fn_type_with_self_type %Dec.WithSelf.Op.type.e71, %Dec.facet.bed [concrete]
// CHECK:STDOUT: %Negate.facet.0a5: %Negate.type = facet_value %Int16, (%custom_witness.e58) [concrete]
// CHECK:STDOUT: %Negate.WithSelf.Op.type.d7d: type = fn_type @Negate.WithSelf.Op, @Negate.WithSelf(%Negate.facet.0a5) [concrete]
// CHECK:STDOUT: %.3e7: type = fn_type_with_self_type %Negate.WithSelf.Op.type.d7d, %Negate.facet.0a5 [concrete]
@@ -3763,32 +3763,32 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
// CHECK:STDOUT: %pattern_type.loc294_22 => constants.%pattern_type.ece
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @TestInc(constants.%Inc.facet.390) {
// CHECK:STDOUT: %T.loc278_13.1 => constants.%Inc.facet.390
// CHECK:STDOUT: specific @TestInc(constants.%Inc.facet.9db) {
// CHECK:STDOUT: %T.loc278_13.1 => constants.%Inc.facet.9db
// CHECK:STDOUT: %T.as_type.loc278_33.1 => constants.%Int32
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.9c9
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.357
// CHECK:STDOUT: %Inc.WithSelf.Op.type => constants.%Inc.WithSelf.Op.type.eaa
// CHECK:STDOUT: %.loc280 => constants.%.696
// CHECK:STDOUT: %Inc.lookup_impl_witness => constants.%custom_witness.934
// CHECK:STDOUT: %impl.elem0.loc280_3.2 => constants.%Int32.cpp_operator.0010d3.16
// CHECK:STDOUT: %specific_impl_fn.loc280_3.2 => constants.%Int32.cpp_operator.0010d3.16
// CHECK:STDOUT: %Inc.WithSelf.Op.type => constants.%Inc.WithSelf.Op.type.755
// CHECK:STDOUT: %.loc280 => constants.%.cfd3
// CHECK:STDOUT: %Inc.lookup_impl_witness => constants.%custom_witness.50d
// CHECK:STDOUT: %impl.elem0.loc280_3.2 => constants.%Int32.Op.6afff1.18
// CHECK:STDOUT: %specific_impl_fn.loc280_3.2 => constants.%Int32.Op.6afff1.18
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @TestDec(constants.%Dec.facet.961) {
// CHECK:STDOUT: %T.loc284_13.1 => constants.%Dec.facet.961
// CHECK:STDOUT: specific @TestDec(constants.%Dec.facet.bed) {
// CHECK:STDOUT: %T.loc284_13.1 => constants.%Dec.facet.bed
// CHECK:STDOUT: %T.as_type.loc284_33.1 => constants.%Int32
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.9c9
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: %require_complete => constants.%complete_type.357
// CHECK:STDOUT: %Dec.WithSelf.Op.type => constants.%Dec.WithSelf.Op.type.6fb
// CHECK:STDOUT: %.loc286 => constants.%.cdd
// CHECK:STDOUT: %Dec.lookup_impl_witness => constants.%custom_witness.99f
// CHECK:STDOUT: %impl.elem0.loc286_3.2 => constants.%Int32.cpp_operator.0010d3.17
// CHECK:STDOUT: %specific_impl_fn.loc286_3.2 => constants.%Int32.cpp_operator.0010d3.17
// CHECK:STDOUT: %Dec.WithSelf.Op.type => constants.%Dec.WithSelf.Op.type.e71
// CHECK:STDOUT: %.loc286 => constants.%.b6e
// CHECK:STDOUT: %Dec.lookup_impl_witness => constants.%custom_witness.e76
// CHECK:STDOUT: %impl.elem0.loc286_3.2 => constants.%Int32.Op.6afff1.19
// CHECK:STDOUT: %specific_impl_fn.loc286_3.2 => constants.%Int32.Op.6afff1.19
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @TestNegate(constants.%Destroy.facet.b0a, constants.%facet_value.70a) {
@@ -3834,8 +3834,8 @@ fn TestUnaryOperators(a: Cpp.Int16, b: Cpp.Int32) {
// CHECK:STDOUT: %Negate.facet => constants.%Negate.facet.3c9
// CHECK:STDOUT: %Negate.WithSelf.Op.type => constants.%Negate.WithSelf.Op.type.1bc
// CHECK:STDOUT: %.loc296_3.3 => constants.%.19b
// CHECK:STDOUT: %impl.elem1.loc296_3.2 => constants.%Int32.Op.6afff1.18
// CHECK:STDOUT: %specific_impl_fn.loc296_3.3 => constants.%Int32.Op.6afff1.18
// CHECK:STDOUT: %impl.elem1.loc296_3.2 => constants.%Int32.Op.6afff1.20
// CHECK:STDOUT: %specific_impl_fn.loc296_3.3 => constants.%Int32.Op.6afff1.20
// CHECK:STDOUT: %Destroy.WithSelf.Op.type => constants.%Destroy.WithSelf.Op.type.2e1
// CHECK:STDOUT: %.loc296_3.4 => constants.%.e6c
// CHECK:STDOUT: %Destroy.lookup_impl_witness => constants.%custom_witness.ce1
@@ -175,8 +175,7 @@ fn TestDerefFail(not_ptr: Cpp.NotAPtr) {
// CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_ptr.ref, %impl.elem1
// CHECK:STDOUT: %Op.ref.loc13_43: %ConstDeref.cpp_operator.type = name_ref Op, imports.%ConstDeref.cpp_operator.decl [concrete = constants.%ConstDeref.cpp_operator]
// CHECK:STDOUT: %ConstDeref.cpp_operator.bound: <bound method> = bound_method %int_ptr.ref, %Op.ref.loc13_43
// CHECK:STDOUT: %.loc13: %ConstDeref = acquire_value %int_ptr.ref
// CHECK:STDOUT: %operator_Star__carbon_thunk.call: ref %i32 = call imports.%operator_Star__carbon_thunk.decl(%.loc13)
// CHECK:STDOUT: %operator_Star__carbon_thunk.call: ref %i32 = call imports.%operator_Star__carbon_thunk.decl(%int_ptr.ref)
// CHECK:STDOUT: return %operator_Star__carbon_thunk.call
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1189,6 +1189,7 @@ fn F() {
// CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
// CHECK:STDOUT: %i32.builtin: type = int_type signed, %int_32 [concrete]
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
// CHECK:STDOUT: %operator_LessLess__carbon_thunk.type: type = fn_type @operator_LessLess__carbon_thunk [concrete]
// CHECK:STDOUT: %operator_LessLess__carbon_thunk: %operator_LessLess__carbon_thunk.type = struct_value () [concrete]
@@ -1252,8 +1253,12 @@ fn F() {
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.577: <bound method> = bound_method %int_42.20e, %Core.IntLiteral.as.ImplicitAs.impl.Convert.f1a [concrete]
// CHECK:STDOUT: %bound_method.cd5: <bound method> = bound_method %int_42.20e, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
// CHECK:STDOUT: %int_42.c68: %i32 = int_value 42 [concrete]
// CHECK:STDOUT: %Destroy.Op.type: type = fn_type @Destroy.Op [concrete]
// CHECK:STDOUT: %Destroy.Op: %Destroy.Op.type = struct_value () [concrete]
// CHECK:STDOUT: %.1a9: ref %i32 = temporary invalid, %int_42.c68 [concrete]
// CHECK:STDOUT: %Destroy.Op.type.bae255.2: type = fn_type @Destroy.Op.loc48_30.2 [concrete]
// CHECK:STDOUT: %Destroy.Op.651ba6.2: %Destroy.Op.type.bae255.2 = struct_value () [concrete]
// CHECK:STDOUT: %Destroy.Op.bound: <bound method> = bound_method %.1a9, %Destroy.Op.651ba6.2 [concrete]
// CHECK:STDOUT: %Destroy.Op.type.bae255.3: type = fn_type @Destroy.Op.loc45 [concrete]
// CHECK:STDOUT: %Destroy.Op.651ba6.3: %Destroy.Op.type.bae255.3 = struct_value () [concrete]
// CHECK:STDOUT: %C.cpp_destructor.type: type = fn_type @C.cpp_destructor [concrete]
// CHECK:STDOUT: %C.cpp_destructor: %C.cpp_destructor.type = struct_value () [concrete]
// CHECK:STDOUT: %C.Op.type: type = fn_type @C.Op [concrete]
@@ -1875,24 +1880,26 @@ fn F() {
// CHECK:STDOUT: %specific_fn.loc48: <specific function> = specific_function %impl.elem0.loc48, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
// CHECK:STDOUT: %bound_method.loc48_30.2: <bound method> = bound_method %int_42, %specific_fn.loc48 [concrete = constants.%bound_method.cd5]
// CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc48: init %i32 = call %bound_method.loc48_30.2(%int_42) [concrete = constants.%int_42.c68]
// CHECK:STDOUT: %.loc48_30.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc48 [concrete = constants.%int_42.c68]
// CHECK:STDOUT: %.loc48_30.2: %i32 = converted %int_42, %.loc48_30.1 [concrete = constants.%int_42.c68]
// CHECK:STDOUT: %C.cpp_operator.call: init %i32 = call %C.cpp_operator.bound(%c1.ref.loc48, %.loc48_30.2)
// CHECK:STDOUT: %.loc48_30.1: init %i32 = converted %int_42, %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc48 [concrete = constants.%int_42.c68]
// CHECK:STDOUT: %.loc48_30.2: ref %i32 = temporary_storage
// CHECK:STDOUT: %.loc48_30.3: ref %i32 = temporary %.loc48_30.2, %.loc48_30.1 [concrete = constants.%.1a9]
// CHECK:STDOUT: %C.cpp_operator.call: init %i32 = call %C.cpp_operator.bound(%c1.ref.loc48, %.loc48_30.3)
// CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
// CHECK:STDOUT: %.loc48_32.1: %i32 = value_of_initializer %C.cpp_operator.call
// CHECK:STDOUT: %.loc48_32.2: %i32 = converted %C.cpp_operator.call, %.loc48_32.1
// CHECK:STDOUT: %index: %i32 = value_binding index, %.loc48_32.2
// CHECK:STDOUT: %Destroy.Op.bound.loc45: <bound method> = bound_method %.loc45_44.3, constants.%Destroy.Op
// CHECK:STDOUT: %Destroy.Op.call.loc48: init %empty_tuple.type = call constants.%Destroy.Op.bound(constants.%.1a9)
// CHECK:STDOUT: %Destroy.Op.bound.loc45: <bound method> = bound_method %.loc45_44.3, constants.%Destroy.Op.651ba6.3
// CHECK:STDOUT: %Destroy.Op.call.loc45: init %empty_tuple.type = call %Destroy.Op.bound.loc45(%.loc45_44.3)
// CHECK:STDOUT: %Destroy.Op.bound.loc44: <bound method> = bound_method %.loc44_47.3, constants.%Destroy.Op
// CHECK:STDOUT: %Destroy.Op.bound.loc44: <bound method> = bound_method %.loc44_47.3, constants.%Destroy.Op.651ba6.3
// CHECK:STDOUT: %Destroy.Op.call.loc44: init %empty_tuple.type = call %Destroy.Op.bound.loc44(%.loc44_47.3)
// CHECK:STDOUT: %Destroy.Op.bound.loc43: <bound method> = bound_method %.loc43_35.3, constants.%Destroy.Op
// CHECK:STDOUT: %Destroy.Op.bound.loc43: <bound method> = bound_method %.loc43_35.3, constants.%Destroy.Op.651ba6.3
// CHECK:STDOUT: %Destroy.Op.call.loc43: init %empty_tuple.type = call %Destroy.Op.bound.loc43(%.loc43_35.3)
// CHECK:STDOUT: %Destroy.Op.bound.loc42: <bound method> = bound_method %.loc42_38.3, constants.%Destroy.Op
// CHECK:STDOUT: %Destroy.Op.bound.loc42: <bound method> = bound_method %.loc42_38.3, constants.%Destroy.Op.651ba6.3
// CHECK:STDOUT: %Destroy.Op.call.loc42: init %empty_tuple.type = call %Destroy.Op.bound.loc42(%.loc42_38.3)
// CHECK:STDOUT: %Destroy.Op.bound.loc41: <bound method> = bound_method %.loc41_35.3, constants.%Destroy.Op
// CHECK:STDOUT: %Destroy.Op.bound.loc41: <bound method> = bound_method %.loc41_35.3, constants.%Destroy.Op.651ba6.3
// CHECK:STDOUT: %Destroy.Op.call.loc41: init %empty_tuple.type = call %Destroy.Op.bound.loc41(%.loc41_35.3)
// CHECK:STDOUT: %Destroy.Op.bound.loc40: <bound method> = bound_method %.loc40_31.3, constants.%Destroy.Op
// CHECK:STDOUT: %Destroy.Op.bound.loc40: <bound method> = bound_method %.loc40_31.3, constants.%Destroy.Op.651ba6.3
// CHECK:STDOUT: %Destroy.Op.call.loc40: init %empty_tuple.type = call %Destroy.Op.bound.loc40(%.loc40_31.3)
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %C.Op.bound.loc23: <bound method> = bound_method %.loc23_38.3, constants.%C.Op
@@ -1946,7 +1953,14 @@ fn F() {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op(%self.param: ref bool) = "no_op";
// CHECK:STDOUT: fn @Destroy.Op.loc48_30.1(%self.param: ref %i32.builtin) = "no_op";
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op.loc48_30.2(%self.param: ref %i32) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: return
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: fn @Destroy.Op.loc45(%self.param: ref bool) = "no_op";
// CHECK:STDOUT:
// CHECK:STDOUT: --- multiple_calls.carbon
// CHECK:STDOUT:
@@ -3175,9 +3189,7 @@ fn F() {
// CHECK:STDOUT: %c2.ref: ref %C = name_ref c2, %c2
// CHECK:STDOUT: %C.cpp_operator.bound.loc10: <bound method> = bound_method %c1.ref.loc10, imports.%C.cpp_operator.decl.828f43.2
// CHECK:STDOUT: %.loc10_3: ref %C = splice_block %c3.var {}
// CHECK:STDOUT: %.loc10_31.1: %C = acquire_value %c2.ref
// CHECK:STDOUT: %.loc10_31.2: ref %C = value_as_ref %.loc10_31.1
// CHECK:STDOUT: %addr.loc10_29.1: %ptr.d9e = addr_of %.loc10_31.2
// CHECK:STDOUT: %addr.loc10_29.1: %ptr.d9e = addr_of %c2.ref
// CHECK:STDOUT: %addr.loc10_29.2: %ptr.d9e = addr_of %.loc10_3
// CHECK:STDOUT: %operator_Plus__carbon_thunk.call: init %empty_tuple.type = call imports.%operator_Plus__carbon_thunk.decl(%c1.ref.loc10, %addr.loc10_29.1, %addr.loc10_29.2)
// CHECK:STDOUT: %.loc10_29: init %C to %.loc10_3 = mark_in_place_init %operator_Plus__carbon_thunk.call
@@ -377,26 +377,13 @@ fn Test(missing_less: Cpp.MissingLess,
// CHECK:STDERR:
OrderedWith(no_relevant_members, no_relevant_members);
// CHECK:STDERR: fail_never_valid.carbon:[[@LINE+20]]:3: error: cannot convert type `Cpp.LessReturnsVoid` into type implementing `Core.OrderedWith(Cpp.LessReturnsVoid)` [ConversionFailureTypeToFacet]
// CHECK:STDERR: fail_never_valid.carbon:[[@LINE+7]]:3: error: cannot convert type `Cpp.LessReturnsVoid` into type implementing `Core.OrderedWith(Cpp.LessReturnsVoid)` [ConversionFailureTypeToFacet]
// CHECK:STDERR: OrderedWith(less_returns_void, less_returns_void);
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_never_valid.carbon:[[@LINE-62]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: fn OrderedWith[U:! type, T:! Core.OrderedWith(U)](x: T, y: U) {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:26:11: error: value expression passed to reference parameter [ValueForRefParam]
// CHECK:STDERR: fn Less[self: Self](other: Other) -> bool;
// CHECK:STDERR: ^~~~~~~~~~
// CHECK:STDERR: fail_never_valid.carbon:[[@LINE-76]]:8: note: initializing function parameter [InCallToFunctionParam]
// CHECK:STDERR: auto operator<(LessNonConst) -> bool;
// CHECK:STDERR: ^
// CHECK:STDERR: {{.*}}/prelude/operators/comparison.carbon:26:3: note: while building thunk to match the signature of this function [ThunkSignature]
// CHECK:STDERR: fn Less[self: Self](other: Other) -> bool;
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR: fail_never_valid.carbon:[[@LINE-75]]:1: note: while deducing parameters of generic declared here [DeductionGenericHere]
// CHECK:STDERR: fn OrderedWith[U:! type, T:! Core.OrderedWith(U)](x: T, y: U) {
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CHECK:STDERR:
OrderedWith(less_returns_void, less_returns_void);
OrderedWith(less_non_const, less_non_const);