Browse Source

Merged revisions 6498 via svnmerge from
svn+ssh://[email protected]/FPC/svn/fpc/trunk

........
r6498 | jonas | 2007-02-15 21:25:36 +0100 (Thu, 15 Feb 2007) | 6 lines

* 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: branches/fpc_2_3@6677 -

Jonas Maebe 18 years ago
parent
commit
b169062c63
2 changed files with 15 additions and 5 deletions
  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
     Copyright (c) 1998-2002 by Florian Klaempfl
 
 
     This unit implements the code generator for the PowerPC
     This unit implements the code generator for the PowerPC
@@ -1047,6 +1047,7 @@ const
 *)
 *)
 
 
         if (not nostackframe) and
         if (not nostackframe) and
+           tppcprocinfo(current_procinfo).needstackframe and
            (localsize <> 0) then
            (localsize <> 0) then
           begin
           begin
             if (localsize <= high(smallint)) then
             if (localsize <= high(smallint)) then
@@ -1110,6 +1111,7 @@ const
         { is translated into a move, which is then registered with the register }
         { is translated into a move, which is then registered with the register }
         { allocator, causing a crash                                            }
         { allocator, causing a crash                                            }
         if (not nostackframe) and
         if (not nostackframe) and
+           tppcprocinfo(current_procinfo).needstackframe and
            (localsize <> 0) then
            (localsize <> 0) then
           a_op_const_reg(list,OP_ADD,OS_ADDR,localsize,NR_R1);
           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
     type
        tppcprocinfo = class(tcgprocinfo)
        tppcprocinfo = class(tcgprocinfo)
+          needstackframe: boolean;
+
           { offset where the frame pointer from the outer procedure is stored. }
           { offset where the frame pointer from the outer procedure is stored. }
           parent_framepointer_offset : longint;
           parent_framepointer_offset : longint;
           constructor create(aparent:tprocinfo);override;
           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
                  ((32-first_save_int_reg)*4+(32-first_save_fpu_reg)*8 <= 220)) or
                 ((target_info.abi = abi_powerpc_sysv) and
                 ((target_info.abi = abi_powerpc_sysv) and
                  (first_save_int_reg + first_save_fpu_reg = 64))) then
                  (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
             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
           end
         else
         else
           begin
           begin