Bug 77646 - [5 Regression] GCC Segfault with -O3
Summary: [5 Regression] GCC Segfault with -O3
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.4.0
: P2 normal
Target Milestone: 5.5
Assignee: Richard Biener
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-09-19 14:30 UTC by Gerald
Modified: 2017-01-24 11:31 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.9.4, 5.4.1, 6.2.1, 7.0
Known to fail: 5.4.0, 6.2.0
Last reconfirmed: 2016-09-19 00:00:00


Attachments
poset.c file (12.66 KB, text/plain)
2016-09-19 14:30 UTC, Gerald
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Gerald 2016-09-19 14:30:13 UTC
Created attachment 39648 [details]
poset.c file

Hi,

I obtain the same compiler internal error when I compile the attached file with gcc 5.4 (either on MacPorts or Linux Ubuntu).

gcc -O3 poset.c -c -o poset.o
poset.c: In function 'ar_poset_log':
poset.c:3238:1: internal compiler error: Segmentation fault
 ar_poset_log(ccl_log_type log, ar_poset *poset,
 ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions.
Comment 1 Marek Polacek 2016-09-19 14:33:27 UTC
Reproduced with trunk:
$ ./cc1 -quiet q.ii -O3
q.ii: In function ‘ar_poset_log’:
q.ii:3238:1: internal compiler error: tree check: expected ssa_name, have var_decl in vuse_ssa_val, at tree-ssa-sccvn.c:339
 ar_poset_log(ccl_log_type log, ar_poset *poset,
 ^~~~~~~~~~~~
0x10e181c tree_check_failed(tree_node const*, char const*, int, char const*, ...)
	/home/marek/src/gcc/gcc/tree.c:9742
0x7143c1 tree_check(tree_node*, char const*, int, char const*, tree_code)
	/home/marek/src/gcc/gcc/tree.h:3031
0xfe6c5d vuse_ssa_val
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:339
0xfeda7c vn_reference_lookup(tree_node*, tree_node*, vn_lookup_kind, vn_reference_s**, bool)
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:2425
0xff0b54 visit_reference_op_load
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:3520
0xff194e visit_use
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:3853
0xff24e9 process_scc
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:4104
0xff2834 extract_and_process_scc_for_name
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:4160
0xff29de DFS
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:4212
0xff42ed sccvn_dom_walker::before_dom_children(basic_block_def*)
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:4665
0x1700ef2 dom_walker::walk(basic_block_def*)
	/home/marek/src/gcc/gcc/domwalk.c:265
0xff4981 run_scc_vn(vn_lookup_kind)
	/home/marek/src/gcc/gcc/tree-ssa-sccvn.c:4789
0xfc63b0 execute
	/home/marek/src/gcc/gcc/tree-ssa-pre.c:5010
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.
Comment 2 Markus Trippelsdorf 2016-09-19 15:05:54 UTC
struct ccl_iterator_ccl_pointer_iterator_st {
  int (*has_more_elements)();
  void (*next_element)();
} * c;
int a;
void *ccl_real_calloc();
typedef struct {
  struct ccl_iterator_ccl_pointer_iterator_st super;
} poset_iterator;
int s_poset_iterator_has_more_elements() { return a; }
const struct ccl_iterator_ccl_pointer_iterator_st b = {
    s_poset_iterator_has_more_elements};
void ar_poset_log() {
  poset_iterator *d = ccl_real_calloc();
  d->super = b;
  c = (struct ccl_iterator_ccl_pointer_iterator_st *)d;
  struct ccl_iterator_ccl_pointer_iterator_st *i = c;
  if (i->has_more_elements(c))
    while (i->has_more_elements(c))
      i->next_element();
}
Comment 3 Markus Trippelsdorf 2016-09-19 15:09:11 UTC
Or with creduce's rename-toks:

struct e {
  int (*f)();
  void (*g)();
} * c;
int a;
void *h();
typedef struct { struct e j; } k;
int l() { return a; }
const struct e b = {l};
void m() {
  k *d = h();
  d->j = b;
  c = (struct e *)d;
  struct e *i = c;
  if (i->f(c))
    while (i->f(c))
      i->g();
}
Comment 4 Richard Biener 2016-09-20 08:16:21 UTC
Mine.
Comment 5 Richard Biener 2016-09-20 08:29:07 UTC
Ok, this is because we value-number the indirect call result to the result of
the direct call (correctly) but that has no VDEF (it's detected pure) and thus
we fail to value-number the indirect calls VDEF.

@@ -3470,6 +3577,10 @@ visit_reference_op_call (tree lhs, gcall
     {
       if (vnresult->result_vdef && vdef)
        changed |= set_ssa_val_to (vdef, vnresult->result_vdef);
+      else if (vdef)
+       /* If the call was discovered to be pure or const reflect
+          that as far as possible.  */
+       changed |= set_ssa_val_to (vdef, gimple_vuse (stmt));
 
       if (!vnresult->result && lhs)
        vnresult->result = lhs;
Comment 6 Richard Biener 2016-09-20 12:21:02 UTC
Fixed on trunk sofar.
Comment 7 Richard Biener 2016-09-20 12:21:09 UTC
Author: rguenth
Date: Tue Sep 20 12:20:37 2016
New Revision: 240261

URL: https://gcc.gnu.org/viewcvs?rev=240261&root=gcc&view=rev
Log:
2016-09-20  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77646
	* tree-ssa-sccvn.c (visit_reference_op_call): Always value-number
	a VDEF.

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

Added:
    trunk/gcc/testsuite/gcc.dg/torture/pr77646.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-sccvn.c
Comment 8 Richard Biener 2016-12-09 08:44:23 UTC
Author: rguenth
Date: Fri Dec  9 08:43:50 2016
New Revision: 243475

URL: https://gcc.gnu.org/viewcvs?rev=243475&root=gcc&view=rev
Log:
2016-12-09  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2016-11-28  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/78542
	* tree-ssa-ccp.c (evaluate_stmt): Only valueize simplification
	if allowed.

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

	2016-11-23  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/78482
	* tree-cfgcleanup.c: Include tree-ssa-loop-niter.h.
	(remove_forwarder_block_with_phi): When merging with a loop
	header creates a new latch reset number of iteration information
	of the loop.

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

	2016-11-23  Richard Biener  <rguenther@suse.de>

	PR middle-end/71762
	* match.pd ((~X & Y) -> X < Y, (X & ~Y) -> Y < X,
	(~X | Y) -> X <= Y, (X | ~Y) -> Y <= X): Remove.

	* gcc.dg/torture/pr71762-1.c: New testcase.
	* gcc.dg/torture/pr71762-2.c: Likewise.
	* gcc.dg/torture/pr71762-3.c: Likewise.
	* gcc.dg/tree-ssa/forwprop-28.c: XFAIL.

	2016-11-11  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/71575
	* graphite-isl-ast-to-gimple.c (copy_cond_phi_nodes): Remove
	bogus assert.

	* gcc.dg/graphite/pr71575-1.c: New testcase.
	* gcc.dg/graphite/pr71575-2.c: Likewise.

	2016-11-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/78224
	* tree-call-cdce.c (shrink_wrap_one_built_in_call_with_conds):
	Split the fallthru edge in case its successor may have PHIs.

	* g++.dg/torture/pr78224.C: New testcase.

	2016-11-05  David Edelsohn  <dje.gcc@gmail.com>
		Richard Biener  <rguenther@suse.de>

	PR bootstrap/78188
	PR c++/71848
	* ipa-comdats.c (pass_ipa_comdats::gate): Require HAVE_COMDAT_GROUP.

	* g++.dg/ipa/pr78188.C: New test.

	2016-09-20  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77646
	* tree-ssa-sccvn.c (visit_reference_op_call): Always value-number
	a VDEF.

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

Added:
    branches/gcc-6-branch/gcc/testsuite/g++.dg/ipa/pr78188.C
    branches/gcc-6-branch/gcc/testsuite/g++.dg/torture/pr78224.C
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/graphite/pr71575-1.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/graphite/pr71575-2.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr71762-1.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr71762-2.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr71762-3.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr77646.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr78482.c
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr78542.c
Modified:
    branches/gcc-6-branch/gcc/ChangeLog
    branches/gcc-6-branch/gcc/graphite-isl-ast-to-gimple.c
    branches/gcc-6-branch/gcc/ipa-comdats.c
    branches/gcc-6-branch/gcc/match.pd
    branches/gcc-6-branch/gcc/testsuite/ChangeLog
    branches/gcc-6-branch/gcc/testsuite/gcc.dg/tree-ssa/forwprop-28.c
    branches/gcc-6-branch/gcc/tree-call-cdce.c
    branches/gcc-6-branch/gcc/tree-cfgcleanup.c
    branches/gcc-6-branch/gcc/tree-ssa-ccp.c
    branches/gcc-6-branch/gcc/tree-ssa-sccvn.c
Comment 9 Richard Biener 2017-01-24 11:31:13 UTC
Fixed.
Comment 10 Richard Biener 2017-01-24 11:31:16 UTC
Author: rguenth
Date: Tue Jan 24 11:30:44 2017
New Revision: 244864

URL: https://gcc.gnu.org/viewcvs?rev=244864&root=gcc&view=rev
Log:
2017-01-24  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2016-09-20  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77646
	* tree-ssa-sccvn.c (visit_reference_op_call): Always value-number
	a VDEF.

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

	2016-11-05  David Edelsohn  <dje.gcc@gmail.com>
		Richard Biener  <rguenther@suse.de>

	PR bootstrap/78188
	PR c++/71848
	* ipa-comdats.c (pass_ipa_comdats::gate): Require HAVE_COMDAT_GROUP.

	* g++.dg/ipa/pr78188.C: New test.	

	2016-09-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77648
	* tree-ssa-structalias.c (process_constraint): Handle all DEREF
	with complex RHS.
	(make_transitive_closure_constraints): Adjust comment.
	(make_any_offset_constraints): New function.
	(handle_rhs_call): Make sure to first expand a pointer to all
	subfields before transitively closing it.
	(handle_const_call): Likewise.  Properly expand returned
	pointers as well.
	(handle_pure_call): Likewise.

	* gcc.dg/torture/pr77648-1.c: New testcase.
	* gcc.dg/torture/pr77648-2.c: Likewise.

	2016-10-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77879
	* tree-ssa-structalias.c (handle_const_call): Properly handle
	NRV return slots.
	(handle_pure_call): Likewise.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/ipa/pr78188.C
    branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr77646.c
    branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr77648-1.c
    branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr77648-2.c
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/ipa-comdats.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
    branches/gcc-5-branch/gcc/tree-ssa-sccvn.c
    branches/gcc-5-branch/gcc/tree-ssa-structalias.c