Bug 90982 - [9 Regression] ICE in make_decl_rtl, at varasm.c:1344
Summary: [9 Regression] ICE in make_decl_rtl, at varasm.c:1344
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 10.0
: P2 normal
Target Milestone: 9.2
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code, needs-bisection
Depends on:
Blocks:
 
Reported: 2019-06-24 16:11 UTC by G. Steinmetz
Modified: 2024-03-09 21:07 UTC (History)
0 users

See Also:
Host:
Target: x86_64-pc-linux-gnu
Build:
Known to work: 10.0, 8.3.0, 9.1.1
Known to fail: 9.1.0
Last reconfirmed: 2019-06-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description G. Steinmetz 2019-06-24 16:11:45 UTC
Changed between 20180513 and 20180527, at -O2+ :


$ cat z1.cc
template <int n> struct S
{
  long c[n];
  void f (S d)
  {
    for (int i = 2;; i++)
      c[i] &= d.c[i];
  }
};

template <int m> struct T:S<m/64>
{
  void operator &= (T d)
  { this -> f (d); }
};

void g (T<192> &d)
{
  T<192> v;
  d &= v;
}


$ g++-8           -c z1.cc -O2
$ g++-10-20190623 -c z1.cc -O1
$
$ g++-10-20190623 -c z1.cc -O2
during RTL pass: expand
z1.cc: In function 'void g(T<192>&)':
z1.cc:7:7: internal compiler error: in make_decl_rtl, at varasm.c:1344
    7 |       c[i] &= d.c[i];
      |       ^
0xe1237d make_decl_rtl(tree_node*)
        ../../gcc/varasm.c:1340
0x8e014a expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:9990
0x8de252 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:10621
0x8e02ba expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:9958
0x8e9026 expand_expr
        ../../gcc/expr.h:281
0x8e9026 expand_operands(tree_node*, tree_node*, rtx_def*, rtx_def**, rtx_def**, expand_modifier)
        ../../gcc/expr.c:7885
0x8ee12c expand_expr_real_2(separate_ops*, rtx_def*, machine_mode, expand_modifier)
        ../../gcc/expr.c:9744
0x8e0be7 expand_expr_real_1(tree_node*, rtx_def*, machine_mode, expand_modifier, rtx_def**, bool)
        ../../gcc/expr.c:9954
0x8e9966 store_expr(tree_node*, rtx_def*, int, bool, bool)
        ../../gcc/expr.c:5685
0x8eac68 expand_assignment(tree_node*, tree_node*, bool)
        ../../gcc/expr.c:5307
0x7e6818 expand_gimple_stmt_1
        ../../gcc/cfgexpand.c:3770
0x7e6818 expand_gimple_stmt
        ../../gcc/cfgexpand.c:3868
0x7ebab7 expand_gimple_basic_block
        ../../gcc/cfgexpand.c:5908
0x7ee156 execute
        ../../gcc/cfgexpand.c:6531
Comment 1 Richard Biener 2019-06-24 17:31:23 UTC
Confirmed.

#1  0x000000000191fad2 in make_decl_rtl (decl=<var_decl 0x7ffff6dbebd0 d>)
    at ../../src/trunk/gcc/varasm.c:1343
