[Bug debug/59575] [4.9 regression] ICE in maybe_record_trace_start, at dwarf2cfi.c:2239

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 22 20:03:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59575

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |ramana at gcc dot gnu.org,
                   |                            |rearnsha at gcc dot gnu.org

--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The #c1 to #c5 comments are completely unrelated to the #c0 issue, which is
clearly a bug in the ARM backend.

When creating prologue, the ARM backend decides to save some garbage registers
(just to avoid having to decrement stack pointer separately?):
      if (optimize_size && !frame_pointer_needed
          && saved_regs == offsets->saved_regs - offsets->saved_args)
        {
          /* If no coprocessor registers are being pushed and we don't have
             to worry about a frame pointer then push extra registers to
             create the stack frame.  This is done is a way that does not
             alter the frame layout, so is independent of the epilogue.  */
          int n;
          int frame;
          n = 0;
          while (n < 8 && (live_regs_mask & (1 << n)) == 0)
            n++;
          frame = offsets->outgoing_args - (offsets->saved_args + saved_regs);
          if (frame && n * 4 >= frame)
            {
              n = frame / 4;
              live_regs_mask |= (1 << n) - 1;
              saved_regs += frame;
            }
        }
so without -g we get:
        stmfd   sp!, {r0, r1, r2, lr}
in the prologue (note, this is shrink wrapped) and
        add     sp, sp, #12
        @ sp needed
        ldr     lr, [sp], #4
in the epilogue (note, r0-r2 not restored there).
This is all fine, except that the
emit_multi_reg_push/arm_emit_strd_push/thumb2_emit_strd_push all record all
those saved registers into
REG_FRAME_RELATED_EXPR, which is a very bad idea.  Only call clobbered
registers that you actually save in prologue and restore in epilogue should be
declared as saved for CFI purposes, the dwarf2cfi.c code verifies this property
and that's the reason for this ICE.

Now, I'm afraid I'm not familiar enough with the multitude of ARM ABIs, so not
sure if the best fix is just to ignore for the REG_FRAME_RELATED_EXPR in those
3 above mentioned functions all non-fixed call_used registers, just ignore
r0..r3, or if the caller should call those functions with two masks, one for
what registers should be actually saved to the stack (as right now) and another
for which registers should be in REG_FRAME_RELATED_EXPR (equal to the first or
some subset thereof).



More information about the Gcc-bugs mailing list