Bug 89711 - [8 Regression] ICE in insert_vi_for_tree, at tree-ssa-structalias.c:2832
Summary: [8 Regression] ICE in insert_vi_for_tree, at tree-ssa-structalias.c:2832
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 9.0
: P2 normal
Target Milestone: 8.4
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2019-03-14 02:30 UTC by Arseny Solokha
Modified: 2019-05-06 09:40 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-*-*, powerpc*
Build:
Known to work: 7.4.0, 8.3.1, 9.0
Known to fail: 8.3.0
Last reconfirmed: 2019-03-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arseny Solokha 2019-03-14 02:30:14 UTC
gcc-9.0.0-alpha20190310 snapshot (r269561) ICEs when compiling the following testcase at any optimization level and w/ -fipa-pta -flto (note: w/o -c):

__attribute__ ((target_clones ("avx", "default"))) void
xd (void)
{
}

__attribute__ ((target_clones ("avx", "default"))) void
tx (void)
{
}

int
main (void)
{
  return 0;
}

% x86_64-pc-linux-gnu-gcc-9.0.0-alpha20190310 -O1 -fipa-pta -flto jrbgpkcn.c
during IPA pass: pta
lto1: internal compiler error: in insert_vi_for_tree, at tree-ssa-structalias.c:2832
0xe371aa insert_vi_for_tree
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20190310/work/gcc-9-20190310/gcc/tree-ssa-structalias.c:2832
0xe4456d create_function_info_for
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20190310/work/gcc-9-20190310/gcc/tree-ssa-structalias.c:5817
0xe4456d ipa_pta_execute
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20190310/work/gcc-9-20190310/gcc/tree-ssa-structalias.c:7970
0xe4456d execute
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20190310/work/gcc-9-20190310/gcc/tree-ssa-structalias.c:8311
Comment 1 Martin Liška 2019-03-14 09:12:22 UTC
Confirmed, started with my commit r249840.
Comment 2 Martin Liška 2019-03-14 09:28:40 UTC
The mentioned patch is responsible for preserving of ifunc resolver:

Bisecting latest revisions
  0e35450b3c1d7164(30 Jun 2017 13:51): [took: 2.646s] result: OK

;; Function xd (xd.default.3, funcdef_no=0, decl_uid=1815, cgraph_uid=0, symbol_order=0)

__attribute__((target ("default"), target_clones ("avx", "default")))
xd ()
{
  <bb 2> [100.00%] [count: INV]:
  return;

}



;; Function tx (tx.default.2, funcdef_no=1, decl_uid=1818, cgraph_uid=1, symbol_order=1)

__attribute__((target ("default"), target_clones ("avx", "default")))
tx ()
{
  <bb 2> [100.00%] [count: INV]:
  return;

}



;; Function tx.avx.0 (tx.avx.0, funcdef_no=3, decl_uid=1832, cgraph_uid=3, symbol_order=3)

__attribute__((target ("avx"), target_clones ("avx", "default")))
tx.avx.0 ()
{
  <bb 2> [100.00%] [count: INV]:
  return;

}



;; Function xd.avx.1 (xd.avx.1, funcdef_no=4, decl_uid=2147, cgraph_uid=4, symbol_order=4)

__attribute__((target ("avx"), target_clones ("avx", "default")))
xd.avx.1 ()
{
  <bb 2> [100.00%] [count: INV]:
  return;

}



;; Function main (main, funcdef_no=2, decl_uid=1821, cgraph_uid=2, symbol_order=2) (executed once)

main ()
{
  <bb 2> [100.00%] [count: INV]:
  return 0;

}



;; Function tx.resolver (tx.resolver, funcdef_no=6, decl_uid=2151, cgraph_uid=6, symbol_order=6)

tx.resolver ()
{
  int _3;

  <bb 2> [100.00%] [count: INV]:
  __builtin_cpu_init ();
  _3 = __builtin_cpu_supports (&"avx"[0]);
  if (_3 > 0)
    goto <bb 3>; [64.00%] [count: INV]
  else
    goto <bb 4>; [36.00%] [count: INV]

  <bb 3> [64.00%] [count: INV]:
  return tx.avx.0;

  <bb 4> [36.00%] [count: INV]:
  return tx;

}



;; Function xd.resolver (xd.resolver, funcdef_no=8, decl_uid=2157, cgraph_uid=10, symbol_order=10)

xd.resolver ()
{
  int _3;

  <bb 2> [100.00%] [count: INV]:
  __builtin_cpu_init ();
  _3 = __builtin_cpu_supports (&"avx"[0]);
  if (_3 > 0)
    goto <bb 3>; [64.00%] [count: INV]
  else
    goto <bb 4>; [36.00%] [count: INV]

  <bb 3> [64.00%] [count: INV]:
  return xd.avx.1;

  <bb 4> [36.00%] [count: INV]:
  return xd;

}

while before it was removed:

  ac45aefc028a5546(30 Jun 2017 13:19): [took: 2.623s] result: OK

;; Function main (main, funcdef_no=2, decl_uid=1821, cgraph_uid=2, symbol_order=2) (executed once)

