@@ -489,11 +489,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
489489 }
490490 } ;
491491
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) ;
497493
498494 // Codegen the actual panic invoke/call.
499495 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> {
509505 self . set_debug_loc ( & mut bx, terminator. source_info ) ;
510506
511507 // 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 ) ;
516509
517510 // Codegen the actual panic invoke/call.
518511 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> {
573566 let location = self . get_caller_location ( bx, source_info) . immediate ( ) ;
574567
575568 // 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 ) ;
582571
583572 // Codegen the actual panic invoke/call.
584573 helper. do_call (
@@ -1440,10 +1429,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14401429 let llretty = self . landing_pad_type ( ) ;
14411430 bx. cleanup_landing_pad ( llretty, llpersonality) ;
14421431
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 ) ;
14471433 let fn_ty = bx. fn_decl_backend_type ( & fn_abi) ;
14481434
14491435 let llret = bx. call ( fn_ty, fn_ptr, & [ ] , None ) ;
0 commit comments