From db460acfca3e761443f6897f3e3b0268bca8e92d Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Wed, 8 Sep 2021 17:47:38 +0000 Subject: [PATCH 1/2] Use a lighter dedup guard in the assert_instr test shims. --- crates/assert-instr-macro/src/lib.rs | 19 ++++++++----------- crates/stdarch-test/src/lib.rs | 6 +++--- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/crates/assert-instr-macro/src/lib.rs b/crates/assert-instr-macro/src/lib.rs index 5b25df7035..89de99746e 100644 --- a/crates/assert-instr-macro/src/lib.rs +++ b/crates/assert-instr-macro/src/lib.rs @@ -58,6 +58,10 @@ pub fn assert_instr( &format!("stdarch_test_shim_{}_{}", name, instr_str), name.span(), ); + let shim_name_ptr = syn::Ident::new( + &format!("stdarch_test_shim_{}_{}_ptr", name, instr_str).to_ascii_uppercase(), + name.span(), + ); let mut inputs = Vec::new(); let mut input_vals = Vec::new(); let mut const_vals = Vec::new(); @@ -125,6 +129,9 @@ pub fn assert_instr( }; let shim_name_str = format!("{}{}", shim_name, assert_name); let to_test = quote! { + + const #shim_name_ptr : *const u8 = #shim_name_str.as_ptr(); + #attrs #[no_mangle] #[inline(never)] @@ -140,17 +147,7 @@ pub fn assert_instr( // generate some code that's hopefully very tight in terms of // codegen but is otherwise unique to prevent code from being // folded. - // - // This is avoided on Wasm32 right now since these functions aren't - // inlined which breaks our tests since each intrinsic looks like it - // calls functions. Turns out functions aren't similar enough to get - // merged on wasm32 anyway. This bug is tracked at - // rust-lang/rust#74320. - #[cfg(not(target_arch = "wasm32"))] - ::stdarch_test::_DONT_DEDUP.store( - std::mem::transmute(#shim_name_str.as_bytes().as_ptr()), - std::sync::atomic::Ordering::Relaxed, - ); + ::stdarch_test::_DONT_DEDUP = #shim_name_ptr; #name::<#(#const_vals),*>(#(#input_vals),*) } }; diff --git a/crates/stdarch-test/src/lib.rs b/crates/stdarch-test/src/lib.rs index 71920e3876..757a9bc745 100644 --- a/crates/stdarch-test/src/lib.rs +++ b/crates/stdarch-test/src/lib.rs @@ -14,7 +14,7 @@ extern crate cfg_if; pub use assert_instr_macro::*; pub use simd_test_macro::*; -use std::{cmp, collections::HashSet, env, hash, hint::black_box, str, sync::atomic::AtomicPtr}; +use std::{cmp, collections::HashSet, env, hash, hint::black_box, str}; cfg_if! { if #[cfg(target_arch = "wasm32")] { @@ -103,7 +103,7 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { // failed inlining something. s[0].starts_with("call ") && s[1].starts_with("pop") // FIXME: original logic but does not match comment }) - } else if cfg!(target_arch = "aarch64") { + } else if cfg!(target_arch = "aarch64") || cfg!(target_arch = "arm") { instrs.iter().any(|s| s.starts_with("bl ")) } else { // FIXME: Add detection for other archs @@ -189,4 +189,4 @@ pub fn assert_skip_test_ok(name: &str) { } // See comment in `assert-instr-macro` crate for why this exists -pub static _DONT_DEDUP: AtomicPtr = AtomicPtr::new(b"".as_ptr() as *mut _); +pub static mut _DONT_DEDUP: *const u8 = std::ptr::null(); From b0c8a6f3e08ef069184ddb0fa7699a9403743ab7 Mon Sep 17 00:00:00 2001 From: Hans Kratz Date: Wed, 8 Sep 2021 20:10:01 +0200 Subject: [PATCH 2/2] Disable arm inlining check again for now as some tests are still failing. --- crates/stdarch-test/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/stdarch-test/src/lib.rs b/crates/stdarch-test/src/lib.rs index 757a9bc745..ab7ed4b5e5 100644 --- a/crates/stdarch-test/src/lib.rs +++ b/crates/stdarch-test/src/lib.rs @@ -103,7 +103,7 @@ pub fn assert(shim_addr: usize, fnname: &str, expected: &str) { // failed inlining something. s[0].starts_with("call ") && s[1].starts_with("pop") // FIXME: original logic but does not match comment }) - } else if cfg!(target_arch = "aarch64") || cfg!(target_arch = "arm") { + } else if cfg!(target_arch = "aarch64") { instrs.iter().any(|s| s.starts_with("bl ")) } else { // FIXME: Add detection for other archs