[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-18 Thread dimhen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

--- Comment #11 from Dmitry G. Dyachenko  ---
r262850 works for me.
Thanks!

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

Richard Biener  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from Richard Biener  ---
Fixed again.

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-18 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

--- Comment #9 from Richard Biener  ---
Author: rguenth
Date: Wed Jul 18 06:54:23 2018
New Revision: 262849

URL: https://gcc.gnu.org/viewcvs?rev=262849=gcc=rev
Log:
2018-07-18  Richard Biener  

PR debug/86523
cp/
* decl2.c (c_parse_final_cleanups): Call write_out_vars before
start_static_storage_duration_function sets current_function_decl.

* g++.dg/lto/pr86523-3_0.C: New testcase.

Added:
trunk/gcc/testsuite/g++.dg/lto/pr86523-3_0.C
Modified:
trunk/gcc/cp/ChangeLog
trunk/gcc/cp/decl2.c
trunk/gcc/testsuite/ChangeLog

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-17 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

--- Comment #8 from Richard Biener  ---
Note while the patch fixes the reported issue it still ICEs the same way
when compiling with -g0 and linking with -g (as I would have expected).

That would be fixed by sth like the following but that then hides
issues with consistent -g as we ran into.  It might be instead interesting
to make it more consistently fail by asserting early_dwarf here ...
(but I expect that to blow up in our face)

So I'm not going to fix this right now but will open a new bug for it.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index bd45e0b0685..3eaa032bb95 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -23732,12 +23732,13 @@ gen_variable_die (tree decl, tree origin, dw_die_ref
context_die)
   else
 add_name_and_src_coords_attributes (var_die, decl, no_linkage_name);

