1
1
use rustc_abi:: { BackendRepr , Float , Integer , Primitive , RegKind } ;
2
2
use rustc_attr_data_structures:: InstructionSetAttr ;
3
- use rustc_hir:: def_id:: DefId ;
4
3
use rustc_middle:: mir:: mono:: { Linkage , MonoItemData , Visibility } ;
5
4
use rustc_middle:: mir:: { InlineAsmOperand , START_BLOCK } ;
6
5
use rustc_middle:: ty:: layout:: { FnAbiOf , LayoutOf , TyAndLayout } ;
7
6
use rustc_middle:: ty:: { Instance , Ty , TyCtxt , TypeVisitableExt } ;
8
- use rustc_middle:: { bug, span_bug , ty} ;
7
+ use rustc_middle:: { bug, ty} ;
9
8
use rustc_span:: sym;
10
9
use rustc_target:: callconv:: { ArgAbi , FnAbi , PassMode } ;
11
- use rustc_target:: spec:: { BinaryFormat , WasmCAbi } ;
10
+ use rustc_target:: spec:: BinaryFormat ;
12
11
13
12
use crate :: common;
14
13
use crate :: mir:: AsmCodegenMethods ;
@@ -287,12 +286,7 @@ fn prefix_and_suffix<'tcx>(
287
286
writeln ! ( begin, "{}" , arch_prefix) . unwrap ( ) ;
288
287
}
289
288
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 ( ) ;
296
290
297
291
writeln ! ( end) . unwrap ( ) ;
298
292
// .size is ignored for function symbols, so we can skip it
@@ -333,7 +327,7 @@ fn prefix_and_suffix<'tcx>(
333
327
/// The webassembly type signature for the given function.
334
328
///
335
329
/// 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 {
337
331
let mut signature = String :: with_capacity ( 64 ) ;
338
332
339
333
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
342
336
other => bug ! ( "wasm pointer size cannot be {other} bits" ) ,
343
337
} ;
344
338
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
-
356
339
let hidden_return = matches ! ( fn_abi. ret. mode, PassMode :: Indirect { .. } ) ;
357
340
358
341
signature. push ( '(' ) ;
@@ -366,7 +349,7 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
366
349
367
350
let mut it = fn_abi. args . iter ( ) . peekable ( ) ;
368
351
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) ;
370
353
if it. peek ( ) . is_some ( ) {
371
354
signature. push_str ( ", " ) ;
372
355
}
@@ -375,35 +358,21 @@ fn wasm_functype<'tcx>(tcx: TyCtxt<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, def_id
375
358
signature. push_str ( ") -> (" ) ;
376
359
377
360
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) ;
379
362
}
380
363
381
364
signature. push ( ')' ) ;
382
365
383
366
signature
384
367
}
385
368
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 ) {
393
370
match arg_abi. mode {
394
371
PassMode :: Ignore => { /* do nothing */ }
395
372
PassMode :: Direct ( _) => {
396
373
let direct_type = match arg_abi. layout . backend_repr {
397
374
BackendRepr :: Scalar ( scalar) => wasm_primitive ( scalar. primitive ( ) , ptr_type) ,
398
375
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
- }
407
376
other => unreachable ! ( "unexpected BackendRepr: {:?}" , other) ,
408
377
} ;
409
378
0 commit comments