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][patch] Fix internal compiler error in stabilize_va_list


The following patch fixes an ICE in stabilize_va_list, when the type
of the va_list parameter does not match the builtin va_list_type_node.
The problem occurs only on x86_64, where the builtin va_list type is
an array type instead of a simple type, and where the parameter has a
pointer type to the underlying type. When building the list of
preloaded common nodes in lto_get_common_nodes, we were recording only
the top-level type nodes, so the underlying type was not recognized as
a common type, and was streamed out and reconstructed by the reader.
As a result, the type was not recognized as the builtin type in
stabilize_va_list. This patch fixes the problem by checking
specifically for an array type in lto_record_common_node, and records
the underlying type node as well.

There's an existing FIXME in lto_record_common_node:

  /* FIXME lto: In principle, we should perform a walk over all nodes reachable
     from each preloaded node.  This is going to be a lot of work.  At present,
     we catch the case that was causing test failures.  A small step.  */

It may be about time to take a longer look at this, but this patch
takes just one more small step.

I've boiled this down to the simple test case included below, but I'm
not sure yet where to put LTO tests.

OK?

-cary


------- valist.c -------
#include <stdarg.h>
#include <stdio.h>

int
myprintf(const char *fmt, ...)
{
 int n;
 va_list args;
 va_start(args,fmt);
 n = vprintf(fmt, args);
 va_end(args);
 return n;
}

int
main()
{
 int n;
 n = myprintf("%s: %d\n", "foo", 1);
 return 0;
}
-------

2008-10-23  Cary Coutant  <ccoutant@google.com>

	* lto-section-out.c (lto_record_common_node): For array types,
	record the underlying type.


Index: lto-section-out.c
===================================================================
--- lto-section-out.c	(revision 141329)
+++ lto-section-out.c	(working copy)
@@ -877,6 +877,10 @@ lto_record_common_node (tree node, VEC(t
 	  lto_record_common_node (TYPE_MAIN_VARIANT (node), common_nodes,
 				  seen_nodes);
 	}
+      if (TREE_CODE (node) == ARRAY_TYPE)
+        {
+          lto_record_common_node (TREE_TYPE (node), common_nodes, seen_nodes);
+        }
     }
 }


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