Disable aggregate walking in ipa code for optimize_debug

Message ID 20200404095815.GV49582@kam.mff.cuni.cz
State New
Headers show
Series
  • Disable aggregate walking in ipa code for optimize_debug
Related show

Commit Message

Jan Hubicka April 4, 2020, 9:58 a.m.
Martin,
with optimize_debug or when FRE is disabled propagating aggregates is
useless since we are not going to use them.  I think we should also
avoid working hard on the jump functions.
This patch disables it in ipa_load_from_param_agg, but I am not sure if
there are other ways ipa-prop can do the memory walk?

Bootstrapped/regtested x86_64. Makes sense?

Honza

	* ipa-fnsummary.c (vrp_will_run_p): Export.
	* ipa-fnsummary.h (vrp_will_run_p): Declare.
	* ipa-prop.c (ipa_load_from_parm_agg): Use it.

Comments

Martin Jambor April 8, 2020, 3:13 p.m. | #1
Hi,

On Sat, Apr 04 2020, Jan Hubicka wrote:
> Martin,

> with optimize_debug or when FRE is disabled propagating aggregates is

> useless since we are not going to use them.  I think we should also

> avoid working hard on the jump functions.

> This patch disables it in ipa_load_from_param_agg, but I am not sure if

> there are other ways ipa-prop can do the memory walk?


if you want to bail out before mem-SSA is walked in order to construct
aggregate jump function, I'd do it in determine_known_aggregate_parts.
Doing it in ipa_load_from_parm_agg means that the code will still look
for stores of constants into aggregates and since this fall, we do not
just do it in the BB with the call.  Bailing out later in
ipa_load_from_parm_agg will however prevent inlining from ever
evaluating the predicate.

Which brings me to another thing.  Note that feeding the results into
FRE is not the only use of aggregate jump functions.  They can also be
used to evaluate inlining predicates and to make calls direct and
facilitate indirect inlining.  Perhaps we don't want to do neither of
those on aggregates at -Og but I do not see them as useless without FRE.

Martin

>

> Bootstrapped/regtested x86_64. Makes sense?

>

> Honza

>

> 	* ipa-fnsummary.c (vrp_will_run_p): Export.

> 	* ipa-fnsummary.h (vrp_will_run_p): Declare.

> 	* ipa-prop.c (ipa_load_from_parm_agg): Use it.

> diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c

> index d96c8e9b03c..e5f43078c27 100644

> --- a/gcc/ipa-fnsummary.c

> +++ b/gcc/ipa-fnsummary.c

> @@ -522,7 +522,7 @@ vrp_will_run_p (struct cgraph_node *node)

>  

>  /* Similarly about FRE.  */

>  

> -static bool

> +bool

>  fre_will_run_p (struct cgraph_node *node)

>  {

>    return (opt_for_fn (node->decl, optimize)

> diff --git a/gcc/ipa-fnsummary.h b/gcc/ipa-fnsummary.h

> index c6ddc9f3199..f4e1fd0cc86 100644

> --- a/gcc/ipa-fnsummary.h

> +++ b/gcc/ipa-fnsummary.h

> @@ -371,6 +371,7 @@ void evaluate_properties_for_edge (struct cgraph_edge *e,

>  void ipa_fnsummary_c_finalize (void);

>  HOST_WIDE_INT ipa_get_stack_frame_offset (struct cgraph_node *node);

>  void ipa_remove_from_growth_caches (struct cgraph_edge *edge);

> +bool fre_will_run_p (struct cgraph_node *);

>  

>  /* Return true if EDGE is a cross module call.  */

>  

> diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c

> index 71ac0e104d2..7f654f3aea3 100644

> --- a/gcc/ipa-prop.c

> +++ b/gcc/ipa-prop.c

> @@ -1091,6 +1091,12 @@ ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,

>    int index;

>    HOST_WIDE_INT size;

>    bool reverse;

> +

> +  /* Do not bother to do analysis when we are not doing propagation of

> +     aggregates anyway.  */

> +  if (!fre_will_run_p (cgraph_node::get (current_function_decl)))

> +    return false;

> +

>    tree base = get_ref_base_and_extent_hwi (op, offset_p, &size, &reverse);

>  

>    if (!base)

Patch

diff --git a/gcc/ipa-fnsummary.c b/gcc/ipa-fnsummary.c
index d96c8e9b03c..e5f43078c27 100644
--- a/gcc/ipa-fnsummary.c
+++ b/gcc/ipa-fnsummary.c
@@ -522,7 +522,7 @@  vrp_will_run_p (struct cgraph_node *node)
 
 /* Similarly about FRE.  */
 
-static bool
+bool
 fre_will_run_p (struct cgraph_node *node)
 {
   return (opt_for_fn (node->decl, optimize)
diff --git a/gcc/ipa-fnsummary.h b/gcc/ipa-fnsummary.h
index c6ddc9f3199..f4e1fd0cc86 100644
--- a/gcc/ipa-fnsummary.h
+++ b/gcc/ipa-fnsummary.h
@@ -371,6 +371,7 @@  void evaluate_properties_for_edge (struct cgraph_edge *e,
 void ipa_fnsummary_c_finalize (void);
 HOST_WIDE_INT ipa_get_stack_frame_offset (struct cgraph_node *node);
 void ipa_remove_from_growth_caches (struct cgraph_edge *edge);
+bool fre_will_run_p (struct cgraph_node *);
 
 /* Return true if EDGE is a cross module call.  */
 
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 71ac0e104d2..7f654f3aea3 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -1091,6 +1091,12 @@  ipa_load_from_parm_agg (struct ipa_func_body_info *fbi,
   int index;
   HOST_WIDE_INT size;
   bool reverse;
+
+  /* Do not bother to do analysis when we are not doing propagation of
+     aggregates anyway.  */
+  if (!fre_will_run_p (cgraph_node::get (current_function_decl)))
+    return false;
+
   tree base = get_ref_base_and_extent_hwi (op, offset_p, &size, &reverse);
 
   if (!base)