Commit d579fcda by Richard Biener Committed by Richard Biener

Makefile.in (LTO_STREAMER_H): Add pointer-set.h dependency.

2013-06-18  Richard Biener  <rguenther@suse.de>

	* Makefile.in (LTO_STREAMER_H): Add pointer-set.h dependency.
	* lto-streamer.h: Include pointer-set.h.
	(struct lto_decl_slot): Remove.
	(struct lto_tree_ref_encoder): Make tree_hash_table a pointer-map.
	Remove next_index entry.
	(lto_hash_decl_slot_node, lto_eq_decl_slot_node,
	lto_hash_type_slot_node, lto_eq_type_slot_node): Remove.
	(lto_init_tree_ref_encoder): Adjust.
	(lto_destroy_tree_ref_encoder): Likewise.
	* lto-section-out.c (lto_hash_decl_slot_node, lto_eq_decl_slot_node,
	lto_hash_type_slot_node, lto_eq_type_slot_node): Remove.
	(lto_output_decl_index): Adjust.
	(lto_new_out_decl_state): Likewise.
	(lto_record_function_out_decl_state): Likewise.
	* lto-streamer-out.c (copy_function): Likewise.

From-SVN: r200171
parent 31ee20ba
2013-06-18 Richard Biener <rguenther@suse.de> 2013-06-18 Richard Biener <rguenther@suse.de>
* Makefile.in (LTO_STREAMER_H): Add pointer-set.h dependency.
* lto-streamer.h: Include pointer-set.h.
(struct lto_decl_slot): Remove.
(struct lto_tree_ref_encoder): Make tree_hash_table a pointer-map.
Remove next_index entry.
(lto_hash_decl_slot_node, lto_eq_decl_slot_node,
lto_hash_type_slot_node, lto_eq_type_slot_node): Remove.
(lto_init_tree_ref_encoder): Adjust.
(lto_destroy_tree_ref_encoder): Likewise.
* lto-section-out.c (lto_hash_decl_slot_node, lto_eq_decl_slot_node,
lto_hash_type_slot_node, lto_eq_type_slot_node): Remove.
(lto_output_decl_index): Adjust.
(lto_new_out_decl_state): Likewise.
(lto_record_function_out_decl_state): Likewise.
* lto-streamer-out.c (copy_function): Likewise.
2013-06-18 Richard Biener <rguenther@suse.de>
* Makefile.in (cgraphunit.o): Add $(CFGLOOP_H) dependency. * Makefile.in (cgraphunit.o): Add $(CFGLOOP_H) dependency.
* cgraphunit.c: Include cfgloop.h. * cgraphunit.c: Include cfgloop.h.
(init_lowered_empty_function): Initialize the loop tree. (init_lowered_empty_function): Initialize the loop tree.
......
...@@ -967,7 +967,7 @@ LRA_INT_H = lra.h $(BITMAP_H) $(RECOG_H) $(INSN_ATTR_H) insn-codes.h \ ...@@ -967,7 +967,7 @@ LRA_INT_H = lra.h $(BITMAP_H) $(RECOG_H) $(INSN_ATTR_H) insn-codes.h \
DBGCNT_H = dbgcnt.h dbgcnt.def DBGCNT_H = dbgcnt.h dbgcnt.def
LTO_STREAMER_H = lto-streamer.h $(LINKER_PLUGIN_API_H) $(TARGET_H) \ LTO_STREAMER_H = lto-streamer.h $(LINKER_PLUGIN_API_H) $(TARGET_H) \
$(CGRAPH_H) $(VEC_H) $(HASH_TABLE_H) $(TREE_H) $(GIMPLE_H) \ $(CGRAPH_H) $(VEC_H) $(HASH_TABLE_H) $(TREE_H) $(GIMPLE_H) \
$(GCOV_IO_H) $(DIAGNOSTIC_H) alloc-pool.h $(GCOV_IO_H) $(DIAGNOSTIC_H) alloc-pool.h pointer-set.h
DATA_STREAMER_H = data-streamer.h $(VEC_H) $(LTO_STREAMER_H) DATA_STREAMER_H = data-streamer.h $(VEC_H) $(LTO_STREAMER_H)
GIMPLE_STREAMER_H = gimple-streamer.h $(LTO_STREAMER_H) $(BASIC_BLOCK_H) \ GIMPLE_STREAMER_H = gimple-streamer.h $(LTO_STREAMER_H) $(BASIC_BLOCK_H) \
$(FUNCTION_H) $(FUNCTION_H)
......
...@@ -48,59 +48,7 @@ static vec<lto_out_decl_state_ptr> decl_state_stack; ...@@ -48,59 +48,7 @@ static vec<lto_out_decl_state_ptr> decl_state_stack;
generate the decl directory later. */ generate the decl directory later. */
vec<lto_out_decl_state_ptr> lto_function_decl_states; vec<lto_out_decl_state_ptr> lto_function_decl_states;
/* Returns a hash code for P. */
hashval_t
lto_hash_decl_slot_node (const void *p)
{
const struct lto_decl_slot *ds = (const struct lto_decl_slot *) p;
/*
return (hashval_t) DECL_UID (ds->t);
*/
return (hashval_t) TREE_HASH (ds->t);
}
/* Returns nonzero if P1 and P2 are equal. */
int
lto_eq_decl_slot_node (const void *p1, const void *p2)
{
const struct lto_decl_slot *ds1 =
(const struct lto_decl_slot *) p1;
const struct lto_decl_slot *ds2 =
(const struct lto_decl_slot *) p2;
/*
return DECL_UID (ds1->t) == DECL_UID (ds2->t);
*/
return ds1->t == ds2->t;
}
/* Returns a hash code for P. */
hashval_t
lto_hash_type_slot_node (const void *p)
{
const struct lto_decl_slot *ds = (const struct lto_decl_slot *) p;
return (hashval_t) TYPE_UID (ds->t);
}
/* Returns nonzero if P1 and P2 are equal. */
int
lto_eq_type_slot_node (const void *p1, const void *p2)
{
const struct lto_decl_slot *ds1 =
(const struct lto_decl_slot *) p1;
const struct lto_decl_slot *ds2 =
(const struct lto_decl_slot *) p2;
return TYPE_UID (ds1->t) == TYPE_UID (ds2->t);
}
/***************************************************************************** /*****************************************************************************
Output routines shared by all of the serialization passes. Output routines shared by all of the serialization passes.
...@@ -278,29 +226,19 @@ lto_output_decl_index (struct lto_output_stream *obs, ...@@ -278,29 +226,19 @@ lto_output_decl_index (struct lto_output_stream *obs,
tree name, unsigned int *this_index) tree name, unsigned int *this_index)
{ {
void **slot; void **slot;
struct lto_decl_slot d_slot;
int index; int index;
bool new_entry_p = FALSE; bool new_entry_p = FALSE;
d_slot.t = name; slot = pointer_map_insert (encoder->tree_hash_table, name);
slot = htab_find_slot (encoder->tree_hash_table, &d_slot, INSERT);
if (*slot == NULL) if (*slot == NULL)
{ {
struct lto_decl_slot *new_slot index = encoder->trees.length ();
= (struct lto_decl_slot *) xmalloc (sizeof (struct lto_decl_slot)); *slot = (void *)(uintptr_t) index;
index = encoder->next_index++;
new_slot->t = name;
new_slot->slot_num = index;
*slot = new_slot;
encoder->trees.safe_push (name); encoder->trees.safe_push (name);
new_entry_p = TRUE; new_entry_p = TRUE;
} }
else else
{ index = (uintptr_t) *slot;
struct lto_decl_slot *old_slot = (struct lto_decl_slot *)*slot;
index = old_slot->slot_num;
}
if (obs) if (obs)
streamer_write_uhwi_stream (obs, index); streamer_write_uhwi_stream (obs, index);
...@@ -440,23 +378,9 @@ lto_new_out_decl_state (void) ...@@ -440,23 +378,9 @@ lto_new_out_decl_state (void)
{ {
struct lto_out_decl_state *state = XCNEW (struct lto_out_decl_state); struct lto_out_decl_state *state = XCNEW (struct lto_out_decl_state);
int i; int i;
htab_hash hash_fn;
htab_eq eq_fn;
for (i = 0; i < LTO_N_DECL_STREAMS; i++) for (i = 0; i < LTO_N_DECL_STREAMS; i++)
{ lto_init_tree_ref_encoder (&state->streams[i]);
if (i == LTO_DECL_STREAM_TYPE)
{
hash_fn = lto_hash_type_slot_node;
eq_fn = lto_eq_type_slot_node;
}
else
{
hash_fn = lto_hash_decl_slot_node;
eq_fn = lto_eq_decl_slot_node;
}
lto_init_tree_ref_encoder (&state->streams[i], hash_fn, eq_fn);
}
return state; return state;
} }
...@@ -514,7 +438,7 @@ lto_record_function_out_decl_state (tree fn_decl, ...@@ -514,7 +438,7 @@ lto_record_function_out_decl_state (tree fn_decl,
for (i = 0; i < LTO_N_DECL_STREAMS; i++) for (i = 0; i < LTO_N_DECL_STREAMS; i++)
if (state->streams[i].tree_hash_table) if (state->streams[i].tree_hash_table)
{ {
htab_delete (state->streams[i].tree_hash_table); pointer_map_destroy (state->streams[i].tree_hash_table);
state->streams[i].tree_hash_table = NULL; state->streams[i].tree_hash_table = NULL;
} }
state->fn_decl = fn_decl; state->fn_decl = fn_decl;
......
...@@ -1922,9 +1922,9 @@ copy_function (struct cgraph_node *node) ...@@ -1922,9 +1922,9 @@ copy_function (struct cgraph_node *node)
So just copy the vector. All the encoders in the in state So just copy the vector. All the encoders in the in state
must be empty where we reach here. */ must be empty where we reach here. */
gcc_assert (lto_tree_ref_encoder_size (encoder) == 0); gcc_assert (lto_tree_ref_encoder_size (encoder) == 0);
encoder->trees.reserve_exact (n);
for (j = 0; j < n; j++) for (j = 0; j < n; j++)
encoder->trees.safe_push (trees[j]); encoder->trees.safe_push (trees[j]);
encoder->next_index = n;
} }
lto_free_section_data (file_data, LTO_section_function_body, name, lto_free_section_data (file_data, LTO_section_function_body, name,
......
...@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3. If not see
#include "alloc-pool.h" #include "alloc-pool.h"
#include "gcov-io.h" #include "gcov-io.h"
#include "diagnostic.h" #include "diagnostic.h"
#include "pointer-set.h"
/* Define when debugging the LTO streamer. This causes the writer /* Define when debugging the LTO streamer. This causes the writer
to output the numeric value for the memory address of the tree node to output the numeric value for the memory address of the tree node
...@@ -474,21 +475,12 @@ struct GTY(()) lto_tree_ref_table ...@@ -474,21 +475,12 @@ struct GTY(()) lto_tree_ref_table
}; };
/* Mapping between trees and slots in an array. */
struct lto_decl_slot
{
tree t;
int slot_num;
};
/* The lto_tree_ref_encoder struct is used to encode trees into indices. */ /* The lto_tree_ref_encoder struct is used to encode trees into indices. */
struct lto_tree_ref_encoder struct lto_tree_ref_encoder
{ {
htab_t tree_hash_table; /* Maps pointers to indices. */ pointer_map_t *tree_hash_table; /* Maps pointers to indices. */
unsigned int next_index; /* Next available index. */ vec<tree> trees; /* Maps indices to pointers. */
vec<tree> trees; /* Maps indices to pointers. */
}; };
...@@ -788,10 +780,6 @@ extern void lto_value_range_error (const char *, ...@@ -788,10 +780,6 @@ extern void lto_value_range_error (const char *,
HOST_WIDE_INT) ATTRIBUTE_NORETURN; HOST_WIDE_INT) ATTRIBUTE_NORETURN;
/* In lto-section-out.c */ /* In lto-section-out.c */
extern hashval_t lto_hash_decl_slot_node (const void *);
extern int lto_eq_decl_slot_node (const void *, const void *);
extern hashval_t lto_hash_type_slot_node (const void *);
extern int lto_eq_type_slot_node (const void *, const void *);
extern void lto_begin_section (const char *, bool); extern void lto_begin_section (const char *, bool);
extern void lto_end_section (void); extern void lto_end_section (void);
extern void lto_write_stream (struct lto_output_stream *); extern void lto_write_stream (struct lto_output_stream *);
...@@ -1007,11 +995,9 @@ lto_tag_check_range (enum LTO_tags actual, enum LTO_tags tag1, ...@@ -1007,11 +995,9 @@ lto_tag_check_range (enum LTO_tags actual, enum LTO_tags tag1,
/* Initialize an lto_out_decl_buffer ENCODER. */ /* Initialize an lto_out_decl_buffer ENCODER. */
static inline void static inline void
lto_init_tree_ref_encoder (struct lto_tree_ref_encoder *encoder, lto_init_tree_ref_encoder (struct lto_tree_ref_encoder *encoder)
htab_hash hash_fn, htab_eq eq_fn)
{ {
encoder->tree_hash_table = htab_create (37, hash_fn, eq_fn, free); encoder->tree_hash_table = pointer_map_create ();
encoder->next_index = 0;
encoder->trees.create (0); encoder->trees.create (0);
} }
...@@ -1023,7 +1009,7 @@ lto_destroy_tree_ref_encoder (struct lto_tree_ref_encoder *encoder) ...@@ -1023,7 +1009,7 @@ lto_destroy_tree_ref_encoder (struct lto_tree_ref_encoder *encoder)
{ {
/* Hash table may be delete already. */ /* Hash table may be delete already. */
if (encoder->tree_hash_table) if (encoder->tree_hash_table)
htab_delete (encoder->tree_hash_table); pointer_map_destroy (encoder->tree_hash_table);
encoder->trees.release (); encoder->trees.release ();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment