[lto] Remove special handling of char_type_node in free_lang_specifics

Diego Novillo dnovillo@google.com
Wed Jan 21 16:02:00 GMT 2009


The rewrite of free_lang_specifics that I posted yesterday
(http://gcc.gnu.org/ml/gcc-patches/2009-01/msg01004.html) is
having stack overflow problems on large C++ applications because
of the recursive walk down types and decls.

This patch is an interim fix that I need to solve the problems we
were having with -funsigned-char in our builds.  These two
patches work around the problem by not writing char_type_node to
the type table in the LTO file.  The ideal solution I want to
implement is to do this in free_lang_data so we have the same IL
in memory as in disk.

There is an additional test that I will add as soon as delta
finishes reducing (10 days and counting).

Tested on x86_64.


Diego.


	* tree.c (reset_type_lang_specific): Do not overwrite
	char_type_node if -funsigned-char is used.
	* lto-function-out.c (output_tree): Do not handle char_type_node.
	(output_tree): Move check for flag_signed_char ... 
	(output_type_ref_1): ... here.

testsuite/ChangeLog.lto

	* gcc.dg/lto/20090120_0.c: New.

Index: lto-function-out.c
===================================================================
--- lto-function-out.c	(revision 143528)
+++ lto-function-out.c	(revision 143529)
@@ -571,6 +571,12 @@ type_decl_is_local (tree decl ATTRIBUTE_
 static void
 output_type_ref_1 (struct output_block *ob, tree node)
 {
+  /* FIXME lto.  This is a hack, the use of -funsigned-char should be
+     reflected in the IL by changing every reference to char_type_node
+     into unsigned_char_type_node in pass_ipa_free_lang_data.  */
+  if (flag_signed_char == 0 && node == char_type_node)
+    node = unsigned_char_type_node;
+
   output_record_start (ob, NULL, NULL, LTO_global_type_ref);
   lto_output_type_ref_index (ob->decl_state, ob->main_stream, node);
 
@@ -3088,9 +3094,6 @@ output_tree (struct output_block *ob, tr
   void **slot;
   struct lto_decl_slot d_slot;
 
-  if (flag_signed_char == 0 && expr == char_type_node)
-    expr = unsigned_char_type_node;
-
   if (expr == NULL_TREE)
     {
       output_zero (ob);
Index: tree.c
===================================================================
--- tree.c	(revision 143544)
+++ tree.c	(working copy)
@@ -3981,23 +3981,6 @@ reset_type_lang_specific (void **slot, v
      FIXME lto: This will break debug info generation.  */
   TYPE_CONTEXT (type) = NULL_TREE;
 
-  /* If -funsigned-char is used, force all the expressions using
-     char_type_node to use unsigned_char_type_node.  */
-  if (flag_signed_char == 0)
-    {
-      if (type == char_type_node)
-	memcpy (type, unsigned_char_type_node, tree_size (type));
-      else if (TYPE_MAIN_VARIANT (type) == char_type_node)
-	TYPE_MAIN_VARIANT (type) = unsigned_char_type_node;
-
-      /* Clear the cached values for TYPE.  */
-      if (TYPE_CACHED_VALUES_P (type))
-	{
-	  TYPE_CACHED_VALUES_P (type) = 0;
-	  TYPE_CACHED_VALUES (type) = NULL;
-	}
-    }
-
   return 1;
 }
 
Index: testsuite/gcc.dg/lto/20090120_0.c
===================================================================
--- testsuite/gcc.dg/lto/20090120_0.c	(revision 0)
+++ testsuite/gcc.dg/lto/20090120_0.c	(revision 0)
@@ -0,0 +1,14 @@
+/* { dg-options "{-flto -funsigned-char}" } */
+
+extern void abort ();
+
+char c = 0xff;
+
+int
+main ()
+{
+ int i = (unsigned) c;
+ if (i < 0)
+   abort ();
+ return 0;
+}



More information about the Gcc-patches mailing list