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.

@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
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 force-pushed the toolchain-unify-needs-thunk branch from a839493 to aa1ff56 Compare October 27, 2025 22:30
@zygoloid zygoloid enabled auto-merge October 27, 2025 22:30
@zygoloid zygoloid added this pull request to the merge queue Oct 27, 2025
Merged via the queue into carbon-language:trunk with commit a1a35c2 Oct 27, 2025
8 checks passed
@zygoloid zygoloid deleted the toolchain-unify-needs-thunk branch October 27, 2025 23:10
@zygoloid zygoloid removed the dependent Depends on another issue/PR label Oct 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants