Reduced Testcase: static int unit_cache[3]; void find_unit_1 (int n, int do_create) { int *p; int c, created = 0; if (p == 0) if (do_create) created = 1; for (c = 0; c < 2; c++) unit_cache[c] = unit_cache[c + 1]; if (created) dec_waiting_unlocked (p); }
Compile that testcase with -O2 and you will recieve an ICE. Backtrace: #0 internal_error (gmsgid=0x9a973c "tree check: %s, have %s in %s, at %s:%d") at /Users/pinskia/src/gcc/local/gcc/gcc/diagnostic.c:586 #1 0x002c8280 in tree_check_failed (node=0x42caf5e4, file=0x9aac6c "/Users/pinskia/src/gcc/local/gcc/gcc/tree-ssanames.c", line=247, function=0x9aacd8 "duplicate_ssa_name") at /Users/pinskia/src/gcc/local/gcc/gcc/tree.c:6034 #2 0x002f77d0 in duplicate_ssa_name (name=0x42caf5e4, stmt=0x42cb418c) at /Users/pinskia/src/gcc/local/gcc/gcc/tree-ssanames.c:247 #3 0x006650b8 in create_new_def_for (old_name=0x42caf5e4, stmt=0x42cb418c, def=0x42cb0534) at /Users/pinskia/src/gcc/local/gcc/gcc/tree-into-ssa.c:2241 #4 0x0047d2dc in tree_duplicate_bb (bb=0x42c15528) at /Users/pinskia/src/gcc/local/gcc/gcc/tree-cfg.c:4341 #5 0x004870b4 in duplicate_block (bb=0x42c15528, e=0x0, after=0x0) at /Users/pinskia/src/gcc/local/gcc/gcc/cfghooks.c:716 #6 0x008f0adc in create_block_for_threading (bb=0x42c15528, rd=0x41e011c0) at /Users/pinskia/src/gcc/local/gcc/gcc/tree-ssa-threadupdate.c:210 #7 0x008f0ec8 in create_duplicates (slot=0x41e05eb8, data=0xbffff640) at /Users/pinskia/src/gcc/local/gcc/gcc/tree-ssa-threadupdate.c:350 #8 0x009744d4 in htab_traverse_noresize (htab=0x9a973c, callback=0x8f0e58 <create_duplicates>, info=0xbffff640) at /Users/pinskia/src/gcc/local/gcc/libiberty/hashtab.c:729 #9 0x008f1910 in thread_block (bb=0x42c15528) at /Users/pinskia/src/gcc/local/gcc/gcc/tree-ssa-threadupdate.c:790 #10 0x008f1ba0 in thread_through_all_blocks () at /Users/pinskia/src/gcc/local/gcc/gcc/tree-ssa-threadupdate.c:872 #11 0x0072e418 in finalize_jump_threads () at /Users/pinskia/src/gcc/local/gcc/gcc/tree-vrp.c:4361 #12 0x0072e814 in execute_vrp () at /Users/pinskia/src/gcc/local/gcc/gcc/tree-vrp.c:4502
I should say this was while building libgfortran/io/unit.c which makes this a blocker.
Subject: Re: [4.2 Regression] ICE in duplicate_ssa_name On Wed, 2006-02-08 at 04:22 +0000, pinskia at gcc dot gnu dot org wrote: > > ------- Comment #2 from pinskia at gcc dot gnu dot org 2006-02-08 04:22 ------- > I should say this was while building libgfortran/io/unit.c which makes this a > blocker. I didn't trip over anything like this on my x86 testing, but I have been able to reproduce it with a cross compiler. The fix is pretty trivial, but it'll take until sometime tomorrow before the regression testing and such is complete. jeff
(In reply to comment #3) > I didn't trip over anything like this on my x86 testing, but I have > been able to reproduce it with a cross compiler. The fix is > pretty trivial, but it'll take until sometime tomorrow before the > regression testing and such is complete. I should mention why you did not trip over it on the x86 testing orginally. This: if (p == 0) if (do_create) Was orginally: if (p == 0 && do_create) Which causes a slightly different IR.
FYI -- this also breaks bootstrap on s390-ibm-linux and s390x-ibm-linux: ../../../gcc-head/libgfortran/io/unit.c: In function 'find_unit_1': ../../../gcc-head/libgfortran/io/unit.c:269: internal compiler error: tree check: expected ssa_name, have struct_field_tag in duplicate_ssa_name, at tree-ssanames.c:247 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Subject: Re: [4.2 Regression] ICE in duplicate_ssa_name On Wed, 2006-02-08 at 16:10 +0000, uweigand at gcc dot gnu dot org wrote: > > ------- Comment #5 from uweigand at gcc dot gnu dot org 2006-02-08 16:10 ------- > FYI -- this also breaks bootstrap on s390-ibm-linux and s390x-ibm-linux: > > ../../../gcc-head/libgfortran/io/unit.c: In function 'find_unit_1': > ../../../gcc-head/libgfortran/io/unit.c:269: internal compiler error: tree > check: expected ssa_name, have struct_field_tag in duplicate_ssa_name, at > tree-ssanames.c:247 > Please submit a full bug report, > with preprocessed source if appropriate. > See <URL:http://gcc.gnu.org/bugs.html> for instructions. Should be fixed within the next couple hours - just waiting on regression testing to finish... jeff
Subject: Re: [4.2 Regression] ICE in duplicate_ssa_name On Wed, 2006-02-08 at 12:43 +0000, pinskia at gcc dot gnu dot org wrote: > > ------- Comment #4 from pinskia at gcc dot gnu dot org 2006-02-08 12:43 ------- > (In reply to comment #3) > > I didn't trip over anything like this on my x86 testing, but I have > > been able to reproduce it with a cross compiler. The fix is > > pretty trivial, but it'll take until sometime tomorrow before the > > regression testing and such is complete. > > I should mention why you did not trip over it on the x86 testing orginally. > This: > if (p == 0) > if (do_create) > Was orginally: > if (p == 0 && do_create) > Which causes a slightly different IR. This patch should fix the various instances of the ICE in duplicate_ssa_name. Basically VRP performed a constant propagation, changing the index in an array reference from a variable to a constant. When this occurs we queue SSA graph updates for the virtual operands of the statement. As a side effect, the virtual operands are no longer SSA_NAMEs, but instead _DECL nodes. We then find that we're able to thread through the block containing the updated array reference. The block duplication code doesn't know how to handle this case and dies. This patch simply handles any queued SSA updates before dealing with jump threads. DOM does the exact same thing. However, my gut tells me that this "solution" is mostly an artifact of how the old old old SSA graph updating code in DOM worked. I suspect that it wouldn't be terribly difficult to do all the SSA graph updates at the same time. Doing so would probably be a compile-time win as well. Regardless, this patch should bring various failing targets back into bootstrap land. Bootstrapped and regression tested on i686-pc-linux-gnu; I've also verified the ICE is fixed using cross compilers.
Created attachment 10803 [details] PPP
Fixed with attached patch.