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
|
||||
}
|
||||
#[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] {
|
||||
#[inline(never)] fn black_box_(x: T) -> T { x }
|
||||
black_box_(dummy)
|
||||
}
|
||||
unsafe {
|
||||
let ret = crate::ptr::read_volatile(&dummy);
|
||||
crate::mem::forget(dummy);
|
||||
ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user