diff --git a/compiler/m68k/cgcpu.pas b/compiler/m68k/cgcpu.pas index 79d1c07e3c..d24ac8060a 100644 --- a/compiler/m68k/cgcpu.pas +++ b/compiler/m68k/cgcpu.pas @@ -1884,6 +1884,11 @@ unit cgcpu; ref : TReference; ref2: TReference; begin + { if a subroutine is marked as non-returning, we do + not generate any exit code, so we really trust the noreturn directive + } + if po_noreturn in current_procinfo.procdef.procoptions then + exit; if not nostackframe then begin list.concat(taicpu.op_reg(A_UNLK,S_NO,NR_FRAME_POINTER_REG)); diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas index a7c129ec82..e5f16bb920 100644 --- a/compiler/ncgutil.pas +++ b/compiler/ncgutil.pas @@ -870,6 +870,8 @@ implementation procedure gen_save_used_regs(list:TAsmList); begin + if po_noreturn in current_procinfo.procdef.procoptions then + exit; { Pure assembler routines need to save the registers themselves } if (po_assembler in current_procinfo.procdef.procoptions) then exit; @@ -880,6 +882,8 @@ implementation procedure gen_restore_used_regs(list:TAsmList); begin + if po_noreturn in current_procinfo.procdef.procoptions then + exit; { Pure assembler routines need to save the registers themselves } if (po_assembler in current_procinfo.procdef.procoptions) then exit;