diff --git a/compiler/x86_64/cgcpu.pas b/compiler/x86_64/cgcpu.pas index c8447259b3..94e014978c 100644 --- a/compiler/x86_64/cgcpu.pas +++ b/compiler/x86_64/cgcpu.pas @@ -369,6 +369,12 @@ unit cgcpu; r : longint; regs_to_save_mm: tcpuregisterarray; 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; + regs_to_save_mm:=paramanager.get_saved_registers_mm(current_procinfo.procdef.proccalloption); { Prevent return address from a possible call from ending up in the epilogue } { (restoring registers happens before epilogue, providing necessary padding) }