Hi All,

Our private backend has the macro  defined as

#define FIRST_PARM_OFFSET(FNDECL)  (get_frame_size() +
STARTING_FRAME_OFFSET  + RETURN_BYTES )

#define STARTING_FRAME_OFFSET  1

#define STACK_POINTER_REGNUM    10

#define FRAME_POINTER_REGNUM STACK_POINTER_REGNUM

#define ARG_POINTER_REGNUM STACK_POINTER_REGNUM

                #define  RETURN_BYTES  2

The  pass i.e instantiate_virtual_regs  set the  in_arg_offset as

in_arg_offset = FIRST_PARM_OFFSET (current_function_decl);

the computed  frame_size is X and in_arg_offset is X + 1 + 2  i.e X + 3.

And calls the instantiate_virtual_regs_in_rtx function  ,which emits
the insns to access the incoming argumnets (that are passed with
stack) via stack_pointer_rtx  + in_arg_offset (stack grows downward).

But in the reload pass the the alter_reg function (spill the  reg to
stack ) expand the stack frame and update the frame_size i.e  X = X +
allocated space.

For each spill the frame_size is updated  and at the end of the reload
pass the frame_size=frame_size+ total_allocated_spilled _space;

Our prologue  code looks like

void expand_prologue()
{

        HOST_WIDE_INT frame_size = get_frame_size ();  //here
frame_size=frame_size+ total_allocated_spilled _space;
        rtx reg,insn ;

        if(frame_size > 0 )
        {
                insn =
emit_move_insn(stack_pointer_rtx,gen_rtx_MINUS(GET_MODE(stack_pointer_rtx),stack_pointer_rtx,(GEN_INT(frame_size))
));
                RTX_FRAME_RELATED_P (insn) = 1;
        }
}


The problem is that the frame_size is not same ,when there is the
spill code between  instantiate_virtual_regs_in_rtx()  and
expand_prologue() ,hence incoming arg offset goes for a  toss like

sub sp ,10            // prologue where frame_size =10

ld  R1,sp               // accessing the first argument that is passed
in the stack;
add R1, 11           // the offset should be 13  i.e frame_size + 1 +
2; but it is 11 (stack_pointer_rtx  + (in_arg_offset =11)  where the
frame_size is 8  for locals )
ld  R2, [R1]

ld[sp+9] ,R10      // spill code

add sp,10 // epilogue

In the above asm  the  incoming arguments fetch  going for a  toss
,Any idea what  going wrong with the computation offset for incoming
arguments  here ??

Thank you
~Umesh

Reply via email to