From bb27442b1963ea767dbcd322ce8beeea7810474a Mon Sep 17 00:00:00 2001 From: Sven/Sarah Barth Date: Fri, 8 Nov 2024 23:29:13 +0100 Subject: [PATCH] * when removing the STP FP,LR and MOV FP,SP instructions, also remove the corresponding SEH directives if available --- compiler/aarch64/aoptcpu.pas | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/compiler/aarch64/aoptcpu.pas b/compiler/aarch64/aoptcpu.pas index c6c08a5a00..e6eb22ca2f 100644 --- a/compiler/aarch64/aoptcpu.pas +++ b/compiler/aarch64/aoptcpu.pas @@ -525,7 +525,7 @@ Implementation function TCpuAsmOptimizer.OptPass1STP(var p : tai): boolean; var - hp1, hp2, hp3, hp4: tai; + hp1, hp2, hp3, hp4, tmp1 : tai; begin Result:=false; { @@ -576,6 +576,22 @@ Implementation MatchInstruction(hp4, A_RET, [C_None], [PF_None]) and (taicpu(hp4).ops = 0) then begin + { remove the SEH instruction for the STP FP,LR } + if GetNextInstruction(p,tmp1,[ait_seh_directive]) and + (tmp1.typ=ait_seh_directive) and + (tai_seh_directive(tmp1).kind=ash_savefplr_x) then + begin + asml.Remove(tmp1); + tmp1.free; + end; + { remove the SEH instruction for the MOV FP,SP } + if GetNextInstruction(hp1,tmp1,[ait_seh_directive]) and + (tmp1.typ=ait_seh_directive) and + (tai_seh_directive(tmp1).kind=ash_setfp) then + begin + asml.Remove(tmp1); + tmp1.free; + end; asml.Remove(p); asml.Remove(hp1); asml.Remove(hp3);