@@ -24,6 +24,7 @@ use smallvec::{SmallVec, smallvec};
2424
2525use self :: pass_mode:: * ;
2626pub ( crate ) use self :: returning:: codegen_return;
27+ use crate :: base:: codegen_unwind_terminate;
2728use crate :: prelude:: * ;
2829
2930fn clif_sig_from_fn_abi < ' tcx > (
@@ -584,7 +585,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(
584585 with_no_trimmed_paths ! ( fx. add_comment( nop_inst, format!( "abi: {:?}" , fn_abi) ) ) ;
585586 }
586587
587- codegen_call_with_unwind_action ( fx, func_ref, unwind, & call_args, None )
588+ codegen_call_with_unwind_action ( fx, source_info . span , func_ref, unwind, & call_args, None )
588589 } ) ;
589590
590591 if let Some ( dest) = target {
@@ -743,6 +744,7 @@ pub(crate) fn codegen_drop<'tcx>(
743744 let sig = fx. bcx . import_signature ( sig) ;
744745 codegen_call_with_unwind_action (
745746 fx,
747+ source_info. span ,
746748 CallTarget :: Indirect ( sig, drop_fn) ,
747749 unwind,
748750 & [ ptr] ,
@@ -792,6 +794,7 @@ pub(crate) fn codegen_drop<'tcx>(
792794 let sig = fx. bcx . import_signature ( sig) ;
793795 codegen_call_with_unwind_action (
794796 fx,
797+ source_info. span ,
795798 CallTarget :: Indirect ( sig, drop_fn) ,
796799 unwind,
797800 & [ data] ,
@@ -823,6 +826,7 @@ pub(crate) fn codegen_drop<'tcx>(
823826 let func_ref = fx. get_function_ref ( drop_instance) ;
824827 codegen_call_with_unwind_action (
825828 fx,
829+ source_info. span ,
826830 CallTarget :: Direct ( func_ref) ,
827831 unwind,
828832 & call_args,
@@ -841,6 +845,7 @@ pub(crate) enum CallTarget {
841845
842846pub ( crate ) fn codegen_call_with_unwind_action (
843847 fx : & mut FunctionCx < ' _ , ' _ , ' _ > ,
848+ span : Span ,
844849 func_ref : CallTarget ,
845850 unwind : UnwindAction ,
846851 call_args : & [ Value ] ,
@@ -854,10 +859,8 @@ pub(crate) fn codegen_call_with_unwind_action(
854859 if target_block. is_some ( ) {
855860 assert ! ( fx. bcx. func. dfg. signatures[ sig_ref] . returns. is_empty( ) ) ;
856861 }
857-
858862 match unwind {
859- // FIXME abort on unreachable and terminate unwinds
860- UnwindAction :: Continue | UnwindAction :: Unreachable | UnwindAction :: Terminate ( _) => {
863+ UnwindAction :: Continue | UnwindAction :: Unreachable => {
861864 let call_inst = match func_ref {
862865 CallTarget :: Direct ( func_ref) => fx. bcx . ins ( ) . call ( func_ref, & call_args) ,
863866 CallTarget :: Indirect ( sig, func_ptr) => {
@@ -878,7 +881,7 @@ pub(crate) fn codegen_call_with_unwind_action(
878881 . collect :: < SmallVec < [ Value ; 2 ] > > ( )
879882 }
880883 }
881- UnwindAction :: Cleanup ( cleanup ) => {
884+ UnwindAction :: Cleanup ( _ ) | UnwindAction :: Terminate ( _ ) => {
882885 let returns_types = fx. bcx . func . dfg . signatures [ sig_ref]
883886 . returns
884887 . iter ( )
@@ -916,10 +919,22 @@ pub(crate) fn codegen_call_with_unwind_action(
916919 fx. bcx . seal_block ( pre_cleanup_block) ;
917920 fx. bcx . switch_to_block ( pre_cleanup_block) ;
918921 fx. bcx . set_cold_block ( pre_cleanup_block) ;
919- let exception_ptr = fx. bcx . append_block_param ( pre_cleanup_block, fx. pointer_type ) ;
920- fx. bcx . def_var ( fx. exception_slot , exception_ptr) ;
921- let cleanup_block = fx. get_block ( cleanup) ;
922- fx. bcx . ins ( ) . jump ( cleanup_block, & [ ] ) ;
922+ match unwind {
923+ UnwindAction :: Continue | UnwindAction :: Unreachable => unreachable ! ( ) ,
924+ UnwindAction :: Cleanup ( cleanup) => {
925+ let exception_ptr =
926+ fx. bcx . append_block_param ( pre_cleanup_block, fx. pointer_type ) ;
927+ fx. bcx . def_var ( fx. exception_slot , exception_ptr) ;
928+ let cleanup_block = fx. get_block ( cleanup) ;
929+ fx. bcx . ins ( ) . jump ( cleanup_block, & [ ] ) ;
930+ }
931+ UnwindAction :: Terminate ( reason) => {
932+ // FIXME dedup terminate blocks
933+ fx. bcx . append_block_param ( pre_cleanup_block, fx. pointer_type ) ;
934+
935+ codegen_unwind_terminate ( fx, span, reason) ;
936+ }
937+ }
923938
924939 if target_block. is_none ( ) {
925940 fx. bcx . seal_block ( fallthrough_block) ;
0 commit comments