diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-12-06 09:27:41 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-06 09:27:41 +0100 |
| commit | 875df6c59c6870d37ffa175172a6dafca94e1198 (patch) | |
| tree | 30f783c50c112664ad05afd584d81073773a8502 | |
| parent | 026d21d2c1751a7896ea44617acc0f72d50534be (diff) | |
| parent | 8922d30a87af199ee217f034e06890a5fd606673 (diff) | |
| download | rust-875df6c59c6870d37ffa175172a6dafca94e1198.tar.gz rust-875df6c59c6870d37ffa175172a6dafca94e1198.zip | |
Rollup merge of #133931 - bjorn3:even_stricter_fn_abi_sanity_checking, r=nnethercote
Only allow PassMode::Direct for aggregates on wasm when using the C ABI For the Rust ABI we don't have any ABI compat reasons to allow PassMode::Direct for aggregates.
| -rw-r--r-- | compiler/rustc_ty_utils/src/abi.rs | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index b746d6299ef..9a625c67ccd 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -473,20 +473,30 @@ fn fn_abi_sanity_check<'tcx>( // This really shouldn't happen even for sized aggregates, since // `immediate_llvm_type` will use `layout.fields` to turn this Rust type into an // LLVM type. This means all sorts of Rust type details leak into the ABI. - // However wasm sadly *does* currently use this mode so we have to allow it -- - // but we absolutely shouldn't let any more targets do that. - // (Also see <https://github.com/rust-lang/rust/issues/115666>.) + // However wasm sadly *does* currently use this mode for it's "C" ABI so we + // have to allow it -- but we absolutely shouldn't let any more targets do + // that. (Also see <https://github.com/rust-lang/rust/issues/115666>.) // // The unstable abi `PtxKernel` also uses Direct for now. // It needs to switch to something else before stabilization can happen. // (See issue: https://github.com/rust-lang/rust/issues/117271) - assert!( - matches!(&*tcx.sess.target.arch, "wasm32" | "wasm64") - || matches!(spec_abi, ExternAbi::PtxKernel | ExternAbi::Unadjusted), - "`PassMode::Direct` for aggregates only allowed for \"unadjusted\" and \"ptx-kernel\" functions and on wasm\n\ - Problematic type: {:#?}", - arg.layout, - ); + // + // And finally the unadjusted ABI is ill specified and uses Direct for all + // args, but unfortunately we need it for calling certain LLVM intrinsics. + + match spec_abi { + ExternAbi::Unadjusted => {} + ExternAbi::PtxKernel => {} + ExternAbi::C { unwind: _ } + if matches!(&*tcx.sess.target.arch, "wasm32" | "wasm64") => {} + _ => { + panic!( + "`PassMode::Direct` for aggregates only allowed for \"unadjusted\" and \"ptx-kernel\" functions and on wasm\n\ + Problematic type: {:#?}", + arg.layout, + ); + } + } } } } |
