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