diff mbox

[google/gcc-4_7] Fix ICE in should_move_die_to_comdat

Message ID 20120823001143.C834FE0415@ccoutant.mtv.corp.google.com
State New
Headers show

Commit Message

Cary Coutant Aug. 23, 2012, 12:11 a.m. UTC
This patch is for the google/gcc-4_7 branch.

If a function contains a local typedef of an anonymous structure, GCC
will generate a typedef DIE in the function, where the typedef DIE points
to a structure_type DIE at the top level.  That structure_type DIE, if
it's a non-POD, can contain ctor and dtor definitions.  This causes an
assertion in should_move_die_to_comdat to fail, as we have up to now
assumed that this could never happen.

Perhaps a better fix would be to fix the generation of the structure_type
DIE somehow, but GDB seems happy with what we're generating, and we don't
want to extract this type into a comdat type unit anyway, so this patch
fixes things up so that we just skip the type instead of asserting.

I'll explore other possible fixes for trunk, but this should be good
for google/gcc-4_7.

Tested with build and validate, and by compiling the failing test case.

Google ref b/6669962.


2012-08-22   Cary Coutant  <ccoutant@google.com>

	* gcc/dwarf2out.c (should_move_die_to_comdat): A type definition
	can contain a subprogram definition, but don't move it to a
	comdat unit.

Comments

Paul Pluzhnikov Aug. 23, 2012, 1:07 a.m. UTC | #1
On Wed, Aug 22, 2012 at 5:11 PM, Cary Coutant <ccoutant@google.com> wrote:
> This patch is for the google/gcc-4_7 branch.

Approved for google/gcc-4_7 branch.

Thanks,
diff mbox

Patch

Index: gcc/dwarf2out.c
===================================================================
--- gcc/dwarf2out.c	(revision 190603)
+++ gcc/dwarf2out.c	(working copy)
@@ -7289,14 +7289,13 @@  should_move_die_to_comdat (dw_die_ref di
     case DW_TAG_structure_type:
     case DW_TAG_enumeration_type:
     case DW_TAG_union_type:
-      /* Don't move declarations, inlined instances, or types nested in a
-	 subprogram.  */
+      /* Don't move declarations, inlined instances, types nested in a
+	 subprogram, or types that contain subprogram definitions.  */
       if (is_declaration_die (die)
           || get_AT (die, DW_AT_abstract_origin)
-          || is_nested_in_subprogram (die))
+          || is_nested_in_subprogram (die)
+	  || contains_subprogram_definition (die))
         return 0;
-      /* A type definition should never contain a subprogram definition.  */
-      gcc_assert (!contains_subprogram_definition (die));
       return 1;
     case DW_TAG_array_type:
     case DW_TAG_interface_type: