The v850 is a dwarf-debug target, but not a dwarf-unwind target.  In
dwarf2out.c we first calculate the "fp to fb offset" in
compute_frame_pointer_to_fb_displacement.  The frame pointer is not
needed, so note that we include the fp-sp elimination offset in
frame_pointer_fb_offset.

-------------------- \/ --------------------

/* Compute a displacement from the "steady-state frame pointer" to the
   frame base (often the same as the CFA), and store it in
   frame_pointer_fb_offset.  OFFSET is added to the displacement
   before the latter is negated.  */

static void
compute_frame_pointer_to_fb_displacement (HOST_WIDE_INT offset)
{
  rtx reg, elim;

#ifdef FRAME_POINTER_CFA_OFFSET
  reg = frame_pointer_rtx;
  offset += FRAME_POINTER_CFA_OFFSET (current_function_decl);
#else
  reg = arg_pointer_rtx;
  offset += ARG_POINTER_CFA_OFFSET (current_function_decl);
#endif

  elim = eliminate_regs (reg, VOIDmode, NULL_RTX);
  if (GET_CODE (elim) == PLUS)
    {
      offset += INTVAL (XEXP (elim, 1));
      elim = XEXP (elim, 0);
    }
  gcc_assert (elim == (frame_pointer_needed ? hard_frame_pointer_rtx
                       : stack_pointer_rtx));

  frame_pointer_fb_offset = -offset;
}

-------------------- /\ --------------------

Later, when we calculate function parameter locations, we end up in
based_loc_descr().  We call eliminate_regs again, adjust for the
elimination offset, then adjust for frame_pointer_fb_offset, which
*also* includes the elimination offset:

-------------------- \/ --------------------

static dw_loc_descr_ref
based_loc_descr (rtx reg, HOST_WIDE_INT offset)
{
  unsigned int regno;

  /* We only use "frame base" when we're sure we're talking about the
     post-prologue local stack frame.  We do this by *not* running
     register elimination until this point, and recognizing the special
     argument pointer and soft frame pointer rtx's.  */
  if (reg == arg_pointer_rtx || reg == frame_pointer_rtx)
    {
      rtx elim = eliminate_regs (reg, VOIDmode, NULL_RTX);

      if (elim != reg)
        {
          if (GET_CODE (elim) == PLUS)
            {
              offset += INTVAL (XEXP (elim, 1));
              elim = XEXP (elim, 0);
            }
          gcc_assert (elim == (frame_pointer_needed ? hard_frame_pointer_rtx
                      : stack_pointer_rtx));
          offset += frame_pointer_fb_offset;

          return new_loc_descr (DW_OP_fbreg, offset, 0);
        }
    }

-------------------- /\ --------------------

The net result is that the dwarf2 debug information is off by the
fp-sp offset.  My question is: which of these adjustments isn't
supposed to happen in this case?

Thanks,
DJ

Reply via email to