mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-08 16:07:43 +00:00
black_box should inhibit optimizations on platforms without inline assembly
This commit is contained in:
parent
f2443831e9
commit
cfa76c438a
@ -106,7 +106,10 @@ pub fn black_box<T>(dummy: T) -> T {
|
|||||||
dummy
|
dummy
|
||||||
}
|
}
|
||||||
#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] {
|
#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] {
|
||||||
#[inline(never)] fn black_box_(x: T) -> T { x }
|
unsafe {
|
||||||
black_box_(dummy)
|
let ret = crate::ptr::read_volatile(&dummy);
|
||||||
}
|
crate::mem::forget(dummy);
|
||||||
|
ret
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user