-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
libcore: Implement VaList::arg in pure rust #56489
Comments
Does this seam reasonable? Should be relatively simple to implement. |
I wouldn't put the manual implementation of |
Seems reasonable. So would this file exist in
If we get them all implemented it should be a fairly large file, but if clang can do it, I don't see why we can't do it for the vast majority of architectures and OSes with just a very select few falling through to the LLVM implementation.
I'm still very new to
you should be able to implement it. |
From a purely "traitification" point of view, I don't think there should be any problem in making these methods generic on the backend. |
@dlrobertson I was thinking having trait impls in |
This is definitely something worth looking into. We could something similar to what the I also realized we couldn't move |
@dlrobertson We can always switch back to something built into the compiler, if we want to support aggregates. But I feel like that's far less likely to happen. |
Cool. I'll try to implement
I don't know enough about |
It's possible the relevant machinery could be generalized to give us the " |
Got it. Yeah, that might work. I'll look into that a bit too. If we do use libcore to generate |
Summary
Implement
VaList::arg
in pure rust, similar to va_list-rs.Details
We currently expose the
va_arg
intrinsic which should emit the correct LLVM forva_arg
for the given architecture and OS. We currently use the LLVM va_arg instruction, but it doesn't emit the correct code for some common OSes and architectures causing us to implement the instruction manually (See [src/librustc_codegen_llvm/va_arg.rs] for details). Since we do not support callingVaList::arg
on arbitrary types, we might be able to implement something similar to va_list-rs in pure rust for most architectures, falling back to the LLVM va_arg instruction only when a pure rust implementation does not exist.Original issue
Note this issue has been changed following #56489 (comment). The original issue is as follows:
codegen: Move custom va_arg logic to librustc_codegen_ssa
The LLVM
va_arg
intrinsic is far from a complete implementation. As a result, we have started to manually implementva_arg
(like clang does) with theBuilder
in src/librustc_codegen_llvm/va_arg.rs. This logic should be moved tolibrustc_codegen_ssa
inBuilderMethods::va_arg
.BuilderMethods::va_arg
needs to fall back to LLVM'sva_arg
intrinsic when there isn't an custom implementation available, so we'll need to add a new trait methodbackend_va_arg
(please suggest a better name 😄) that exposes the backend specific implementation ofva_arg
.The text was updated successfully, but these errors were encountered: