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

ICE with asm macro #89875

Closed
dobasy opened this issue Oct 14, 2021 · 0 comments · Fixed by #89937
Closed

ICE with asm macro #89875

dobasy opened this issue Oct 14, 2021 · 0 comments · Fixed by #89937
Assignees
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dobasy
Copy link

dobasy commented Oct 14, 2021

Code

#![feature(asm)]

#[target_feature(enable = "avx")]
pub unsafe fn foo() {
    asm!(
        "/* {} */",
        out(ymm_reg) _,
    );
}

Meta

rustc --version --verbose:

rustc 1.57.0-nightly (dfc5add91 2021-10-13)
binary: rustc
commit-hash: dfc5add915e8bf4accbb7cf4de00351a7c6126a1
commit-date: 2021-10-13
host: x86_64-pc-windows-msvc
release: 1.57.0-nightly
LLVM version: 13.0.0

Error output

thread 'rustc' panicked at 'assertion failed: matches!(reg, InlineAsmRegOrRegClass :: Reg(_))', compiler\rustc_codegen_llvm\src\asm.rs:179:25
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.57.0-nightly (dfc5add91 2021-10-13) running on x86_64-pc-windows-msvc

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
error: could not compile `foo`

Also, #[target_feature(enable = "avx2")] doesn't allow the use of ymm_reg:

error: register class `ymm_reg` requires the `avx` target feature
@dobasy dobasy added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 14, 2021
@JohnTitor JohnTitor self-assigned this Oct 16, 2021
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Oct 26, 2021
Properly check `target_features` not to trigger an assertion

Fixes rust-lang#89875
I think it should be a condition instead of an assertion to check if it's a register as it's possible that `reg` is a register class.
Also, this isn't related to the issue directly, but `is_target_supported` doesn't check `target_features` attributes. Is there any way to check it on rustc_codegen_llvm?

r? `@Amanieu`
@bors bors closed this as completed in a9b2bfb Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants