legolas[14:13] make% /opt/gcc/gcc-3.5/bin/gcc -O2 -g -c bug.c bug.c: In function `Buf_GetAll': bug.c:13: error: unrecognizable insn: (insn 31 25 55 bug.c:13 (use (reg/i:SI 28 %r28 [ <result> ])) -1 (insn_list 41 (nil)) (nil)) bug.c:13: internal compiler error: in insn_default_length, at insn-attrtab.c:825 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. ICE doesn't happen without -g, or with -O1 -g code snippet extracted from freebsd-buildutils -------- bug.c -------- typedef struct Buffer { char *inPtr; char *outPtr; } *Buffer; char * Buf_GetAll (Buffer bp, int *numcharsPtr) { if (numcharsPtr != 0) *numcharsPtr = bp->inPtr - bp->outPtr; return (bp->outPtr); } -------- bug.c --------
The ICE is generated by a call to insn_default_length in pa_output_function_epilogue. It does a call to get_last_nonnote_insn to get the last nonnote insn. However, in this case, get_last_nonnote_insn doesn't actually return the last nonnote insn. It returns the next to last nonnote insn which is the `use' insn which insn_default_length doesn't like. The code in get_last_nonnote_insn assumes that the last insn in the current sequence or current function is a note. However, when get_last_nonnote_insn is called, the last insn is (jump_insn 55 31 0 (parallel [ (return) (use (reg:SI 2 %r2)) (const_int 0 [0x0]) ]) 184 {return} (insn_list:REG_DEP_ANTI 31 (insn_list 41 (nil))) (expr_list:REG_BR_PRED (const_int 12 [0xc]) (expr_list:REG_DEAD (reg:SI 2 %r2) (nil)))) We did have the following note: (note 71 55 0 NOTE_INSN_DELETED) However, it is removed by a call to remove_insn: Breakpoint 13, remove_insn (insn=0x40196580) at ../../gcc/gcc/emit-rtl.c:3578 3578 rtx next = NEXT_INSN (insn); (gdb) bt #0 remove_insn (insn=0x40196580) at ../../gcc/gcc/emit-rtl.c:3578 #1 0x0011bb8c in delete_insn (insn=0x40196580) at ../../gcc/gcc/cfgrtl.c:149 #2 0x00113f5c in reemit_insn_block_notes () at ../../gcc/gcc/cfglayout.c:559 #3 0x001ebef0 in final_start_function (first=0x401961a0, file=0x66ddd0, optimize=2) at ../../gcc/gcc/final.c:1374 #4 0x00470108 in rest_of_handle_final (decl=0x4021af50, insns=0x401961a0) at ../../gcc/gcc/passes.c:447 The comment for NOTE_INSN_DELETED says /* This note is used to get rid of an insn when it isn't safe to patch the insn out of the chain. */ So, I don't think delete_insn should be trying to remove this note. If the note isn't removed, then get_last_nonnote_insn will work correctly and we shouldn't get the ICE.
Moving the target to 3.4.2 as per GDR and regressions on the 3.4 branch.
Confirmed by JDA.
Postponed until GCC 3.4.3.
*** Bug 17858 has been marked as a duplicate of this bug. ***
Postponed until GCC 3.4.4.
*** Bug 18593 has been marked as a duplicate of this bug. ***
Subject: Bug 14838 CVSROOT: /cvs/gcc Module name: gcc Changes by: danglin@gcc.gnu.org 2004-11-23 02:15:19 Modified files: gcc : ChangeLog emit-rtl.c Log message: PR rtl-optimization/14838 * emit-rtl.c (get_first_nonnote_insn): Don't assume first insn is a note. (get_last_nonnote_insn): Don't assume last insn is a note. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6475&r2=2.6476 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/emit-rtl.c.diff?cvsroot=gcc&r1=1.425&r2=1.426
Subject: Bug 14838 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: danglin@gcc.gnu.org 2004-11-23 03:01:19 Modified files: gcc : ChangeLog emit-rtl.c Log message: PR rtl-optimization/14838 * emit-rtl.c (get_first_nonnote_insn): Don't assume first insn is a note. (get_last_nonnote_insn): Don't assume last insn is a note. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.696&r2=2.2326.2.697 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/emit-rtl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.365.4.5&r2=1.365.4.6
Subject: Bug 14838 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: danglin@gcc.gnu.org 2004-11-23 03:37:53 Modified files: gcc : ChangeLog emit-rtl.c Log message: PR rtl-optimization/14838 * emit-rtl.c (get_first_nonnote_insn): Don't assume first insn is a note. (get_last_nonnote_insn): Don't assume last insn is a note. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.1024&r2=1.16114.2.1025 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/emit-rtl.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.303.2.5&r2=1.303.2.6
Fixed.
*** Bug 18647 has been marked as a duplicate of this bug. ***
*** Bug 19752 has been marked as a duplicate of this bug. ***