11use rustc_abi:: { BackendRepr , Float , Integer , Primitive , RegKind } ;
22use rustc_attr_parsing:: InstructionSetAttr ;
3- use rustc_hir:: def_id:: DefId ;
43use rustc_middle:: mir:: mono:: { Linkage , MonoItem , MonoItemData , Visibility } ;
54use rustc_middle:: mir:: { Body , InlineAsmOperand } ;
65use rustc_middle:: ty:: layout:: { FnAbiOf , HasTyCtxt , HasTypingEnv , LayoutOf } ;
76use rustc_middle:: ty:: { Instance , Ty , TyCtxt } ;
8- use rustc_middle:: { bug, span_bug , ty} ;
7+ use rustc_middle:: { bug, ty} ;
98use rustc_span:: sym;
109use rustc_target:: callconv:: { ArgAbi , FnAbi , PassMode } ;
11- use rustc_target:: spec:: { BinaryFormat , WasmCAbi } ;
10+ use rustc_target:: spec:: BinaryFormat ;
1211
1312use crate :: common;
1413use crate :: traits:: { AsmCodegenMethods , BuilderMethods , GlobalAsmOperandRef , MiscCodegenMethods } ;
@@ -268,12 +267,7 @@ fn prefix_and_suffix<'tcx>(
268267 writeln ! ( begin, "{}" , arch_prefix) . unwrap ( ) ;
269268 }
270269 writeln ! ( begin, "{asm_name}:" ) . unwrap ( ) ;
271- writeln ! (
272- begin,
273- ".functype {asm_name} {}" ,
274- wasm_functype( tcx, fn_abi, instance. def_id( ) )
275- )
276- . unwrap ( ) ;
270+ writeln ! ( begin, ".functype {asm_name} {}" , wasm_functype( tcx, fn_abi) ) . unwrap ( ) ;
277271
278272 writeln ! ( end) . unwrap ( ) ;
279273 // .size is ignored for function symbols, so we can skip it
@@ -287,7 +281,7 @@ fn prefix_and_suffix<'tcx>(
287281/// The webassembly type signature for the given function.
288282///
289283/// Used by the `.functype` directive on wasm targets.
290- fn wasm_functype < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > , def_id : DefId ) -> String {
284+ fn wasm_functype < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ) -> String {
291285 let mut signature = String :: with_capacity ( 64 ) ;
292286
293287 let ptr_type = match tcx. data_layout . pointer_size . bits ( ) {
@@ -296,17 +290,6 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
296290 other => bug ! ( "wasm pointer size cannot be {other} bits" ) ,
297291 } ;
298292
299- // FIXME: remove this once the wasm32-unknown-unknown ABI is fixed
300- // please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
301- // basically the commit introducing this comment should be reverted
302- if let PassMode :: Pair { .. } = fn_abi. ret . mode {
303- let _ = WasmCAbi :: Legacy ;
304- span_bug ! (
305- tcx. def_span( def_id) ,
306- "cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
307- ) ;
308- }
309-
310293 let hidden_return = matches ! ( fn_abi. ret. mode, PassMode :: Indirect { .. } ) ;
311294
312295 signature. push ( '(' ) ;
@@ -320,7 +303,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
320303
321304 let mut it = fn_abi. args . iter ( ) . peekable ( ) ;
322305 while let Some ( arg_abi) = it. next ( ) {
323- wasm_type ( tcx , & mut signature, arg_abi, ptr_type, def_id ) ;
306+ wasm_type ( & mut signature, arg_abi, ptr_type) ;
324307 if it. peek ( ) . is_some ( ) {
325308 signature. push_str ( ", " ) ;
326309 }
@@ -329,35 +312,21 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
329312 signature. push_str ( ") -> (" ) ;
330313
331314 if !hidden_return {
332- wasm_type ( tcx , & mut signature, & fn_abi. ret , ptr_type, def_id ) ;
315+ wasm_type ( & mut signature, & fn_abi. ret , ptr_type) ;
333316 }
334317
335318 signature. push ( ')' ) ;
336319
337320 signature
338321}
339322
340- fn wasm_type < ' tcx > (
341- tcx : TyCtxt < ' tcx > ,
342- signature : & mut String ,
343- arg_abi : & ArgAbi < ' _ , Ty < ' tcx > > ,
344- ptr_type : & ' static str ,
345- def_id : DefId ,
346- ) {
323+ fn wasm_type < ' tcx > ( signature : & mut String , arg_abi : & ArgAbi < ' _ , Ty < ' tcx > > , ptr_type : & ' static str ) {
347324 match arg_abi. mode {
348325 PassMode :: Ignore => { /* do nothing */ }
349326 PassMode :: Direct ( _) => {
350327 let direct_type = match arg_abi. layout . backend_repr {
351328 BackendRepr :: Scalar ( scalar) => wasm_primitive ( scalar. primitive ( ) , ptr_type) ,
352329 BackendRepr :: Vector { .. } => "v128" ,
353- BackendRepr :: Memory { .. } => {
354- // FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
355- let _ = WasmCAbi :: Legacy ;
356- span_bug ! (
357- tcx. def_span( def_id) ,
358- "cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
359- ) ;
360- }
361330 other => unreachable ! ( "unexpected BackendRepr: {:?}" , other) ,
362331 } ;
363332
0 commit comments