Bug 59763 - ICE in dwarf2out_frame_debug_expr, at dwarf2cfi.c:1550 with -mno-accumulate-outgoing-args
Summary: ICE in dwarf2out_frame_debug_expr, at dwarf2cfi.c:1550 with -mno-accumulate-o...
Status: RESOLVED DUPLICATE of bug 54694
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-10 18:53 UTC by Uroš Bizjak
Modified: 2014-01-10 19:12 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-01-10 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uroš Bizjak 2014-01-10 18:53:18 UTC
Following testcase:

--cut here--
extern void abort(void);

register long *B asm ("ebp");

int main()
{
  abort();
  return 0;
}
--cut here--

ICEs with -mno-accumulate-outgoing-args on 32bit and 64bit x86 targets, when preferred stack boundary is larger than the word size (2 for 32bit and 4 for 64bit targets) Please note that default stack boundary is set to 4 by default, so the ICE triggers even without -mpreferred-stack-boundary option.

-m32 -mno-accumulate-outgoing-args

t.c: In function ‘main’:
t.c:9:1: internal compiler error: in dwarf2out_frame_debug_expr, at dwarf2cfi.c:1550
 }
 ^
0x6c5cd3 dwarf2out_frame_debug_expr
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:1548
0x6c6133 dwarf2out_frame_debug
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2043
0x6c6133 scan_insn_after
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2369
0x6c7fd3 scan_trace
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2526
0x6c8a92 create_cfi_notes
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2565
0x6c8a92 execute_dwarf2_frame
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2925
0x6c8a92 execute
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:3421
Please submit a full bug report,
...

-m64 -mno-accumulate-outgoing-args -mpreferred-stack-boundary=5

t.c: In function ‘main’:
t.c:9:1: internal compiler error: in dwarf2out_frame_debug_expr, at dwarf2cfi.c:1550
 }
 ^
0x6c5cd3 dwarf2out_frame_debug_expr
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:1548
0x6c6133 dwarf2out_frame_debug
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2043
0x6c6133 scan_insn_after
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2369
0x6c7fd3 scan_trace
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2526
0x6c8a92 create_cfi_notes
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2565
0x6c8a92 execute_dwarf2_frame
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:2925
0x6c8a92 execute
        /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:3421
Please submit a full bug report,
...


(gdb) up
#2  0x00000000006c5cd4 in dwarf2out_frame_debug_expr (expr=expr@entry=0x7ffff19c8eb8) at /home/uros/gcc-svn/trunk/gcc/dwarf2cfi.c:1548
1548                  gcc_assert (!fixed_regs [REGNO (dest)]
(gdb) p debug_rtx (dest)
(reg/f:DI 6 bp)
$3 = void
(gdb) p debug_rtx(expr)
(set (reg/f:DI 6 bp)
    (reg/f:DI 7 sp))
$4 = void

(gdb) list
1543                  cur_trace->cfa_temp.offset = cur_cfa->offset;
1544                }
1545              else
1546                {
1547                  /* Saving a register in a register.  */
1548                  gcc_assert (!fixed_regs [REGNO (dest)]
1549                              /* For the SPARC and its register window.  */
1550                              || (dwf_regno (src) == DWARF_FRAME_RETURN_COLUMN));
1551
1552                  /* After stack is aligned, we can only save SP in FP

The problem is that compiler emits the frame for main(), even when -fomit-frame-pointer is active (the default for 64bit and 32bit targets).

(insn/f 16 3 17 2 (set (reg:DI 39 r10)
        (plus:DI (reg/f:DI 7 sp)
            (const_int 8 [0x8]))) t.c:6 259 {*leadi}
     (nil))
(insn/f 17 16 18 2 (parallel [
            (set (reg/f:DI 7 sp)
                (and:DI (reg/f:DI 7 sp)
                    (const_int -32 [0xffffffffffffffe0])))
            (clobber (reg:CC 17 flags))
        ]) t.c:6 400 {*anddi_1}
     (nil))
(insn/f 18 17 19 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0  S8 A8])
        (mem/c:DI (plus:DI (reg:DI 39 r10)
                (const_int -8 [0xfffffffffffffff8])) [0  S8 A8])) t.c:6 65 {*pushdi2_rex64}
     (nil))
(insn/f 19 18 20 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0  S8 A8])
        (reg/f:DI 6 bp)) t.c:6 65 {*pushdi2_rex64}
     (nil))
(insn/f 20 19 21 2 (set (reg/f:DI 6 bp)
        (reg/f:DI 7 sp)) t.c:6 89 {*movdi_internal}
     (nil))
(insn/f 21 20 22 2 (set (mem:DI (pre_dec:DI (reg/f:DI 7 sp)) [0  S8 A8])
        (reg:DI 39 r10)) t.c:6 65 {*pushdi2_rex64}
     (nil))
(insn/f 22 21 23 2 (parallel [
            (set (reg/f:DI 7 sp)
                (plus:DI (reg/f:DI 7 sp)
                    (const_int -8 [0xfffffffffffffff8])))
            (clobber (reg:CC 17 flags))
            (clobber (mem:BLK (scratch) [0  A8]))
        ]) t.c:6 969 {pro_epilogue_adjust_stack_di_add}
     (nil))

The compiler trips on a frame-related (insn/f 20), where fixed reg (bp) is touched. So, is it really necessary to emit frame-reg setup for main, even with -fomit-frame-pointer?

This problem is the cause of the gcc.target/i386/pr9771-1.c testsuite failure [1] when the compiler defaults to -march=corei7.

[1] http://gcc.gnu.org/ml/gcc-testresults/2014-01/msg00720.html
Comment 1 Uroš Bizjak 2014-01-10 19:06:27 UTC
The compilation with -maccumulate-outgoing-args avoids the ICE, although the resulting asm code touches %ebp in frame-related insn:

#(insn/f 16 20 21 2 (set (reg/f:SI 6 bp)
#        (reg/f:SI 7 sp)) t.c:6 90 {*movsi_internal}
#     (nil))
        movl    %esp, %ebp      # 16    *movsi_internal/1       [length = 2]
Comment 2 H.J. Lu 2014-01-10 19:09:30 UTC
Dup
Comment 3 Uroš Bizjak 2014-01-10 19:11:13 UTC
(In reply to H.J. Lu from comment #2)
> Dup

... of ?
Comment 4 H.J. Lu 2014-01-10 19:12:01 UTC
Reopened
Comment 5 H.J. Lu 2014-01-10 19:12:23 UTC
Dup.

*** This bug has been marked as a duplicate of bug 54694 ***