Bug 61221 - [4.10 Regression] ICE on valid code at -O1 and above on x86_64-linux-gnu
Summary: [4.10 Regression] ICE on valid code at -O1 and above on x86_64-linux-gnu
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-18 22:58 UTC by Zhendong Su
Modified: 2014-05-20 08:16 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-05-19 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhendong Su 2014-05-18 22:58:41 UTC
The following code causes an ICE when compiled with the current gcc trunk at -O1 and above on x86_64-linux-gnu in both 32-bit and 64-bit modes.

It is a regression from 4.9.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.10.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.10.0 20140518 (experimental) [trunk revision 210581] (GCC) 
$ 
$ gcc-trunk -O0 -c small.c
$ gcc-4.9.0 -O1 -c small.c
$ 
$ gcc-trunk -O1 -c small.c
small.c: In function ‘bar’:
small.c:30:1: internal compiler error: Segmentation fault
 }
 ^
0x988c1f crash_signal
	../../gcc-trunk/gcc/toplev.c:337
0xa5b6de gimple_code
	../../gcc-trunk/gcc/gimple.h:1405
0xa5b6de gimple_nop_p
	../../gcc-trunk/gcc/gimple.h:5559
0xa5b6de walk_non_aliased_vuses(ao_ref*, tree_node*, void* (*)(ao_ref*, tree_node*, unsigned int, void*), void* (*)(ao_ref*, tree_node*, void*, bool), void*)
	../../gcc-trunk/gcc/tree-ssa-alias.c:2550
0xb02599 vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind, vn_reference_s**)
	../../gcc-trunk/gcc/tree-ssa-sccvn.c:2117
0xae040a eliminate_dom_walker::before_dom_children(basic_block_def*)
	../../gcc-trunk/gcc/tree-ssa-pre.c:4285
0xe93527 dom_walker::walk(basic_block_def*)
	../../gcc-trunk/gcc/domwalk.c:177
0xaddcad eliminate
	../../gcc-trunk/gcc/tree-ssa-pre.c:4429
0xade193 execute
	../../gcc-trunk/gcc/tree-ssa-pre.c:4852
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.
$ 

---------------------------

void __assert_fail (void);

int **a, b, c, e, *j;
short *d, **f;

int *
foo ()
{
  *a = j;
  if (!(1 & e)) 
    __assert_fail ();
  return 0;
}

void
bar ()
{
  int *g = &b;
  short **h = &d;
  if ((f = &d) != h)
    for (; b;)
      {
	int i = 1;
	if (i)
	  g = foo ();
	c = 0;
      }
  if (!g)
    __assert_fail ();
}
Comment 1 Richard Biener 2014-05-19 10:28:21 UTC
Confirmed, mine.
Comment 2 Richard Biener 2014-05-19 11:21:26 UTC
Interesting ;)  We do some non-sensical simplification on dead code and ICE.
But our dead-CFG compute code in SCCVN isn't up to recognizing a dead loop
because it's conservative and not optimistic.

Ultimatively this all is because of replacing a call with sth that doesn't
have a VDEF and gsi_replace/update_stmt being called which releases an SSA
name which corrupts the value-numbering lattice.
Comment 3 Richard Biener 2014-05-19 14:34:02 UTC
Author: rguenth
Date: Mon May 19 14:33:31 2014
New Revision: 210614

URL: http://gcc.gnu.org/viewcvs?rev=210614&root=gcc&view=rev
Log:
2014-05-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/61221
	* tree-ssa-pre.c (eliminate_dom_walker::before_dom_children):
	Do nothing for unreachable blocks.
	* tree-ssa-sccvn.c (cond_dom_walker::before_dom_children):
	Improve unreachability detection.

	* gcc.dg/torture/pr61221.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr61221.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-pre.c
    trunk/gcc/tree-ssa-sccvn.c
Comment 4 Richard Biener 2014-05-19 14:36:42 UTC
Fixed (worked around, real fix in testing).
Comment 5 Richard Biener 2014-05-20 08:16:45 UTC
Author: rguenth
Date: Tue May 20 08:16:13 2014
New Revision: 210633

URL: http://gcc.gnu.org/viewcvs?rev=210633&root=gcc&view=rev
Log:
2014-05-20  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/61221
	* tree-ssa-pre.c (el_to_update): Remove.
	(eliminate_dom_walker::before_dom_children): Handle released
	VDEFs by value-numbering them to the associated VUSE.  Update
	stmt immediately for substituted call address.
	(eliminate): Remove delayed stmt updating code.
	* tree-ssa-sccvn.c (vuse_ssa_val): New function valueizing
	possibly late re-numbered vuses.
	(vn_reference_lookup_2): Adjust.
	(vn_reference_lookup_pieces): Likewise.
	(vn_reference_lookup): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-pre.c
    trunk/gcc/tree-ssa-sccvn.c