https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81570

            Bug ID: 81570
           Summary: create_pseudo_cfg assumes that
                    INCOMING_FRAME_SP_OFFSET is a constant
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hjl.tools at gmail dot com
  Target Milestone: ---

There are

@defmac INCOMING_FRAME_SP_OFFSET
A C expression whose value is an integer giving the offset, in bytes,
from the value of the stack pointer register to the top of the stack
frame at the beginning of any function, before the prologue.  The top of
the frame is defined to be the value of the stack pointer in the
previous frame, just before the call instruction.

You only need to define this macro if you want to support call frame
debugging information like that provided by DWARF 2.
@end defmac

It doesn't say that INCOMING_FRAME_SP_OFFSET must be a constant.  There
are

config/stormy16/stormy16.h:#define INCOMING_FRAME_SP_OFFSET
(xstormy16_interrupt_function_p () ? -6 : -4)

But create_cie_data has

create_cie_data (void)
{
  dw_cfa_location loc;
  dw_trace_info cie_trace;

  dw_stack_pointer_regnum = DWARF_FRAME_REGNUM (STACK_POINTER_REGNUM);

  memset (&cie_trace, 0, sizeof (cie_trace));
  cur_trace = &cie_trace;

  add_cfi_vec = &cie_cfi_vec;
  cie_cfi_row = cur_row = new_cfi_row ();

  /* On entry, the Canonical Frame Address is at SP.  */
  memset (&loc, 0, sizeof (loc));
  loc.reg = dw_stack_pointer_regnum;
  loc.offset = INCOMING_FRAME_SP_OFFSET;
  def_cfa_1 (&loc);

and create_pseudo_cfg has

  bool saw_barrier, switch_sections;
  dw_trace_info ti;
  rtx_insn *insn;
  unsigned i;

  /* The first trace begins at the start of the function,
     and begins with the CIE row state.  */
  trace_info.create (16);
  memset (&ti, 0, sizeof (ti));
  ti.head = get_insns ();
  ti.beg_row = cie_cfi_row;
  ti.cfa_store = cie_cfi_row->cfa; <<<<<<<  This assumes
INCOMING_FRAME_SP_OFFSET
is constant for different functions.
  ti.cfa_temp.reg = INVALID_REGNUM;
  trace_info.quick_push (ti);

When INCOMING_FRAME_SP_OFFSET changes, the debug info is broken.

Reply via email to