From 2629bd7ba92a03ed6b106448b7eae6429b63e94a Mon Sep 17 00:00:00 2001 From: florian Date: Thu, 15 Jul 2021 20:58:46 +0000 Subject: [PATCH] * patch by J. Gareth Moreton: x86: Lea2Nop for stack pointer, resolves #39225 git-svn-id: trunk@49612 - --- compiler/x86/aoptx86.pas | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index 10142585f3..7be27d4cf4 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -3742,8 +3742,15 @@ unit aoptx86; { changes "lea (%reg1), %reg2" into "mov %reg1, %reg2" } if (taicpu(p).oper[0]^.ref^.base <> NR_NO) and (taicpu(p).oper[0]^.ref^.index = NR_NO) and - { do not mess with leas acessing the stack pointer } - (taicpu(p).oper[1]^.reg <> NR_STACK_POINTER_REG) and + ( + { do not mess with leas accessing the stack pointer + unless it's a null operation } + (taicpu(p).oper[1]^.reg <> NR_STACK_POINTER_REG) or + ( + (taicpu(p).oper[0]^.ref^.base = NR_STACK_POINTER_REG) and + (taicpu(p).oper[0]^.ref^.offset = 0) + ) + ) and (not(Assigned(taicpu(p).oper[0]^.ref^.Symbol))) then begin if (taicpu(p).oper[0]^.ref^.offset = 0) then