public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [lto][patch] Fix internal compiler error in stabilize_va_list
@ 2008-10-24  6:17 Cary Coutant
  2008-10-24 15:27 ` Diego Novillo
  0 siblings, 1 reply; 2+ messages in thread
From: Cary Coutant @ 2008-10-24  6:17 UTC (permalink / raw)
  To: gcc-patches

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);
+        }
     }
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-24 14:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-24  6:17 [lto][patch] Fix internal compiler error in stabilize_va_list Cary Coutant
2008-10-24 15:27 ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).