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

Add bad-reg inline assembly ui test for RISC-V and s390x #132516

Merged
merged 5 commits into from
Nov 4, 2024

Conversation

taiki-e
Copy link
Member

@taiki-e taiki-e commented Nov 2, 2024

#131341 (comment)

Btw, such unsupported registers are present in most architectures, but only aarch64/arm64ec, x86_64, and not yet merged sparc/sparc64 (and powerpc/powerpc64 by this PR) currently have ui tests for them. I plan to add tests for other arches later.

Starting with RISC-V and s390x, which I'm familiar with and relatively easy to check for correctness.

(Relevant rustc code are supported_types/def_regs/overlapping_regs in compiler/rustc_target/src/asm/riscv.rs and compiler/rustc_target/src/asm/s390x.rs.)

r? workingjubilee

@rustbot label +A-inline-assembly

@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. A-inline-assembly Area: Inline assembly (`asm!(…)`) labels Nov 2, 2024
@jieyouxu jieyouxu self-assigned this Nov 2, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Nov 2, 2024

@taiki-e I took the liberty to adjust these tests to use minicore core stubs via //@ add-core-stubs (see rust-lang/rustc-dev-guide#2097) which was just merged like 2 days ago, so that we don't have to keep reinventing core stubs :3 Please readjust/rebase the commits as suitable.

@jieyouxu jieyouxu removed their assignment Nov 2, 2024
tests/auxiliary/minicore.rs Outdated Show resolved Hide resolved
Co-authored-by: Jubilee <workingjubilee@gmail.com>
tests/auxiliary/minicore.rs Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

There's a similar test for rv32e, actually: https://github.com/rust-lang/rust/blob/b3f75cc872cfd306860c3ad76a239e719015f855/tests/ui/abi/riscv32e-registers.rs

I suppose we should merge them?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think both should be placed in ui/asm/riscv, but I don't think they can be merged since they test checks that are performed at different stages.

  • riscv32e-registers.rs is to see if the LLVM's assembler can reject the use of unsupported registers in assembly code (i.e., invalid assembly code).
  • bad-reg.rs is to see if the rustc can reject the use of unsupported registers in the asm! API (in,out,inout,etc.).

Only code that passes the latter check is passed to LLVM, so it is probably difficult to test that both work in a single test file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved tests/ui/abi/riscv32e-registers.rs to tests/ui/asm/riscv and added comments explaining the difference to bad-reg.rs. (b07232d)

Copy link
Member

@workingjubilee workingjubilee Nov 3, 2024

Choose a reason for hiding this comment

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

Ah, I see. That makes sense, thank you! I wasn't entirely sure of which things were checked where.

This also adds comments explaining the difference to bad-reg.rs.
@workingjubilee
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Nov 3, 2024

📌 Commit b07232d has been approved by workingjubilee

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 3, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 4, 2024
…kingjubilee

Rollup of 6 pull requests

Successful merges:

 - rust-lang#126136 (Call the target libdir target libdir)
 - rust-lang#132516 (Add bad-reg inline assembly ui test for RISC-V and s390x)
 - rust-lang#132521 (replace manual time convertions with std ones, comptime time format parsing)
 - rust-lang#132560 (Remove outdated tidy license fixmes)
 - rust-lang#132563 (Modify `NonZero` documentation to reference the underlying integer type)
 - rust-lang#132574 (compiler: Directly use rustc_abi almost everywhere)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 6bc7be5 into rust-lang:master Nov 4, 2024
6 checks passed
@rustbot rustbot added this to the 1.84.0 milestone Nov 4, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Nov 4, 2024
Rollup merge of rust-lang#132516 - taiki-e:asm-ui, r=workingjubilee

Add bad-reg inline assembly ui test for RISC-V and s390x

rust-lang#131341 (comment)

> Btw, such unsupported registers are present in most architectures, but only aarch64/arm64ec, x86_64, and not yet merged [sparc/sparc64](https://github.com/rust-lang/rust/pull/132472/files#diff-02aebda3376c2b020265137f9ce2c387669ca5cfecd7d60494275c2387db5114) (and powerpc/powerpc64 by this PR) currently have ui tests for them.  I plan to add tests for other arches later.

Starting with RISC-V and s390x, which I'm familiar with and relatively easy to check for correctness.

(Relevant rustc code are supported_types/def_regs/overlapping_regs in [compiler/rustc_target/src/asm/riscv.rs](https://github.com/rust-lang/rust/blob/588a4203508ed7c76750c96b482641261630ed36/compiler/rustc_target/src/asm/riscv.rs) and [compiler/rustc_target/src/asm/s390x.rs](https://github.com/rust-lang/rust/blob/588a4203508ed7c76750c96b482641261630ed36/compiler/rustc_target/src/asm/s390x.rs).)

r? workingjubilee

`@rustbot` label +A-inline-assembly
@taiki-e taiki-e deleted the asm-ui branch November 4, 2024 13:06
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 16, 2024
…r-errors

tests/ui/asm: Remove uses of rustc_attrs, lang_items, and decl_macro features by using minicore

Follow-up to rust-lang#132516 (comment).
This PR do similar things for remaining tests in tests/ui/asm.

r? jieyouxu
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 16, 2024
…r-errors

tests/ui/asm: Remove uses of rustc_attrs, lang_items, and decl_macro features by using minicore

Follow-up to rust-lang#132516 (comment).
This PR do similar things for remaining tests in tests/ui/asm.

r? jieyouxu
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Dec 16, 2024
…r-errors

tests/ui/asm: Remove uses of rustc_attrs, lang_items, and decl_macro features by using minicore

Follow-up to rust-lang#132516 (comment).
This PR do similar things for remaining tests in tests/ui/asm.

r? jieyouxu
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Dec 16, 2024
…r-errors

tests/ui/asm: Remove uses of rustc_attrs, lang_items, and decl_macro features by using minicore

Follow-up to rust-lang#132516 (comment).
This PR do similar things for remaining tests in tests/ui/asm.

r? jieyouxu
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 16, 2024
Rollup merge of rust-lang#134385 - taiki-e:ui-asm-minicore, r=compiler-errors

tests/ui/asm: Remove uses of rustc_attrs, lang_items, and decl_macro features by using minicore

Follow-up to rust-lang#132516 (comment).
This PR do similar things for remaining tests in tests/ui/asm.

r? jieyouxu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

5 participants