Commit 6adcb793 by Martin Liska Committed by Martin Liska

Use symtab_summary in ipa-reference.c.

2018-06-08  Martin Liska  <mliska@suse.cz>

	* ipa-reference.c (remove_node_data): Remove.
	(duplicate_node_data): Likewise.
	(class ipa_ref_var_info_summary_t): New class.
	(class ipa_ref_opt_summary_t): Likewise.
	(get_reference_vars_info): Use ipa_ref_var_info_summaries.
	(get_reference_optimization_summary): Use
	ipa_ref_opt_sum_summaries.
	(set_reference_vars_info): Remove.
	(set_reference_optimization_summary): Likewise.
	(ipa_init): Create summaries.
	(init_function_info): Use function summary.
	(ipa_ref_opt_summary_t::duplicate): New function.
	(ipa_ref_opt_summary_t::remove): New function.
	(get_read_write_all_from_node): Fix GNU coding style.
	(propagate): Use function summary.
	(write_node_summary_p): Fix GNU coding style.
	(stream_out_bitmap): Likewise.
	(ipa_reference_read_optimization_summary): Use function summary.
	(ipa_reference_c_finalize): Do not release hooks.

From-SVN: r261312
parent cf9b0b5f
2018-06-08 Martin Liska <mliska@suse.cz> 2018-06-08 Martin Liska <mliska@suse.cz>
* ipa-reference.c (remove_node_data): Remove.
(duplicate_node_data): Likewise.
(class ipa_ref_var_info_summary_t): New class.
(class ipa_ref_opt_summary_t): Likewise.
(get_reference_vars_info): Use ipa_ref_var_info_summaries.
(get_reference_optimization_summary): Use
ipa_ref_opt_sum_summaries.
(set_reference_vars_info): Remove.
(set_reference_optimization_summary): Likewise.
(ipa_init): Create summaries.
(init_function_info): Use function summary.
(ipa_ref_opt_summary_t::duplicate): New function.
(ipa_ref_opt_summary_t::remove): New function.
(get_read_write_all_from_node): Fix GNU coding style.
(propagate): Use function summary.
(write_node_summary_p): Fix GNU coding style.
(stream_out_bitmap): Likewise.
(ipa_reference_read_optimization_summary): Use function summary.
(ipa_reference_c_finalize): Do not release hooks.
2018-06-08 Martin Liska <mliska@suse.cz>
* ipa-fnsummary.c (dump_ipa_call_summary): Use ::get method. * ipa-fnsummary.c (dump_ipa_call_summary): Use ::get method.
(analyze_function_body): Extract multiple calls of get_create. (analyze_function_body): Extract multiple calls of get_create.
* ipa-inline-analysis.c (simple_edge_hints): Likewise. * ipa-inline-analysis.c (simple_edge_hints): Likewise.
......
...@@ -49,12 +49,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -49,12 +49,7 @@ along with GCC; see the file COPYING3. If not see
#include "splay-tree.h" #include "splay-tree.h"
#include "ipa-utils.h" #include "ipa-utils.h"
#include "ipa-reference.h" #include "ipa-reference.h"
#include "symbol-summary.h"
static void remove_node_data (struct cgraph_node *node,
void *data ATTRIBUTE_UNUSED);
static void duplicate_node_data (struct cgraph_node *src,
struct cgraph_node *dst,
void *data ATTRIBUTE_UNUSED);
/* The static variables defined within the compilation unit that are /* The static variables defined within the compilation unit that are
loaded or stored directly by function that owns this structure. */ loaded or stored directly by function that owns this structure. */
...@@ -84,9 +79,10 @@ struct ipa_reference_optimization_summary_d ...@@ -84,9 +79,10 @@ struct ipa_reference_optimization_summary_d
bitmap statics_not_written; bitmap statics_not_written;
}; };
typedef struct ipa_reference_local_vars_info_d *ipa_reference_local_vars_info_t; typedef ipa_reference_local_vars_info_d *ipa_reference_local_vars_info_t;
typedef struct ipa_reference_global_vars_info_d *ipa_reference_global_vars_info_t; typedef ipa_reference_global_vars_info_d *ipa_reference_global_vars_info_t;
typedef struct ipa_reference_optimization_summary_d *ipa_reference_optimization_summary_t; typedef ipa_reference_optimization_summary_d *
ipa_reference_optimization_summary_t;
struct ipa_reference_vars_info_d struct ipa_reference_vars_info_d
{ {
...@@ -114,57 +110,55 @@ static bitmap_obstack local_info_obstack; ...@@ -114,57 +110,55 @@ static bitmap_obstack local_info_obstack;
/* Obstack holding global analysis live forever. */ /* Obstack holding global analysis live forever. */
static bitmap_obstack optimization_summary_obstack; static bitmap_obstack optimization_summary_obstack;
/* Holders of ipa cgraph hooks: */ class ipa_ref_var_info_summary_t: public function_summary
static struct cgraph_2node_hook_list *node_duplication_hook_holder; <ipa_reference_vars_info_d *>
static struct cgraph_node_hook_list *node_removal_hook_holder; {
public:
ipa_ref_var_info_summary_t (symbol_table *symtab):
function_summary <ipa_reference_vars_info_d *> (symtab) {}
};
/* Vector where the reference var infos are actually stored. static ipa_ref_var_info_summary_t *ipa_ref_var_info_summaries = NULL;
Indexed by UID of call graph nodes. */
static vec<ipa_reference_vars_info_t> ipa_reference_vars_vector;
/* TODO: find a place where we should release the vector. */ class ipa_ref_opt_summary_t: public function_summary
static vec<ipa_reference_optimization_summary_t> ipa_reference_opt_sum_vector; <ipa_reference_optimization_summary_d *>
{
public:
ipa_ref_opt_summary_t (symbol_table *symtab):
function_summary <ipa_reference_optimization_summary_d *> (symtab) {}
virtual void remove (cgraph_node *src_node,
ipa_reference_optimization_summary_d *data);
virtual void duplicate (cgraph_node *src_node, cgraph_node *dst_node,
ipa_reference_optimization_summary_d *src_data,
ipa_reference_optimization_summary_d *dst_data);
};
static ipa_ref_opt_summary_t *ipa_ref_opt_sum_summaries = NULL;
/* Return the ipa_reference_vars structure starting from the cgraph NODE. */ /* Return the ipa_reference_vars structure starting from the cgraph NODE. */
static inline ipa_reference_vars_info_t static inline ipa_reference_vars_info_t
get_reference_vars_info (struct cgraph_node *node) get_reference_vars_info (struct cgraph_node *node)
{ {
if (!ipa_reference_vars_vector.exists () if (ipa_ref_var_info_summaries == NULL)
|| ipa_reference_vars_vector.length () <= (unsigned int) node->uid)
return NULL; return NULL;
return ipa_reference_vars_vector[node->uid];
ipa_reference_vars_info_t v = ipa_ref_var_info_summaries->get (node);
return v == NULL ? NULL : v;
} }
/* Return the ipa_reference_vars structure starting from the cgraph NODE. */ /* Return the ipa_reference_vars structure starting from the cgraph NODE. */
static inline ipa_reference_optimization_summary_t static inline ipa_reference_optimization_summary_t
get_reference_optimization_summary (struct cgraph_node *node) get_reference_optimization_summary (struct cgraph_node *node)
{ {
if (!ipa_reference_opt_sum_vector.exists () if (ipa_ref_opt_sum_summaries == NULL)
|| (ipa_reference_opt_sum_vector.length () <= (unsigned int) node->uid))
return NULL; return NULL;
return ipa_reference_opt_sum_vector[node->uid];
}
/* Return the ipa_reference_vars structure starting from the cgraph NODE. */ ipa_reference_optimization_summary_t v
static inline void = ipa_ref_opt_sum_summaries->get (node);
set_reference_vars_info (struct cgraph_node *node,
ipa_reference_vars_info_t info)
{
if (!ipa_reference_vars_vector.exists ()
|| ipa_reference_vars_vector.length () <= (unsigned int) node->uid)
ipa_reference_vars_vector.safe_grow_cleared (node->uid + 1);
ipa_reference_vars_vector[node->uid] = info;
}
/* Return the ipa_reference_vars structure starting from the cgraph NODE. */ return v == NULL ? NULL : v;
static inline void
set_reference_optimization_summary (struct cgraph_node *node,
ipa_reference_optimization_summary_t info)
{
if (!ipa_reference_opt_sum_vector.exists ()
|| (ipa_reference_opt_sum_vector.length () <= (unsigned int) node->uid))
ipa_reference_opt_sum_vector.safe_grow_cleared (node->uid + 1);
ipa_reference_opt_sum_vector[node->uid] = info;
} }
/* Return a bitmap indexed by ipa_reference_var_uid for the static variables /* Return a bitmap indexed by ipa_reference_var_uid for the static variables
...@@ -430,10 +424,14 @@ ipa_init (void) ...@@ -430,10 +424,14 @@ ipa_init (void)
all_module_statics = BITMAP_ALLOC (&optimization_summary_obstack); all_module_statics = BITMAP_ALLOC (&optimization_summary_obstack);
ignore_module_statics = BITMAP_ALLOC (&optimization_summary_obstack); ignore_module_statics = BITMAP_ALLOC (&optimization_summary_obstack);
node_removal_hook_holder = if (ipa_ref_var_info_summaries == NULL)
symtab->add_cgraph_removal_hook (&remove_node_data, NULL); ipa_ref_var_info_summaries = new ipa_ref_var_info_summary_t (symtab);
node_duplication_hook_holder =
symtab->add_cgraph_duplication_hook (&duplicate_node_data, NULL); if (ipa_ref_opt_sum_summaries != NULL)
{
delete ipa_ref_opt_sum_summaries;
ipa_ref_opt_sum_summaries = NULL;
}
} }
...@@ -443,10 +441,7 @@ static ipa_reference_local_vars_info_t ...@@ -443,10 +441,7 @@ static ipa_reference_local_vars_info_t
init_function_info (struct cgraph_node *fn) init_function_info (struct cgraph_node *fn)
{ {
ipa_reference_vars_info_t info ipa_reference_vars_info_t info
= XCNEW (struct ipa_reference_vars_info_d); = ipa_ref_var_info_summaries->get_create (fn);
/* Add the info to the tree's annotation. */
set_reference_vars_info (fn, info);
info->local.statics_read = BITMAP_ALLOC (&local_info_obstack); info->local.statics_read = BITMAP_ALLOC (&local_info_obstack);
info->local.statics_written = BITMAP_ALLOC (&local_info_obstack); info->local.statics_written = BITMAP_ALLOC (&local_info_obstack);
...@@ -510,18 +505,12 @@ analyze_function (struct cgraph_node *fn) ...@@ -510,18 +505,12 @@ analyze_function (struct cgraph_node *fn)
/* Called when new clone is inserted to callgraph late. */ /* Called when new clone is inserted to callgraph late. */
static void void
duplicate_node_data (struct cgraph_node *src, struct cgraph_node *dst, ipa_ref_opt_summary_t::duplicate (cgraph_node *, cgraph_node *,
void *data ATTRIBUTE_UNUSED) ipa_reference_optimization_summary_d *ginfo,
ipa_reference_optimization_summary_d
*dst_ginfo)
{ {
ipa_reference_optimization_summary_t ginfo;
ipa_reference_optimization_summary_t dst_ginfo;
ginfo = get_reference_optimization_summary (src);
if (!ginfo)
return;
dst_ginfo = XCNEW (struct ipa_reference_optimization_summary_d);
set_reference_optimization_summary (dst, dst_ginfo);
dst_ginfo->statics_not_read = dst_ginfo->statics_not_read =
copy_static_var_set (ginfo->statics_not_read); copy_static_var_set (ginfo->statics_not_read);
dst_ginfo->statics_not_written = dst_ginfo->statics_not_written =
...@@ -530,23 +519,17 @@ duplicate_node_data (struct cgraph_node *src, struct cgraph_node *dst, ...@@ -530,23 +519,17 @@ duplicate_node_data (struct cgraph_node *src, struct cgraph_node *dst,
/* Called when node is removed. */ /* Called when node is removed. */
static void void
remove_node_data (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) ipa_ref_opt_summary_t::remove (cgraph_node *,
ipa_reference_optimization_summary_d *ginfo)
{ {
ipa_reference_optimization_summary_t ginfo; if (ginfo->statics_not_read
ginfo = get_reference_optimization_summary (node); && ginfo->statics_not_read != all_module_statics)
if (ginfo) BITMAP_FREE (ginfo->statics_not_read);
{
if (ginfo->statics_not_read if (ginfo->statics_not_written
&& ginfo->statics_not_read != all_module_statics) && ginfo->statics_not_written != all_module_statics)
BITMAP_FREE (ginfo->statics_not_read); BITMAP_FREE (ginfo->statics_not_written);
if (ginfo->statics_not_written
&& ginfo->statics_not_written != all_module_statics)
BITMAP_FREE (ginfo->statics_not_written);
free (ginfo);
set_reference_optimization_summary (node, NULL);
}
} }
/* Analyze each function in the cgraph to see which global or statics /* Analyze each function in the cgraph to see which global or statics
...@@ -671,7 +654,8 @@ get_read_write_all_from_node (struct cgraph_node *node, ...@@ -671,7 +654,8 @@ get_read_write_all_from_node (struct cgraph_node *node,
struct cgraph_node *callee = e->callee->function_symbol (&avail); struct cgraph_node *callee = e->callee->function_symbol (&avail);
gcc_checking_assert (callee); gcc_checking_assert (callee);
if (avail <= AVAIL_INTERPOSABLE if (avail <= AVAIL_INTERPOSABLE
|| (callee->analyzed && !opt_for_fn (callee->decl, flag_ipa_reference))) || (callee->analyzed && !opt_for_fn (callee->decl,
flag_ipa_reference)))
read_write_all_from_decl (callee, read_all, write_all); read_write_all_from_decl (callee, read_all, write_all);
} }
...@@ -849,12 +833,14 @@ propagate (void) ...@@ -849,12 +833,14 @@ propagate (void)
} }
} }
if (ipa_ref_opt_sum_summaries == NULL)
ipa_ref_opt_sum_summaries = new ipa_ref_opt_summary_t (symtab);
/* Cleanup. */ /* Cleanup. */
FOR_EACH_DEFINED_FUNCTION (node) FOR_EACH_DEFINED_FUNCTION (node)
{ {
ipa_reference_vars_info_t node_info; ipa_reference_vars_info_t node_info;
ipa_reference_global_vars_info_t node_g; ipa_reference_global_vars_info_t node_g;
ipa_reference_optimization_summary_t opt;
node_info = get_reference_vars_info (node); node_info = get_reference_vars_info (node);
if (!node->alias && opt_for_fn (node->decl, flag_ipa_reference) if (!node->alias && opt_for_fn (node->decl, flag_ipa_reference)
...@@ -863,8 +849,8 @@ propagate (void) ...@@ -863,8 +849,8 @@ propagate (void)
{ {
node_g = &node_info->global; node_g = &node_info->global;
opt = XCNEW (struct ipa_reference_optimization_summary_d); ipa_reference_optimization_summary_d *opt
set_reference_optimization_summary (node, opt); = ipa_ref_opt_sum_summaries->get_create (node);
/* Create the complimentary sets. */ /* Create the complimentary sets. */
...@@ -892,14 +878,20 @@ propagate (void) ...@@ -892,14 +878,20 @@ propagate (void)
node_g->statics_written); node_g->statics_written);
} }
} }
free (node_info);
} }
ipa_free_postorder_info (); ipa_free_postorder_info ();
free (order); free (order);
bitmap_obstack_release (&local_info_obstack); bitmap_obstack_release (&local_info_obstack);
ipa_reference_vars_vector.release ();
if (ipa_ref_var_info_summaries == NULL)
{
delete ipa_ref_var_info_summaries;
ipa_ref_var_info_summaries = NULL;
}
ipa_ref_var_info_summaries = NULL;
if (dump_file) if (dump_file)
splay_tree_delete (reference_vars_to_consider); splay_tree_delete (reference_vars_to_consider);
reference_vars_to_consider = NULL; reference_vars_to_consider = NULL;
...@@ -919,8 +911,9 @@ write_node_summary_p (struct cgraph_node *node, ...@@ -919,8 +911,9 @@ write_node_summary_p (struct cgraph_node *node,
if (!node->definition || node->global.inlined_to) if (!node->definition || node->global.inlined_to)
return false; return false;
info = get_reference_optimization_summary (node); info = get_reference_optimization_summary (node);
if (!info || (bitmap_empty_p (info->statics_not_read) if (!info
&& bitmap_empty_p (info->statics_not_written))) || (bitmap_empty_p (info->statics_not_read)
&& bitmap_empty_p (info->statics_not_written)))
return false; return false;
/* See if we want to encode it. /* See if we want to encode it.
...@@ -970,7 +963,8 @@ stream_out_bitmap (struct lto_simple_output_block *ob, ...@@ -970,7 +963,8 @@ stream_out_bitmap (struct lto_simple_output_block *ob,
return; return;
EXECUTE_IF_AND_IN_BITMAP (bits, ltrans_statics, 0, index, bi) EXECUTE_IF_AND_IN_BITMAP (bits, ltrans_statics, 0, index, bi)
{ {
tree decl = (tree)splay_tree_lookup (reference_vars_to_consider, index)->value; tree decl = (tree)splay_tree_lookup (reference_vars_to_consider,
index)->value;
lto_output_var_decl_index (ob->decl_state, ob->main_stream, decl); lto_output_var_decl_index (ob->decl_state, ob->main_stream, decl);
} }
} }
...@@ -1060,10 +1054,9 @@ ipa_reference_read_optimization_summary (void) ...@@ -1060,10 +1054,9 @@ ipa_reference_read_optimization_summary (void)
unsigned int j = 0; unsigned int j = 0;
bitmap_obstack_initialize (&optimization_summary_obstack); bitmap_obstack_initialize (&optimization_summary_obstack);
node_removal_hook_holder = if (ipa_ref_opt_sum_summaries == NULL)
symtab->add_cgraph_removal_hook (&remove_node_data, NULL); ipa_ref_opt_sum_summaries = new ipa_ref_opt_summary_t (symtab);
node_duplication_hook_holder =
symtab->add_cgraph_duplication_hook (&duplicate_node_data, NULL);
all_module_statics = BITMAP_ALLOC (&optimization_summary_obstack); all_module_statics = BITMAP_ALLOC (&optimization_summary_obstack);
while ((file_data = file_data_vec[j++])) while ((file_data = file_data_vec[j++]))
...@@ -1099,7 +1092,6 @@ ipa_reference_read_optimization_summary (void) ...@@ -1099,7 +1092,6 @@ ipa_reference_read_optimization_summary (void)
{ {
unsigned int j, index; unsigned int j, index;
struct cgraph_node *node; struct cgraph_node *node;
ipa_reference_optimization_summary_t info;
int v_count; int v_count;
lto_symtab_encoder_t encoder; lto_symtab_encoder_t encoder;
...@@ -1107,10 +1099,14 @@ ipa_reference_read_optimization_summary (void) ...@@ -1107,10 +1099,14 @@ ipa_reference_read_optimization_summary (void)
encoder = file_data->symtab_node_encoder; encoder = file_data->symtab_node_encoder;
node = dyn_cast<cgraph_node *> (lto_symtab_encoder_deref node = dyn_cast<cgraph_node *> (lto_symtab_encoder_deref
(encoder, index)); (encoder, index));
info = XCNEW (struct ipa_reference_optimization_summary_d);
set_reference_optimization_summary (node, info); ipa_reference_optimization_summary_d *info
info->statics_not_read = BITMAP_ALLOC (&optimization_summary_obstack); = ipa_ref_opt_sum_summaries->get_create (node);
info->statics_not_written = BITMAP_ALLOC (&optimization_summary_obstack);
info->statics_not_read = BITMAP_ALLOC
(&optimization_summary_obstack);
info->statics_not_written = BITMAP_ALLOC
(&optimization_summary_obstack);
if (dump_file) if (dump_file)
fprintf (dump_file, fprintf (dump_file,
"\nFunction name:%s:\n static not read:", "\nFunction name:%s:\n static not read:",
...@@ -1167,9 +1163,9 @@ ipa_reference_read_optimization_summary (void) ...@@ -1167,9 +1163,9 @@ ipa_reference_read_optimization_summary (void)
ib, data, len); ib, data, len);
} }
else else
/* Fatal error here. We do not want to support compiling ltrans units with /* Fatal error here. We do not want to support compiling ltrans units
different version of compiler or different flags than the WPA unit, so with different version of compiler or different flags than
this should never happen. */ the WPA unit, so this should never happen. */
fatal_error (input_location, fatal_error (input_location,
"ipa reference summary is missing in ltrans unit"); "ipa reference summary is missing in ltrans unit");
} }
...@@ -1239,15 +1235,4 @@ ipa_reference_c_finalize (void) ...@@ -1239,15 +1235,4 @@ ipa_reference_c_finalize (void)
bitmap_obstack_release (&optimization_summary_obstack); bitmap_obstack_release (&optimization_summary_obstack);
ipa_init_p = false; ipa_init_p = false;
} }
if (node_removal_hook_holder)
{
symtab->remove_cgraph_removal_hook (node_removal_hook_holder);
node_removal_hook_holder = NULL;
}
if (node_duplication_hook_holder)
{
symtab->remove_cgraph_duplication_hook (node_duplication_hook_holder);
node_duplication_hook_holder = NULL;
}
} }
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