瀏覽代碼

* don't save stack pointer if we don't need to allocate a
stack frame but nevertheless have to store registers to
the stack (not only optimization, but also needed because
in that case no room for the stack pointer is reserved
and thus it'll overwrite one of the saved registers!)

git-svn-id: trunk@6498 -

Jonas Maebe 18 年之前
父節點
當前提交
c4913ac85d
共有 2 個文件被更改,包括 15 次插入5 次删除
  1. 3 1
      compiler/powerpc/cgcpu.pas
  2. 12 4
      compiler/powerpc/cpupi.pas

+ 3 - 1
compiler/powerpc/cgcpu.pas

@@ -1,4 +1,4 @@
-    {
+{
     Copyright (c) 1998-2002 by Florian Klaempfl
 
     This unit implements the code generator for the PowerPC
@@ -1055,6 +1055,7 @@ const
 *)
 
         if (not nostackframe) and
+           tppcprocinfo(current_procinfo).needstackframe and
            (localsize <> 0) then
           begin
             if (localsize <= high(smallint)) then
@@ -1118,6 +1119,7 @@ const
         { is translated into a move, which is then registered with the register }
         { allocator, causing a crash                                            }
         if (not nostackframe) and
+           tppcprocinfo(current_procinfo).needstackframe and
            (localsize <> 0) then
           a_op_const_reg(list,OP_ADD,OS_ADDR,localsize,NR_R1);
 

+ 12 - 4
compiler/powerpc/cpupi.pas

@@ -34,6 +34,8 @@ unit cpupi;
 
     type
        tppcprocinfo = class(tcgprocinfo)
+          needstackframe: boolean;
+
           { offset where the frame pointer from the outer procedure is stored. }
           parent_framepointer_offset : longint;
           constructor create(aparent:tprocinfo);override;
@@ -167,11 +169,17 @@ unit cpupi;
                  ((32-first_save_int_reg)*4+(32-first_save_fpu_reg)*8 <= 220)) or
                 ((target_info.abi = abi_powerpc_sysv) and
                  (first_save_int_reg + first_save_fpu_reg = 64))) then
-              { don't allocate a stack frame }
-              result := (32-first_save_int_reg)*4+(32-first_save_fpu_reg)*8
+              begin
+                { don't allocate a stack frame }
+                result := (32-first_save_int_reg)*4+(32-first_save_fpu_reg)*8;
+                needstackframe := false;
+              end
             else
-              result := (32-first_save_int_reg)*4+(32-first_save_fpu_reg)*8+tg.lasttemp;
-            result := align(result,16);
+              begin
+                result := (32-first_save_int_reg)*4+(32-first_save_fpu_reg)*8+tg.lasttemp;
+                result := align(result,16);
+                needstackframe := result<>0;
+              end;
           end
         else
           result := align(tg.lasttemp,16);