This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cgraph alias reorg 14/14 (ipa-pure-const, ipa-reference and tree-profile fixes)


Hi,
the patch series will be a bit longer as I found some problems exposed by the
breakup.

This patch fixes latent bug in tree-profile that needs to call execute_fixup_cfg.
This is because local pure const might find some edges nothrow and cfg needs to
be updated (that usually happens only after ipa passes).

Second problem is ipa-pure-const overactively marking aliases as
nothrow/const/pure. Since we ignore them for analysis, we should skip
them while updating the flags, too.

Bootstrapped/regested x86_64-linux, comitted.

Honza

	* cgraph.c (cgraph_set_nothrow_flag_1): Update cgraph after
	setting the nothrow flag.
	* ipa-reference.c (propagate): Skip aliases.
	* ipa-pure-const.c (propagate_pure_const): Skip aliases.
	(propagate_nothrow): Skip aliases; do not update cgraph.
	(local_pure_const): Do not update cgraph.
	* tree-profile.c (tree_profiling): Do fixup_cfg.
Index: cgraph.c
===================================================================
*** cgraph.c	(revision 174904)
--- cgraph.c	(working copy)
*************** cgraph_make_node_local (struct cgraph_no
*** 2681,2687 ****
--- 2681,2693 ----
  static bool
  cgraph_set_nothrow_flag_1 (struct cgraph_node *node, void *data)
  {
+   struct cgraph_edge *e;
+ 
    TREE_NOTHROW (node->decl) = data != NULL;
+ 
+   if (data != NULL)
+     for (e = node->callers; e; e = e->next_caller)
+       e->can_throw_external = false;
    return false;
  }
  
Index: ipa-reference.c
===================================================================
*** ipa-reference.c	(revision 174904)
--- ipa-reference.c	(working copy)
*************** propagate (void)
*** 645,650 ****
--- 645,652 ----
        struct ipa_dfs_info * w_info;
  
        node = order[i];
+       if (node->alias)
+ 	continue;
        node_info = get_reference_vars_info (node);
        gcc_assert (node_info);
  
*************** propagate (void)
*** 802,807 ****
--- 804,811 ----
  	  struct ipa_dfs_info * w_info;
  
  	  node = order[i];
+ 	  if (node->alias)
+ 	    continue;
  	  node_info = get_reference_vars_info (node);
  	  node_g = &node_info->global;
  	  node_l = &node_info->local;
*************** propagate (void)
*** 885,891 ****
        ipa_reference_global_vars_info_t node_g;
        ipa_reference_optimization_summary_t opt;
  
!       if (!node->analyzed)
          continue;
  
        node_info = get_reference_vars_info (node);
--- 889,895 ----
        ipa_reference_global_vars_info_t node_g;
        ipa_reference_optimization_summary_t opt;
  
!       if (!node->analyzed || node->alias)
          continue;
  
        node_info = get_reference_vars_info (node);
Index: ipa-pure-const.c
===================================================================
*** ipa-pure-const.c	(revision 174904)
--- ipa-pure-const.c	(working copy)
*************** propagate_pure_const (void)
*** 1116,1121 ****
--- 1116,1124 ----
        int count = 0;
        node = order[i];
  
+       if (node->alias)
+ 	continue;
+ 
        if (dump_file && (dump_flags & TDF_DETAILS))
  	fprintf (dump_file, "Starting cycle\n");
  
*************** propagate_nothrow (void)
*** 1383,1388 ****
--- 1386,1394 ----
        bool can_throw = false;
        node = order[i];
  
+       if (node->alias)
+ 	continue;
+ 
        /* Find the worst state for any node in the cycle.  */
        w = node;
        while (w)
*************** propagate_nothrow (void)
*** 1430,1439 ****
  	  funct_state w_l = get_function_state (w);
  	  if (!can_throw && !TREE_NOTHROW (w->decl))
  	    {
- 	      struct cgraph_edge *e;
  	      cgraph_set_nothrow_flag (w, true);
- 	      for (e = w->callers; e; e = e->next_caller)
- 	        e->can_throw_external = false;
  	      if (dump_file)
  		fprintf (dump_file, "Function found to be nothrow: %s\n",
  			 cgraph_node_name (w));
--- 1436,1442 ----
*************** local_pure_const (void)
*** 1640,1650 ****
      }
    if (!l->can_throw && !TREE_NOTHROW (current_function_decl))
      {
-       struct cgraph_edge *e;
- 
        cgraph_set_nothrow_flag (node, true);
-       for (e = node->callers; e; e = e->next_caller)
- 	e->can_throw_external = false;
        changed = true;
        if (dump_file)
  	fprintf (dump_file, "Function found to be nothrow: %s\n",
--- 1643,1649 ----
Index: tree-profile.c
===================================================================
*** tree-profile.c	(revision 174904)
--- tree-profile.c	(working copy)
*************** tree_profiling (void)
*** 470,477 ****
    for (node = cgraph_nodes; node; node = node->next)
      {
        if (!node->analyzed
! 	  || !gimple_has_body_p (node->decl)
! 	  || !(!node->clone_of || node->decl != node->clone_of->decl))
  	continue;
  
        /* Don't profile functions produced for builtin stuff.  */
--- 470,476 ----
    for (node = cgraph_nodes; node; node = node->next)
      {
        if (!node->analyzed
! 	  || !gimple_has_body_p (node->decl))
  	continue;
  
        /* Don't profile functions produced for builtin stuff.  */
*************** tree_profiling (void)
*** 485,490 ****
--- 484,491 ----
        /* Re-set global shared temporary variable for edge-counters.  */
        gcov_type_tmp_var = NULL_TREE;
  
+       /* Local pure-const may imply need to fixup the cfg.  */
+       execute_fixup_cfg ();
        branch_prob ();
  
        if (! flag_branch_probabilities


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]