@@ -682,7 +682,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
682
682
}
683
683
} ;
684
684
685
- let ( fn_abi, llfn, instance) = common:: build_langcall ( bx, Some ( span) , lang_item) ;
685
+ let ( fn_abi, llfn, instance) = common:: build_langcall ( bx, Some ( span) , lang_item, None ) ;
686
686
687
687
// Codegen the actual panic invoke/call.
688
688
let merging_succ =
@@ -702,7 +702,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
702
702
self . set_debug_loc ( bx, terminator. source_info ) ;
703
703
704
704
// Obtain the panic entry point.
705
- let ( fn_abi, llfn, instance) = common:: build_langcall ( bx, Some ( span) , reason. lang_item ( ) ) ;
705
+ let ( fn_abi, llfn, instance) =
706
+ common:: build_langcall ( bx, Some ( span) , reason. lang_item ( ) , None ) ;
706
707
707
708
// Codegen the actual panic invoke/call.
708
709
let merging_succ = helper. do_call (
@@ -764,8 +765,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
764
765
let msg = bx. const_str ( & msg_str) ;
765
766
766
767
// Obtain the panic entry point.
767
- let ( fn_abi, llfn, instance) =
768
- common:: build_langcall ( bx, Some ( source_info. span ) , LangItem :: PanicNounwind ) ;
768
+ let ( fn_abi, llfn, instance) = common:: build_langcall (
769
+ bx,
770
+ Some ( source_info. span ) ,
771
+ LangItem :: PanicNounwind ,
772
+ None ,
773
+ ) ;
769
774
770
775
// Codegen the actual panic invoke/call.
771
776
helper. do_call (
@@ -1284,6 +1289,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1284
1289
) -> MergingSucc {
1285
1290
debug ! ( "codegen_terminator: {:?}" , terminator) ;
1286
1291
1292
+ if bx. tcx ( ) . may_insert_niche_checks ( ) {
1293
+ if let mir:: TerminatorKind :: Return = terminator. kind {
1294
+ let op = mir:: Operand :: Copy ( mir:: Place :: return_place ( ) ) ;
1295
+ let ty = op. ty ( self . mir , bx. tcx ( ) ) ;
1296
+ let ty = self . monomorphize ( ty) ;
1297
+ if let Some ( niche) = bx. layout_of ( ty) . largest_niche {
1298
+ self . codegen_niche_check ( bx, op, niche, terminator. source_info ) ;
1299
+ }
1300
+ }
1301
+ }
1302
+
1287
1303
let helper = TerminatorCodegenHelper { bb, terminator } ;
1288
1304
1289
1305
let mergeable_succ = || {
@@ -1552,7 +1568,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1552
1568
tuple. layout . fields . count ( )
1553
1569
}
1554
1570
1555
- fn get_caller_location (
1571
+ pub fn get_caller_location (
1556
1572
& mut self ,
1557
1573
bx : & mut Bx ,
1558
1574
source_info : mir:: SourceInfo ,
@@ -1693,12 +1709,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
1693
1709
1694
1710
self . set_debug_loc ( & mut bx, mir:: SourceInfo :: outermost ( self . mir . span ) ) ;
1695
1711
1696
- let ( fn_abi, fn_ptr, instance) = common:: build_langcall ( & bx, None , reason. lang_item ( ) ) ;
1712
+ let ( fn_abi, fn_ptr, instance) =
1713
+ common:: build_langcall ( & bx, None , reason. lang_item ( ) , None ) ;
1697
1714
if is_call_from_compiler_builtins_to_upstream_monomorphization ( bx. tcx ( ) , instance) {
1698
1715
bx. abort ( ) ;
1699
1716
} else {
1700
1717
let fn_ty = bx. fn_decl_backend_type ( fn_abi) ;
1701
-
1702
1718
let llret = bx. call ( fn_ty, None , Some ( fn_abi) , fn_ptr, & [ ] , funclet. as_ref ( ) ) ;
1703
1719
bx. apply_attrs_to_cleanup_callsite ( llret) ;
1704
1720
}
0 commit comments