@@ -489,11 +489,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
489
489
}
490
490
} ;
491
491
492
- // Obtain the panic entry point.
493
- let def_id = common:: langcall ( bx. tcx ( ) , Some ( span) , "" , lang_item) ;
494
- let instance = ty:: Instance :: mono ( bx. tcx ( ) , def_id) ;
495
- let fn_abi = bx. fn_abi_of_instance ( instance, ty:: List :: empty ( ) ) ;
496
- let llfn = bx. get_fn_addr ( instance) ;
492
+ let ( fn_abi, llfn) = common:: build_langcall ( & bx, Some ( span) , lang_item) ;
497
493
498
494
// Codegen the actual panic invoke/call.
499
495
helper. do_call ( self , & mut bx, fn_abi, llfn, & args, None , cleanup) ;
@@ -509,10 +505,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
509
505
self . set_debug_loc ( & mut bx, terminator. source_info ) ;
510
506
511
507
// Obtain the panic entry point.
512
- let def_id = common:: langcall ( bx. tcx ( ) , Some ( span) , "" , LangItem :: PanicNoUnwind ) ;
513
- let instance = ty:: Instance :: mono ( bx. tcx ( ) , def_id) ;
514
- let fn_abi = bx. fn_abi_of_instance ( instance, ty:: List :: empty ( ) ) ;
515
- let llfn = bx. get_fn_addr ( instance) ;
508
+ let ( fn_abi, llfn) = common:: build_langcall ( & bx, Some ( span) , LangItem :: PanicNoUnwind ) ;
516
509
517
510
// Codegen the actual panic invoke/call.
518
511
helper. do_call ( self , & mut bx, fn_abi, llfn, & [ ] , None , None ) ;
@@ -573,12 +566,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
573
566
let location = self . get_caller_location ( bx, source_info) . immediate ( ) ;
574
567
575
568
// Obtain the panic entry point.
576
- // FIXME: dedup this with `codegen_assert_terminator` above.
577
- let def_id =
578
- common:: langcall ( bx. tcx ( ) , Some ( source_info. span ) , "" , LangItem :: Panic ) ;
579
- let instance = ty:: Instance :: mono ( bx. tcx ( ) , def_id) ;
580
- let fn_abi = bx. fn_abi_of_instance ( instance, ty:: List :: empty ( ) ) ;
581
- let llfn = bx. get_fn_addr ( instance) ;
569
+ let ( fn_abi, llfn) =
570
+ common:: build_langcall ( bx, Some ( source_info. span ) , LangItem :: Panic ) ;
582
571
583
572
// Codegen the actual panic invoke/call.
584
573
helper. do_call (
@@ -1440,10 +1429,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1440
1429
let llretty = self . landing_pad_type ( ) ;
1441
1430
bx. cleanup_landing_pad ( llretty, llpersonality) ;
1442
1431
1443
- let def_id = common:: langcall ( bx. tcx ( ) , None , "" , LangItem :: PanicNoUnwind ) ;
1444
- let instance = ty:: Instance :: mono ( bx. tcx ( ) , def_id) ;
1445
- let fn_abi = bx. fn_abi_of_instance ( instance, ty:: List :: empty ( ) ) ;
1446
- let fn_ptr = bx. get_fn_addr ( instance) ;
1432
+ let ( fn_abi, fn_ptr) = common:: build_langcall ( & bx, None , LangItem :: PanicNoUnwind ) ;
1447
1433
let fn_ty = bx. fn_decl_backend_type ( & fn_abi) ;
1448
1434
1449
1435
let llret = bx. call ( fn_ty, fn_ptr, & [ ] , None ) ;
0 commit comments