Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support s390x z13 vector ABI #131586

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Oct 12, 2024

cc #130869

This resolves the following fixmes:

Refs: Section 1.2.3 "Parameter Passing" and section 1.2.5 "Return Values" in ELF Application Binary Interface s390x Supplement, Version 1.6.1 (lzsabi_s390x.pdf in https://github.com/IBM/s390x-abi/releases/tag/v1.6.1)

Depends on #127731. (The first commit is from it and the second commit is fix errors happened after rebased it.)

This PR extends #127731 's ABI check for that PR to reject cases where vector target feature is disabled.
If we do not do ABI check, we run into the ABI problems as described in #116558 and #130869 (comment), and the problem of the compiler generating strange code (#131586 (comment)).

cc @uweigand

@rustbot label +O-SystemZ +A-ABI

@rustbot
Copy link
Collaborator

rustbot commented Oct 12, 2024

r? @jieyouxu

rustbot has assigned @jieyouxu.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. O-SystemZ Target: SystemZ processors (s390x) labels Oct 12, 2024
@taiki-e taiki-e mentioned this pull request Oct 12, 2024
10 tasks
@rust-log-analyzer

This comment has been minimized.

@jieyouxu
Copy link
Member

r? compiler

@rust-log-analyzer

This comment has been minimized.

@taiki-e taiki-e force-pushed the s390x-vector-abi branch 3 times, most recently from c14d9b2 to d39e822 Compare October 12, 2024 13:40
@taiki-e
Copy link
Member Author

taiki-e commented Oct 12, 2024

Fixed #[repr(C)] wrapper test and added #[repr(transparent)] wrapper test.

@taiki-e
Copy link
Member Author

taiki-e commented Oct 12, 2024

For now, this is planned not to be completed until #127731 is merged.

@rustbot label -S-waiting-on-review, +S-blocked

@rustbot rustbot added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. A-ABI Area: Concerning the application binary interface (ABI) and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 12, 2024
Copy link
Contributor

@uweigand uweigand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the problem mentioned inline, we should also verify that building with soft-float works as expected. This option implicitly disables any use of floating-point or vector registers, and therefore also disables use of the vector facility. I believe the LLVM back-end should handle that logic correctly, but it would be good to have the test check.

*x
}

// FIXME: should check output for z10, but it is very long...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also incorrect. Without the vector feature, vector types of any length are supposed to be passed via implicit reference, which in the case means a pointer in %r2. The body of the function should simply be:

lg %r2, 0(%r2)

Not sure what exactly the compiler is doing here, but it appears to have scalarized the input and pass it as 8 distinct one-byte arguments ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case and soft-float case should eventually result in a compilation error once the ABI check is implemented, and I will add UI tests for these cases once the ABI check is implemented.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I just wanted to point out the incorrect code, in case we do end up going back to supporting the no-vector case.

@taiki-e taiki-e force-pushed the s390x-vector-abi branch 2 times, most recently from 0a6b7ad to c1835bd Compare October 14, 2024 11:31
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Oct 14, 2024
@rust-log-analyzer

This comment has been minimized.

@taiki-e taiki-e force-pushed the s390x-vector-abi branch 2 times, most recently from 546fd91 to 857dbc6 Compare October 14, 2024 15:10
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@taiki-e taiki-e force-pushed the s390x-vector-abi branch 2 times, most recently from a9242d0 to 524c9f6 Compare October 15, 2024 15:54
@bors
Copy link
Contributor

bors commented Oct 16, 2024

☔ The latest upstream changes (presumably #131747) made this pull request unmergeable. Please resolve the merge conflicts.

veluca93 and others added 3 commits October 17, 2024 00:04
On some architectures, vector types may have a different ABI when
relevant target features are enabled.

As discussed in rust-lang/lang-team#235, this
turns out to very easily lead to unsound code.

This commit makes it an error to declare or call functions using those
vector types in a context in which the corresponding target features are
disabled, if using an ABI for which the difference is relevant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ABI Area: Concerning the application binary interface (ABI) A-testsuite Area: The testsuite used to check the correctness of rustc O-SystemZ Target: SystemZ processors (s390x) S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants