@@ -466,7 +466,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
466
466
* destination,
467
467
) ;
468
468
}
469
- TerminatorKind :: Resume | TerminatorKind :: Abort => {
469
+ TerminatorKind :: Abort => {
470
+ codegen_panic_cannot_unwind ( fx, source_info) ;
471
+ }
472
+ TerminatorKind :: Resume => {
470
473
// FIXME implement unwinding
471
474
fx. bcx . ins ( ) . trap ( TrapCode :: UnreachableCodeReached ) ;
472
475
}
@@ -931,7 +934,28 @@ pub(crate) fn codegen_panic<'tcx>(
931
934
codegen_panic_inner ( fx, rustc_hir:: LangItem :: Panic , & args, source_info. span ) ;
932
935
}
933
936
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 > (
935
959
fx : & mut FunctionCx < ' _ , ' _ , ' tcx > ,
936
960
lang_item : rustc_hir:: LangItem ,
937
961
args : & [ Value ] ,
@@ -948,11 +972,7 @@ pub(crate) fn codegen_panic_inner<'tcx>(
948
972
949
973
fx. lib_call (
950
974
& * 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 ( ) ,
956
976
vec ! [ ] ,
957
977
args,
958
978
) ;
0 commit comments