Merge pull request #646 from rchaser53/issue-58645
use copy_op directly insteadof write_scalar
This commit is contained in:
commit
433e494d79
@ -50,22 +50,30 @@ fn call_intrinsic(
|
||||
|
||||
"atomic_load" |
|
||||
"atomic_load_relaxed" |
|
||||
"atomic_load_acq" |
|
||||
"volatile_load" => {
|
||||
"atomic_load_acq" => {
|
||||
let ptr = this.deref_operand(args[0])?;
|
||||
let val = this.read_scalar(ptr.into())?; // make sure it fits into a scalar; otherwise it cannot be atomic
|
||||
this.write_scalar(val, dest)?;
|
||||
}
|
||||
|
||||
"volatile_load" => {
|
||||
let ptr = this.deref_operand(args[0])?;
|
||||
this.copy_op(ptr.into(), dest)?;
|
||||
}
|
||||
|
||||
"atomic_store" |
|
||||
"atomic_store_relaxed" |
|
||||
"atomic_store_rel" |
|
||||
"volatile_store" => {
|
||||
"atomic_store_rel" => {
|
||||
let ptr = this.deref_operand(args[0])?;
|
||||
let val = this.read_scalar(args[1])?; // make sure it fits into a scalar; otherwise it cannot be atomic
|
||||
this.write_scalar(val, ptr.into())?;
|
||||
}
|
||||
|
||||
"volatile_store" => {
|
||||
let ptr = this.deref_operand(args[0])?;
|
||||
this.copy_op(args[1], ptr.into())?;
|
||||
}
|
||||
|
||||
"atomic_fence_acq" => {
|
||||
// we are inherently singlethreaded and singlecored, this is a nop
|
||||
}
|
||||
|
12
tests/run-pass/volatile.rs
Normal file
12
tests/run-pass/volatile.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// related: #58645
|
||||
#![feature(core_intrinsics)]
|
||||
use std::intrinsics::{volatile_load, volatile_store};
|
||||
|
||||
pub fn main() {
|
||||
unsafe {
|
||||
let i: &mut (isize, isize) = &mut (0, 0);
|
||||
volatile_store(i, (1, 2));
|
||||
assert_eq!(volatile_load(i), (1, 2));
|
||||
assert_eq!(i, &mut (1, 2));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user