Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: Fix va_list - aarch64 iOS/Windows #56599

Merged
merged 1 commit into from
Dec 8, 2018

Conversation

dlrobertson
Copy link
Contributor

@dlrobertson dlrobertson commented Dec 7, 2018

Summary

Fix code generated for VaList on Aarch64 iOS/Windows.

Details

According to the Apple - ARM64 Function Calling Conventions:

... the type va_list is an alias for char * rather than for the struct
type specified in the generic PCS.

The current implementation uses the generic Aarch64 structure for VaList
for Aarch64 iOS. Switch to using the char * variant of the VaList
and use the corresponding emit_ptr_va_arg for the va_arg intrinsic.

Windows always uses the char * variant of the VaList. Update the va_arg
intrinsic to use emit_ptr_va_arg.

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 7, 2018
@dlrobertson dlrobertson changed the title codegen: Fix va_list - aarch64 Darwin/Windows codegen: Fix va_list - aarch64 iOS/Windows Dec 7, 2018
bx.cx.tcx.sess.target.target.options.is_like_windows) {
("x86", true) => {
bx.cx.tcx.sess.target.target.options.is_like_windows,
bx.cx.tcx.sess.target.target.options.is_like_osx) {
Copy link
Contributor Author

@dlrobertson dlrobertson Dec 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct by circumstance, but is not ideal. Technically if there was a aarch64-apple-darwin spec (there isn't one currently) it would match here, but not in libcore. So we'd end up generating a generic Aarch64 ABI VaList structure in libcore and then use the char * variant of the va_arg instruction here 😳. Is there a better way to match against IOS here other than using the target_os string or is_like_osx?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @rust-lang/compiler ^

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to check target_os directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 updated

According to the Apple developer docs:

> The type va_list is an alias for char * rather than for the struct
> type specified in the generic PCS.

The current implementation uses the generic Aarch64 structure for VaList
for Aarch64 iOS.

Windows always uses the char * variant of the va_list.
@eddyb
Copy link
Member

eddyb commented Dec 7, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Dec 7, 2018

📌 Commit 3dfd8f7 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 7, 2018
Centril added a commit to Centril/rust that referenced this pull request Dec 8, 2018
codegen: Fix va_list - aarch64 iOS/Windows

## Summary

Fix code generated for `VaList` on Aarch64 iOS/Windows.

## Details

According to the [Apple - ARM64 Function Calling Conventions]:

> ... the type va_list is an alias for char * rather than for the struct
> type specified in the generic PCS.

The current implementation uses the generic Aarch64 structure for `VaList`
for Aarch64 iOS. Switch to using the `char *` variant of the `VaList`
and use the corresponding `emit_ptr_va_arg` for the `va_arg` intrinsic.

Windows always uses the `char *` variant of the `VaList`. Update the `va_arg`
intrinsic to use `emit_ptr_va_arg`.

[Apple - ARM64 Function Calling Conventions]: https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html
bors added a commit that referenced this pull request Dec 8, 2018
Rollup of 6 pull requests

Successful merges:

 - #56248 (Suggest an appropriate token when encountering `pub Ident<'a>`)
 - #56597 (Improve the usage message for `-Z dump-mir`.)
 - #56599 (codegen: Fix va_list - aarch64 iOS/Windows)
 - #56602 (Fix the just-introduced ptr::hash docs)
 - #56620 (resolve: Reduce some clutter in import ambiguity errors)
 - #56621 (Add missing comma in Generators)

Failed merges:

r? @ghost
@bors bors merged commit 3dfd8f7 into rust-lang:master Dec 8, 2018
@dlrobertson dlrobertson deleted the fix_va_arg branch December 8, 2018 18:28
@workingjubilee workingjubilee added the F-c_variadic `#![feature(c_variadic)]` label Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-c_variadic `#![feature(c_variadic)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants