The following code causes an ICE when compiled with the current gcc trunk at -O2 and -O3 on x86_64-linux-gnu in 64-bit mode (but not in 32-bit mode). It is a regression from 4.8.x. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --prefix=/usr/local/gcc-trunk --enable-languages=c,c++ --disable-werror --enable-multilib Thread model: posix gcc version 4.9.0 20131204 (experimental) [trunk revision 205660] (GCC) $ $ gcc-trunk -m64 -Os -c small.c $ gcc-4.8 -m64 -O2 -c small.c $ gcc-trunk -m32 -O2 -c small.c $ $ gcc-trunk -m64 -O2 -c small.c small.c: In function ‘fn2’: small.c:31:1: error: incorrect sharing of tree nodes } ^ a.f2 # .MEM_11 = VDEF <.MEM_10> a.f2 = D.1782; small.c:31:1: internal compiler error: verify_gimple failed 0x9d3821 verify_gimple_in_cfg(function*) ../../gcc-trunk/gcc/tree-cfg.c:4848 0x8fa874 execute_function_todo ../../gcc-trunk/gcc/passes.c:1843 0x8fb273 execute_todo ../../gcc-trunk/gcc/passes.c:1877 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. $ --------------------------- struct S0 { int f0; }; struct S1 { int f1; struct S0 f2; } c; int b; struct S0 fn1 () { struct S1 d; if (b) for (; c.f1;) ; else return d.f2; } struct S0 fn2 () { struct S1 a; a.f2 = fn1 (); return a.f2; }
Confirmed.
Created attachment 31411 [details] gcc49-pr59386.patch Untested fix.
Author: jakub Date: Wed Dec 11 09:18:33 2013 New Revision: 205883 URL: http://gcc.gnu.org/viewcvs?rev=205883&root=gcc&view=rev Log: PR tree-optimization/59386 * tree-inline.c (remap_gimple_stmt): If not id->do_not_unshare, unshare_expr (id->retval) before passing it to gimple_build_assign. * gcc.c-torture/compile/pr59386.c: New test. Added: trunk/gcc/testsuite/gcc.c-torture/compile/pr59386.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-inline.c
Fixed.