Skip to content

Commit

Permalink
Only allow PassMode::Direct for aggregates on wasm when using the C ABI
Browse files Browse the repository at this point in the history
For the Rust ABI we don't have any ABI compat reasons to allow
PassMode::Direct for aggregates.
  • Loading branch information
bjorn3 committed Dec 5, 2024
1 parent 0e98766 commit 6ed4038
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions compiler/rustc_ty_utils/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,13 +480,22 @@ fn fn_abi_sanity_check<'tcx>(
// 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,
);

match spec_abi {
// The unadjusted ABI is ill specified, but unfortunately we need it for
// calling certain LLVM intrinsics.
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,
);
}
}
}
}
}
Expand Down

0 comments on commit 6ed4038

Please sign in to comment.