@@ -16,7 +16,7 @@ use rustc::hir::CodegenFnAttrFlags;
16
16
use rustc:: hir:: def_id:: { DefId , CrateNum , LOCAL_CRATE } ;
17
17
use rustc:: ty:: subst:: { SubstsRef , GenericArgKind } ;
18
18
19
- use crate :: abi:: { Abi , FnAbi } ;
19
+ use crate :: abi:: FnAbi ;
20
20
use crate :: common:: CodegenCx ;
21
21
use crate :: builder:: Builder ;
22
22
use crate :: value:: Value ;
@@ -308,13 +308,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
308
308
let file_metadata = file_metadata ( self , & loc. file . name , def_id. krate ) ;
309
309
310
310
let function_type_metadata = unsafe {
311
- // FIXME(eddyb) avoid this `Instance::fn_sig` call, by
312
- // rewriting `get_function_signature` to use `fn_abi` instead.
313
- let sig = self . tcx ( ) . normalize_erasing_late_bound_regions (
314
- ty:: ParamEnv :: reveal_all ( ) ,
315
- & instance. fn_sig ( self . tcx ( ) ) ,
316
- ) ;
317
- let fn_signature = get_function_signature ( self , sig) ;
311
+ let fn_signature = get_function_signature ( self , fn_abi) ;
318
312
llvm:: LLVMRustDIBuilderCreateSubroutineType ( DIB ( self ) , file_metadata, fn_signature)
319
313
} ;
320
314
@@ -396,28 +390,22 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
396
390
397
391
return Some ( fn_debug_context) ;
398
392
399
- // FIXME(eddyb) rewrite this to be based on `FnAbi` instead of `FnSig`.
400
393
fn get_function_signature < ' ll , ' tcx > (
401
394
cx : & CodegenCx < ' ll , ' tcx > ,
402
- sig : ty :: FnSig < ' tcx > ,
395
+ fn_abi : & FnAbi < ' tcx , Ty < ' tcx > > ,
403
396
) -> & ' ll DIArray {
404
397
if cx. sess ( ) . opts . debuginfo == DebugInfo :: Limited {
405
398
return create_DIArray ( DIB ( cx) , & [ ] ) ;
406
399
}
407
400
408
- let mut signature = Vec :: with_capacity ( sig . inputs ( ) . len ( ) + 1 ) ;
401
+ let mut signature = Vec :: with_capacity ( fn_abi . args . len ( ) + 1 ) ;
409
402
410
403
// Return type -- llvm::DIBuilder wants this at index 0
411
- signature. push ( match sig. output ( ) . kind {
412
- ty:: Tuple ( ref tys) if tys. is_empty ( ) => None ,
413
- _ => Some ( type_metadata ( cx, sig. output ( ) , syntax_pos:: DUMMY_SP ) )
414
- } ) ;
415
-
416
- let inputs = if sig. abi == Abi :: RustCall {
417
- & sig. inputs ( ) [ ..sig. inputs ( ) . len ( ) - 1 ]
404
+ signature. push ( if fn_abi. ret . is_ignore ( ) {
405
+ None
418
406
} else {
419
- sig . inputs ( )
420
- } ;
407
+ Some ( type_metadata ( cx , fn_abi . ret . layout . ty , syntax_pos :: DUMMY_SP ) )
408
+ } ) ;
421
409
422
410
// Arguments types
423
411
if cx. sess ( ) . target . target . options . is_like_msvc {
@@ -431,7 +419,8 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
431
419
// and a function `fn bar(x: [(); 7])` as `fn bar(x: *const ())`.
432
420
// This transformed type is wrong, but these function types are
433
421
// already inaccurate due to ABI adjustments (see #42800).
434
- signature. extend ( inputs. iter ( ) . map ( |& t| {
422
+ signature. extend ( fn_abi. args . iter ( ) . map ( |arg| {
423
+ let t = arg. layout . ty ;
435
424
let t = match t. kind {
436
425
ty:: Array ( ct, _)
437
426
if ( ct == cx. tcx . types . u8 ) || cx. layout_of ( ct) . is_zst ( ) => {
@@ -442,21 +431,11 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
442
431
Some ( type_metadata ( cx, t, syntax_pos:: DUMMY_SP ) )
443
432
} ) ) ;
444
433
} else {
445
- signature. extend ( inputs . iter ( ) . map ( |t | {
446
- Some ( type_metadata ( cx, t , syntax_pos:: DUMMY_SP ) )
434
+ signature. extend ( fn_abi . args . iter ( ) . map ( |arg | {
435
+ Some ( type_metadata ( cx, arg . layout . ty , syntax_pos:: DUMMY_SP ) )
447
436
} ) ) ;
448
437
}
449
438
450
- if sig. abi == Abi :: RustCall && !sig. inputs ( ) . is_empty ( ) {
451
- if let ty:: Tuple ( args) = sig. inputs ( ) [ sig. inputs ( ) . len ( ) - 1 ] . kind {
452
- signature. extend (
453
- args. iter ( ) . map ( |argument_type| {
454
- Some ( type_metadata ( cx, argument_type. expect_ty ( ) , syntax_pos:: DUMMY_SP ) )
455
- } )
456
- ) ;
457
- }
458
- }
459
-
460
439
create_DIArray ( DIB ( cx) , & signature[ ..] )
461
440
}
462
441
0 commit comments