-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
mir: prohibit projection into scalable vec #160642
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
Open
davidtwco
wants to merge
1
commit into
rust-lang:main
Choose a base branch
from
davidtwco:sve-field-projection
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
|
folkertdev marked this conversation as resolved.
|
This file contains hidden or 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
32 changes: 32 additions & 0 deletions
32
tests/mir-opt/sroa/scalable_sroa.bar.ScalarReplacementOfAggregates.diff
This file contains hidden or 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,32 @@ | ||
| - // MIR for `bar` before ScalarReplacementOfAggregates | ||
| + // MIR for `bar` after ScalarReplacementOfAggregates | ||
|
|
||
| fn bar(_1: &[svuint32x2_t], _2: svuint32x2_t) -> () { | ||
| debug simds => _1; | ||
| debug _unused => _2; | ||
| let mut _0: (); | ||
| let _3: std::arch::aarch64::svuint32x2_t; | ||
| let _4: usize; | ||
| let mut _5: usize; | ||
| let mut _6: bool; | ||
| scope 1 { | ||
| debug a => _3; | ||
| } | ||
|
|
||
| bb0: { | ||
| StorageLive(_3); | ||
| StorageLive(_4); | ||
| _4 = const 0_usize; | ||
| _5 = PtrMetadata(copy _1); | ||
| _6 = Lt(copy _4, copy _5); | ||
| assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, copy _4) -> [success: bb1, unwind continue]; | ||
| } | ||
|
|
||
| bb1: { | ||
| _3 = copy (*_1)[_4]; | ||
| StorageDead(_4); | ||
| StorageDead(_3); | ||
| return; | ||
| } | ||
| } | ||
|
|
32 changes: 32 additions & 0 deletions
32
tests/mir-opt/sroa/scalable_sroa.foo.ScalarReplacementOfAggregates.diff
This file contains hidden or 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,32 @@ | ||
| - // MIR for `foo` before ScalarReplacementOfAggregates | ||
| + // MIR for `foo` after ScalarReplacementOfAggregates | ||
|
|
||
| fn foo(_1: &[svuint32_t], _2: svuint32_t) -> () { | ||
| debug simds => _1; | ||
| debug _unused => _2; | ||
| let mut _0: (); | ||
| let _3: std::arch::aarch64::svuint32_t; | ||
| let _4: usize; | ||
| let mut _5: usize; | ||
| let mut _6: bool; | ||
| scope 1 { | ||
| debug a => _3; | ||
| } | ||
|
|
||
| bb0: { | ||
| StorageLive(_3); | ||
| StorageLive(_4); | ||
| _4 = const 0_usize; | ||
| _5 = PtrMetadata(copy _1); | ||
| _6 = Lt(copy _4, copy _5); | ||
| assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, copy _4) -> [success: bb1, unwind continue]; | ||
| } | ||
|
|
||
| bb1: { | ||
| _3 = copy (*_1)[_4]; | ||
| StorageDead(_4); | ||
| StorageDead(_3); | ||
| return; | ||
| } | ||
| } | ||
|
|
This file contains hidden or 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,30 @@ | ||
| //@ only-aarch64 | ||
| //@ needs-unwind | ||
| #![feature(stdarch_aarch64_sve)] | ||
|
|
||
| // SRoA expands things even if they're unused | ||
| // <https://github.com/rust-lang/rust/issues/144621> | ||
|
|
||
| use std::arch::aarch64::{svuint32_t, svuint32x2_t}; | ||
|
|
||
| // EMIT_MIR scalable_sroa.foo.ScalarReplacementOfAggregates.diff | ||
| pub(crate) fn foo(simds: &[svuint32_t], _unused: svuint32_t) { | ||
| // CHECK-LABEL: fn foo | ||
| // CHECK-NOT: u32 | ||
| // CHECK: let [[SIMD:_.+]]: std::arch::aarch64::svuint32_t; | ||
| // CHECK-NOT: u32 | ||
| // CHECK: [[SIMD]] = copy (*_1)[0 of 1]; | ||
| // CHECK-NOT: u32 | ||
| let a = simds[0]; | ||
| } | ||
|
|
||
| // EMIT_MIR scalable_sroa.bar.ScalarReplacementOfAggregates.diff | ||
| pub(crate) fn bar(simds: &[svuint32x2_t], _unused: svuint32x2_t) { | ||
| // CHECK-LABEL: fn bar | ||
| // CHECK-NOT: { <vscale x u32 x 4>, <vscale x u32 x 4> } | ||
| // CHECK: let [[SIMD:_.+]]: std::arch::aarch64::svuint32x2_t; | ||
| // CHECK-NOT: { <vscale x u32 x 4>, <vscale x u32 x 4> } | ||
| // CHECK: [[SIMD]] = copy (*_1)[0 of 1]; | ||
| // CHECK-NOT: { <vscale x u32 x 4>, <vscale x u32 x 4> } | ||
| let a = simds[0]; | ||
| } |
This file contains hidden or 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 @@ | ||
| //@ add-minicore | ||
| //@ compile-flags: -Copt-level=0 | ||
| //@ only-aarch64 | ||
| #![feature(no_core, rustc_attrs)] | ||
| #![no_std] | ||
| #![no_core] | ||
| #![crate_type = "rlib"] | ||
| #![allow(internal_features)] | ||
|
|
||
| extern crate minicore; | ||
|
|
||
| #[allow(unused)] // Only used on aarch64-unknown-linux-gnu. | ||
| #[rustc_scalable_vector(4)] | ||
| pub struct Sv(f32); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to silence a lint. |
||
This file contains hidden or 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 @@ | ||
| //@ add-minicore | ||
| //@ aux-build: simple.rs | ||
| //@ compile-flags: -Copt-level=0 | ||
| //@ check-fail | ||
| //@ only-aarch64 | ||
| #![feature(no_core, rustc_attrs)] | ||
| #![no_std] | ||
| #![no_core] | ||
| #![crate_type = "lib"] | ||
| #![allow(internal_features)] | ||
|
|
||
| extern crate minicore; | ||
| extern crate simple; | ||
|
|
||
| pub use simple::Sv; | ||
|
|
||
| #[target_feature(enable = "sve")] | ||
| pub fn field(x: Sv) -> f32 { | ||
| x.0 | ||
| //~^ ERROR: field `0` of struct `Sv` is private | ||
| } |
This file contains hidden or 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,9 @@ | ||
| error[E0616]: field `0` of struct `Sv` is private | ||
| --> $DIR/project-into-field-extern.rs:19:7 | ||
| | | ||
| LL | x.0 | ||
| | ^ private field | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| For more information about this error, try `rustc --explain E0616`. |
This file contains hidden or 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,24 @@ | ||
| //@ add-minicore | ||
| //@ build-fail | ||
| //@ compile-flags: -Copt-level=0 --target=aarch64-unknown-linux-gnu | ||
| //@ dont-check-compiler-stderr | ||
| //@ failure-status: 101 | ||
| //@ ignore-backends: gcc | ||
| //@ needs-llvm-components: aarch64 | ||
| #![feature(no_core, rustc_attrs)] | ||
| #![no_std] | ||
| #![no_core] | ||
| #![crate_type = "lib"] | ||
| #![allow(internal_features)] | ||
|
|
||
| extern crate minicore; | ||
|
|
||
| #[rustc_scalable_vector(4)] | ||
| pub struct Sv(f32); | ||
|
|
||
| #[target_feature(enable = "sve")] | ||
| pub fn field(x: Sv) -> f32 { | ||
| x.0 | ||
| //~^ ERROR broken MIR in Item | ||
| //~| ERROR Projecting into SIMD type Sv is banned by MCP#838 | ||
| } |
This file contains hidden or 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,8 @@ | ||
| error: cannot project into scalable vector type `Sv` | ||
| --> $DIR/project-into-field.rs:18:5 | ||
| | | ||
| LL | x.0 | ||
| | ^^^ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it worth having a negative test that mir-opt SRoA doesn't try to explode one of these, or similar?
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added one now