public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [lto] PATCH COMMITTED to read in FUNCTION_DECLs properly.
@ 2007-08-28 18:27 Kenneth Zadeck
  0 siblings, 0 replies; only message in thread
From: Kenneth Zadeck @ 2007-08-28 18:27 UTC (permalink / raw)
  To: gcc-patches, William Maddox, Jim Blandy, Hubicha, Jan, Mark Mitchell

[-- Attachment #1: Type: text/plain, Size: 935 bytes --]

This patch removes some code that was supposed to protect me while Mark was
still writing his side of the lto reading and writing but now that that
he has done that, it turns out to be incorrect.

committed as revision 127869.


2007-08-28  Kenneth Zadeck <zadeck@naturalbridge.com>

        * lto-read.c (input_expr_operand): Assert that there really is a
    FUNCTION_DECL.
    (input_globals): Removed checks on 0 section.

This patch makes it possible to write and read the following function
but the compiler crashes because the cgraph is messed up.  I need some
help from a cgraph expert.  Apparently this file requires edges between
the cgraph function nodes and i do not know how to get them there.

Any suggestions (or patches) would be appreciated.

Kenny

unsigned fact(unsigned x)
{
  if (x == 0)
    return 1;
  else
    return x * fact(x - 1);
}

int
main()
{
  (void)fact(5);  /* dont' bother to print */
  return 0;
}


[-- Attachment #2: postmerge8.diff --]
[-- Type: text/x-patch, Size: 1393 bytes --]

Index: lto/lto-read.c
===================================================================
--- lto/lto-read.c	(revision 127862)
+++ lto/lto-read.c	(working copy)
@@ -589,6 +589,7 @@ input_expr_operand (struct input_block *
 
     case FUNCTION_DECL:
       result = fun_in->fn_decls [input_uleb128 (ib)];
+      gcc_assert (result);
       break;
 
     case VAR_DECL:
@@ -927,19 +928,16 @@ input_globals (struct lto_function_heade
   fun_in->types       = xcalloc (header->num_types, sizeof (tree*));
 
   for (i=0; i<header->num_field_decls; i++)
-    if (in_field_decls[i].section)
-      fun_in->field_decls[i] 
-        = lto_resolve_field_ref (fd, context, &in_field_decls[i]);
+    fun_in->field_decls[i] 
+      = lto_resolve_field_ref (fd, context, &in_field_decls[i]);
 
   for (i=0; i<header->num_fn_decls; i++)
-    if (in_fn_decls[i].section)
-      fun_in->fn_decls[i] 
-	= lto_resolve_fn_ref (fd, context, &in_fn_decls[i]);
+    fun_in->fn_decls[i] 
+      = lto_resolve_fn_ref (fd, context, &in_fn_decls[i]);
 
   for (i=0; i<header->num_var_decls; i++)
-    if (in_var_decls[i].section)
-      fun_in->var_decls[i] 
-	= lto_resolve_var_ref (fd, context, &in_var_decls[i]);
+    fun_in->var_decls[i] 
+      = lto_resolve_var_ref (fd, context, &in_var_decls[i]);
 
   for (i=0; i<header->num_types; i++)
     fun_in->types[i] = lto_resolve_type_ref (fd, context, &in_types[i]);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-08-28 18:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-28 18:27 [lto] PATCH COMMITTED to read in FUNCTION_DECLs properly Kenneth Zadeck

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).