-
Notifications
You must be signed in to change notification settings - Fork 287
use 'unadjusted' ABI for wasm LLVM intrinsics #1782
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
Conversation
If anything I would like to get rid of the unadjusted ABI (which is equivalent to the broken abi for wasm). It isn't a real ABI. It is just whatever way cg_llvm decides to lower rust types to LLVM types, which frequently doesn't have any relation whatsoever with the rust type, especially for unions and enums. And even for regular structs it contains fake fields for padding. I would like to change cg_llvm eventually to only support lowering |
For calling LLVM intrinsics, I think this makes perfect sense. These are not real fn calls, so we don't need a real ABI.
|
LLVM intrinsic calls are still going through the regular ABI handling. If LLVM intrinsic calls are split out from the regular ABI handling and the LLVM intrinsic call handling is changed to only allow the unadjusted ABI (and the regular ABI handling to not allow unadjusted calls at all) and the unadjusted ABI stops supporting enums and unions, I did be fine with keeping unadjusted calls. The problem is that they are currently complicating regular calls a fair bit and thus also infecting other codegen backends that aren't LLVM based at all. |
I read rust-lang/rust#139809 but don't see the relation with this PR. The issue that rust-lang/rust#139809 addresses is related to the public
Historical reasons: previously everything was using |
I believe the relation of rust-lang/rust#139809 and this PR is that the source of the warning reported here is a monomorphization-time (inlining-time?) warning about usage of |
Yes, that's why we need "unadjusted" -- to disable the regular ABI handling for these intrinsics. This could potentially be done more cleanly by doing this automatically for all LLVM intrinsics or so. But I am trying to fix an existing issue here, not redo the underlying system in a clean way.
As Alex explained, this is a monomorphization-time lint, so the details of the private intrinsics can affect warnings shown in user crates. |
On wasm-u-u, |
I have no objections to restricting that ABI o just what stdarch needs. Scalars and SIMD vectors should probably be enough. |
stdarch also needs structs for some cases. It doesn't need structs with padding though afaik. |
I am fully aware of what "unadjusted" does. :) It disables regular ABI handling. You seem to make a difference between "disable regular ABI handling" and "go through regular ABI handling but make it a NOP (i.e., disabling all ABI adjustments)", I don't understand the point of that. We have to set some
Ah, that is unfortunate. Yes that will leak some implementation details. It's highly unstable though and it's unclear to me what a better alternative would look like -- we want to call an LLVM intrinsic whose signature is defines in terms of LLVM types, this fundamentally has to rely on how Rust types are mapped to LLVM types. |
What I want is in the implementation of the Call terminator before even creating an FnAbi have cg_llvm or cg_ssa catch all LLVM intrinsics and do completely separate lowering of the call to LLVM IR implementing exactly the subset of rust type -> LLVM type lowering that is needed without any regards for the FnAbi. That way the regular FnAbi handling never sees LLVM intrinsics at all. |
Ah I see. Yeah I guess that could work, no strong opinion either way. |
See rust-lang/rust#139809 for context.
Currently this crate uses a mix of "C" and "unadjusted", sometimes even for the same target -- no idea why. I would assume it should be "unadjusted" everywhere when importing an LLVM intrinsic? I don't want to make any sweeping changes in this PR though so this only touches wasm.
Cc @alexcrichton