Add finalize method to modref summary.

gcc/ChangeLog:

	* ipa-modref.c (modref_summary::global_memory_read_p): Remove.
	(modref_summary::global_memory_written_p): Remove.
	(modref_summary::dump): Dump new flags.
	(modref_summary::finalize): New member function.
	(analyze_function): Call it.
	(read_section): Call it.
	(update_signature): Call it.
	(pass_ipa_modref::execute): Call it.
	* ipa-modref.h (struct modref_summary): Remove
	global_memory_read_p and global_memory_written_p.
	Add global_memory_read, global_memory_written.
	* tree-ssa-structalias.c (determine_global_memory_access):
	Update.
This commit is contained in:
Jan Hubicka 2021-11-13 18:21:12 +01:00
parent 2af63f0f53
commit e0040bc3d9
3 changed files with 36 additions and 29 deletions

View File

@ -276,7 +276,8 @@ static GTY(()) fast_function_summary <modref_summary_lto *, va_gc>
modref_summary::modref_summary ()
: loads (NULL), stores (NULL), retslot_flags (0), static_chain_flags (0),
writes_errno (false), side_effects (false)
writes_errno (false), side_effects (false), global_memory_read (false),
global_memory_written (false)
{
}
@ -339,26 +340,6 @@ modref_summary::useful_p (int ecf_flags, bool check_flags)
return stores && !stores->every_base;
}
/* Return true if global memory is read
(that is loads summary contains global memory access). */
bool
modref_summary::global_memory_read_p ()
{
if (!loads)
return true;
return loads->global_access_p ();
}
/* Return true if global memory is written. */
bool
modref_summary::global_memory_written_p ()
{
if (!stores)
return true;
return stores->global_access_p ();
}
/* Single function summary used for LTO. */
typedef modref_tree <tree> modref_records_lto;
@ -621,6 +602,10 @@ modref_summary::dump (FILE *out)
fprintf (out, " Writes errno\n");
if (side_effects)
fprintf (out, " Side effects\n");
if (global_memory_read)
fprintf (out, " Global memory read\n");
if (global_memory_written)
fprintf (out, " Global memory written\n");
if (arg_flags.length ())
{
for (unsigned int i = 0; i < arg_flags.length (); i++)
@ -676,6 +661,15 @@ modref_summary_lto::dump (FILE *out)
}
}
/* Called after summary is produced and before it is used by local analysis.
Can be called multiple times in case summary needs to update signature. */
void
modref_summary::finalize ()
{
global_memory_read = !loads || loads->global_access_p ();
global_memory_written = !stores || stores->global_access_p ();
}
/* Get function summary for FUNC if it exists, return NULL otherwise. */
modref_summary *
@ -2809,8 +2803,7 @@ analyze_function (function *f, bool ipa)
first = false;
}
}
if (summary && !summary->global_memory_written_p () && !summary->side_effects
&& !finite_function_p ())
if (summary && !summary->side_effects && !finite_function_p ())
summary->side_effects = true;
if (summary_lto && !summary_lto->side_effects && !finite_function_p ())
summary_lto->side_effects = true;
@ -2838,6 +2831,8 @@ analyze_function (function *f, bool ipa)
summaries->remove (fnode);
summary = NULL;
}
if (summary)
summary->finalize ();
if (summary_lto && !summary_lto->useful_p (ecf_flags))
{
summaries_lto->remove (fnode);
@ -3557,6 +3552,8 @@ read_section (struct lto_file_decl_data *file_data, const char *data,
modref_read_escape_summary (&bp, e);
}
}
if (flag_ltrans)
modref_sum->finalize ();
if (dump_file)
{
fprintf (dump_file, "Read modref for %s\n",
@ -3713,6 +3710,8 @@ update_signature (struct cgraph_node *node)
if (r_lto)
r_lto->dump (dump_file);
}
if (r)
r->finalize ();
return;
}
@ -4914,6 +4913,11 @@ pass_ipa_modref::execute (function *)
pureconst |= modref_propagate_in_scc (component_node);
modref_propagate_flags_in_scc (component_node);
if (optimization_summaries)
for (struct cgraph_node *cur = component_node; cur;
cur = ((struct ipa_dfs_info *) cur->aux)->next_cycle)
if (modref_summary *sum = optimization_summaries->get (cur))
sum->finalize ();
if (dump_file)
modref_propagate_dump_scc (component_node);
}

View File

@ -33,15 +33,18 @@ struct GTY(()) modref_summary
auto_vec<eaf_flags_t> GTY((skip)) arg_flags;
eaf_flags_t retslot_flags;
eaf_flags_t static_chain_flags;
bool writes_errno;
bool side_effects;
unsigned writes_errno : 1;
unsigned side_effects : 1;
/* Flags coputed by finalize method. */
unsigned global_memory_read : 1;
unsigned global_memory_written : 1;
modref_summary ();
~modref_summary ();
void dump (FILE *);
bool useful_p (int ecf_flags, bool check_flags = true);
bool global_memory_read_p ();
bool global_memory_written_p ();
void finalize ();
};
modref_summary *get_modref_function_summary (cgraph_node *func);

View File

@ -4262,9 +4262,9 @@ determine_global_memory_access (gcall *stmt,
&& (summary = get_modref_function_summary (node)))
{
if (writes_global_memory && *writes_global_memory)
*writes_global_memory = summary->global_memory_written_p ();
*writes_global_memory = summary->global_memory_written;
if (reads_global_memory && *reads_global_memory)
*reads_global_memory = summary->global_memory_read_p ();
*reads_global_memory = summary->global_memory_read;
if (reads_global_memory && uses_global_memory
&& !*reads_global_memory && node->binds_to_current_def_p ())
*uses_global_memory = false;