* [lto] add support for reading/writing functions whose context is a type
@ 2008-04-15 23:22 Ollie Wild
2008-04-16 7:49 ` Diego Novillo
0 siblings, 1 reply; 2+ messages in thread
From: Ollie Wild @ 2008-04-15 23:22 UTC (permalink / raw)
To: GCC Patches; +Cc: Diego Novillo, Bill Maddox
[-- Attachment #1: Type: text/plain, Size: 893 bytes --]
In C++, the DECL_CONTEXT of a method is a type. Currently, this
generates an assertion failure inside output_expr_operand(). This
patch adds a new tag, LTO_type, and support for reading/writing it
within the lto driver.
Tested with a C/C++ bootstrap and dg-torture testsuite on i686-pc-linux-gnu.
Ollie
2008-04-15 Ollie Wild <aaw@google.com>
* lto-function-out.c (output_type_ref_1): New function.
(output_type_ref): Split into two functions.
(output_function): Output an LTO_type record if DECL_CONTEXT (function)
is a type.
* lto-tags.h (LTO_tags): Add LTO_type enumerator.
* lto-tree-tags.def (LTO_type): Add new name.
2008-04-15 Ollie Wild <aaw@google.com>
* lto-function-in.c (input_type_ref_1): New function.
(input_type_ref): Split into two functions.
(input_function): Add support for type contexts.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: decl_context.patch --]
[-- Type: text/x-patch; name=decl_context.patch, Size: 5221 bytes --]
commit 93ae936f933a6ba49e176f0b7c2a6338f8382117
Author: Ollie Wild <aaw@google.com>
Date: Tue Apr 15 13:55:24 2008 -0700
Add LTO support for functions whose DECL_CONTEXT is a type.
gcc/
* lto-function-out.c (output_type_ref_1): New function.
(output_type_ref): Split into two functions.
(output_function): Output an LTO_type record if DECL_CONTEXT (function)
is a type.
* lto-tags.h (LTO_tags): Add LTO_type enumerator.
* lto-tree-tags.def (LTO_type): Add new name.
gcc/lto/
* lto-function-in.c (input_type_ref_1): New function.
(input_type_ref): Split into two functions.
(input_function): Add support for type contexts.
diff --git a/gcc/lto-function-out.c b/gcc/lto-function-out.c
index 029a35c..3bcc3de 100644
--- a/gcc/lto-function-out.c
+++ b/gcc/lto-function-out.c
@@ -594,17 +594,14 @@ output_tree_flags (struct output_block *ob,
}
-/* Look up TYPE in the type table and write the uleb128 index for it.
- This is a hack and will be replaced with a real reference to the
- type. */
+/* Like output_type_ref, but no debug information is written. */
static void
-output_type_ref (struct output_block *ob, tree node)
+output_type_ref_1 (struct output_block *ob, tree node)
{
bool new;
unsigned int index;
- LTO_DEBUG_TOKEN ("type");
new = lto_output_decl_index (ob->main_stream,
ob->decl_state->type_hash_table,
&ob->decl_state->next_type_index,
@@ -615,6 +612,18 @@ output_type_ref (struct output_block *ob, tree node)
}
+/* Look up TYPE in the type table and write the uleb128 index for it.
+ This is a hack and will be replaced with a real reference to the
+ type. */
+
+static void
+output_type_ref (struct output_block *ob, tree node)
+{
+ LTO_DEBUG_TOKEN ("type");
+ output_type_ref_1 (ob, node);
+}
+
+
/* Look up NAME in the type table and if WRITE, write the uleb128
index for it to OB. */
@@ -1953,6 +1962,7 @@ output_function (struct cgraph_node* node)
struct function *fn = DECL_STRUCT_FUNCTION (function);
basic_block bb;
struct output_block *ob = create_output_block (LTO_section_function_body);
+ tree context;
LTO_SET_DEBUGGING_STREAM (debug_main_stream, main_data);
clear_line_info (ob);
@@ -1985,10 +1995,17 @@ output_function (struct cgraph_node* node)
output_zero (ob);
LTO_DEBUG_INDENT_TOKEN ("decl_context");
- if (DECL_CONTEXT (function))
- output_expr_operand (ob, DECL_CONTEXT (function));
- else
+ context = DECL_CONTEXT (function);
+ if (!context)
output_zero (ob);
+ else if (TYPE_P (context))
+ {
+ output_record_start (ob, NULL, NULL, LTO_type);
+ output_type_ref_1 (ob, context);
+ LTO_DEBUG_UNDENT ();
+ }
+ else
+ output_expr_operand (ob, DECL_CONTEXT (function));
/* We will renumber the statements. The code that does this uses
the same ordering that we use for serializing them so we can use
diff --git a/gcc/lto-tags.h b/gcc/lto-tags.h
index 82aa3e3..3c1d399 100644
--- a/gcc/lto-tags.h
+++ b/gcc/lto-tags.h
@@ -427,6 +427,7 @@ enum LTO_tags {
LTO_asm_clobbers,
LTO_function,
+ LTO_type,
LTO_eh_table,
/* Each of these requires 4 variants. 1 and 3 are have_inner and 2
diff --git a/gcc/lto-tree-tags.def b/gcc/lto-tree-tags.def
index 91b6f93..aa6f47a 100644
--- a/gcc/lto-tree-tags.def
+++ b/gcc/lto-tree-tags.def
@@ -305,6 +305,7 @@
SET_NAME (LTO_asm_outputs, "asm_outputs")
SET_NAME (LTO_asm_clobbers, "asm_clobbers")
SET_NAME (LTO_function, "function")
+ SET_NAME (LTO_type, "type")
SET_NAME (LTO_eh_table, "eh_table")
SET_NAME (LTO_eh_table_cleanup0, "eh_table_cleanup0")
SET_NAME (LTO_eh_table_cleanup1, "eh_table_cleanup1")
diff --git a/gcc/lto/lto-function-in.c b/gcc/lto/lto-function-in.c
index a637ee4..0c40767 100644
--- a/gcc/lto/lto-function-in.c
+++ b/gcc/lto/lto-function-in.c
@@ -226,18 +226,27 @@ get_label_decl (struct data_in *data_in, struct lto_input_block *ib)
}
-/* Get the type referenced by the next token in IB. */
+/* Like get_type_ref, but no debug information is read. */
static tree
-input_type_ref (struct data_in *data_in, struct lto_input_block *ib)
+input_type_ref_1 (struct data_in *data_in, struct lto_input_block *ib)
{
int index;
- LTO_DEBUG_TOKEN ("type");
index = lto_input_uleb128 (ib);
return data_in->file_data->types[index];
}
+
+/* Get the type referenced by the next token in IB. */
+
+static tree
+input_type_ref (struct data_in *data_in, struct lto_input_block *ib)
+{
+ LTO_DEBUG_TOKEN ("type");
+ return input_type_ref_1 (data_in, ib);
+}
+
/* Set all of the FLAGS for NODE. */
#define CLEAROUT (BITS_PER_LTO_FLAGS_TYPE - 1)
@@ -1506,7 +1515,15 @@ input_function (tree fn_decl, struct data_in *data_in,
LTO_DEBUG_INDENT_TOKEN ("decl_context");
tag = input_record_start (ib);
if (tag)
- DECL_CONTEXT (fn_decl) = input_expr_operand (ib, data_in, fn, tag);
+ {
+ if (tag == LTO_type)
+ {
+ DECL_CONTEXT (fn_decl) = input_type_ref_1 (data_in, ib);
+ LTO_DEBUG_UNDENT ();
+ }
+ else
+ DECL_CONTEXT (fn_decl) = input_expr_operand (ib, data_in, fn, tag);
+ }
tag = input_record_start (ib);
while (tag)
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [lto] add support for reading/writing functions whose context is a type
2008-04-15 23:22 [lto] add support for reading/writing functions whose context is a type Ollie Wild
@ 2008-04-16 7:49 ` Diego Novillo
0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2008-04-16 7:49 UTC (permalink / raw)
To: Ollie Wild; +Cc: GCC Patches, Bill Maddox
On 4/15/08 2:57 PM, Ollie Wild wrote:
> +/* Look up TYPE in the type table and write the uleb128 index for it.
> + This is a hack and will be replaced with a real reference to the
> + type. */
Not your bug, but this comment needs to document OB and NODE.
> +/* Get the type referenced by the next token in IB. */
> +
> +static tree
> +input_type_ref (struct data_in *data_in, struct lto_input_block *ib)
Likewise for IN.
OK with those changes.
Diego.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-04-16 7:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-15 23:22 [lto] add support for reading/writing functions whose context is a type Ollie Wild
2008-04-16 7:49 ` 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).