Browse Source

* on aarch64-win64 we need to restore the stack by first increasing the stackpointer and then restoring FP to match the code from the prologue

Sven/Sarah Barth 9 months ago
parent
commit
552ba93536
1 changed files with 9 additions and 1 deletions
  1. 9 1
      compiler/aarch64/cgcpu.pas

+ 9 - 1
compiler/aarch64/cgcpu.pas

@@ -2167,7 +2167,15 @@ implementation
             else if current_procinfo.final_localsize<>0 then
               begin
                 { restore stack pointer }
-                if pi_no_framepointer_needed in current_procinfo.flags then
+                { Note: for Windows we need to restore the stack using an ADD
+                        and to set FP back to SP }
+                if target_info.system=system_aarch64_win64 then
+                  begin
+                    handle_reg_imm12_reg(list,A_ADD,OS_ADDR,current_procinfo.framepointer,current_procinfo.final_localsize,
+                      current_procinfo.framepointer,NR_IP0,false,true);
+                      a_load_reg_reg(list,OS_ADDR,OS_ADDR,NR_FP,NR_SP);
+                  end
+                else if pi_no_framepointer_needed in current_procinfo.flags  then
                   handle_reg_imm12_reg(list,A_ADD,OS_ADDR,current_procinfo.framepointer,current_procinfo.final_localsize,
                     current_procinfo.framepointer,NR_IP0,false,true)
                 else