[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 --- Comment #17 from Jason Merrill 2012-06-20 07:22:13 UTC --- Author: jason Date: Wed Jun 20 07:22:07 2012 New Revision: 188811 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188811 Log: 2012-06-11 Richard Guenther PR middle-end/53470 * tree.c (free_lang_data_in_type): Do not clear TYPE_CONTEXT but replace it with the first non-BLOCK context. * g++.dg/lto/pr53470_0.C: New testcase. * gcc.dg/lto/pr53470_0.c: Likewise. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/lto/pr53470_0.C branches/gcc-4_7-branch/gcc/testsuite/gcc.dg/lto/pr53470_0.c Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/testsuite/ChangeLog branches/gcc-4_7-branch/gcc/tree.c
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 --- Comment #16 from vincenzo Innocente 2012-06-12 05:16:28 UTC --- Confirmed that the fix solves the problem as I originally observed.
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 Richard Guenther changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution||FIXED --- Comment #15 from Richard Guenther 2012-06-11 14:16:22 UTC --- Fixed.
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 --- Comment #14 from Richard Guenther 2012-06-11 14:14:15 UTC --- Author: rguenth Date: Mon Jun 11 14:14:09 2012 New Revision: 188387 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188387 Log: 2012-06-11 Richard Guenther PR middle-end/53470 * tree.c (free_lang_data_in_type): Do not clear TYPE_CONTEXT but replace it with the first non-BLOCK context. * g++.dg/lto/pr53470_0.C: New testcase. * gcc.dg/lto/pr53470_0.c: Likewise. Added: trunk/gcc/testsuite/g++.dg/lto/pr53470_0.C trunk/gcc/testsuite/gcc.dg/lto/pr53470_0.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree.c
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 --- Comment #13 from Jason Merrill 2012-06-11 13:37:27 UTC --- (In reply to comment #12) > thus, replace a BLOCK context with the first non-BLOCK context, works. That sounds good.
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 --- Comment #12 from Richard Guenther 2012-06-11 12:54:50 UTC --- It seems we never come along with a DECL_CONTEXT that is a BLOCK (nor does the C++ frontend do that ...). Replacing the TYPE_CONTEXT clearing with if (TYPE_CONTEXT (type) && TREE_CODE (TYPE_CONTEXT (type)) == BLOCK) { tree ctx = TYPE_CONTEXT (type); do { ctx = BLOCK_SUPERCONTEXT (ctx); } while (ctx && TREE_CODE (ctx) == BLOCK); TYPE_CONTEXT (type) = ctx; } thus, replace a BLOCK context with the first non-BLOCK context, works.
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 --- Comment #11 from Richard Guenther 2012-06-11 12:38:06 UTC --- Removing the whole if (debug_info_level < DINFO_LEVEL_TERSE || (TYPE_CONTEXT (type) && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_DECL && TREE_CODE (TYPE_CONTEXT (type)) != NAMESPACE_DECL)) TYPE_CONTEXT (type) = NULL_TREE; block causes us to ICE for gcc.c-torture/execute/20111208-1.c and gcc.c-torture/execute/pr42833.c Even though I think that would be the correct thing to do. Reduced testcase for that ICE: int main () { { union { } v; } } works with int main () { union { } v; }
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 Jason Merrill changed: What|Removed |Added CC|jason at redhat dot com | --- Comment #10 from Jason Merrill 2012-06-06 16:09:59 UTC --- I wish bugzilla were clever enough not to add me to CC if my other email address is already there...
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 --- Comment #9 from Jason Merrill 2012-06-06 15:27:02 UTC --- (In reply to comment #8) > All of the clearing is done to push down memory usage and/or cause > types to be referenced that are otherwise unused. A way to retain the > latter would be to not recurse into TYPE_CONTEXT during find_decls_types_r > and in free_lang_data_in_type only reset TYPE_CONTEXT when > that is not in fld.pset (thus we didn't visit it, aka, it is unused). If a type is nested inside another type, using the inner type necessarily uses the outer type; we need to at least declare the outer type so we have some place to put the inner type. So I don't think there's any optimization opportunity here. > Note that the fundamental issue with running free-lang-data with -g0 > and lto1 with -g is that free-lang-data with -g0 assumes we won't > generate debug information. Yes, but that isn't the problem with this PR; in this case cc1plus and lto1 are both run with -g. free_lang_data_in_type is clearing TYPE_CONTEXT even though we want full debug information, and this lying to the debugging back end results in the ICE.
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 --- Comment #8 from rguenther at suse dot de 2012-06-06 11:55:32 UTC --- On Tue, 5 Jun 2012, jason at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 > > Jason Merrill changed: > >What|Removed |Added > > CC||jason at gcc dot gnu.org > > --- Comment #7 from Jason Merrill 2012-06-05 > 18:07:14 UTC --- > OK, here's the problem: > > free_lang_data_in_type clears TYPE_CONTEXT of Holder. > gen_tagged_type_die tries to emit an enclosing class first, but since > TYPE_CONTEXT is null, it thinks Holder isn't a nested class. > gen_struct_or_union_type_die calls scope_die_for, which forces out > ExtensionCord, which also generates a DIE for Holder. > gen_struct_or_union_type_die contiues to generate what is now a duplicate DIE > for Holder. > > What is the rationale for clearing TYPE_CONTEXT of Holder? It seems quite > deliberate, but there's no comment explaining why it would be a good idea. All of the clearing is done to push down memory usage and/or cause types to be referenced that are otherwise unused. A way to retain the latter would be to not recurse into TYPE_CONTEXT during find_decls_types_r and in free_lang_data_in_type only reset TYPE_CONTEXT when that is not in fld.pset (thus we didn't visit it, aka, it is unused). Not sure if this will reliably fix this kind of ICEs. Note that the fundamental issue with running free-lang-data with -g0 and lto1 with -g is that free-lang-data with -g0 assumes we won't generate debug information. I think the case in question is the only remaining case we do different things -g0 vs. -g in free-lang-data - and we should definitely remove that inconsistency. Thus, I suppose even the simple Index: tree.c === --- tree.c (revision 188260) +++ tree.c (working copy) @@ -4575,10 +4575,9 @@ free_lang_data_in_type (tree type) free_lang_data_in_one_sizepos (&TYPE_SIZE (type)); free_lang_data_in_one_sizepos (&TYPE_SIZE_UNIT (type)); - if (debug_info_level < DINFO_LEVEL_TERSE - || (TYPE_CONTEXT (type) - && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_DECL - && TREE_CODE (TYPE_CONTEXT (type)) != NAMESPACE_DECL)) + if (TYPE_CONTEXT (type) + && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_DECL + && TREE_CODE (TYPE_CONTEXT (type)) != NAMESPACE_DECL) TYPE_CONTEXT (type) = NULL_TREE; } should be ok at the expense of extra memory/disk space usage at -g0 (note we walk TYPE_CONTEXT for all types in find_decls_types_r, so even the restriction above looks odd - either we should restrict recursion as well or never clear TYPE_CONTEXT). Richard.
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 Jason Merrill changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment #7 from Jason Merrill 2012-06-05 18:07:14 UTC --- OK, here's the problem: free_lang_data_in_type clears TYPE_CONTEXT of Holder. gen_tagged_type_die tries to emit an enclosing class first, but since TYPE_CONTEXT is null, it thinks Holder isn't a nested class. gen_struct_or_union_type_die calls scope_die_for, which forces out ExtensionCord, which also generates a DIE for Holder. gen_struct_or_union_type_die contiues to generate what is now a duplicate DIE for Holder. What is the rationale for clearing TYPE_CONTEXT of Holder? It seems quite deliberate, but there's no comment explaining why it would be a good idea.
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 Richard Guenther changed: What|Removed |Added Keywords||lto Status|NEW |ASSIGNED AssignedTo|unassigned at gcc dot |rguenth at gcc dot gnu.org |gnu.org | --- Comment #6 from Richard Guenther 2012-05-29 10:33:56 UTC --- I'll have a look.
[Bug debug/53470] [4.8 Regression] ICE when linking with -g in splice_child_die, at dwarf2out.c:4264
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53470 H.J. Lu changed: What|Removed |Added Status|WAITING |NEW CC||jason at redhat dot com Component|lto |debug Target Milestone|--- |4.8.0 Summary|[4.8 LTO] ICE when linking |[4.8 Regression] ICE when |with -g in |linking with -g in |splice_child_die, at|splice_child_die, at |dwarf2out.c:4264|dwarf2out.c:4264 --- Comment #5 from H.J. Lu 2012-05-25 12:31:12 UTC --- It is caused by revision 187106: http://gcc.gnu.org/ml/gcc-cvs/2012-05/msg00102.html