11use rustc_abi:: { BackendRepr , Float , Integer , Primitive , RegKind } ;
22use rustc_attr_data_structures:: InstructionSetAttr ;
3- use rustc_hir:: def_id:: DefId ;
43use rustc_middle:: mir:: mono:: { Linkage , MonoItemData , Visibility } ;
54use rustc_middle:: mir:: { InlineAsmOperand , START_BLOCK } ;
65use rustc_middle:: ty:: layout:: { FnAbiOf , LayoutOf , TyAndLayout } ;
76use rustc_middle:: ty:: { Instance , Ty , TyCtxt , TypeVisitableExt } ;
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 :: mir:: AsmCodegenMethods ;
@@ -287,12 +286,7 @@ fn prefix_and_suffix<'tcx>(
287286 writeln ! ( begin, "{}" , arch_prefix) . unwrap ( ) ;
288287 }
289288 writeln ! ( begin, "{asm_name}:" ) . unwrap ( ) ;
290- writeln ! (
291- begin,
292- ".functype {asm_name} {}" ,
293- wasm_functype( tcx, fn_abi, instance. def_id( ) )
294- )
295- . unwrap ( ) ;
289+ writeln ! ( begin, ".functype {asm_name} {}" , wasm_functype( tcx, fn_abi) ) . unwrap ( ) ;
296290
297291 writeln ! ( end) . unwrap ( ) ;
298292 // .size is ignored for function symbols, so we can skip it
@@ -333,7 +327,7 @@ fn prefix_and_suffix<'tcx>(
333327/// The webassembly type signature for the given function.
334328///
335329/// Used by the `.functype` directive on wasm targets.
336- fn wasm_functype < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > , def_id : DefId ) -> String {
330+ fn wasm_functype < ' tcx > ( tcx : TyCtxt < ' tcx > , fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ) -> String {
337331 let mut signature = String :: with_capacity ( 64 ) ;
338332
339333 let ptr_type = match tcx. data_layout . pointer_size . bits ( ) {
@@ -342,17 +336,6 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
342336 other => bug ! ( "wasm pointer size cannot be {other} bits" ) ,
343337 } ;
344338
345- // FIXME: remove this once the wasm32-unknown-unknown ABI is fixed
346- // please also add `wasm32-unknown-unknown` back in `tests/assembly/wasm32-naked-fn.rs`
347- // basically the commit introducing this comment should be reverted
348- if let PassMode :: Pair { .. } = fn_abi. ret . mode {
349- let _ = WasmCAbi :: Legacy { with_lint : true } ;
350- span_bug ! (
351- tcx. def_span( def_id) ,
352- "cannot return a pair (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
353- ) ;
354- }
355-
356339 let hidden_return = matches ! ( fn_abi. ret. mode, PassMode :: Indirect { .. } ) ;
357340
358341 signature. push ( '(' ) ;
@@ -366,7 +349,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
366349
367350 let mut it = fn_abi. args . iter ( ) . peekable ( ) ;
368351 while let Some ( arg_abi) = it. next ( ) {
369- wasm_type ( tcx , & mut signature, arg_abi, ptr_type, def_id ) ;
352+ wasm_type ( & mut signature, arg_abi, ptr_type) ;
370353 if it. peek ( ) . is_some ( ) {
371354 signature. push_str ( ", " ) ;
372355 }
@@ -375,35 +358,21 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
375358 signature. push_str ( ") -> (" ) ;
376359
377360 if !hidden_return {
378- wasm_type ( tcx , & mut signature, & fn_abi. ret , ptr_type, def_id ) ;
361+ wasm_type ( & mut signature, & fn_abi. ret , ptr_type) ;
379362 }
380363
381364 signature. push ( ')' ) ;
382365
383366 signature
384367}
385368
386- fn wasm_type < ' tcx > (
387- tcx : TyCtxt < ' tcx > ,
388- signature : & mut String ,
389- arg_abi : & ArgAbi < ' _ , Ty < ' tcx > > ,
390- ptr_type : & ' static str ,
391- def_id : DefId ,
392- ) {
369+ fn wasm_type < ' tcx > ( signature : & mut String , arg_abi : & ArgAbi < ' _ , Ty < ' tcx > > , ptr_type : & ' static str ) {
393370 match arg_abi. mode {
394371 PassMode :: Ignore => { /* do nothing */ }
395372 PassMode :: Direct ( _) => {
396373 let direct_type = match arg_abi. layout . backend_repr {
397374 BackendRepr :: Scalar ( scalar) => wasm_primitive ( scalar. primitive ( ) , ptr_type) ,
398375 BackendRepr :: SimdVector { .. } => "v128" ,
399- BackendRepr :: Memory { .. } => {
400- // FIXME: remove this branch once the wasm32-unknown-unknown ABI is fixed
401- let _ = WasmCAbi :: Legacy { with_lint : true } ;
402- span_bug ! (
403- tcx. def_span( def_id) ,
404- "cannot use memory args (the wasm32-unknown-unknown ABI is broken, see https://github.com/rust-lang/rust/issues/115666"
405- ) ;
406- }
407376 other => unreachable ! ( "unexpected BackendRepr: {:?}" , other) ,
408377 } ;
409378
0 commit comments