diff options
| author | Ralf Jung <post@ralfj.de> | 2023-09-07 16:04:22 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-09-08 09:14:07 +0200 |
| commit | 28d152935e5f62ecbb6d2c99865de39c1993189b (patch) | |
| tree | 7acba234280ede7f7cddc6d14d89b1d1a36f0672 /compiler/rustc_codegen_llvm/src | |
| parent | 243ef313a52835e5e980ffcc2a6d3cfce849e33d (diff) | |
| download | rust-28d152935e5f62ecbb6d2c99865de39c1993189b.tar.gz rust-28d152935e5f62ecbb6d2c99865de39c1993189b.zip | |
the wasm ABI behavior is a bug
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/abi.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 1e72b7db1e4..64587f98b8a 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -351,15 +351,12 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { // guarnateeing that we generate ABI-compatible LLVM IR. Things get tricky for // aggregates... if matches!(arg.layout.abi, abi::Abi::Aggregate { .. }) { - // This is the most critical case for ABI compatibility, since - // `immediate_llvm_type` will use `layout.fields` to turn this Rust type - // into an LLVM type. ABI-compatible Rust types can have different `fields`, - // so we need to be very sure that LLVM wil treat those different types in - // an ABI-compatible way. Mostly we do this by disallowing - // `PassMode::Direct` for aggregates, but we actually do use that mode on - // wasm. wasm doesn't have aggregate types so we are fairly sure that LLVM - // will treat `{ i32, i32, i32 }` and `{ { i32, i32, i32 } }` the same way - // for ABI purposes. + // This really shouldn't happen, 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>.) assert!( matches!(&*cx.tcx.sess.target.arch, "wasm32" | "wasm64"), "`PassMode::Direct` for aggregates only allowed on wasm targets\nProblematic type: {:#?}", |
