From 34be9e464331921895f19699348ef7c663dd7e05 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 1 Mar 2020 09:37:09 +0000 Subject: [PATCH] * CallRet2* optimization may not misalign the stack, reported by C Western on fpc-devel git-svn-id: trunk@44253 - --- compiler/x86/aoptx86.pas | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index 920119b448..898e3e7dda 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -176,6 +176,7 @@ unit aoptx86; uses cutils,verbose, + systems, globals, cpuinfo, procinfo, @@ -5902,7 +5903,9 @@ unit aoptx86; MatchInstruction(hp1,A_RET,[S_NO]) and (taicpu(hp1).ops=0) then begin - if cs_opt_level4 in current_settings.optimizerswitches then + if (cs_opt_level4 in current_settings.optimizerswitches) and + { we might destroy stack alignment here if we do not do a call } + (target_info.stackalign<=sizeof(SizeUInt)) then begin taicpu(p).opcode := A_JMP; taicpu(p).is_jmp := true;