get rid of some uses of core_intrinsics

This commit is contained in:
Ralf Jung 2022-07-24 08:48:58 -04:00
parent c33fc24566
commit 3ee56989c7
10 changed files with 16 additions and 29 deletions

View File

@ -1,10 +1,8 @@
// We want to control preemption here.
//@compile-flags: -Zmiri-preemption-rate=0
//@ignore-target-windows: Concurrency on Windows is not supported yet.
#![feature(core_intrinsics)]
use std::intrinsics;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]
@ -23,8 +21,7 @@ pub fn main() {
});
let j2 = spawn(move || {
//Equivalent to: (&*c.0).load(Ordering::SeqCst)
intrinsics::atomic_load_seqcst(c.0 as *mut usize) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
(&*c.0).load(Ordering::SeqCst) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
});
j1.join().unwrap();

View File

@ -1,8 +1,8 @@
error: Undefined Behavior: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
--> $DIR/atomic_read_na_write_race1.rs:LL:CC
|
LL | intrinsics::atomic_load_seqcst(c.0 as *mut usize)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
LL | (&*c.0).load(Ordering::SeqCst)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
|
= 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

View File

@ -1,10 +1,8 @@
// We want to control preemption here.
//@compile-flags: -Zmiri-preemption-rate=0
//@ignore-target-windows: Concurrency on Windows is not supported yet.
#![feature(core_intrinsics)]
use std::intrinsics::atomic_store;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]
@ -23,8 +21,7 @@ pub fn main() {
});
let j2 = spawn(move || {
//Equivalent to: (&*c.0).store(32, Ordering::SeqCst)
atomic_store(c.0 as *mut usize, 32); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>`
(&*c.0).store(32, Ordering::SeqCst); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>`
});
j1.join().unwrap();

View File

@ -1,7 +1,7 @@
error: Undefined Behavior: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>` at ALLOC
--> $DIR/atomic_write_na_read_race2.rs:LL:CC
|
LL | atomic_store(c.0 as *mut usize, 32);
LL | (&*c.0).store(32, Ordering::SeqCst);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>` at ALLOC
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior

View File

@ -1,10 +1,8 @@
// We want to control preemption here.
//@compile-flags: -Zmiri-preemption-rate=0
//@ignore-target-windows: Concurrency on Windows is not supported yet.
#![feature(core_intrinsics)]
use std::intrinsics::atomic_store;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]
@ -23,8 +21,7 @@ pub fn main() {
});
let j2 = spawn(move || {
//Equivalent to: (&*c.0).store(64, Ordering::SeqCst)
atomic_store(c.0 as *mut usize, 64); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>`
(&*c.0).store(64, Ordering::SeqCst); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>`
});
j1.join().unwrap();

View File

@ -1,7 +1,7 @@
error: Undefined Behavior: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
--> $DIR/atomic_write_na_write_race1.rs:LL:CC
|
LL | atomic_store(c.0 as *mut usize, 64);
LL | (&*c.0).store(64, Ordering::SeqCst);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior

View File

@ -2,10 +2,8 @@
//@compile-flags: -Zmiri-preemption-rate=0
//@ignore-target-windows: Concurrency on Windows is not supported yet.
#![feature(core_intrinsics)]
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering::*;
use std::sync::atomic::{AtomicU16, AtomicU32};
use std::thread::spawn;
fn static_atomic(val: u32) -> &'static AtomicU32 {
@ -31,8 +29,8 @@ pub fn main() {
let x_ptr = x as *const AtomicU32 as *const u32;
let x_split = split_u32_ptr(x_ptr);
unsafe {
let hi = &(*x_split)[0] as *const u16;
std::intrinsics::atomic_load_relaxed(hi); //~ ERROR: imperfectly overlapping
let hi = x_split as *const u16 as *const AtomicU16;
(*hi).load(Relaxed); //~ ERROR: imperfectly overlapping
}
});

View File

@ -1,8 +1,8 @@
error: unsupported operation: racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
--> $DIR/racing_mixed_size_read.rs:LL:CC
|
LL | std::intrinsics::atomic_load_relaxed(hi);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
LL | (*hi).load(Relaxed);
| ^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
|
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
= note: backtrace:

View File

@ -5,7 +5,6 @@
// but doable in safe (at least sound) Rust.
#![feature(atomic_from_mut)]
#![feature(core_intrinsics)]
use std::sync::atomic::Ordering::*;
use std::sync::atomic::{AtomicU16, AtomicU32};

View File

@ -7,7 +7,6 @@
// memory model in the future.
#![feature(atomic_from_mut)]
#![feature(core_intrinsics)]
use std::sync::atomic::AtomicU32;
use std::sync::atomic::Ordering::*;
@ -27,7 +26,7 @@ fn racing_mixed_atomicity_read() {
let j2 = spawn(move || {
let x_ptr = x as *const AtomicU32 as *const u32;
unsafe { std::intrinsics::atomic_load_relaxed(x_ptr) }
unsafe { x_ptr.read() }
});
let r1 = j1.join().unwrap();