about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsayantn <sayantn05@gmail.com>2025-04-16 03:53:48 +0530
committerAmanieu d'Antras <amanieu@gmail.com>2025-04-20 21:39:39 +0000
commitf2870b76fdc8d3e31340749ae5feb94c27e396e6 (patch)
tree46466dedfbaa6db8af99ec5bdf7543d9652063da
parentbc9e29d9be2601e406a03bb6749a051c4ecab01e (diff)
downloadrust-f2870b76fdc8d3e31340749ae5feb94c27e396e6.tar.gz
rust-f2870b76fdc8d3e31340749ae5feb94c27e396e6.zip
Remove `STDARCH_DISABLE_DEDUP_GUARD` as it was unused
-rwxr-xr-xlibrary/stdarch/ci/run.sh2
-rw-r--r--library/stdarch/crates/assert-instr-macro/src/lib.rs54
-rw-r--r--library/stdarch/crates/stdarch-test/src/lib.rs3
3 files changed, 8 insertions, 51 deletions
diff --git a/library/stdarch/ci/run.sh b/library/stdarch/ci/run.sh
index cb516b5c57f..82a6f8dfc72 100755
--- a/library/stdarch/ci/run.sh
+++ b/library/stdarch/ci/run.sh
@@ -14,8 +14,6 @@ export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled "
 export HOST_RUSTFLAGS="${RUSTFLAGS}"
 export PROFILE="${PROFILE:="--profile=release"}"
 
-export STDARCH_DISABLE_DEDUP_GUARD=1
-
 case ${TARGET} in
     # On Windows the linker performs identical COMDAT folding (ICF) by default
     # in release mode which removes identical COMDAT sections. This interferes
diff --git a/library/stdarch/crates/assert-instr-macro/src/lib.rs b/library/stdarch/crates/assert-instr-macro/src/lib.rs
index acc764e7aa8..96b86d93bbc 100644
--- a/library/stdarch/crates/assert-instr-macro/src/lib.rs
+++ b/library/stdarch/crates/assert-instr-macro/src/lib.rs
@@ -50,10 +50,6 @@ pub fn assert_instr(
     // testing for.
     let disable_assert_instr = std::env::var("STDARCH_DISABLE_ASSERT_INSTR").is_ok();
 
-    // Disable dedup guard. Only works if the LLVM MergeFunctions pass is disabled, e.g.
-    // with `-Z merge-functions=disabled` in RUSTFLAGS.
-    let disable_dedup_guard = std::env::var("STDARCH_DISABLE_DEDUP_GUARD").is_ok();
-
     // If instruction tests are disabled avoid emitting this shim at all, just
     // return the original item without our attribute.
     if !cfg!(optimized) || disable_assert_instr {
@@ -69,10 +65,6 @@ pub fn assert_instr(
         &format!("stdarch_test_shim_{name}_{instr_str}"),
         name.span(),
     );
-    let shim_name_ptr = syn::Ident::new(
-        &format!("stdarch_test_shim_{name}_{instr_str}_ptr").to_ascii_uppercase(),
-        name.span(),
-    );
     let mut inputs = Vec::new();
     let mut input_vals = Vec::new();
     let mut const_vals = Vec::new();
@@ -138,41 +130,13 @@ pub fn assert_instr(
     } else {
         syn::LitStr::new("C", proc_macro2::Span::call_site())
     };
-    let shim_name_str = format!("{shim_name}{assert_name}");
-    let to_test = if disable_dedup_guard {
-        quote! {
-            #attrs
-            #maybe_allow_deprecated
-            #[unsafe(no_mangle)]
-            #[inline(never)]
-            pub unsafe extern #abi fn #shim_name(#(#inputs),*) #ret {
-                #name::<#(#const_vals),*>(#(#input_vals),*)
-            }
-        }
-    } else {
-        quote! {
-
-            const #shim_name_ptr : *const u8 = #shim_name_str.as_ptr();
-
-            #attrs
-            #maybe_allow_deprecated
-            #[unsafe(no_mangle)]
-            #[inline(never)]
-            pub unsafe extern #abi fn #shim_name(#(#inputs),*) #ret {
-                // The compiler in optimized mode by default runs a pass called
-                // "mergefunc" where it'll merge functions that look identical.
-                // Turns out some intrinsics produce identical code and they're
-                // folded together, meaning that one just jumps to another. This
-                // messes up our inspection of the disassembly of this function and
-                // we're not a huge fan of that.
-                //
-                // To thwart this pass and prevent functions from being merged we
-                // generate some code that's hopefully very tight in terms of
-                // codegen but is otherwise unique to prevent code from being
-                // folded.
-                ::stdarch_test::_DONT_DEDUP = #shim_name_ptr;
-                #name::<#(#const_vals),*>(#(#input_vals),*)
-            }
+    let to_test = quote! {
+        #attrs
+        #maybe_allow_deprecated
+        #[unsafe(no_mangle)]
+        #[inline(never)]
+        pub unsafe extern #abi fn #shim_name(#(#inputs),*) #ret {
+            #name::<#(#const_vals),*>(#(#input_vals),*)
         }
     };
 
@@ -182,9 +146,7 @@ pub fn assert_instr(
         fn #assert_name() {
             #to_test
 
-            ::stdarch_test::assert(#shim_name as usize,
-                                   stringify!(#shim_name),
-                                   #instr);
+            ::stdarch_test::assert(#shim_name as usize, stringify!(#shim_name), #instr);
         }
     };
 
diff --git a/library/stdarch/crates/stdarch-test/src/lib.rs b/library/stdarch/crates/stdarch-test/src/lib.rs
index ff224376ecf..e5ce79b1dce 100644
--- a/library/stdarch/crates/stdarch-test/src/lib.rs
+++ b/library/stdarch/crates/stdarch-test/src/lib.rs
@@ -203,6 +203,3 @@ pub fn assert_skip_test_ok(name: &str, missing_features: &[&str]) {
         Err(_) => println!("Set STDARCH_TEST_EVERYTHING to make this an error."),
     }
 }
-
-// See comment in `assert-instr-macro` crate for why this exists
-pub static mut _DONT_DEDUP: *const u8 = std::ptr::null();