This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[LTO][PATCH] Fix local register variable serialization
- From: simonb at google dot com (Simon Baldwin)
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 25 Nov 2008 21:08:55 +0000 (GMT)
- Subject: [LTO][PATCH] Fix local register variable serialization
This patch fixes a compiler error that can occur in lto1 when a register
local variable is serialized and then read back -- in this case, the variable's
assembler name, containing the register designation, is omitted. Compilation
fails in lto1 with "error: register name not specified for '...'".
The patch adds the assembler name, where set, to the serialized tree.
gcc/ChangeLog.lto
2008-11-25 Simon Baldwin <simonb@google.com>
* lto-function-out.c (output_local_var_decl): If set, add assembler
name to output stream.
* lto-function-in.c (input_local_var_decl): Retrieve any assembler
name from output stream, and if present set in result decl.
gcc/testsuite/ChangeLog.lto
2008-11-25 Simon Baldwin <simonb@google.com>
* gcc.dg/lto/20081125_0.c: New.
Index: gcc/lto-function-out.c
===================================================================
--- gcc/lto-function-out.c (revision 142193)
+++ gcc/lto-function-out.c (working copy)
@@ -1308,6 +1308,16 @@ output_local_var_decl (struct output_blo
output_string (ob, ob->main_stream,
IDENTIFIER_POINTER (name),
IDENTIFIER_LENGTH (name));
+
+ if (DECL_ASSEMBLER_NAME_SET_P (decl))
+ {
+ tree assembler_name = DECL_ASSEMBLER_NAME (decl);
+ output_string (ob, ob->main_stream,
+ IDENTIFIER_POINTER (assembler_name),
+ IDENTIFIER_LENGTH (assembler_name));
+ }
+ else
+ output_zero (ob);
}
else
output_zero (ob);
Index: gcc/lto-function-in.c
===================================================================
--- gcc/lto-function-in.c (revision 142193)
+++ gcc/lto-function-in.c (working copy)
@@ -1223,7 +1223,8 @@ input_local_var_decl (struct lto_input_b
unsigned int variant;
bool is_var;
unsigned int name_index;
- tree name;
+ tree name = NULL_TREE;
+ tree assembler_name = NULL_TREE;
tree type;
lto_flags_type flags;
tree result;
@@ -1238,9 +1239,14 @@ input_local_var_decl (struct lto_input_b
unsigned int len;
const char *s = input_string_internal (data_in, name_index, &len);
name = get_identifier_with_length (s, len);
+
+ name_index = lto_input_uleb128 (ib);
+ if (name_index)
+ {
+ s = input_string_internal (data_in, name_index, &len);
+ assembler_name = get_identifier_with_length (s, len);
+ }
}
- else
- name = NULL_TREE;
type = input_type_ref (data_in, ib);
gcc_assert (type);
@@ -1250,6 +1256,9 @@ input_local_var_decl (struct lto_input_b
else
result = build_decl (PARM_DECL, name, type);
+ if (assembler_name != NULL_TREE)
+ SET_DECL_ASSEMBLER_NAME (result, assembler_name);
+
data_in->local_decls[i] = result;
if (is_var)
Index: gcc/testsuite/gcc.dg/lto/20081125_0.c
===================================================================
--- gcc/testsuite/gcc.dg/lto/20081125_0.c (revision 0)
+++ gcc/testsuite/gcc.dg/lto/20081125_0.c (revision 0)
@@ -0,0 +1,7 @@
+/* { dg-do link { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "{-flto-single -shared}" } */
+
+int f(void) {
+ register int ri asm("edi");
+ return ri;
+}