This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto] fix ICE in int_mode_for_mode


The patch below fixes an ICE in int_mode_for_mode; the root of the
problem actually occurs in the LTO reader.  When we're reading a
structure type, we might create copies of that type while reading fields
of that structure.  While we're reading the fields of the structure, the
mode of the structure type is set to VOIDmode -- and so copies of the
structure are also marked with VOIDmode.  After we're done reading the
fields, we layout the structure, which changes its mode to something
sane; its copies, however, remain in VOIDmode and if they get used for
something, they will cause the aforementioned ICE in int_mode_for_mode.

The fix is to use a record_layout_info and its associated functions to
properly layout the structure.  With this, the TYPE_NEXT_VARIANTs
properly inherit the computed properties of their parent.

Committed to the LTO branch.

-Nathan

2007-11-05  Nathan Froyd  <froydnj@codesourcery.com>

	* lto.c (lto_read_structure_union_class_type_DIE): Use proper record
	layout functions to compute information about the newly constructed
	type.

Index: lto.c
===================================================================
--- lto.c	(revision 129904)
+++ lto.c	(working copy)
@@ -1636,6 +1636,7 @@ lto_read_structure_union_class_type_DIE 
   int i, n;
   tree *fields_tail;
   tree *methods_tail;
+  record_layout_info rli;
 
   LTO_BEGIN_READ_ATTRS ()
     {
@@ -1741,6 +1742,7 @@ lto_read_structure_union_class_type_DIE 
   n = VEC_length (tree, children);
   fields_tail = &TYPE_FIELDS (type);
   methods_tail = &TYPE_METHODS (type);
+  rli = start_record_layout (type);
   for (i = 0; i < n; i++)
     {
       tree child = VEC_index (tree, children, i);
@@ -1811,20 +1813,17 @@ lto_read_structure_union_class_type_DIE 
 		}
 	    }
 	}
-    }
-  VEC_free (tree, heap, children);
 
-  /* We might not have any information about how big the structure is.  */
-  if (size)
-    {
-      /* The type mode isn't encoded in the DWARF spec, either, so just
-         recompute it from scratch.  */
-      compute_record_mode (type);
-      if (GET_MODE_ALIGNMENT (TYPE_MODE (type)) > align)
-        align = GET_MODE_ALIGNMENT (TYPE_MODE (type));
-      TYPE_ALIGN (type) = align;
+      if (TREE_CODE_CLASS (TREE_CODE (child)) == tcc_declaration)
+        place_field (rli, child);
     }
 
+  /* We have all the information we need about this structure.  */
+  finish_record_layout (rli, false);
+
+  VEC_free (tree, heap, children);
+  free (rli);
+
   /* Finish debugging output for this type.  */
   if (!declaration)
     rest_of_type_compilation (type, /*top_level=*/1);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]