* 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 -
This commit is contained in:
Jonas Maebe 2007-02-15 20:25:36 +00:00
parent ead7ecf73a
commit c4913ac85d
2 changed files with 15 additions and 5 deletions

View File

@ -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
@ -1055,6 +1055,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
@ -1118,6 +1119,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);

View File

@ -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 } begin
result := (32-first_save_int_reg)*4+(32-first_save_fpu_reg)*8 { 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; begin
result := align(result,16); 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
result := align(tg.lasttemp,16); result := align(tg.lasttemp,16);