@@ -50,10 +50,6 @@ pub fn assert_instr(
5050 // testing for.
5151 let disable_assert_instr = std:: env:: var ( "STDARCH_DISABLE_ASSERT_INSTR" ) . is_ok ( ) ;
5252
53- // Disable dedup guard. Only works if the LLVM MergeFunctions pass is disabled, e.g.
54- // with `-Z merge-functions=disabled` in RUSTFLAGS.
55- let disable_dedup_guard = std:: env:: var ( "STDARCH_DISABLE_DEDUP_GUARD" ) . is_ok ( ) ;
56-
5753 // If instruction tests are disabled avoid emitting this shim at all, just
5854 // return the original item without our attribute.
5955 if !cfg ! ( optimized) || disable_assert_instr {
@@ -69,10 +65,6 @@ pub fn assert_instr(
6965 & format ! ( "stdarch_test_shim_{name}_{instr_str}" ) ,
7066 name. span ( ) ,
7167 ) ;
72- let shim_name_ptr = syn:: Ident :: new (
73- & format ! ( "stdarch_test_shim_{name}_{instr_str}_ptr" ) . to_ascii_uppercase ( ) ,
74- name. span ( ) ,
75- ) ;
7668 let mut inputs = Vec :: new ( ) ;
7769 let mut input_vals = Vec :: new ( ) ;
7870 let mut const_vals = Vec :: new ( ) ;
@@ -138,41 +130,13 @@ pub fn assert_instr(
138130 } else {
139131 syn:: LitStr :: new ( "C" , proc_macro2:: Span :: call_site ( ) )
140132 } ;
141- let shim_name_str = format ! ( "{shim_name}{assert_name}" ) ;
142- let to_test = if disable_dedup_guard {
143- quote ! {
144- #attrs
145- #maybe_allow_deprecated
146- #[ unsafe ( no_mangle) ]
147- #[ inline( never) ]
148- pub unsafe extern #abi fn #shim_name( #( #inputs) , * ) #ret {
149- #name:: <#( #const_vals) , * >( #( #input_vals) , * )
150- }
151- }
152- } else {
153- quote ! {
154-
155- const #shim_name_ptr : * const u8 = #shim_name_str. as_ptr( ) ;
156-
157- #attrs
158- #maybe_allow_deprecated
159- #[ unsafe ( no_mangle) ]
160- #[ inline( never) ]
161- pub unsafe extern #abi fn #shim_name( #( #inputs) , * ) #ret {
162- // The compiler in optimized mode by default runs a pass called
163- // "mergefunc" where it'll merge functions that look identical.
164- // Turns out some intrinsics produce identical code and they're
165- // folded together, meaning that one just jumps to another. This
166- // messes up our inspection of the disassembly of this function and
167- // we're not a huge fan of that.
168- //
169- // To thwart this pass and prevent functions from being merged we
170- // generate some code that's hopefully very tight in terms of
171- // codegen but is otherwise unique to prevent code from being
172- // folded.
173- :: stdarch_test:: _DONT_DEDUP = #shim_name_ptr;
174- #name:: <#( #const_vals) , * >( #( #input_vals) , * )
175- }
133+ let to_test = quote ! {
134+ #attrs
135+ #maybe_allow_deprecated
136+ #[ unsafe ( no_mangle) ]
137+ #[ inline( never) ]
138+ pub unsafe extern #abi fn #shim_name( #( #inputs) , * ) #ret {
139+ #name:: <#( #const_vals) , * >( #( #input_vals) , * )
176140 }
177141 } ;
178142
@@ -182,9 +146,7 @@ pub fn assert_instr(
182146 fn #assert_name( ) {
183147 #to_test
184148
185- :: stdarch_test:: assert( #shim_name as usize ,
186- stringify!( #shim_name) ,
187- #instr) ;
149+ :: stdarch_test:: assert( #shim_name as usize , stringify!( #shim_name) , #instr) ;
188150 }
189151 } ;
190152
0 commit comments