forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#134070 - oli-obk:push-nquzymupzlsq, r=jieyouxu Some asm! diagnostic adjustments and a papercut fix Best reviewed commit by commit. We forgot a `normalize` call in intrinsic checking, causing us to allow literal integers, but not named constants containing that literal. This can in theory affect stable code, but only if libstd contains a stable SIMD type that has an array length that is a named constant. I'd assume we'd have noticed by now due to asm! rejecting those outright. The error message left me scratching my head for a bit, so I added some extra information to the diagnostic, too.
- Loading branch information
Showing
4 changed files
with
131 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//! This is a regression test to ensure that we emit a diagnostic pointing to the | ||
//! reason the type was rejected in inline assembly. | ||
//@ only-x86_64 | ||
|
||
#![feature(repr_simd)] | ||
|
||
#[repr(simd)] | ||
#[derive(Copy, Clone)] | ||
pub struct Foo<const C: usize>([u8; C]); | ||
//~^ ERROR: cannot evaluate SIMD vector length | ||
|
||
pub unsafe fn foo<const C: usize>(a: Foo<C>) { | ||
std::arch::asm!( | ||
"movaps {src}, {src}", | ||
src = in(xmm_reg) a, | ||
//~^ NOTE: SIMD vector length needs to be known statically | ||
); | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error: cannot evaluate SIMD vector length `C` | ||
--> $DIR/generic_const_simd_vec_len.rs:10:32 | ||
| | ||
LL | pub struct Foo<const C: usize>([u8; C]); | ||
| ^^^^^^^ | ||
| | ||
note: SIMD vector length needs to be known statically for use in `asm!` | ||
--> $DIR/generic_const_simd_vec_len.rs:16:27 | ||
| | ||
LL | src = in(xmm_reg) a, | ||
| ^ | ||
|
||
error: aborting due to 1 previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//! This is a regression test to ensure that we evaluate | ||
//! SIMD vector length constants instead of assuming they are literals. | ||
//@ only-x86_64 | ||
//@ check-pass | ||
|
||
#![feature(repr_simd)] | ||
|
||
const C: usize = 16; | ||
|
||
#[repr(simd)] | ||
#[derive(Copy, Clone)] | ||
pub struct Foo([u8; C]); | ||
|
||
pub unsafe fn foo(a: Foo) { | ||
std::arch::asm!( | ||
"movaps {src}, {src}", | ||
src = in(xmm_reg) a, | ||
); | ||
} | ||
|
||
fn main() {} |