-  if ((origin == NULL && !specialization_p)
-  || (origin != NULL
- && !DECL_ABSTRACT_P (decl_or_origin)
- && variably_modified_type_p (TREE_TYPE (decl_or_origin),
-  decl_function_context
-   (decl_or_origin
+  if (early_dwarf
+  && ((origin == NULL && !specialization_p)
+ || (origin != NULL
+ && !DECL_ABSTRACT_P (decl_or_origin)
+ && variably_modified_type_p (TREE_TYPE (decl_or_origin),
+  decl_function_context
+(decl_or_origin)
 {
   tree type = TREE_TYPE (decl_or_origin);

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-17 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

--- Comment #7 from Richard Biener  ---
So there was no early debug info generated for the decl

 

in fact there's no early debug for anything besides the globals
c,d,f and g and artifical infrastructure.

Which is likely because everything is optimized away.  But we _do_ end up
assembling the instantiated k::e.  Somehow dwarf2out_early_global_decl
doesn't see it but only the guard variable for its initialization.

This is because when the C++ FE calls rest_of_decl_compilation we
have current_function_decl set to __static_initialization_and_destruction_0
which looks spurious.

The following fixes that and properly generates debug info early (also
for non-LTO though that's currently harmless becuase we do not perform
free-lang-data):

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index f8fc20e4093..d67ced097da 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -4754,14 +4754,14 @@ c_parse_final_cleanups (void)
 inline, with resulting performance improvements.  */
  tree ssdf_body;

+ /* Make sure the back end knows about all the variables.  */
+ write_out_vars (vars);
+
  /* Set the line and file, so that it is obviously not from
 the source file.  */
  input_location = locus_at_end_of_parsing;
  ssdf_body = start_static_storage_duration_function (ssdf_count);

- /* Make sure the back end knows about all the variables.  */
- write_out_vars (vars);
-
  /* First generate code to do all the initializations.  */
  if (vars)
do_static_initialization_or_destruction (vars, /*initp=*/true);

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-17 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

Martin Liška  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|FIXED   |---

--- Comment #6 from Martin Liška  ---
I see that same in Inkscape package, it's great you reduced that.

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-17 Thread dimhen at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

--- Comment #5 from Dmitry G. Dyachenko  ---
r262559 PASS
r262747 FAIL

$ cat x.ii
class a {
  int b;
};
int const c = 0, d = 1, f = 2, g = 3;
struct B {
  typedef a h;
  h i;
};
template  B j();
template  struct k { static B const e; };
template  B const k::e = j();
inline B m() {
  switch (0) {
  case c:
  case d:
return k::e;
  case f:
  case g:;
  }
}

$ /usr/local/gcc_current/bin/g++ -std=c++98 -g -flto x.ii
lto1: internal compiler error: in gen_member_die, at dwarf2out.c:24935
0x5e5fef gen_member_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:24935
0x5e5fef gen_struct_or_union_type_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25130
0x97104f gen_tagged_type_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25331
0x97143f gen_typedef_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25245
0x9758d6 gen_decl_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:26231
0x96fe7c gen_type_die_with_usage
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25396
0x970d76 gen_type_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25580
0x975baf gen_decl_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:26299
0x98f09a gen_member_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25034
0x98f09a gen_struct_or_union_type_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25130
0x97104f gen_tagged_type_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25331
0x9706cc gen_type_die_with_usage
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25526
0x970d76 gen_type_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:25580
0x97d26c modified_type_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:13397
0x97d46d modified_type_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:13267
0x97e589 add_type_attribute
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:21511
0x97f5fc gen_variable_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:23748
0x975af2 gen_decl_die
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:26288
0x97639e dwarf2out_decl
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:26770
0x99147f dwarf2out_late_global_decl
/home/dimhen/src/gcc_current/gcc/dwarf2out.c:26467
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

$ /usr/local/gcc_current/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/usr/local/gcc_current/bin/g++
COLLECT_LTO_WRAPPER=/usr/local/gcc_current/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-pc-linux-gnu
Configured with: /home/dimhen/src/gcc_current/configure
--prefix=/usr/local/gcc_current --enable-checking=yes,df,fold,rtl,extra
--enable-languages=c,c++,lto --disable-multilib --enable-shared
--enable-threads=posix --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl
--enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver
--enable-gnu-indirect-function --with-tune=native
Thread model: posix
gcc version 9.0.0 20180716 (experimental) [trunk revision 262747] (GCC)

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-16 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

Richard Biener  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--- Comment #3 from Richard Biener  ---
Fixed.

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-16 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

--- Comment #4 from Richard Biener  ---
Author: rguenth
Date: Mon Jul 16 13:57:32 2018
New Revision: 262696

URL: https://gcc.gnu.org/viewcvs?rev=262696=gcc=rev
Log:
2018-07-16  Richard Biener  

PR lto/86523
* dwarf2out.c (dwarf2out_register_external_die): Assign DIE parents
for function-local FUNCTION_DECL and RESULT_DECL immediately.

* g++.dg/lto/pr86523-1_0.C: New testcase.
* g++.dg/lto/pr86523-2_0.C: Likewise.

Added:
trunk/gcc/testsuite/g++.dg/lto/pr86523-1_0.C
trunk/gcc/testsuite/g++.dg/lto/pr86523-2_0.C
Modified:
trunk/gcc/ChangeLog
trunk/gcc/dwarf2out.c
trunk/gcc/testsuite/ChangeLog

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-16 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |ASSIGNED
   Last reconfirmed||2018-07-16
   Assignee|unassigned at gcc dot gnu.org  |rguenth at gcc dot 
gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Richard Biener  ---
(In reply to Martin Liška from comment #1)
> One more test-case with a bit different BT:
> 
> $  cat ice.ii
> namespace {
> class a typedef b;
> class a {};
> } // namespace
> class c {
>   struct C {
> b d;
>   };
>   C e() const;
> };
> c::C c::e() const {
>   C g;
>   struct h {
> C g;
> h(C *) {}
>   } f();
> }
> 
> $ g++ ice.ii -O2 -flto=8 -g -shared
> ice.ii: In member function ‘c::C c::e() const’:
> ice.ii:17:1: warning: no return statement in function returning non-void
> [-Wreturn-type]
>  }
>  ^
> 
> lto1: internal compiler error: in dwarf2out_finish, at dwarf2out.c:31107
> 0x5c87cd dwarf2out_finish
>   /home/marxin/Programming/gcc/gcc/dwarf2out.c:31107
> Please submit a full bug report,
> with preprocessed source if appropriate.
> Please include the complete backtrace with any bug report.
> See  for instructions.
> make: *** [/tmp/cc5TI8Oi.mk:2: /tmp/ccQqbTv7.ltrans0.ltrans.o] Error 1
> lto-wrapper: fatal error: make returned 2 exit status
> compilation terminated.
> /usr/bin/ld: error: lto-wrapper failed
> collect2: error: ld returned 1 exit status

We generate a DECL_ASSEMBLER_NAME for  through

#0  0x009e1269 in add_linkage_name_raw (
die=>, decl=)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:21233
#1  0x009ec5df in gen_typedef_die (decl=, 
context_die=>)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25251
#2  0x009ef609 in gen_decl_die (decl=, 
origin=, ctx=0x0, 
context_die=>)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:26229
#3  0x009ecd95 in gen_type_die_with_usage (
type=, 
context_die=>, usage=DINFO_USAGE_DIR_USE)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25394
#4  0x009ed695 in gen_type_die (type=, 
context_die=>)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25578
#5  0x009ef8c6 in gen_decl_die (decl=, 
origin=, ctx=0x7fffcdc0, 
context_die=>)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:26297
#6  0x009eb81f in gen_member_die (type=, 
context_die=>)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25032
#7  0x009ebf69 in gen_struct_or_union_type_die (
type=, 
context_die=>, usage=DINFO_USAGE_DIR_USE)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25128
#8  0x009eca10 in gen_tagged_type_die (
type=, 
context_die=>, usage=DINFO_USAGE_DIR_USE)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25329
#9  0x009ed321 in gen_type_die_with_usage (
type=, 
context_die=>, usage=DINFO_USAGE_DIR_USE)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25524
...
#18 0x009eea5f in force_type_die (type=)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25973
#19 0x009ee6d7 in get_context_die (
context=)
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:25888
#20 0x009fa4c9 in flush_limbo_die_list ()
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:31053
#21 0x009fa5dc in dwarf2out_finish ()
at /space/rguenther/src/gcc-sccvn/gcc/dwarf2out.c:31093

