rust/tests
Jakub Beránek 4479d42d60
Rollup merge of #139340 - beetrees:riscv-float-struct-abi, r=workingjubilee
Fix RISC-V C function ABI when passing/returning structs containing floats

RISC-V passes structs containing only one or two floats (or a float and integer pair) in registers, as long as the individual floats/integers fit in a single corresponding register (see [the ABI specification](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/releases/download/v1.0/riscv-abi.pdf) for details). Before this PR, Rust would not check what offset the second float/integer was at, instead assuming that it was at the standard offset for its default alignment. However, as the offset can be affected by `#[repr(align(N))]` and `#[repr(packed)]`, this caused miscompilations (see #115609). To fix this, this PR introduces a `rest_offset` field to `CastTarget` that can be used to explicitly specify at what offset the `rest` part of the cast is located at.

While fixing this, I discovered another bug: the size of the cast target was being used as the size of the MIR return place (when the function was using a `PassMode::Cast` return type). However, the cast target is allowed to be smaller than the size of the actual type, causing a miscompilation. This PR fixes this issue by using the largest of the size of the type and the size of the cast target as the size of the MIR return place, ensuring all reads/writes will be inbounds.

Fixes the RISC-V part of #115609.

cc target maintainers of `riscv64gc-unknown-linux-gnu`: `@kito-cheng` `@michaelmaitland` `@robin-randhawa-sifive` `@topperc`

r? `@workingjubilee`
2025-06-16 19:54:32 +02:00
..
assembly Fix RISC-V C function ABI when passing/returning structs containing floats 2025-06-16 10:14:07 +01:00
auxiliary stabilize naked_functions 2025-04-20 11:18:38 +02:00
codegen Fix RISC-V C function ABI when passing/returning structs containing floats 2025-06-16 10:14:07 +01:00
codegen-units Remove mono item collection strategy override from -Zprint-mono-items 2025-05-09 12:19:09 +02:00
coverage coverage: Revert "unused local file IDs" due to empty function names 2025-05-27 23:33:29 +10:00
coverage-run-rustdoc
crashes Rollup merge of #142347 - azhogin:azhogin/async-drop-storage-live-dead-fix, r=oli-obk 2025-06-15 23:51:56 +02:00
debuginfo tests: Change "fastcall" to "system" in some tests 2025-06-09 16:10:21 -07:00
incremental tests: Change "fastcall" to "system" in some tests 2025-06-09 16:10:21 -07:00
mir-opt Rollup merge of #142347 - azhogin:azhogin/async-drop-storage-live-dead-fix, r=oli-obk 2025-06-15 23:51:56 +02:00
pretty Rollup merge of #134847 - dtolnay:asymmetrical, r=fmease 2025-06-13 05:16:54 +02:00
run-make Rollup merge of #142297 - jieyouxu:needs-target-std, r=Kobzol 2025-06-11 13:48:11 +02:00
rustdoc Auto merge of #142443 - matthiaskrgr:rollup-l1l6d0v, r=matthiaskrgr 2025-06-13 17:44:15 +00:00
rustdoc-gui Rollup merge of #139831 - lolbinarycat:rustdoc-mobile-sidebar, r=GuillaumeGomez 2025-05-25 04:00:55 +02:00
rustdoc-js yeet CanonicalVarInfo 2025-05-23 12:10:53 +00:00
rustdoc-js-std Consistent trait bounds for ExtractIf Debug impls 2025-05-05 19:46:46 -07:00
rustdoc-json rustdoc-json: Rearrange deck chairs in ABI testing 2025-06-09 16:11:06 -07:00
rustdoc-ui Add new extracted option doctest ui test for result returning doctest 2025-06-10 13:54:47 +02:00
ui Fix RISC-V C function ABI when passing/returning structs containing floats 2025-06-16 10:14:07 +01:00
ui-fulldeps Fix test description 2025-06-16 10:51:59 +03:00
COMPILER_TESTS.md