Skip to content

Conversation

@zygoloid
Copy link
Contributor

Remove duplication between determining whether a parameter needs custom
thunk mapping and whether a function needs a thunk. Now a function needs
a thunk if any parameter or the return type does.

This fixes some inconsistencies; previously:

  • We would not require a thunk when passing an unsigned int, but if we
    had a thunk we'd pass unsigned int indirectly.
  • We would always require a thunk for an enum parameter, even though
    we'd actually pass it directly if its underlying type is a 32- or
    64-bit integer.
  • We would require a thunk for a nullable pointer, even though
    we arrange for all pointer types to have the same ABI in Carbon and
    C++, including nullable pointers / Optional(T*).

This also causes us to use a thunk for rvalue reference return types,
which we used to miscompile.

Depends on #6276.

Don't go through the `PerformCall` machinery a second recursive time --
this is redundant, creates additional unnecessary temporaries, and is in
theory wrong because `PerformCall` takes a syntactic argument list (one
argument per callee parameter pattern), but we have a call argument list
(one argument per callee parameter).
Remove duplication between determining whether a parameter needs custom
thunk mapping and whether a function needs a thunk. Now a function needs
a thunk if any parameter or the return type does.

This fixes some inconsistencies; previously:
- We would not require a thunk when passing an `unsigned int`, but if we
  had a thunk we'd pass `unsigned int` indirectly.
- We would always require a thunk for an enum parameter, even though
  we'd actually pass it directly if its underlying type is a 32- or
  64-bit integer.
- We would require a thunk for a nullable pointer, even though
  we arrange for all pointer types to have the same ABI in Carbon and
  C++, including nullable pointers / Optional(T*).
@zygoloid zygoloid added the dependent Depends on another issue/PR label Oct 25, 2025
@zygoloid zygoloid requested a review from a team as a code owner October 25, 2025 00:59
@zygoloid zygoloid requested review from dwblaikie and removed request for a team October 25, 2025 00:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependent Depends on another issue/PR toolchain

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant