http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59763
Bug ID: 59763 Summary: ICE in dwarf2out_frame_debug_expr, at dwarf2cfi.c:1550 with -mno-accumulate-outgoing-args Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: ubizjak at gmail dot com 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