Bug 90194 - ICE in expand_debug_expr, at cfgexpand.c:5244
Summary: ICE in expand_debug_expr, at cfgexpand.c:5244
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords: ice-checking, ice-on-valid-code, missed-optimization
Depends on:
Blocks:
 
Reported: 2019-04-20 11:26 UTC by Arseny Solokha
Modified: 2019-08-30 16:47 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 7.4.1, 8.3.1, 9.0
Known to fail: 6.3.0, 7.4.0, 8.3.0
Last reconfirmed: 2019-04-24 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-04-20 11:26:36 UTC
g++-9.0.0-alpha20190407 snapshot (r270192) ICEs when compiling the following testcase at any optimization level (except -Og) and w/ -g:

struct cb {
  int yr;
};

void *
operator new (__SIZE_TYPE__, void *nq)
{
  return nq;
}

void
af (int xn)
{
  new (&xn) cb { };
}

% g++-9.0.0-alpha20190407 -O1 -g -c vquxpovp.cc
 <constructor 0x7fd5336356d8
    type <record_type 0x7fd53360e690 cb asm_written type_5 type_6 SI
        size <integer_cst 0x7fd5334d9078 constant 32>
        unit-size <integer_cst 0x7fd5334d9090 constant 4>
        align:32 warn_if_not_align:0 symtab:860696976 alias-set 1 canonical-type 0x7fd53360e690
        fields <function_decl 0x7fd533613f00 __dt  type <method_type 0x7fd533628738>
            public abstract external autoinline decl_3 QI vquxpovp.cc:1:8 align:16 warn_if_not_align:0 context <record_type 0x7fd53360e690 cb>
            full-name "cb::~cb() noexcept (<uninstantiated>)"
            not-really-extern chain <function_decl 0x7fd533629100 __dt_base >> context <translation_unit_decl 0x7fd5334c4168 vquxpovp.cc>
        full-name "struct cb"
        X() X(constX&) this=(X&) n_parents=0 use_template=0 interface-unknown
        pointer_to_this <pointer_type 0x7fd53360ebd0> reference_to_this <reference_type 0x7fd5336282a0> chain <type_decl 0x7fd5335da688 cb>>
    constant static tree_0 length:0>
during RTL pass: expand
vquxpovp.cc: In function 'void af(int)':
vquxpovp.cc:12:1: internal compiler error: in expand_debug_expr, at cfgexpand.c:5244
   12 | af (int xn)
      | ^~
0xb29d93 expand_debug_expr
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20190407/work/gcc-9-20190407/gcc/cfgexpand.c:5244
0xb2a044 expand_debug_expr
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20190407/work/gcc-9-20190407/gcc/cfgexpand.c:4560
0xb359e3 expand_debug_locations
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20190407/work/gcc-9-20190407/gcc/cfgexpand.c:5442
0xb359e3 execute
	/var/tmp/portage/sys-devel/gcc-9.0.0_alpha20190407/work/gcc-9-20190407/gcc/cfgexpand.c:6512

g++ 8.3, 7.4, 6.3 fail differently:

% g++-8.3.0 -O1 -fchecking -g -c vquxpovp.cc
vquxpovp.cc: In function 'void af(int)':
vquxpovp.cc:12:1: error: invalid reference prefix
 af (int xn)
 ^~
{}
vquxpovp.cc:14:3: note: in statement
   new (&xn) cb { };
   ^~~~~~~~~~~~~~~~
