@@ -50,10 +50,6 @@ pub fn assert_instr(
50
50
// testing for.
51
51
let disable_assert_instr = std:: env:: var ( "STDARCH_DISABLE_ASSERT_INSTR" ) . is_ok ( ) ;
52
52
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
-
57
53
// If instruction tests are disabled avoid emitting this shim at all, just
58
54
// return the original item without our attribute.
59
55
if !cfg ! ( optimized) || disable_assert_instr {
@@ -69,10 +65,6 @@ pub fn assert_instr(
69
65
& format ! ( "stdarch_test_shim_{name}_{instr_str}" ) ,
70
66
name. span ( ) ,
71
67
) ;
72
- let shim_name_ptr = syn:: Ident :: new (
73
- & format ! ( "stdarch_test_shim_{name}_{instr_str}_ptr" ) . to_ascii_uppercase ( ) ,
74
- name. span ( ) ,
75
- ) ;
76
68
let mut inputs = Vec :: new ( ) ;
77
69
let mut input_vals = Vec :: new ( ) ;
78
70
let mut const_vals = Vec :: new ( ) ;
@@ -138,41 +130,13 @@ pub fn assert_instr(
138
130
} else {
139
131
syn:: LitStr :: new ( "C" , proc_macro2:: Span :: call_site ( ) )
140
132
} ;
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) , * )
176
140
}
177
141
} ;
178
142
@@ -182,9 +146,7 @@ pub fn assert_instr(
182
146
fn #assert_name( ) {
183
147
#to_test
184
148
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) ;
188
150
}
189
151
} ;
190
152
0 commit comments