Skip to content

Commit

Permalink
black_box should inhibit optimizations on platforms without inline as…
Browse files Browse the repository at this point in the history
…sembly
  • Loading branch information
gnzlbg committed Mar 25, 2019
1 parent f244383 commit cfa76c4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/libcore/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}

0 comments on commit cfa76c4

Please sign in to comment.