summaryrefslogtreecommitdiff
path: root/gcc/lto-streamer-out.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-07-30 12:14:58 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-07-30 12:14:58 +0000
commitf6bcdb5e058773874be9c63386cdbc3b9ff1581e (patch)
tree17ed7ba165f1d2672b9045df3792853564446f62 /gcc/lto-streamer-out.c
parent93a87598b928f58f9e467bea8c718c5e2c91e498 (diff)
downloadgcc-f6bcdb5e058773874be9c63386cdbc3b9ff1581e.tar.gz
lto-streamer.h (lto_write_data): New function.
2014-07-30 Richard Biener <rguenther@suse.de> * lto-streamer.h (lto_write_data): New function. * langhooks.c (lhd_append_data): Do not free block. * lto-section-out.c (lto_write_data): New function writing raw data to the current section. (lto_write_stream): Adjust for langhook semantic change. (lto_destroy_simple_output_block): Write header directly. * lto-opts.c (lto_write_options): Write options directly. * lto-streamer-out.c (produce_asm): Write heaeder directly. (lto_output_toplevel_asms): Likewise. (copy_function_or_variable): Copy data directly. (write_global_references): Output index table directly. (lto_output_decl_state_refs): Likewise. (write_symbol): Write data directly. (produce_symtab): Adjust. (produce_asm_for_decls): Output header and refs directly. lto/ * lto-object.c (lto_obj_append_data): Do not free block. From-SVN: r213253
Diffstat (limited to 'gcc/lto-streamer-out.c')
-rw-r--r--gcc/lto-streamer-out.c74
1 files changed, 25 insertions, 49 deletions
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 271fbd56591..6b3f78fd3ab 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -1872,7 +1872,6 @@ produce_asm (struct output_block *ob, tree fn)
enum lto_section_type section_type = ob->section_type;
struct lto_function_header header;
char *section_name;
- struct lto_output_stream *header_stream;
if (section_type == LTO_section_function_body)
{
@@ -1898,11 +1897,7 @@ produce_asm (struct output_block *ob, tree fn)
header.cfg_size = ob->cfg_stream->total_size;
header.main_size = ob->main_stream->total_size;
header.string_size = ob->string_stream->total_size;
-
- header_stream = XCNEW (struct lto_output_stream);
- lto_output_data_stream (header_stream, &header, sizeof header);
- lto_write_stream (header_stream);
- free (header_stream);
+ lto_write_data (&header, sizeof header);
/* Put all of the gimple and the string table out the asm file as a
block of text. */
@@ -2104,7 +2099,6 @@ lto_output_toplevel_asms (void)
struct output_block *ob;
struct asm_node *can;
char *section_name;
- struct lto_output_stream *header_stream;
struct lto_asm_header header;
if (! asm_nodes)
@@ -2136,11 +2130,7 @@ lto_output_toplevel_asms (void)
header.main_size = ob->main_stream->total_size;
header.string_size = ob->string_stream->total_size;
-
- header_stream = XCNEW (struct lto_output_stream);
- lto_output_data_stream (header_stream, &header, sizeof (header));
- lto_write_stream (header_stream);
- free (header_stream);
+ lto_write_data (&header, sizeof header);
/* Put all of the gimple and the string table out the asm file as a
block of text. */
@@ -2160,7 +2150,6 @@ copy_function_or_variable (struct symtab_node *node)
{
tree function = node->decl;
struct lto_file_decl_data *file_data = node->lto_file_data;
- struct lto_output_stream *output_stream = XCNEW (struct lto_output_stream);
const char *data;
size_t len;
const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function));
@@ -2181,8 +2170,7 @@ copy_function_or_variable (struct symtab_node *node)
gcc_assert (data);
/* Do a bit copy of the function body. */
- lto_output_data_stream (output_stream, data, len);
- lto_write_stream (output_stream);
+ lto_write_data (data, len);
/* Copy decls. */
in_state =
@@ -2206,7 +2194,6 @@ copy_function_or_variable (struct symtab_node *node)
lto_free_section_data (file_data, LTO_section_function_body, name,
data, len);
- free (output_stream);
lto_end_section ();
}
@@ -2348,15 +2335,15 @@ write_global_stream (struct output_block *ob,
static void
write_global_references (struct output_block *ob,
- struct lto_output_stream *ref_stream,
struct lto_tree_ref_encoder *encoder)
{
tree t;
uint32_t index;
const uint32_t size = lto_tree_ref_encoder_size (encoder);
- /* Write size as 32-bit unsigned. */
- lto_output_data_stream (ref_stream, &size, sizeof (int32_t));
+ /* Write size and slot indexes as 32-bit unsigned numbers. */
+ uint32_t *data = XNEWVEC (uint32_t, size + 1);
+ data[0] = size;
for (index = 0; index < size; index++)
{
@@ -2365,8 +2352,11 @@ write_global_references (struct output_block *ob,
t = lto_tree_ref_encoder_get_tree (encoder, index);
streamer_tree_cache_lookup (ob->writer_cache, t, &slot_num);
gcc_assert (slot_num != (unsigned)-1);
- lto_output_data_stream (ref_stream, &slot_num, sizeof slot_num);
+ data[index + 1] = slot_num;
}
+
+ lto_write_data (data, sizeof (int32_t) * (size + 1));
+ free (data);
}
@@ -2389,7 +2379,6 @@ lto_output_decl_state_streams (struct output_block *ob,
void
lto_output_decl_state_refs (struct output_block *ob,
- struct lto_output_stream *out_stream,
struct lto_out_decl_state *state)
{
unsigned i;
@@ -2401,10 +2390,10 @@ lto_output_decl_state_refs (struct output_block *ob,
decl = (state->fn_decl) ? state->fn_decl : void_type_node;
streamer_tree_cache_lookup (ob->writer_cache, decl, &ref);
gcc_assert (ref != (unsigned)-1);
- lto_output_data_stream (out_stream, &ref, sizeof (uint32_t));
+ lto_write_data (&ref, sizeof (uint32_t));
for (i = 0; i < LTO_N_DECL_STREAMS; i++)
- write_global_references (ob, out_stream, &state->streams[i]);
+ write_global_references (ob, &state->streams[i]);
}
@@ -2432,7 +2421,6 @@ lto_out_decl_state_written_size (struct lto_out_decl_state *state)
static void
write_symbol (struct streamer_tree_cache_d *cache,
- struct lto_output_stream *stream,
tree t, struct pointer_set_t *seen, bool alias)
{
const char *name;
@@ -2531,14 +2519,14 @@ write_symbol (struct streamer_tree_cache_d *cache,
else
comdat = "";
- lto_output_data_stream (stream, name, strlen (name) + 1);
- lto_output_data_stream (stream, comdat, strlen (comdat) + 1);
+ lto_write_data (name, strlen (name) + 1);
+ lto_write_data (comdat, strlen (comdat) + 1);
c = (unsigned char) kind;
- lto_output_data_stream (stream, &c, 1);
+ lto_write_data (&c, 1);
c = (unsigned char) visibility;
- lto_output_data_stream (stream, &c, 1);
- lto_output_data_stream (stream, &size, 8);
- lto_output_data_stream (stream, &slot_num, 4);
+ lto_write_data (&c, 1);
+ lto_write_data (&size, 8);
+ lto_write_data (&slot_num, 4);
}
/* Return true if NODE should appear in the plugin symbol table. */
@@ -2589,7 +2577,6 @@ produce_symtab (struct output_block *ob)
struct streamer_tree_cache_d *cache = ob->writer_cache;
char *section_name = lto_get_section_name (LTO_section_symtab, NULL, NULL);
struct pointer_set_t *seen;
- struct lto_output_stream stream;
lto_symtab_encoder_t encoder = ob->decl_state->symtab_node_encoder;
lto_symtab_encoder_iterator lsei;
@@ -2597,7 +2584,6 @@ produce_symtab (struct output_block *ob)
free (section_name);
seen = pointer_set_create ();
- memset (&stream, 0, sizeof (stream));
/* Write the symbol table.
First write everything defined and then all declarations.
@@ -2609,7 +2595,7 @@ produce_symtab (struct output_block *ob)
if (!output_symbol_p (node) || DECL_EXTERNAL (node->decl))
continue;
- write_symbol (cache, &stream, node->decl, seen, false);
+ write_symbol (cache, node->decl, seen, false);
}
for (lsei = lsei_start (encoder);
!lsei_end_p (lsei); lsei_next (&lsei))
@@ -2618,10 +2604,9 @@ produce_symtab (struct output_block *ob)
if (!output_symbol_p (node) || !DECL_EXTERNAL (node->decl))
continue;
- write_symbol (cache, &stream, node->decl, seen, false);
+ write_symbol (cache, node->decl, seen, false);
}
- lto_write_stream (&stream);
pointer_set_destroy (seen);
lto_end_section ();
@@ -2642,7 +2627,6 @@ produce_asm_for_decls (void)
struct lto_decl_header header;
char *section_name;
struct output_block *ob;
- struct lto_output_stream *header_stream, *decl_state_stream;
unsigned idx, num_fns;
size_t decl_state_size;
int32_t num_decl_states;
@@ -2701,26 +2685,18 @@ produce_asm_for_decls (void)
header.main_size = ob->main_stream->total_size;
header.string_size = ob->string_stream->total_size;
- header_stream = XCNEW (struct lto_output_stream);
- lto_output_data_stream (header_stream, &header, sizeof header);
- lto_write_stream (header_stream);
- free (header_stream);
+ lto_write_data (&header, sizeof header);
/* Write the main out-decl state, followed by out-decl states of
functions. */
- decl_state_stream = XCNEW (struct lto_output_stream);
num_decl_states = num_fns + 1;
- lto_output_data_stream (decl_state_stream, &num_decl_states,
- sizeof (num_decl_states));
- lto_output_decl_state_refs (ob, decl_state_stream, out_state);
+ lto_write_data (&num_decl_states, sizeof (num_decl_states));
+ lto_output_decl_state_refs (ob, out_state);
for (idx = 0; idx < num_fns; idx++)
{
- fn_out_state =
- lto_function_decl_states[idx];
- lto_output_decl_state_refs (ob, decl_state_stream, fn_out_state);
+ fn_out_state = lto_function_decl_states[idx];
+ lto_output_decl_state_refs (ob, fn_out_state);
}
- lto_write_stream (decl_state_stream);
- free (decl_state_stream);
lto_write_stream (ob->main_stream);
lto_write_stream (ob->string_stream);