summaryrefslogtreecommitdiff
path: root/compiler/x86_64
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-02-16 13:06:19 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-02-16 13:06:19 +0000
commit4920b71f6c1a110a0faa862fc435de5a116866ec (patch)
tree30c2e0c68c14ce97d55b871a2e5da337f584fb55 /compiler/x86_64
parent3e31e7769f6b7f1e7bb125a2a39ac9b594c46942 (diff)
downloadfpc-4920b71f6c1a110a0faa862fc435de5a116866ec.tar.gz
* there is no exit stackframe needed if a subroutine never returns
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@44191 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'compiler/x86_64')
-rw-r--r--compiler/x86_64/cgcpu.pas9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/x86_64/cgcpu.pas b/compiler/x86_64/cgcpu.pas
index 409009f46d..4533276050 100644
--- a/compiler/x86_64/cgcpu.pas
+++ b/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