Browse Source

* generate no exit code at all on x86-64 if the subroutine is compiled with po_noreturn

florian 3 years ago
parent
commit
0b3fb55c6a
1 changed files with 6 additions and 0 deletions
  1. 6 0
      compiler/x86_64/cgcpu.pas

+ 6 - 0
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) }