@@ -687,7 +687,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
687
687
}
688
688
} ;
689
689
690
- let ( fn_abi, llfn, instance) = common:: build_langcall ( bx, Some ( span) , lang_item) ;
690
+ let ( fn_abi, llfn, instance) = common:: build_langcall ( bx, Some ( span) , lang_item, None ) ;
691
691
692
692
// Codegen the actual panic invoke/call.
693
693
let merging_succ =
@@ -707,7 +707,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
707
707
self . set_debug_loc ( bx, terminator. source_info ) ;
708
708
709
709
// Obtain the panic entry point.
710
- let ( fn_abi, llfn, instance) = common:: build_langcall ( bx, Some ( span) , reason. lang_item ( ) ) ;
710
+ let ( fn_abi, llfn, instance) =
711
+ common:: build_langcall ( bx, Some ( span) , reason. lang_item ( ) , None ) ;
711
712
712
713
// Codegen the actual panic invoke/call.
713
714
let merging_succ = helper. do_call (
@@ -769,8 +770,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
769
770
let msg = bx. const_str ( & msg_str) ;
770
771
771
772
// Obtain the panic entry point.
772
- let ( fn_abi, llfn, instance) =
773
- common:: build_langcall ( bx, Some ( source_info. span ) , LangItem :: PanicNounwind ) ;
773
+ let ( fn_abi, llfn, instance) = common:: build_langcall (
774
+ bx,
775
+ Some ( source_info. span ) ,
776
+ LangItem :: PanicNounwind ,
777
+ None ,
778
+ ) ;
774
779
775
780
// Codegen the actual panic invoke/call.
776
781
helper. do_call (
@@ -1289,6 +1294,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1289
1294
) -> MergingSucc {
1290
1295
debug ! ( "codegen_terminator: {:?}" , terminator) ;
1291
1296
1297
+ if bx. tcx ( ) . may_insert_niche_checks ( ) {
1298
+ if let mir:: TerminatorKind :: Return = terminator. kind {
1299
+ let op = mir:: Operand :: Copy ( mir:: Place :: return_place ( ) ) ;
1300
+ let ty = op. ty ( self . mir , bx. tcx ( ) ) ;
1301
+ let ty = self . monomorphize ( ty) ;
1302
+ if let Some ( niche) = bx. layout_of ( ty) . largest_niche {
1303
+ self . codegen_niche_check ( bx, op, niche, terminator. source_info ) ;
1304
+ }
1305
+ }
1306
+ }
1307
+
1292
1308
let helper = TerminatorCodegenHelper { bb, terminator } ;
1293
1309
1294
1310
let mergeable_succ = || {
@@ -1557,7 +1573,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1557
1573
tuple. layout . fields . count ( )
1558
1574
}
1559
1575
1560
- fn get_caller_location (
1576
+ pub fn get_caller_location (
1561
1577
& mut self ,
1562
1578
bx : & mut Bx ,
1563
1579
source_info : mir:: SourceInfo ,
@@ -1698,12 +1714,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1698
1714
1699
1715
self . set_debug_loc ( & mut bx, mir:: SourceInfo :: outermost ( self . mir . span ) ) ;
1700
1716
1701
- let ( fn_abi, fn_ptr, instance) = common:: build_langcall ( & bx, None , reason. lang_item ( ) ) ;
1717
+ let ( fn_abi, fn_ptr, instance) =
1718
+ common:: build_langcall ( & bx, None , reason. lang_item ( ) , None ) ;
1702
1719
if is_call_from_compiler_builtins_to_upstream_monomorphization ( bx. tcx ( ) , instance) {
1703
1720
bx. abort ( ) ;
1704
1721
} else {
1705
1722
let fn_ty = bx. fn_decl_backend_type ( fn_abi) ;
1706
-
1707
1723
let llret = bx. call ( fn_ty, None , Some ( fn_abi) , fn_ptr, & [ ] , funclet. as_ref ( ) , None ) ;
1708
1724
bx. apply_attrs_to_cleanup_callsite ( llret) ;
1709
1725
}
0 commit comments