Skip to content

Commit

Permalink
miri: Move patterns for simd tests
Browse files Browse the repository at this point in the history
It isn't clear to me why these error patterns do not trigger,
but I am not going to waste time analyzing bugs in compiletest.
  • Loading branch information
workingjubilee committed May 11, 2023
1 parent 4499daa commit de858e7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 35 deletions.
3 changes: 1 addition & 2 deletions src/tools/miri/tests/fail/intrinsics/simd-float-to-int.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//@error-in-other-file: cannot be represented in target type `i32`
#![feature(portable_simd)]
use std::simd::*;

fn main() {
unsafe {
let _x: i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked();
let _x: i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked(); //~ERROR: cannot be represented in target type `i32`
}
}
13 changes: 4 additions & 9 deletions src/tools/miri/tests/fail/intrinsics/simd-float-to-int.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 3.40282347E+38 which cannot be represented in target type `i32`
--> RUSTLIB/core/src/../../portable-simd/crates/core_simd/src/vector.rs:LL:CC
--> $DIR/simd-float-to-int.rs:LL:CC
|
LL | unsafe { intrinsics::simd_cast(self) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 3.40282347E+38 which cannot be represented in target type `i32`
LL | let _x: i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 3.40282347E+38 which cannot be represented in target type `i32`
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `std::simd::Simd::<f32, 2>::to_int_unchecked::<i32>` at RUSTLIB/core/src/../../portable-simd/crates/core_simd/src/vector.rs:LL:CC
note: inside `main`
--> $DIR/simd-float-to-int.rs:LL:CC
|
LL | let _x: i32x2 = f32x2::from_array([f32::MAX, f32::MIN]).to_int_unchecked();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: inside `main` at $DIR/simd-float-to-int.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

Expand Down
3 changes: 1 addition & 2 deletions src/tools/miri/tests/fail/intrinsics/simd-gather.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
//@error-in-other-file: pointer to 1 byte starting at offset 9 is out-of-bounds
#![feature(portable_simd)]
use std::simd::*;

fn main() {
unsafe {
let vec: &[i8] = &[10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 17]);
let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0)); //~ERROR: pointer to 1 byte starting at offset 9 is out-of-bounds
}
}
13 changes: 4 additions & 9 deletions src/tools/miri/tests/fail/intrinsics/simd-gather.stderr
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
--> RUSTLIB/core/src/../../portable-simd/crates/core_simd/src/vector.rs:LL:CC
--> $DIR/simd-gather.rs:LL:CC
|
LL | unsafe { intrinsics::simd_gather(or, ptrs, enable.to_int()) }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
LL | let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `std::simd::Simd::<i8, 4>::gather_select_unchecked` at RUSTLIB/core/src/../../portable-simd/crates/core_simd/src/vector.rs:LL:CC
note: inside `main`
--> $DIR/simd-gather.rs:LL:CC
|
LL | let _result = Simd::gather_select_unchecked(&vec, Mask::splat(true), idxs, Simd::splat(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: inside `main` at $DIR/simd-gather.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

Expand Down
3 changes: 1 addition & 2 deletions src/tools/miri/tests/fail/intrinsics/simd-scatter.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
//@error-in-other-file: pointer to 1 byte starting at offset 9 is out-of-bounds
#![feature(portable_simd)]
use std::simd::*;

fn main() {
unsafe {
let mut vec: Vec<i8> = vec![10, 11, 12, 13, 14, 15, 16, 17, 18];
let idxs = Simd::from_array([9, 3, 0, 17]);
Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked( //~ERROR: pointer to 1 byte starting at offset 9 is out-of-bounds
&mut vec,
Mask::splat(true),
idxs,
Expand Down
17 changes: 6 additions & 11 deletions src/tools/miri/tests/fail/intrinsics/simd-scatter.stderr
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
--> RUSTLIB/core/src/../../portable-simd/crates/core_simd/src/vector.rs:LL:CC
|
LL | intrinsics::simd_scatter(self, ptrs, enable.to_int())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `std::simd::Simd::<i8, 4>::scatter_select_unchecked` at RUSTLIB/core/src/../../portable-simd/crates/core_simd/src/vector.rs:LL:CC
note: inside `main`
--> $DIR/simd-scatter.rs:LL:CC
|
LL | / Simd::from_array([-27, 82, -41, 124]).scatter_select_unchecked(
LL | | &mut vec,
LL | | Mask::splat(true),
LL | | idxs,
LL | | );
| |_________^
| |_________^ dereferencing pointer failed: ALLOC has size 9, so pointer to 1 byte starting at offset 9 is out-of-bounds
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
= note: BACKTRACE:
= note: inside `main` at $DIR/simd-scatter.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

Expand Down

0 comments on commit de858e7

Please sign in to comment.