From 24db5174191c915bb7a61809837aaa5cb98cfa11 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 25 Mar 2019 18:11:42 +0100 Subject: [PATCH] black_box should use inline assembly on wasm32 --- src/libcore/hint.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/hint.rs b/src/libcore/hint.rs index abaf0b31b468f..e73a1a2879347 100644 --- a/src/libcore/hint.rs +++ b/src/libcore/hint.rs @@ -99,17 +99,17 @@ pub fn spin_loop() { /// This function is a no-op, and does not even read from `dummy`. #[unstable(feature = "test", issue = "27812")] pub fn black_box(dummy: T) -> T { - #[cfg(not(any(target_arch = "asmjs", target_arch = "wasm32")))] { + #[cfg(not(target_arch = "asmjs"))] { // we need to "use" the argument in some way LLVM can't // introspect. unsafe { asm!("" : : "r"(&dummy)) } dummy } - #[cfg(any(target_arch = "asmjs", target_arch = "wasm32"))] { + #[cfg(target_arch = "asmjs")] { unsafe { let ret = crate::ptr::read_volatile(&dummy); crate::mem::forget(dummy); ret } - } + } }