main ()
{
  <bb 2> [100.00%] [count: INV]:
  return 0;

}



;; Function tx.avx.0 (tx.avx.0, funcdef_no=3, decl_uid=1832, cgraph_uid=3, symbol_order=3)

__attribute__((target ("avx"), target_clones ("avx", "default")))
tx.avx.0 ()
{
  <bb 2> [100.00%] [count: INV]:
  return;

}



;; Function xd.avx.1 (xd.avx.1, funcdef_no=4, decl_uid=2147, cgraph_uid=4, symbol_order=4)

__attribute__((target ("avx"), target_clones ("avx", "default")))
xd.avx.1 ()
{
  <bb 2> [100.00%] [count: INV]:
  return;

}

Thus I'm leaving that to Richi, it's probably IPA PTA issue.
Comment 3 Richard Biener 2019-03-14 11:01:15 UTC
The issue is that the same DECL_RESULT is used for xd.resolver and tx.resolver.
Maybe they are commoned by IPA ICF?  But the function decls still are
different...

tx.resolver/6 (tx.resolver) @0x7ffff687c870
  Type: function definition analyzed
  Visibility: force_output prevailing_def_ironly artificial
  References: tx.avx.0/3 (addr)tx.default.1/1 (addr)
  Referring: 
  Availability: available
  Function flags: count:1073741824 (estimated locally) body
  Called by: 
  Calls: __builtin_cpu_supports/8 (1073741824 (estimated locally),1.00 per call) __builtin_cpu_init/7 (1073741824 (estimated locally),1.00 per call) 
$23 = void

xd.resolver/10 (xd.resolver) @0x7ffff687c438
  Type: function definition analyzed
  Visibility: force_output prevailing_def_ironly artificial
  References: xd.avx.0/4 (addr)xd.default.1/0 (addr)
  Referring: 
  Availability: available
  Function flags: count:1073741824 (estimated locally) body
  Called by: 
  Calls: __builtin_cpu_supports/8 (1073741824 (estimated locally),1.00 per call) __builtin_cpu_init/7 (1073741824 (estimated locally),1.00 per call) 
$27 = void

DECL_RESULT (tx.resolver):
 <result_decl 0x7ffff6884258 D.4339
    type <pointer_type 0x7ffff6896000
        type <void_type 0x7ffff688ff18 void VOID
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality
            pointer_to_this <pointer_type 0x7ffff6896000>>
        public unsigned DI
        size <integer_cst 0x7ffff687ab70 constant 64>
        unit-size <integer_cst 0x7ffff687ab88 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality
        pointer_to_this <pointer_type 0x7ffff689bb28>>
    unsigned ignored DI (null):0:0 size <integer_cst 0x7ffff687ab70 64> unit-size <integer_cst 0x7ffff687ab88 8>
    align:64 warn_if_not_align:0 context <translation_unit_decl 0x7ffff68841e0 t.c>>

DECL_RESULT (xd.resolver):
 <result_decl 0x7ffff6884258 D.4339
    type <pointer_type 0x7ffff6896000
        type <void_type 0x7ffff688ff18 void VOID
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality
            pointer_to_this <pointer_type 0x7ffff6896000>>
        public unsigned DI
        size <integer_cst 0x7ffff687ab70 constant 64>
        unit-size <integer_cst 0x7ffff687ab88 constant 8>
        align:64 warn_if_not_align:0 symtab:0 alias-set -1 structural-equality
        pointer_to_this <pointer_type 0x7ffff689bb28>>
    unsigned ignored DI (null):0:0 size <integer_cst 0x7ffff687ab70 64> unit-size <integer_cst 0x7ffff687ab88 8>
    align:64 warn_if_not_align:0 context <translation_unit_decl 0x7ffff68841e0 t.c>>

maybe they are somehow commoned by tree merging?  Indeed they are.  I
wonder why they have the same DECL_CONTEXT?  Where are they generated?
Comment 4 Richard Biener 2019-03-14 11:06:20 UTC
Ah, the target:

  /* Build result decl and add to function_decl. */
  t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node);
  DECL_ARTIFICIAL (t) = 1;
  DECL_IGNORED_P (t) = 1;
  DECL_RESULT (decl) = t;

fails to set DECL_CONTEXT.  But I wonder whether we need a result decl at all
here.  Fix:

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c      (revision 269678)
+++ gcc/config/i386/i386.c      (working copy)
@@ -32572,6 +32572,7 @@ make_resolver_func (const tree default_d
     }
   /* Build result decl and add to function_decl. */
   t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node);
+  DECL_CONTEXT (t) = decl;
   DECL_ARTIFICIAL (t) = 1;
   DECL_IGNORED_P (t) = 1;
   DECL_RESULT (decl) = t;
Comment 5 Richard Biener 2019-03-14 14:05:58 UTC
Author: rguenth
Date: Thu Mar 14 14:05:26 2019
New Revision: 269683

URL: https://gcc.gnu.org/viewcvs?rev=269683&root=gcc&view=rev
Log:
2019-03-14  Richard Biener  <rguenther@suse.de>

	PR target/89711
	* config/i386/i386.c (make_resolver_func): Properly set
	DECL_CONTEXT on the RESULT_DECL.
	* config/rs6000/rs6000.c (make_resolver_func): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/config/rs6000/rs6000.c
