Implement va_list and va_arg for s390x FFI#105381
Conversation
|
r? @davidtwco (rustbot has picked a reviewer for you, use r? to override) |
|
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
|
@davidtwco if you're not comfortable looking at s390x, I can take review on this. |
dlrobertson
left a comment
There was a problem hiding this comment.
This is awesome! Thanks for the work! I don't know a ton about s390x, but is va_end by chance a nop? See this comment.
Yes, |
dlrobertson
left a comment
There was a problem hiding this comment.
Thanks again for working on this! Looks reasonable after look at clangs implementation followed by a review of this, but note that I have no experience with s390x. Also not that I don't have a box to test this on.
There was a problem hiding this comment.
nit: I like the way clang does this with a reg_count_field here (either 0 or 1) followed by something like:
let reg_count = bx.struct_gep(...,reg_count_field))
There was a problem hiding this comment.
nit: could we use something more clang-like (e.g. scaled_reg_count). I have no real strong opinions, but it would be nice to avoid re-using reg_off.
There was a problem hiding this comment.
padded_size - unpadded_size is used at least twice, would it make sense to add a variable for this?
Following the s390x ELF ABI and based on the clang implementation, provide appropriate definitions of va_list in library/core/src/ffi/mod.rs and va_arg handling in compiler/rustc_codegen_llvm/src/va_arg.rs. Fixes the following test cases on s390x: src/test/run-make-fulldeps/c-link-to-rust-va-list-fn src/test/ui/abi/variadic-ffi.rs Fixes rust-lang#84628.
972833d to
eb22d70
Compare
Thanks for the review! I've addressed your comments, and also resolved the one FIXME about aggregate handling. FWIW I'm pretty confident that the s390x ABI parts are correct (I'm the code owner of the IBM Z LLVM back-end, and one of the authors of the platform ABI specification); if there's still a bug somewhere, it's more likely to be about the Rust compiler implementation details, which I'm not very familar with. I have run the full test suite ( |
There was a problem hiding this comment.
if there's still a bug somewhere, it's more likely to be about the Rust compiler implementation details, which I'm not very familar with.
Looks like you got those bits right!
FWIW I'm pretty confident that the s390x ABI parts are correct (I'm the code owner of the IBM Z LLVM back-end, and one of the authors of the platform ABI specification);
👍 just wanted to spot check, and learn a bit about s390x 😃
|
I'm unable to r+ this, but this looks great! |
|
@bors r+ |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (d6da428): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. |
|
\o/ Thanks @uweigand for working on this! |
Following the s390x ELF ABI and based on the clang implementation, provide appropriate definitions of va_list in library/core/src/ffi/mod.rs and va_arg handling in compiler/rustc_codegen_llvm/src/va_arg.rs.
Fixes the following test cases on s390x:
src/test/run-make-fulldeps/c-link-to-rust-va-list-fn src/test/ui/abi/variadic-ffi.rs
Fixes #84628.