Repository navigation
unit and [1 x unit] layouts are incompatible on big-endian targets - #163343
Conversation
1e606f5 to
8c080e2
Compare
This comment has been minimized.
This comment has been minimized.
8c080e2 to
7b90831
Compare
|
LLVM ABI continues to be a treasure trove... @nikic is this expected behavior? |
|
I think so? LLVM doesn't seem to be doing anything particularly interesting here. If the psABI says that a float and a 1-element float HFA have different ABI, then... that's just how it is. https://clang.godbolt.org/z/TMec497aj just to double check that Clang and GCC agree on the ABI here. |
|
|
This comment has been minimized.
This comment has been minimized.
`unit` and `[1 x unit]` layouts are incompatible on big-endian targets try-job: test-various
|
Reminder, once the PR becomes ready for a review, use |
7b90831 to
29b40c3
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot ready Added an llvm IR test (just like the others), assuming that is what you meant? |
|
I was thinking an assembly LLVM test that would fail if #[repr(C)]
struct Hfa(f32);
#[unsafe(no_mangle)]
extern "C" fn float_hfa(_: f32, _: f32, _: f32, _: f32, _: f32, _: f32, _: f32, _: f32, x: Hfa) -> f32 {
// CHECK-LABEL: float_hfa
// CHECK: ldr s0, [sp]
x.0
}for AArch64 BE and the equivalent for PowerPC64. @rustbot author |
so don't unwrap singleton arrays for it
29b40c3 to
b1a3475
Compare
There was a problem hiding this comment.
|
Thanks. @bors r+ rollup |
… r=beetrees `unit` and `[1 x unit]` layouts are incompatible on big-endian targets cc @beetrees @RalfJung Observe https://godbolt.org/z/G6qrdT1Ez ```llvm target triple = "aarch64_be" define float @Unit([8 x float] %claim_all_regs, float %x) { ret float %x } define float @array([8 x float] %claim_all_regs, [1 x float] %x) { %v = extractvalue [1 x float] %x, 0 ret float %v } ``` results in ```asm unit: // @Unit ldr s0, [sp, rust-lang#4] ret array: // @array ldr s0, [sp] ret ``` So the value is stored in different halves of the register-sized stack slot when it is `unit` versus `[1 x unit]`. --- On `powerpc64` (also a big-endian target) the layouts are also not equivalent: https://godbolt.org/z/szfr6xPM7 in this case we want the bare `float` semantics https://godbolt.org/z/vGKczqzcE No other big-endian targets use `Uniform::consecutive` from what I can tell. --- Maybe there is a better way to fix this? Like guarding on endianness if we really want the simpler LLVM type on LE.
…uwer Rollup of 25 pull requests Successful merges: - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI) - #163806 (even more `tests/crashes` migration for `-Znext-solver`) - #162156 (add IBM f128 type) - #163508 (Document the `rustc_on_unimplemented` attribute.) - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`) - #163863 (use the type name instead of `Self` in constructor paths again) - #163864 (Remove CLAUDE.md) - #163877 (Add regression test for duplicated rustdoc search results between std and core) - #163916 (Shrink `PartialRes` and its alignment) - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error) - #152557 (Oneshot `is_ready`) - #157273 (Stabilize `optimize` attribute) - #162000 (peel_transparent_wrappers only works on non-1ZST) - #163257 (abby DSL: sanity checks on forall where clauses) - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets) - #163348 (perf:cache FFI safety results in improper_ctypes lint) - #163768 (Move more `rustdoc-html` tests in the right location) - #163778 (check is_indirect_first_projection when replacing in RefProp) - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places) - #163807 (Add `has_reliable_f16b` for Arm) - #163809 (Switch TLS implementation for wasi and bump SDK version to 34) - #163826 (Update books) - #163849 (ci: update to PowerShell 7.6.6) - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section) - #163870 (Add if-installed:auto:spellcheck to pre-push script)
… r=beetrees `unit` and `[1 x unit]` layouts are incompatible on big-endian targets cc @beetrees @RalfJung Observe https://godbolt.org/z/G6qrdT1Ez ```llvm target triple = "aarch64_be" define float @Unit([8 x float] %claim_all_regs, float %x) { ret float %x } define float @array([8 x float] %claim_all_regs, [1 x float] %x) { %v = extractvalue [1 x float] %x, 0 ret float %v } ``` results in ```asm unit: // @Unit ldr s0, [sp, rust-lang#4] ret array: // @array ldr s0, [sp] ret ``` So the value is stored in different halves of the register-sized stack slot when it is `unit` versus `[1 x unit]`. --- On `powerpc64` (also a big-endian target) the layouts are also not equivalent: https://godbolt.org/z/szfr6xPM7 in this case we want the bare `float` semantics https://godbolt.org/z/vGKczqzcE No other big-endian targets use `Uniform::consecutive` from what I can tell. --- Maybe there is a better way to fix this? Like guarding on endianness if we really want the simpler LLVM type on LE.
…uwer Rollup of 24 pull requests Successful merges: - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI) - #163806 (even more `tests/crashes` migration for `-Znext-solver`) - #163508 (Document the `rustc_on_unimplemented` attribute.) - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`) - #163863 (use the type name instead of `Self` in constructor paths again) - #163864 (Remove CLAUDE.md) - #163877 (Add regression test for duplicated rustdoc search results between std and core) - #163916 (Shrink `PartialRes` and its alignment) - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error) - #152557 (Oneshot `is_ready`) - #157273 (Stabilize `optimize` attribute) - #162000 (peel_transparent_wrappers only works on non-1ZST) - #163257 (abby DSL: sanity checks on forall where clauses) - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets) - #163348 (perf:cache FFI safety results in improper_ctypes lint) - #163768 (Move more `rustdoc-html` tests in the right location) - #163778 (check is_indirect_first_projection when replacing in RefProp) - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places) - #163807 (Add `has_reliable_f16b` for Arm) - #163809 (Switch TLS implementation for wasi and bump SDK version to 34) - #163826 (Update books) - #163849 (ci: update to PowerShell 7.6.6) - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section) - #163870 (Add if-installed:auto:spellcheck to pre-push script)
…uwer Rollup of 24 pull requests Successful merges: - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI) - #163806 (even more `tests/crashes` migration for `-Znext-solver`) - #163508 (Document the `rustc_on_unimplemented` attribute.) - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`) - #163863 (use the type name instead of `Self` in constructor paths again) - #163864 (Remove CLAUDE.md) - #163877 (Add regression test for duplicated rustdoc search results between std and core) - #163916 (Shrink `PartialRes` and its alignment) - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error) - #152557 (Oneshot `is_ready`) - #157273 (Stabilize `optimize` attribute) - #162000 (peel_transparent_wrappers only works on non-1ZST) - #163257 (abby DSL: sanity checks on forall where clauses) - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets) - #163348 (perf:cache FFI safety results in improper_ctypes lint) - #163768 (Move more `rustdoc-html` tests in the right location) - #163778 (check is_indirect_first_projection when replacing in RefProp) - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places) - #163807 (Add `has_reliable_f16b` for Arm) - #163809 (Switch TLS implementation for wasi and bump SDK version to 34) - #163826 (Update books) - #163849 (ci: update to PowerShell 7.6.6) - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section) - #163870 (Add if-installed:auto:spellcheck to pre-push script)
…uwer Rollup of 24 pull requests Successful merges: - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI) - #163806 (even more `tests/crashes` migration for `-Znext-solver`) - #163508 (Document the `rustc_on_unimplemented` attribute.) - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`) - #163863 (use the type name instead of `Self` in constructor paths again) - #163864 (Remove CLAUDE.md) - #163877 (Add regression test for duplicated rustdoc search results between std and core) - #163916 (Shrink `PartialRes` and its alignment) - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error) - #152557 (Oneshot `is_ready`) - #157273 (Stabilize `optimize` attribute) - #162000 (peel_transparent_wrappers only works on non-1ZST) - #163257 (abby DSL: sanity checks on forall where clauses) - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets) - #163348 (perf:cache FFI safety results in improper_ctypes lint) - #163768 (Move more `rustdoc-html` tests in the right location) - #163778 (check is_indirect_first_projection when replacing in RefProp) - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places) - #163807 (Add `has_reliable_f16b` for Arm) - #163809 (Switch TLS implementation for wasi and bump SDK version to 34) - #163826 (Update books) - #163849 (ci: update to PowerShell 7.6.6) - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section) - #163870 (Add if-installed:auto:spellcheck to pre-push script)
…uwer Rollup of 24 pull requests Successful merges: - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI) - #163806 (even more `tests/crashes` migration for `-Znext-solver`) - #163508 (Document the `rustc_on_unimplemented` attribute.) - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`) - #163863 (use the type name instead of `Self` in constructor paths again) - #163864 (Remove CLAUDE.md) - #163877 (Add regression test for duplicated rustdoc search results between std and core) - #163916 (Shrink `PartialRes` and its alignment) - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error) - #152557 (Oneshot `is_ready`) - #157273 (Stabilize `optimize` attribute) - #162000 (peel_transparent_wrappers only works on non-1ZST) - #163257 (abby DSL: sanity checks on forall where clauses) - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets) - #163348 (perf:cache FFI safety results in improper_ctypes lint) - #163768 (Move more `rustdoc-html` tests in the right location) - #163778 (check is_indirect_first_projection when replacing in RefProp) - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places) - #163807 (Add `has_reliable_f16b` for Arm) - #163809 (Switch TLS implementation for wasi and bump SDK version to 34) - #163826 (Update books) - #163849 (ci: update to PowerShell 7.6.6) - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section) - #163870 (Add if-installed:auto:spellcheck to pre-push script)
…uwer Rollup of 23 pull requests Successful merges: - #163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI) - #163806 (even more `tests/crashes` migration for `-Znext-solver`) - #163508 (Document the `rustc_on_unimplemented` attribute.) - #163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`) - #163863 (use the type name instead of `Self` in constructor paths again) - #163864 (Remove CLAUDE.md) - #163877 (Add regression test for duplicated rustdoc search results between std and core) - #163916 (Shrink `PartialRes` and its alignment) - #149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error) - #152557 (Oneshot `is_ready`) - #157273 (Stabilize `optimize` attribute) - #162000 (peel_transparent_wrappers only works on non-1ZST) - #163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets) - #163348 (perf:cache FFI safety results in improper_ctypes lint) - #163768 (Move more `rustdoc-html` tests in the right location) - #163778 (check is_indirect_first_projection when replacing in RefProp) - #163789 (cg_llvm: Avoid `as_c_char_ptr` in several places) - #163807 (Add `has_reliable_f16b` for Arm) - #163809 (Switch TLS implementation for wasi and bump SDK version to 34) - #163826 (Update books) - #163849 (ci: update to PowerShell 7.6.6) - #163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section) - #163870 (Add if-installed:auto:spellcheck to pre-push script)
Rollup merge of #163343 - folkertdev:abi-array-incompatible, r=beetrees `unit` and `[1 x unit]` layouts are incompatible on big-endian targets cc @beetrees @RalfJung Observe https://godbolt.org/z/G6qrdT1Ez ```llvm target triple = "aarch64_be" define float @Unit([8 x float] %claim_all_regs, float %x) { ret float %x } define float @array([8 x float] %claim_all_regs, [1 x float] %x) { %v = extractvalue [1 x float] %x, 0 ret float %v } ``` results in ```asm unit: // @Unit ldr s0, [sp, #4] ret array: // @array ldr s0, [sp] ret ``` So the value is stored in different halves of the register-sized stack slot when it is `unit` versus `[1 x unit]`. --- On `powerpc64` (also a big-endian target) the layouts are also not equivalent: https://godbolt.org/z/szfr6xPM7 in this case we want the bare `float` semantics https://godbolt.org/z/vGKczqzcE No other big-endian targets use `Uniform::consecutive` from what I can tell. --- Maybe there is a better way to fix this? Like guarding on endianness if we really want the simpler LLVM type on LE.
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (90495a8): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Artifact size: 408.59 MiB -> 408.68 MiB (0.02%) |
|
This is noise, all PRs in the rollup have the same results |
…uwer Rollup of 23 pull requests Successful merges: - rust-lang/rust#163090 (Run LLDB debuginfo tests on `x86_64-pc-windows-msvc` in CI) - rust-lang/rust#163806 (even more `tests/crashes` migration for `-Znext-solver`) - rust-lang/rust#163508 (Document the `rustc_on_unimplemented` attribute.) - rust-lang/rust#163794 (Use `target_family = "wasm"` instead of `target_arch = "wasm32"`) - rust-lang/rust#163863 (use the type name instead of `Self` in constructor paths again) - rust-lang/rust#163864 (Remove CLAUDE.md) - rust-lang/rust#163877 (Add regression test for duplicated rustdoc search results between std and core) - rust-lang/rust#163916 (Shrink `PartialRes` and its alignment) - rust-lang/rust#149753 (On name resolution error in parameter list, suggest possible `const` typo and avoid unnecessary second error) - rust-lang/rust#152557 (Oneshot `is_ready`) - rust-lang/rust#157273 (Stabilize `optimize` attribute) - rust-lang/rust#162000 (peel_transparent_wrappers only works on non-1ZST) - rust-lang/rust#163343 (`unit` and `[1 x unit]` layouts are incompatible on big-endian targets) - rust-lang/rust#163348 (perf:cache FFI safety results in improper_ctypes lint) - rust-lang/rust#163768 (Move more `rustdoc-html` tests in the right location) - rust-lang/rust#163778 (check is_indirect_first_projection when replacing in RefProp) - rust-lang/rust#163789 (cg_llvm: Avoid `as_c_char_ptr` in several places) - rust-lang/rust#163807 (Add `has_reliable_f16b` for Arm) - rust-lang/rust#163809 (Switch TLS implementation for wasi and bump SDK version to 34) - rust-lang/rust#163826 (Update books) - rust-lang/rust#163849 (ci: update to PowerShell 7.6.6) - rust-lang/rust#163869 (INSTALL.md: use UCRT64 instead of MINGW64 in MSYS2 section) - rust-lang/rust#163870 (Add if-installed:auto:spellcheck to pre-push script)
cc @beetrees @RalfJung
Observe
https://godbolt.org/z/G6qrdT1Ez
results in
So the value is stored in different halves of the register-sized stack slot when it is
unitversus[1 x unit].On
powerpc64(also a big-endian target) the layouts are also not equivalent:https://godbolt.org/z/szfr6xPM7
in this case we want the bare
floatsemanticshttps://godbolt.org/z/vGKczqzcE
No other big-endian targets use
Uniform::consecutivefrom what I can tell.Maybe there is a better way to fix this? Like guarding on endianness if we really want the simpler LLVM type on LE.