Fix passing/returning structs with the 64-bit SPARC ABI#142680
Fix passing/returning structs with the 64-bit SPARC ABI#142680beetrees wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
|
|
r? @bjorn3 |
|
Note that there are currently two places that Clang and GCC disagree AFAIK:
|
|
Thank you for doing this! My knowledge in this area is rather limited. I was able to build latest Rust sources with your fix on top on Solaris 11.4 SPARC. Then I used this version to build Firefox on Solaris. There was no problem. Firefox also worked as expected. I also tested some problematic cases which I was handling few years ago (https://github.com/psumbera/rust-sparc64-abi-tests). All seemed to be ok. |
|
I don't have time to properly review this right now. r? compiler |
|
☔ The latest upstream changes (presumably #143521) made this pull request unmergeable. Please resolve the merge conflicts. |
4eb3ce5 to
9e4a7bc
Compare
|
Rebased |
|
☔ The latest upstream changes (presumably #144249) made this pull request unmergeable. Please resolve the merge conflicts. |
9e4a7bc to
b7b3ed7
Compare
|
Hi @workingjubilee, are you still interested in reviewing this? If not, we can reroll for a different reviewer. Thanks! |
|
Looks like there is a Clang fix in llvm/llvm-project#155829 |
|
Sorry about that, currently in catchup mode so I am going to delegate, yes. r? @tgross35 |
b7b3ed7 to
7cba46f
Compare
This comment has been minimized.
This comment has been minimized.
7cba46f to
b2e4ee9
Compare
This comment has been minimized.
This comment has been minimized.
| if let [Some(reg), None, ..] = regs { | ||
| arg.cast_to_and_pad_i32(CastTarget::from(reg).with_attrs(attrs.into()), pad); | ||
| } else { | ||
| arg.cast_to_and_pad_i32( | ||
| CastTarget::prefixed(regs, Uniform::new(Reg::i8(), Size::ZERO)) | ||
| .with_attrs(attrs.into()), | ||
| pad, | ||
| ); | ||
| } |
There was a problem hiding this comment.
Could you add a note about why the Some(reg), None case is special?
| _ => { | ||
| if let BackendRepr::ScalarPair(scalar1, scalar2) = &layout.backend_repr { | ||
| data = arg_scalar_pair(cx, scalar1, scalar2, offset, data); | ||
| _ => {} |
There was a problem hiding this comment.
What happens in the fallback case where offset isn't aligned?
| }, | ||
| Size::ZERO, | ||
| ); | ||
| let mut double_words = [DoubleWord::Words([Word::Integer; 2]); 4]; |
There was a problem hiding this comment.
Could you note where the length 4 comes from, or put it in a const? Assuming 8 word-sized registers for arg passing.
|
Reminder, once the PR becomes ready for a review, use |
|
@psumbera if you have access to a sparc machine, any chance you could run https://github.com/Gankra/abi-cafe with and without this PR as a sanity check? You should be able to clone the repo and run It picks the first rustc/gcc/cc/clang so I think it needs to be run with Edit: looks like packed structs may not work yet Gankra/abi-cafe#33. Still a valuable test._ |
|
The LLVM fix llvm/llvm-project#155829 has gone into main and I am going to see about backporting to 21. |
Not sure how to analyze it. But Generally I would suggest to use for tests: https://portal.cfarm.net/machines/list/ (cfarm216). This is latest Solaris (SPARC-M8). I'm ready to help and provide full logs somewhere or anything. Here are just few tests which are newly failing: |
|
☔ The latest upstream changes (presumably #147145) made this pull request unmergeable. Please resolve the merge conflicts. |
|
llvm/llvm-project#144709 has been backported to the 21 branch and has shipped with 21.1.3. |
|
Presumably this also fixes #147883, though it would be good to test for it explicitly. We potentially also need to handle https://godbolt.org/z/7sW5TE5Gx. In any case, that probably deserves a test too given that LLVM calls it out as a special case. |
|
Hi @beetrees, ping from triage team. Are there any further updates on this PR? |
b2e4ee9 to
7df3c25
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. |
| let cast_target = match regs { | ||
| [Some(reg), None, ..] => CastTarget::from(reg), | ||
| _ => CastTarget::prefixed(regs, Uniform::new(Reg::i8(), Size::ZERO)), | ||
| }; |
There was a problem hiding this comment.
I'm not entirely sure why the special-casing is, but the first case fits in a register no problem, while the second case requires some sort of larger struct that is cast.
This comment has been minimized.
This comment has been minimized.
7df3c25 to
7515aca
Compare
|
@rustbot ready |
Fixes the 64-bit SPARC part of #115609 by replacing the current implementation with a new implementation modelled on the RISC-V calling convention code (SPARC ABI reference).
Pinging
sparcv9-sun-solaristarget maintainers: @psumbera @kulikjakFixes #115336
Fixes #115399
Fixes #122620
Fixes #147883
r? @workingjubilee