xn_5 = VIEW_CONVERT_EXPR<int>({});
vquxpovp.cc:12: confused by earlier errors, bailing out
Comment 1 Richard Biener 2019-04-24 11:31:53 UTC
Confirmed.  update-address-taken does, after CCP:

 af (int xn)
 {
   void * D.2359;
-  void * _2;
 
   <bb 2> [local count: 1073741824]:
   # DEBUG BEGIN_STMT
   # DEBUG D.2357 => 4
   # DEBUG nq => &xn
   # DEBUG BEGIN_STMT
-  _4 = &xn;
   # DEBUG D.2357 => NULL
   # DEBUG nq => NULL
-  _2 = _4;
-  MEM[(struct cb *)_2] = {};
+  xn_5 = VIEW_CONVERT_EXPR<int>({});
+  # DEBUG xn => xn_5
   return;

which failed to "fold" the V_C_E.  It does reach

                      rhs = fold_build1 (VIEW_CONVERT_EXPR,
                                         TREE_TYPE (lhs), rhs);

but this does nothing.
Comment 2 Richard Biener 2019-04-24 11:32:14 UTC
Mine.
Comment 3 Richard Biener 2019-04-25 11:14:46 UTC
Fixed on trunk sofar.
Comment 4 Richard Biener 2019-04-25 11:16:06 UTC
Author: rguenth
Date: Thu Apr 25 11:15:35 2019
New Revision: 270569

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

	PR middle-end/90194
	* match.pd: Add pattern to simplify view-conversion of an
	empty constructor.

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

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr90194.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/match.pd
    trunk/gcc/testsuite/ChangeLog
Comment 5 Richard Biener 2019-08-30 11:44:04 UTC
Author: rguenth
Date: Fri Aug 30 11:43:33 2019
New Revision: 275103

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

	Backport from mainline
	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-15  Richard Biener  <rguenther@suse.de>

	PR c/90474
	* c-common.c (c_common_mark_addressable_vec): Also mark
	a COMPOUND_LITERAL_EXPR_DECL addressable similar to
	c_mark_addressable.

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

	PR tree-optimization/90278
	* tree-ssa-forwprop.c (pass_forwprop::execute): Transfer/clean
	EH on comparison simplification.

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

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

	PR middle-end/90194
	* match.pd: Add pattern to simplify view-conversion of an
	empty constructor.

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

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.dg/torture/pr90194.C
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/gomp/pr90900.c
    branches/gcc-8-branch/gcc/testsuite/gcc.dg/torture/pr90278.c
Modified:
    branches/gcc-8-branch/gcc/ChangeLog
    branches/gcc-8-branch/gcc/c-family/ChangeLog
    branches/gcc-8-branch/gcc/c-family/c-common.c
    branches/gcc-8-branch/gcc/cfgexpand.c
    branches/gcc-8-branch/gcc/match.pd
    branches/gcc-8-branch/gcc/testsuite/ChangeLog
    branches/gcc-8-branch/gcc/tree-ssa-forwprop.c
Comment 6 Richard Biener 2019-08-30 16:44:49 UTC
Author: rguenth
Date: Fri Aug 30 16:44:17 2019
New Revision: 275208

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

	Backport from mainline
	2019-05-27  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/90637
	* tree-ssa-sink.c (statement_sink_location): Honor the
	computed sink location for single-uses.

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

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

	PR tree-optimization/90930
	* tree-ssa-reassoc.c (rewrite_expr_tree_parallel): Set visited
	flag on new stmts to avoid re-processing them.

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

	PR c/90474
	* c-common.c (c_common_mark_addressable_vec): Also mark
	a COMPOUND_LITERAL_EXPR_DECL addressable similar to
	c_mark_addressable.

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

	PR middle-end/90194
	* match.pd: Add pattern to simplify view-conversion of an
	empty constructor.

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

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

	PR middle-end/90213
	* gimple-fold.c (fold_const_aggregate_ref_1): Do multiplication
	by size and BITS_PER_UNIT on poly-wide-ints.

	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.

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

	PR middle-end/89677
	* tree-scalar-evolution.c (simplify_peeled_chrec): Do not
	throw FP expressions at tree-affine.

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

Added:
    branches/gcc-7-branch/gcc/testsuite/g++.dg/torture/pr90194.C
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/torture/pr89677.c
    branches/gcc-7-branch/gcc/testsuite/gcc.dg/torture/pr90071.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/c-family/ChangeLog
    branches/gcc-7-branch/gcc/c-family/c-common.c
    branches/gcc-7-branch/gcc/gimple-fold.c
    branches/gcc-7-branch/gcc/match.pd
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/tree-scalar-evolution.c
    branches/gcc-7-branch/gcc/tree-ssa-reassoc.c
    branches/gcc-7-branch/gcc/tree-ssa-sink.c
Comment 7 Richard Biener 2019-08-30 16:47:59 UTC
Fixed.