where the limbo DIE is

$8 = {die = , 
  created_for = , 
  next = 0x76a7c510}

DIE0: DW_TAG_subprogram (0x76a852d0)
  abbrev id: 0 offset: 0 mark: 0
  DW_AT_abstract_origin: die -> label: t.ii.e437cd39 + 316 (0x76a85320)

so the issue here is that the context is a RECORD_TYPE which context is
$12 = 
but at the time of dwarf2out_register_external_die it isn't assigned the
proper parent.

So the real bug is that we do this "inclusive":

  else if (TREE_CODE (ctx) == FUNCTION_DECL
   && TREE_CODE (decl) != PARM_DECL
   && TREE_CODE (decl) != BLOCK)
/* Leave function local entities parent determination to when
   we process scope vars.  */
;

including != FUNCTION_DECL makes both testcases work, another somewhat
obvious addition would be RESULT_DECL.

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-16 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

Richard Biener  changed:

   What|Removed |Added

 CC||rguenth at gcc dot gnu.org
   Target Milestone|--- |9.0

[Bug debug/86523] [9 Regression] ICE in gen_member_die, at dwarf2out.c:24933 starting from r262560

2018-07-14 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86523

--- Comment #1 from Martin Liška  ---
One more test-case with a bit different BT:

$  cat ice.ii
namespace {
class a typedef b;
class a {};
} // namespace
class c {
  struct C {
b d;
  };
  C e() const;
};
c::C c::e() const {
  C g;
  struct h {
C g;
h(C *) {}
  } f();
}

$ g++ ice.ii -O2 -flto=8 -g -shared
ice.ii: In member function ‘c::C c::e() const’:
ice.ii:17:1: warning: no return statement in function returning non-void
[-Wreturn-type]
 }
 ^

lto1: internal compiler error: in dwarf2out_finish, at dwarf2out.c:31107
0x5c87cd dwarf2out_finish
/home/marxin/Programming/gcc/gcc/dwarf2out.c:31107
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
make: *** [/tmp/cc5TI8Oi.mk:2: /tmp/ccQqbTv7.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status