1343      gcc_assert (!VAR_P (decl)
(gdb) l
1338      /* Check that we are not being given an automatic variable.  */
1339      gcc_assert (TREE_CODE (decl) != PARM_DECL
1340                  && TREE_CODE (decl) != RESULT_DECL);
1341
1342      /* A weak alias has TREE_PUBLIC set but not the other bits.  */
1343      gcc_assert (!VAR_P (decl)
1344                  || TREE_STATIC (decl)
1345                  || TREE_PUBLIC (decl)
1346                  || DECL_EXTERNAL (decl)
1347                  || DECL_REGISTER (decl));
(gdb) p debug_tree (decl)
 <var_decl 0x7ffff6dbebd0 d
    type <record_type 0x7ffff6daaa80 S sizes-gimplified type_5 type_6 BLK
        size <integer_cst 0x7ffff6c5e2e8 constant 192>
        unit-size <integer_cst 0x7ffff6c5e2b8 constant 24>
        align:64 warn_if_not_align:0 symtab:0 alias-set 2 canonical-type 0x7ffff6daaa80
        fields <function_decl 0x7ffff6db3500 __dt  type <method_type 0x7ffff6dafa80>
            public abstract external autoinline decl_3 QI t.ii:1:25 align:16 warn_if_not_align:0 context <record_type 0x7ffff6daaa80 S>
            full-name "S<3>::~S() noexcept (<uninstantiated>)"
            not-really-extern chain <function_decl 0x7ffff6db3700 __dt_base >> context <translation_unit_decl 0x7ffff6c4a168 t.ii>
        full-name "struct S<3>"
        X() X(constX&) this=(X&) n_parents=0 use_template=1 interface-unknown
        pointer_to_this <pointer_type 0x7ffff6daad20> reference_to_this <reference_type 0x7ffff6daf2a0> chain <type_decl 0x7ffff6d61c78 S>>
    used BLK t.ii:13:12 size <integer_cst 0x7ffff6c5e2e8 192> unit-size <integer_cst 0x7ffff6c5e2b8 24>
    align:64 warn_if_not_align:0 context <function_decl 0x7ffff6d98700 g> abstract_origin <parm_decl 0x7ffff6c66b00 d>>

d is an automatic var but somehow it got no RTL assigned during expansion.
Comment 2 Martin Liška 2019-06-25 07:19:13 UTC
Btw. started with r260354.
Comment 3 Richard Biener 2019-06-25 07:28:17 UTC
I will investigate then.
Comment 4 Richard Biener 2019-06-25 08:20:58 UTC
OK, so this is IPA SRAs fault which fails to rewrite the d.c[i] expression
with the parameter replacement.  After the cited rev. range-info makes d.c[i] appear as d.c[2] from get_ref_base_and_extent analysis.

Evaluating PARAM group sizes for d (UID: 2336):
access { base = (2336)'d', offset = 128, size = 64, expr = d.c[i_4], type = long int, non_addressable = 0, reverse = 0, grp_read = 0, grp_write = 0, grp_assignment_read = 1, grp_assignment_write = 0, grp_scalar_read = 0, grp_scalar_write = 0, grp_total_scalarization = 0, grp_hint = 0, grp_covered = 0, grp_unscalarizable_region = 0, grp_unscalarized_data = 0, grp_same_access_path = 0, grp_partial_lhs = 0, grp_to_be_replaced = 0, grp_to_be_debug_replaced = 0, grp_maybe_modified = 0, grp_not_necessarilly_dereferenced = 0
    ....will be split into 1 components
IPA param adjustments: 0. base_index: 0 - this, base: this, copy_param
                 1. base_index: 1 - d, base: d, offset 128, type:  <integer_type 0x7ffff6897738 long int>
...
S<3>::_ZN1SILi3EE1fES0_.isra.0 (struct SD.2331 * const thisD.2425, long intD.12 ISRA.1D.2429)
{
  intD.9 iD.2427;
  long intD.12 _3;
  long intD.12 _4;
  long intD.12 _5;

  <bb 5> :

  <bb 2> :

  <bb 3> :
  # i_2 = PHI <2(2), i_6(4)>
  _3 = this_1(D)->cD.2333[i_2];
  _4 = dD.2426.cD.2333[i_2];
  _5 = _3 & _4;
  this_1(D)->cD.2333[i_2] = _5;
  i_6 = i_2 + 1;


and now dD.2426 is stale.  With -fno-inline we ICE differently:

during IPA pass: cp
t.ii: In function ‘void S<n>::f(S<n>) [with int n = 3]’:
t.ii:21:1: internal compiler error: in visit_ref_for_mod_analysis, at ipa-prop.c:2461
   21 | }
      | ^
0x112f91e visit_ref_for_mod_analysis
        /space/rguenther/src/svn/trunk2/gcc/ipa-prop.c:2461
0x102985b walk_stmt_load_store_addr_ops(gimple*, void*, bool (*)(gimple*, tree_node*, tree_node*, void*), bool (*)(gimple*, tree_node*, tree_node*, void*), bool (*)(gimple*, tree_node*, tree_node*, void*))
        /space/rguenther/src/svn/trunk2/gcc/gimple-walk.c:783
0x112f9e8 ipa_analyze_params_uses_in_bb
        /space/rguenther/src/svn/trunk2/gcc/ipa-prop.c:2488
0x112fcbc analysis_dom_walker::before_dom_children(basic_block_def*)
        /space/rguenther/src/svn/trunk2/gcc/ipa-prop.c:2568

probably because there's a PARAM_DECL in the IL that isn't an actual
parameter.

Somehow during ipa_get_adjustment_candidate the access appears
unconstrained by i_2 value-range.

Ah, this is because we do

  new_node = node->create_version_clone_with_body (redirect_callers, NULL,
                                                   NULL, false, NULL, NULL,
                                                   "isra");

and the inline machinery doesn't copy SSA name range info.
Comment 5 Richard Biener 2019-06-26 11:17:27 UTC
Author: rguenth
Date: Wed Jun 26 11:16:56 2019
New Revision: 272688

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

	PR ipa/90982
	* tree-inline.c (remap_ssa_name): Copy SSA range info.

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

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr90982.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-inline.c
Comment 6 Richard Biener 2019-06-26 11:26:32 UTC
Fixed on trunk sofar.
Comment 7 Richard Biener 2019-07-12 14:42:47 UTC
Author: rguenth
Date: Fri Jul 12 14:42:14 2019
New Revision: 273446

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

	Backport from mainline
	2019-07-04  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/91063
	* tree-vect-stmts.c (vect_init_vector): Call gsi_remove to remove
	stmt from stmts sequence before calling vect_init_vector_1.
	Formatting fix.

	* gcc.dg/gomp/pr91063.c: New test.

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

	PR ipa/91062
	* tree-pass.h (execute_all_ipa_transforms): Add a flag
	parameter whether to disable GC collection.
	* passes.c (execute_one_ipa_transform_pass): Likewise, and
	honor it.
	(execute_all_ipa_transforms): Likewise and pass it down.
	* cgraph.c (cgraph_node::get_body): Do not invoke garbage
	collection from applying IPA transforms.
	* cgraphunit.c (cgraph_node::expand): Allow garbage collection
	from applying IPA transforms.

	2019-06-27  Richard Biener  <rguenther@suse.de>

	PR testsuite/91004
	* g++.dg/torture/pr34850.C: Fix overly reduced testcase.

	2019-06-26  Richard Biener  <rguenther@suse.de>

	PR ipa/90982
	* tree-inline.c (remap_ssa_name): Copy SSA range info.

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

	2019-06-24  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/90972
	* tree-vect-stmts.c (vect_init_vector): Handle CONSTANT_CLASS_P
	in common code, dealing with STRING_CST properly.

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

	2019-06-21  Richard Biener  <rguenther@suse.de>

	PR debug/90914
	* dwarf2out.c (prune_unused_types_walk): Always consider
	function-local extern declarations as used.

	* g++.dg/debug/pr90914.C: New testcase.

	2019-06-18  Richard Biener  <rguenther@suse.de>

	PR debug/90900
	* cfgexpand.c (expand_debug_expr): Treat NOTE_P DECL_RTL
	as if optimized away.

	* gcc.dg/gomp/pr90900.c: New testcase.

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

	PR lto/90369
	* lto-wrapper.c (debug_objcopy): Use the original filename
	including archive offset for the filename used for -save-temps.

Added:
    branches/gcc-9-branch/gcc/testsuite/g++.dg/debug/pr90914.C
    branches/gcc-9-branch/gcc/testsuite/g++.dg/torture/pr90982.C
    branches/gcc-9-branch/gcc/testsuite/gcc.dg/gomp/pr90900.c
    branches/gcc-9-branch/gcc/testsuite/gcc.dg/gomp/pr91063.c
    branches/gcc-9-branch/gcc/testsuite/gcc.dg/torture/pr90972.c
Modified:
    branches/gcc-9-branch/gcc/ChangeLog
    branches/gcc-9-branch/gcc/cfgexpand.c
    branches/gcc-9-branch/gcc/cgraph.c
    branches/gcc-9-branch/gcc/cgraphunit.c
    branches/gcc-9-branch/gcc/dwarf2out.c
    branches/gcc-9-branch/gcc/lto-wrapper.c
    branches/gcc-9-branch/gcc/passes.c
    branches/gcc-9-branch/gcc/testsuite/ChangeLog
    branches/gcc-9-branch/gcc/testsuite/g++.dg/torture/pr34850.C
    branches/gcc-9-branch/gcc/tree-inline.c
    branches/gcc-9-branch/gcc/tree-pass.h
    branches/gcc-9-branch/gcc/tree-vect-stmts.c
Comment 8 Richard Biener 2019-07-12 14:44:04 UTC
Fixed.