Skip to content

Commit 4fbef53

Browse files
committed
Auto merge of #3320 - RalfJung:rustup, r=RalfJung
Rustup Let's see if rust-lang/rust#121114 gets perf back to the old level.
2 parents 3fe1097 + c703c7a commit 4fbef53

File tree

7 files changed

+42
-22
lines changed

7 files changed

+42
-22
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c5f69bdd5173a948e0131f934fa7c4cbf5e0b55f
1+
a2f3c0cf880ad819c4eab2b320525b6a31ac6513

src/shims/intrinsics/simd.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
563563
let right_idx = src_index.checked_sub(left_len).unwrap();
564564
this.read_immediate(&this.project_index(&right, right_idx)?)?
565565
} else {
566-
span_bug!(
567-
this.cur_span(),
568-
"simd_shuffle index {src_index} is out of bounds for 2 vectors of size {left_len}",
566+
throw_ub_format!(
567+
"`simd_shuffle_generic` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}"
569568
);
570569
};
571570
this.write_immediate(*val, &dest)?;
@@ -604,9 +603,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
604603
let right_idx = src_index.checked_sub(left_len).unwrap();
605604
this.read_immediate(&this.project_index(&right, right_idx)?)?
606605
} else {
607-
span_bug!(
608-
this.cur_span(),
609-
"simd_shuffle index {src_index} is out of bounds for 2 vectors of size {left_len}",
606+
throw_ub_format!(
607+
"`simd_shuffle` index {src_index} is out-of-bounds for 2 vectors with length {dest_len}"
610608
);
611609
};
612610
this.write_immediate(*val, &dest)?;

tests/fail/intrinsics/simd-extract.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(portable_simd, core_intrinsics)]
2+
use std::simd::*;
3+
4+
fn main() {
5+
let v = i32x4::splat(0);
6+
let _x: i32 = unsafe { std::intrinsics::simd::simd_extract(v, 4) };
7+
//~^ERROR: index 4 is out-of-bounds
8+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: `simd_extract` index 4 is out-of-bounds of vector with length 4
2+
--> $DIR/simd-extract.rs:LL:CC
3+
|
4+
LL | let _x: i32 = unsafe { std::intrinsics::simd::simd_extract(v, 4) };
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `simd_extract` index 4 is out-of-bounds of vector with length 4
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/simd-extract.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

tests/fail/tls/tls_static_dealloc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Ensure that thread-local statics get deallocated when the thread dies.
22
33
#![feature(thread_local)]
4-
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
5-
#![allow(static_mut_refs)]
4+
5+
use std::ptr::addr_of;
66

77
#[thread_local]
88
static mut TLS: u8 = 0;
@@ -12,7 +12,7 @@ unsafe impl Send for SendRaw {}
1212

1313
fn main() {
1414
unsafe {
15-
let dangling_ptr = std::thread::spawn(|| SendRaw(&TLS as *const u8)).join().unwrap();
15+
let dangling_ptr = std::thread::spawn(|| SendRaw(addr_of!(TLS))).join().unwrap();
1616
let _val = *dangling_ptr.0; //~ ERROR: has been freed
1717
}
1818
}

tests/pass/static_mut.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
use std::ptr::addr_of;
2+
13
static mut FOO: i32 = 42;
24

3-
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
4-
#[allow(static_mut_refs)]
5-
static BAR: Foo = Foo(unsafe { &FOO as *const _ });
5+
static BAR: Foo = Foo(unsafe { addr_of!(FOO) });
66

77
#[allow(dead_code)]
88
struct Foo(*const i32);

tests/pass/tls/tls_static.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
//! test, we also check that thread-locals act as per-thread statics.
99
1010
#![feature(thread_local)]
11-
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
12-
#![allow(static_mut_refs)]
1311

12+
use std::ptr::addr_of_mut;
1413
use std::thread;
1514

1615
#[thread_local]
@@ -23,8 +22,8 @@ static mut C: u8 = 0;
2322
#[thread_local]
2423
static READ_ONLY: u8 = 42;
2524

26-
unsafe fn get_a_ref() -> *mut u8 {
27-
&mut A
25+
unsafe fn get_a_ptr() -> *mut u8 {
26+
addr_of_mut!(A)
2827
}
2928

3029
struct Sender(*mut u8);
@@ -35,12 +34,12 @@ fn main() {
3534
let _val = READ_ONLY;
3635

3736
let ptr = unsafe {
38-
let x = get_a_ref();
37+
let x = get_a_ptr();
3938
*x = 5;
4039
assert_eq!(A, 5);
4140
B = 15;
4241
C = 25;
43-
Sender(&mut A)
42+
Sender(addr_of_mut!(A))
4443
};
4544

4645
thread::spawn(move || unsafe {
@@ -51,18 +50,18 @@ fn main() {
5150
assert_eq!(C, 25);
5251
B = 14;
5352
C = 24;
54-
let y = get_a_ref();
53+
let y = get_a_ptr();
5554
assert_eq!(*y, 0);
5655
*y = 4;
5756
assert_eq!(*ptr.0, 5);
5857
assert_eq!(A, 4);
59-
assert_eq!(*get_a_ref(), 4);
58+
assert_eq!(*get_a_ptr(), 4);
6059
})
6160
.join()
6261
.unwrap();
6362

6463
unsafe {
65-
assert_eq!(*get_a_ref(), 5);
64+
assert_eq!(*get_a_ptr(), 5);
6665
assert_eq!(A, 5);
6766
assert_eq!(B, 15);
6867
assert_eq!(C, 24);

0 commit comments

Comments
 (0)