This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[lto] PATCH COMMITTED to read in FUNCTION_DECLs properly.
- From: Kenneth Zadeck <zadeck at naturalbridge dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>, William Maddox <maddox at google dot com>, Jim Blandy <jimb at codesourcery dot com>, "Hubicha, Jan" <jh at suse dot cz>, Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 28 Aug 2007 14:16:07 -0400
- Subject: [lto] PATCH COMMITTED to read in FUNCTION_DECLs properly.
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;
}
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]);