sparc: make ABI consistent with clang - #160401
Conversation
|
r? workingjubilee (who else lol) This is totally tier 3, but if we have it, it should be correct. |
|
|
|
I will dig out my TSIM3 licence and double check this on the LEON3 simulator. I'm pinging @glaubitz who knows more about the 64-bit SPARC Linux side than I do. (Also, |
|
Neat, to be clear I validated the changes with qemu, clang and gcc 16.
The changes here only touch 32-bit SPARC, and the ABI is, from what I can tell, quite different to SPARC64. |
There was a problem hiding this comment.
Since this PR is to fix the SPARC struct ABI could you add "Fixes: #43894"?
There was a problem hiding this comment.
Since this PR is to fix the SPARC struct ABI could you add "Fixes: #43894"?
added, but also wow from 2017 huh
ccdb6c7 to
4873fa1
Compare
|
Do our SPARC Linux and SPARC bare-metal targets have the same ABI? Bare metal SPARC is aimed at the LEON3 but I think SPARC Linux is for 32 bit applications for 64 bit SPARC machines? Which QEMU machine did you test with? |
|
LLVM does not take the OS into account at all My config is [target.sparc-unknown-linux-gnu]
runner = "qemu-sparc32plus -L /usr/sparc-linux-gnu"So that runs the v9-flavored v8, at least based on https://stackoverflow.com/questions/23506538/what-is-em-sparc32plus-for. That is needed because we configure the To clarify: I believe this uses V9 instructions (or something like it), but still uses the V8 abi. |
|
I don't think so, no. At least, sparc-unknown-none-elf does not set v8plus which I think means it uses a different ABI. |
|
#160562 adds a rustc_abi toggle for v8plus. |
|
I tried testing with Gaisler's version of clang for LEON3, but it didn't even support __float128. |
|
could we add a sparc-linux revision to tests/ui/abi/c-zst.rs? the ZST commit (sparc: pass ZST arguments) only changes sparc.rs and adds no test. the tests added in the later commits cover f128 and aggregates, but not ZSTs, so this part currently has no in-tree regression test compatibility.rs does run for SPARC, but its standalone-ZST checks only compare ZSTs with other ABI-equivalent ZSTs, so they pass whether those arguments are all Ignore or all Indirect. c-zst.rs already checks the indirect argument FnAbi for powerpc, s390x, sparc64 and x86_64-pc-windows-gnu testing only sparc-unknown-linux-gnu would keep the test on the Linux V8+ target you validated, without pinning any behavior for sparc-unknown-none-elf |
4873fa1 to
2518d95
Compare
This comment has been minimized.
This comment has been minimized.
2518d95 to
3821a92
Compare
This comment has been minimized.
This comment has been minimized.
3821a92 to
2a9a885
Compare
What is I've added the additional ABI tests, so this should be good to go. |
|
|
sparc: make ABI consistent with clang fixes #43894 I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation. For reference - [`SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/Targets/Sparc.cpp#L34-L59) - [`DefaultABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/ABIInfoImpl.cpp#L17-L68) ## Pass ZST arguments https://godbolt.org/z/P7KoqTWvr The `sparc` ABI does not skip zero-sized arguments. ## Pass and return `f128` (i.e. `long double`) indirectly The `long double` type, which corresponds to rust `f128`, is special-cased, it uses `getNaturalAlignIndirect` for both arguments and returns. ## pass aggregate arguments by reference https://godbolt.org/z/hM8Gh1bfY The implementation defers to `DefaultABIInfo::{classifyReturnType, classifyArgumentType}`, which use `byval` and `sret` for aggregate types.
…rees sparc: make ABI consistent with clang fixes rust-lang#43894 I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation. For reference - [`SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/Targets/Sparc.cpp#L34-L59) - [`DefaultABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/ABIInfoImpl.cpp#L17-L68) ## Pass ZST arguments https://godbolt.org/z/P7KoqTWvr The `sparc` ABI does not skip zero-sized arguments. ## Pass and return `f128` (i.e. `long double`) indirectly The `long double` type, which corresponds to rust `f128`, is special-cased, it uses `getNaturalAlignIndirect` for both arguments and returns. ## pass aggregate arguments by reference https://godbolt.org/z/hM8Gh1bfY The implementation defers to `DefaultABIInfo::{classifyReturnType, classifyArgumentType}`, which use `byval` and `sret` for aggregate types.
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #162973. |
…uwer Rollup of 14 pull requests Successful merges: - #160401 (sparc: make ABI consistent with clang) - #161777 (Add Natvis visualiser and debuginfo tests for `f128`) - #162740 (stdarch subtree update) - #162824 (link Enzyme and the offload with in-tree lld if possible) - #161005 (fix: unfulfilled nested dead code lint) - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase) - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch) - #162661 (simplify `Target::GenericParam`) - #162666 (Tidy footnote in `platform-support.md`) - #162803 (docs(num): add documentation for `NonZero::from_str`) - #162906 (Move more `rustdoc-html` tests in the right location) - #162922 (An assortment of polonius tweaks) - #162929 (Update unicode_data to Unicode version 18.0.0) - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound)
…rees sparc: make ABI consistent with clang fixes rust-lang#43894 I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation. For reference - [`SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/Targets/Sparc.cpp#L34-L59) - [`DefaultABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/ABIInfoImpl.cpp#L17-L68) ## Pass ZST arguments https://godbolt.org/z/P7KoqTWvr The `sparc` ABI does not skip zero-sized arguments. ## Pass and return `f128` (i.e. `long double`) indirectly The `long double` type, which corresponds to rust `f128`, is special-cased, it uses `getNaturalAlignIndirect` for both arguments and returns. ## pass aggregate arguments by reference https://godbolt.org/z/hM8Gh1bfY The implementation defers to `DefaultABIInfo::{classifyReturnType, classifyArgumentType}`, which use `byval` and `sret` for aggregate types.
…rees sparc: make ABI consistent with clang fixes rust-lang#43894 I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation. For reference - [`SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/Targets/Sparc.cpp#L34-L59) - [`DefaultABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/ABIInfoImpl.cpp#L17-L68) ## Pass ZST arguments https://godbolt.org/z/P7KoqTWvr The `sparc` ABI does not skip zero-sized arguments. ## Pass and return `f128` (i.e. `long double`) indirectly The `long double` type, which corresponds to rust `f128`, is special-cased, it uses `getNaturalAlignIndirect` for both arguments and returns. ## pass aggregate arguments by reference https://godbolt.org/z/hM8Gh1bfY The implementation defers to `DefaultABIInfo::{classifyReturnType, classifyArgumentType}`, which use `byval` and `sret` for aggregate types.
…uwer Rollup of 20 pull requests Successful merges: - #160401 (sparc: make ABI consistent with clang) - #162715 (don't calculate dtors if the self ty has impossible bounds) - #162740 (stdarch subtree update) - #162824 (link Enzyme and the offload with in-tree lld if possible) - #162946 (Simplify query stack printing) - #161005 (fix: unfulfilled nested dead code lint) - #161246 (Normalize non-rigid aliases in ty_known_to_outlive) - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase) - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch) - #162661 (simplify `Target::GenericParam`) - #162666 (Tidy footnote in `platform-support.md`) - #162803 (docs(num): add documentation for `NonZero::from_str`) - #162879 (use u64 limbs in core::num::bignum) - #162903 (PassWrapper: adapt to LLVM reading exception model from module flag) - #162905 (c-variadic: add checks for windows i686) - #162906 (Move more `rustdoc-html` tests in the right location) - #162922 (An assortment of polonius tweaks) - #162929 (Update unicode_data to Unicode version 18.0.0) - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound) - #162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
|
⌛ Testing commit e8534c6 with merge 404a5c7... Workflow: https://github.com/rust-lang/rust/actions/runs/35394398078 |
sparc: make ABI consistent with clang fixes #43894 I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation. For reference - [`SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/Targets/Sparc.cpp#L34-L59) - [`DefaultABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/ABIInfoImpl.cpp#L17-L68) ## Pass ZST arguments https://godbolt.org/z/P7KoqTWvr The `sparc` ABI does not skip zero-sized arguments. ## Pass and return `f128` (i.e. `long double`) indirectly The `long double` type, which corresponds to rust `f128`, is special-cased, it uses `getNaturalAlignIndirect` for both arguments and returns. ## pass aggregate arguments by reference https://godbolt.org/z/hM8Gh1bfY The implementation defers to `DefaultABIInfo::{classifyReturnType, classifyArgumentType}`, which use `byval` and `sret` for aggregate types.
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #162499. |
|
⌛ Testing commit e8534c6 with merge 39ac449... Workflow: https://github.com/rust-lang/rust/actions/runs/35394981074 |
sparc: make ABI consistent with clang fixes #43894 I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation. For reference - [`SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/Targets/Sparc.cpp#L34-L59) - [`DefaultABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/ABIInfoImpl.cpp#L17-L68) ## Pass ZST arguments https://godbolt.org/z/P7KoqTWvr The `sparc` ABI does not skip zero-sized arguments. ## Pass and return `f128` (i.e. `long double`) indirectly The `long double` type, which corresponds to rust `f128`, is special-cased, it uses `getNaturalAlignIndirect` for both arguments and returns. ## pass aggregate arguments by reference https://godbolt.org/z/hM8Gh1bfY The implementation defers to `DefaultABIInfo::{classifyReturnType, classifyArgumentType}`, which use `byval` and `sret` for aggregate types.
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #162989. |
…uwer Rollup of 19 pull requests Successful merges: - #160401 (sparc: make ABI consistent with clang) - #162715 (don't calculate dtors if the self ty has impossible bounds) - #162740 (stdarch subtree update) - #162946 (Simplify query stack printing) - #161005 (fix: unfulfilled nested dead code lint) - #161246 (Normalize non-rigid aliases in ty_known_to_outlive) - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase) - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch) - #162661 (simplify `Target::GenericParam`) - #162666 (Tidy footnote in `platform-support.md`) - #162803 (docs(num): add documentation for `NonZero::from_str`) - #162879 (use u64 limbs in core::num::bignum) - #162903 (PassWrapper: adapt to LLVM reading exception model from module flag) - #162905 (c-variadic: add checks for windows i686) - #162906 (Move more `rustdoc-html` tests in the right location) - #162922 (An assortment of polonius tweaks) - #162929 (Update unicode_data to Unicode version 18.0.0) - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound) - #162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
|
⌛ Testing commit e8534c6 with merge dc4794c... Workflow: https://github.com/rust-lang/rust/actions/runs/35396727322 |
sparc: make ABI consistent with clang fixes #43894 I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation. For reference - [`SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/Targets/Sparc.cpp#L34-L59) - [`DefaultABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/ABIInfoImpl.cpp#L17-L68) ## Pass ZST arguments https://godbolt.org/z/P7KoqTWvr The `sparc` ABI does not skip zero-sized arguments. ## Pass and return `f128` (i.e. `long double`) indirectly The `long double` type, which corresponds to rust `f128`, is special-cased, it uses `getNaturalAlignIndirect` for both arguments and returns. ## pass aggregate arguments by reference https://godbolt.org/z/hM8Gh1bfY The implementation defers to `DefaultABIInfo::{classifyReturnType, classifyArgumentType}`, which use `byval` and `sret` for aggregate types.
|
@bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #162989. |
…uwer Rollup of 19 pull requests Successful merges: - #160401 (sparc: make ABI consistent with clang) - #162715 (don't calculate dtors if the self ty has impossible bounds) - #162740 (stdarch subtree update) - #162946 (Simplify query stack printing) - #161005 (fix: unfulfilled nested dead code lint) - #161246 (Normalize non-rigid aliases in ty_known_to_outlive) - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase) - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch) - #162661 (simplify `Target::GenericParam`) - #162666 (Tidy footnote in `platform-support.md`) - #162803 (docs(num): add documentation for `NonZero::from_str`) - #162879 (use u64 limbs in core::num::bignum) - #162903 (PassWrapper: adapt to LLVM reading exception model from module flag) - #162905 (c-variadic: add checks for windows i686) - #162906 (Move more `rustdoc-html` tests in the right location) - #162922 (An assortment of polonius tweaks) - #162929 (Update unicode_data to Unicode version 18.0.0) - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound) - #162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
Rollup merge of #160401 - folkertdev:sparc-abi-fixes, r=beetrees sparc: make ABI consistent with clang fixes #43894 I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation. For reference - [`SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/Targets/Sparc.cpp#L34-L59) - [`DefaultABIInfo::{classifyArgumentType, classifyReturnType}`](https://github.com/llvm/llvm-project/blob/6849789a8fa1fc4a09f4f81dc655235e648eb15a/clang/lib/CodeGen/ABIInfoImpl.cpp#L17-L68) ## Pass ZST arguments https://godbolt.org/z/P7KoqTWvr The `sparc` ABI does not skip zero-sized arguments. ## Pass and return `f128` (i.e. `long double`) indirectly The `long double` type, which corresponds to rust `f128`, is special-cased, it uses `getNaturalAlignIndirect` for both arguments and returns. ## pass aggregate arguments by reference https://godbolt.org/z/hM8Gh1bfY The implementation defers to `DefaultABIInfo::{classifyReturnType, classifyArgumentType}`, which use `byval` and `sret` for aggregate types.
…uwer Rollup of 19 pull requests Successful merges: - rust-lang/rust#160401 (sparc: make ABI consistent with clang) - rust-lang/rust#162715 (don't calculate dtors if the self ty has impossible bounds) - rust-lang/rust#162740 (stdarch subtree update) - rust-lang/rust#162946 (Simplify query stack printing) - rust-lang/rust#161005 (fix: unfulfilled nested dead code lint) - rust-lang/rust#161246 (Normalize non-rigid aliases in ty_known_to_outlive) - rust-lang/rust#161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase) - rust-lang/rust#162256 (Add mentions to sync back `RELEASES.md` to the `main` branch) - rust-lang/rust#162661 (simplify `Target::GenericParam`) - rust-lang/rust#162666 (Tidy footnote in `platform-support.md`) - rust-lang/rust#162803 (docs(num): add documentation for `NonZero::from_str`) - rust-lang/rust#162879 (use u64 limbs in core::num::bignum) - rust-lang/rust#162903 (PassWrapper: adapt to LLVM reading exception model from module flag) - rust-lang/rust#162905 (c-variadic: add checks for windows i686) - rust-lang/rust#162906 (Move more `rustdoc-html` tests in the right location) - rust-lang/rust#162922 (An assortment of polonius tweaks) - rust-lang/rust#162929 (Update unicode_data to Unicode version 18.0.0) - rust-lang/rust#162930 (Use niche length type for strlen to guarantee `isize::MAX` bound) - rust-lang/rust#162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
View all comments
fixes #43894
I've hacked together a version of abi-cafe that can cross-compile. It finds many GCC vs. Clang inconsistencies, but for this target it found 3 ABI bugs that are specific to the rust implementation.
For reference
SparcV8ABIInfo::{classifyArgumentType, classifyReturnType}DefaultABIInfo::{classifyArgumentType, classifyReturnType}Pass ZST arguments
https://godbolt.org/z/P7KoqTWvr
The
sparcABI does not skip zero-sized arguments.Pass and return
f128(i.e.long double) indirectlyThe
long doubletype, which corresponds to rustf128, is special-cased, it usesgetNaturalAlignIndirectfor both arguments and returns.pass aggregate arguments by reference
https://godbolt.org/z/hM8Gh1bfY
The implementation defers to
DefaultABIInfo::{classifyReturnType, classifyArgumentType}, which usebyvalandsretfor aggregate types.