Comment 6 Richard Biener 2019-03-14 14:06:43 UTC
Fixed on trunk sofar.
Comment 7 Martin Liška 2019-03-14 15:11:17 UTC
(In reply to Richard Biener from comment #4)
> Ah, the target:
> 
>   /* Build result decl and add to function_decl. */
>   t = build_decl (UNKNOWN_LOCATION, RESULT_DECL, NULL_TREE, ptr_type_node);
>   DECL_ARTIFICIAL (t) = 1;
>   DECL_IGNORED_P (t) = 1;
>   DECL_RESULT (decl) = t;
> 
> fails to set DECL_CONTEXT.  But I wonder whether we need a result decl at all
> here.  Fix:

I guess yes as void * is expected as return value of ifunc resolver.
Comment 8 Richard Biener 2019-05-03 08:19:11 UTC
Fixed.
Comment 9 Richard Biener 2019-05-03 08:19:20 UTC
Author: rguenth
Date: Fri May  3 08:18:48 2019
New Revision: 270841

URL: https://gcc.gnu.org/viewcvs?rev=270841&root=gcc&view=rev
Log:
2019-05-03  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2019-03-14  Richard Biener  <rguenther@suse.de>

	PR middle-end/89698
	* fold-const.c (operand_equal_p): For INDIRECT_REF check
	that the access types are similar.

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

	2019-03-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/89595
	* tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Take
	stmt iterator as reference, take boolean output parameter to
	indicate whether the stmt was removed and thus the iterator
	already advanced.
	(dom_opt_dom_walker::before_dom_children): Re-iterate over
	stmts created by folding.

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

	2019-03-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/89710
	* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use
	safe_dyn_cast.

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

	2019-04-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/90071
	* tree-ssa-reassoc.c (init_range_entry): Do not pick up
	abnormal operands from def stmts.

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

	2018-08-20  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR target/86984
	* expr.c (expand_assignment): Assert that bitpos is positive.
	(store_field): Likewise
	(expand_expr_real_1): Make sure that bitpos is positive.
	* config/alpha/alpha.h (CONSTANT_ADDRESS_P): Avoid signed
	integer overflow.

	* gcc.target/alpha/pr86984.c: New test.

	2019-03-14  Richard Biener  <rguenther@suse.de>

	PR target/89711
	* config/i386/i386.c (make_resolver_func): Properly set
	DECL_CONTEXT on the RESULT_DECL.
	* config/rs6000/rs6000.c (make_resolver_func): Likewise.

Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/config/alpha/alpha.h
    branches/gcc-8-branch/gcc/config/i386/i386.c
    branches/gcc-8-branch/gcc/config/rs6000/rs6000.c
    branches/gcc-8-branch/gcc/expr.c
    branches/gcc-8-branch/gcc/fold-const.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
    branches/gcc-8-branch/gcc/tree-ssa-dom.c
    branches/gcc-8-branch/gcc/tree-ssa-loop-ch.c
    branches/gcc-8-branch/gcc/tree-ssa-reassoc.c
Comment 10 Richard Biener 2019-05-06 09:40:46 UTC
Author: rguenth
Date: Mon May  6 09:40:15 2019
New Revision: 270904

URL: https://gcc.gnu.org/viewcvs?rev=270904&root=gcc&view=rev
Log:
2019-05-03  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2019-03-14  Richard Biener  <rguenther@suse.de>

	PR middle-end/89698
	* fold-const.c (operand_equal_p): For INDIRECT_REF check
	that the access types are similar.

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

	2019-03-07  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/89595
	* tree-ssa-dom.c (dom_opt_dom_walker::optimize_stmt): Take
	stmt iterator as reference, take boolean output parameter to
	indicate whether the stmt was removed and thus the iterator
	already advanced.
	(dom_opt_dom_walker::before_dom_children): Re-iterate over
	stmts created by folding.

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

	2019-03-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/89710
	* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use
	safe_dyn_cast.

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

	2019-04-15  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/90071
	* tree-ssa-reassoc.c (init_range_entry): Do not pick up
	abnormal operands from def stmts.

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

	2018-08-20  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	PR target/86984
	* expr.c (expand_assignment): Assert that bitpos is positive.
	(store_field): Likewise
	(expand_expr_real_1): Make sure that bitpos is positive.
	* config/alpha/alpha.h (CONSTANT_ADDRESS_P): Avoid signed
	integer overflow.

	* gcc.target/alpha/pr86984.c: New test.

	2019-03-14  Richard Biener  <rguenther@suse.de>

	PR target/89711
	* config/i386/i386.c (make_resolver_func): Properly set
	DECL_CONTEXT on the RESULT_DECL.
	* config/rs6000/rs6000.c (make_resolver_func): Likewise.

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.dg/torture/pr89698.C
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/torture/pr89595.c
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/torture/pr89710.c
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/torture/pr90071.c
    branches/gcc-8-branch/gcc/testsuite/gcc.target/alpha/pr86984.c