@@ -466,7 +466,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
466466 * destination,
467467 ) ;
468468 }
469- TerminatorKind :: Resume | TerminatorKind :: Abort => {
469+ TerminatorKind :: Abort => {
470+ codegen_panic_cannot_unwind ( fx, source_info) ;
471+ }
472+ TerminatorKind :: Resume => {
470473 // FIXME implement unwinding
471474 fx. bcx . ins ( ) . trap ( TrapCode :: UnreachableCodeReached ) ;
472475 }
@@ -931,7 +934,28 @@ pub(crate) fn codegen_panic<'tcx>(
931934 codegen_panic_inner ( fx, rustc_hir:: LangItem :: Panic , & args, source_info. span ) ;
932935}
933936
934- pub ( crate ) fn codegen_panic_inner < ' tcx > (
937+ pub ( crate ) fn codegen_panic_nounwind < ' tcx > (
938+ fx : & mut FunctionCx < ' _ , ' _ , ' tcx > ,
939+ msg_str : & str ,
940+ source_info : mir:: SourceInfo ,
941+ ) {
942+ let msg_ptr = fx. anonymous_str ( msg_str) ;
943+ let msg_len = fx. bcx . ins ( ) . iconst ( fx. pointer_type , i64:: try_from ( msg_str. len ( ) ) . unwrap ( ) ) ;
944+ let args = [ msg_ptr, msg_len] ;
945+
946+ codegen_panic_inner ( fx, rustc_hir:: LangItem :: PanicNounwind , & args, source_info. span ) ;
947+ }
948+
949+ pub ( crate ) fn codegen_panic_cannot_unwind < ' tcx > (
950+ fx : & mut FunctionCx < ' _ , ' _ , ' tcx > ,
951+ source_info : mir:: SourceInfo ,
952+ ) {
953+ let args = [ ] ;
954+
955+ codegen_panic_inner ( fx, rustc_hir:: LangItem :: PanicCannotUnwind , & args, source_info. span ) ;
956+ }
957+
958+ fn codegen_panic_inner < ' tcx > (
935959 fx : & mut FunctionCx < ' _ , ' _ , ' tcx > ,
936960 lang_item : rustc_hir:: LangItem ,
937961 args : & [ Value ] ,
@@ -948,11 +972,7 @@ pub(crate) fn codegen_panic_inner<'tcx>(
948972
949973 fx. lib_call (
950974 & * symbol_name,
951- vec ! [
952- AbiParam :: new( fx. pointer_type) ,
953- AbiParam :: new( fx. pointer_type) ,
954- AbiParam :: new( fx. pointer_type) ,
955- ] ,
975+ args. iter ( ) . map ( |& arg| AbiParam :: new ( fx. bcx . func . dfg . value_type ( arg) ) ) . collect ( ) ,
956976 vec ! [ ] ,
957977 args,
958978 ) ;
0 commit comments