Browse Source

* there is no exit stackframe needed if a subroutine never returns

git-svn-id: trunk@44191 -
florian 5 years ago
parent
commit
ef3155c2ef
1 changed files with 8 additions and 1 deletions
  1. 8 1
      compiler/x86_64/cgcpu.pas

+ 8 - 1
compiler/x86_64/cgcpu.pas

@@ -370,7 +370,14 @@ unit cgcpu;
         if (current_procinfo.flags*[pi_has_unwind_info,pi_do_call,pi_has_saved_regs])=[pi_has_unwind_info,pi_do_call] then
           list.concat(Taicpu.op_none(A_NOP));
         { remove stackframe }
-        if not nostackframe then
+        if not(nostackframe) and
+          { we do not need an exit stack frame when we never return
+
+            * the final ret is left so the peephole optimizer can easily do call/ret -> jmp or call conversions
+            * the entry stack frame must be normally generated because the subroutine could be still left by
+              an exception and then the unwinding code might need to restore the registers stored by the entry code
+          }
+          not(po_noreturn in current_procinfo.procdef.procoptions) then
           begin
             if use_push then
               begin