@@ -339,26 +339,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 +601,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 +660,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 *
@@ -2782,8 +2775,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;
@@ -2810,6 +2802,8 @@ analyze_function (function *f, bool ipa)
summaries->remove (fnode);
summary = NULL;
}
+ else
+ summary->finalize ();
if (summary_lto && !summary_lto->useful_p (ecf_flags))
{
summaries_lto->remove (fnode);
@@ -3529,6 +3523,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",
@@ -3685,6 +3681,8 @@ update_signature (struct cgraph_node *node)
if (r_lto)
r_lto->dump (dump_file);
}
+ if (r)
+ r->finalize ();
return;
}
@@ -4905,6 +4903,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);
}
@@ -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);
@@ -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;