On Tue, Jun 18, 2024 at 2:11 AM David Malcolm <dmalc...@redhat.com> wrote:
>
> Be explicit when we use "cfun".
>
> No functional change intended.
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
>
> OK for trunk?
>
> gcc/ChangeLog:
>         * dominance.cc (compute_dom_fast_query): Replace uses of
>         "dom_computed" macro with explicit use of cfun.
>         (compute_dom_fast_query_in_region): Likewise.
>         (calculate_dominance_info): Likewise, also for macro
>         "n_bbs_in_dom_tree".
>         (calculate_dominance_info_for_region): Likewise for
>         "dom_computed" macro.
>         (get_immediate_dominator): Likewise.
>         (set_immediate_dominator): Likewise.
>         (get_dominated_by): Likewise.
>         (redirect_immediate_dominators): Likewise.
>         (nearest_common_dominator): Likewise.
>         (dominated_by_p): Likewise.
>         (bb_dom_dfs_in): Likewise.
>         (bb_dom_dfs_out): Likewise.
>         (recompute_dominator): Likewise.
>         (iterate_fix_dominators): Likewise.
>         (add_to_dominance_info): Likewise, also for macro
>         "n_bbs_in_dom_tree".
>         (delete_from_dominance_info): Likewise.
>         (set_dom_info_availability): Likewise for
>         "dom_computed" macro.
>         * function.h (dom_computed): Delete macro.
>         (n_bbs_in_dom_tree): Delete macro.
>
> Signed-off-by: David Malcolm <dmalc...@redhat.com>
> ---
>  gcc/dominance.cc | 70 +++++++++++++++++++++++++-----------------------
>  gcc/function.h   |  3 ---
>  2 files changed, 36 insertions(+), 37 deletions(-)
>
> diff --git a/gcc/dominance.cc b/gcc/dominance.cc
> index 0357210ed27f..528b38caa9db 100644
> --- a/gcc/dominance.cc
> +++ b/gcc/dominance.cc
> @@ -672,7 +672,7 @@ compute_dom_fast_query (enum cdi_direction dir)
>
>    gcc_checking_assert (dom_info_available_p (dir));
>
> -  if (dom_computed[dir_index] == DOM_OK)
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)

The x_* members are named this way to be not used directly.  I think the
canonical replacement these days would be a

inline bool dom_computed (function *, enum cdi_direction) {...}

inline function.

Richard.

>      return;
>
>    FOR_ALL_BB_FN (bb, cfun)
> @@ -681,7 +681,7 @@ compute_dom_fast_query (enum cdi_direction dir)
>         assign_dfs_numbers (bb->dom[dir_index], &num);
>      }
>
> -  dom_computed[dir_index] = DOM_OK;
> +  cfun->cfg->x_dom_computed[dir_index] = DOM_OK;
>  }
>
>  /* Analogous to the previous function but compute the data for reducible
> @@ -697,7 +697,7 @@ compute_dom_fast_query_in_region (enum cdi_direction dir,
>
>    gcc_checking_assert (dom_info_available_p (dir));
>
> -  if (dom_computed[dir_index] == DOM_OK)
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)
>      return;
>
>    /* Assign dfs numbers for region nodes except for entry and exit nodes.  */
> @@ -708,7 +708,7 @@ compute_dom_fast_query_in_region (enum cdi_direction dir,
>         assign_dfs_numbers (bb->dom[dir_index], &num);
>      }
>
> -  dom_computed[dir_index] = DOM_OK;
> +  cfun->cfg->x_dom_computed[dir_index] = DOM_OK;
>  }
>
>  /* The main entry point into this module.  DIR is set depending on whether
> @@ -721,7 +721,7 @@ calculate_dominance_info (cdi_direction dir, bool 
> compute_fast_query)
>  {
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> -  if (dom_computed[dir_index] == DOM_OK)
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)
>      {
>        checking_verify_dominators (dir);
>        return;
> @@ -730,14 +730,14 @@ calculate_dominance_info (cdi_direction dir, bool 
> compute_fast_query)
>    timevar_push (TV_DOMINANCE);
>    if (!dom_info_available_p (dir))
>      {
> -      gcc_assert (!n_bbs_in_dom_tree[dir_index]);
> +      gcc_assert (!cfun->cfg->x_n_bbs_in_dom_tree[dir_index]);
>
>        basic_block b;
>        FOR_ALL_BB_FN (b, cfun)
>         {
>           b->dom[dir_index] = et_new_tree (b);
>         }
> -      n_bbs_in_dom_tree[dir_index] = n_basic_blocks_for_fn (cfun);
> +      cfun->cfg->x_n_bbs_in_dom_tree[dir_index] = n_basic_blocks_for_fn 
> (cfun);
>
>        dom_info di (cfun, dir);
>        di.calc_dfs_tree ();
> @@ -749,7 +749,7 @@ calculate_dominance_info (cdi_direction dir, bool 
> compute_fast_query)
>             et_set_father (b->dom[dir_index], d->dom[dir_index]);
>         }
>
> -      dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> +      cfun->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
>      }
>    else
>      checking_verify_dominators (dir);
> @@ -772,7 +772,7 @@ calculate_dominance_info_for_region (cdi_direction dir,
>    basic_block bb;
>    unsigned int i;
>
> -  if (dom_computed[dir_index] == DOM_OK)
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)
>      return;
>
>    timevar_push (TV_DOMINANCE);
> @@ -791,7 +791,7 @@ calculate_dominance_info_for_region (cdi_direction dir,
>      if (basic_block d = di.get_idom (bb))
>        et_set_father (bb->dom[dir_index], d->dom[dir_index]);
>
> -  dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> +  cfun->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
>    compute_dom_fast_query_in_region (dir, region);
>
>    timevar_pop (TV_DOMINANCE);
> @@ -858,7 +858,7 @@ get_immediate_dominator (enum cdi_direction dir, 
> basic_block bb)
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>    struct et_node *node = bb->dom[dir_index];
>
> -  gcc_checking_assert (dom_computed[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]);
>
>    if (!node->father)
>      return NULL;
> @@ -875,7 +875,7 @@ set_immediate_dominator (enum cdi_direction dir, 
> basic_block bb,
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>    struct et_node *node = bb->dom[dir_index];
>
> -  gcc_checking_assert (dom_computed[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]);
>
>    if (node->father)
>      {
> @@ -887,8 +887,8 @@ set_immediate_dominator (enum cdi_direction dir, 
> basic_block bb,
>    if (dominated_by)
>      et_set_father (node, dominated_by->dom[dir_index]);
>
> -  if (dom_computed[dir_index] == DOM_OK)
> -    dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)
> +    cfun->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
>  }
>
>  /* Returns the list of basic blocks immediately dominated by BB, in the
> @@ -900,7 +900,7 @@ get_dominated_by (enum cdi_direction dir, basic_block bb)
>    struct et_node *node = bb->dom[dir_index], *son = node->son, *ason;
>    auto_vec<basic_block> bbs;
>
> -  gcc_checking_assert (dom_computed[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]);
>
>    if (!son)
>      return bbs;
> @@ -992,7 +992,7 @@ redirect_immediate_dominators (enum cdi_direction dir, 
> basic_block bb,
>    bb_node = bb->dom[dir_index];
>    to_node = to->dom[dir_index];
>
> -  gcc_checking_assert (dom_computed[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]);
>
>    if (!bb_node->son)
>      return;
> @@ -1005,8 +1005,8 @@ redirect_immediate_dominators (enum cdi_direction dir, 
> basic_block bb,
>        et_set_father (son, to_node);
>      }
>
> -  if (dom_computed[dir_index] == DOM_OK)
> -    dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)
> +    cfun->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
>  }
>
>  /* Find first basic block in the tree dominating both BB1 and BB2.  */
> @@ -1015,7 +1015,7 @@ nearest_common_dominator (enum cdi_direction dir, 
> basic_block bb1, basic_block b
>  {
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> -  gcc_checking_assert (dom_computed[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]);
>
>    if (!bb1)
>      return bb2;
> @@ -1127,9 +1127,9 @@ dominated_by_p (enum cdi_direction dir, 
> const_basic_block bb1, const_basic_block
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>    struct et_node *n1 = bb1->dom[dir_index], *n2 = bb2->dom[dir_index];
>
> -  gcc_checking_assert (dom_computed[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]);
>
> -  if (dom_computed[dir_index] == DOM_OK)
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)
>      return (n1->dfs_num_in >= n2->dfs_num_in
>             && n1->dfs_num_out <= n2->dfs_num_out);
>
> @@ -1144,7 +1144,7 @@ bb_dom_dfs_in (enum cdi_direction dir, basic_block bb)
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>    struct et_node *n = bb->dom[dir_index];
>
> -  gcc_checking_assert (dom_computed[dir_index] == DOM_OK);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index] == DOM_OK);
>    return n->dfs_num_in;
>  }
>
> @@ -1156,7 +1156,7 @@ bb_dom_dfs_out (enum cdi_direction dir, basic_block bb)
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>    struct et_node *n = bb->dom[dir_index];
>
> -  gcc_checking_assert (dom_computed[dir_index] == DOM_OK);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index] == DOM_OK);
>    return n->dfs_num_out;
>  }
>
> @@ -1207,7 +1207,7 @@ recompute_dominator (enum cdi_direction dir, 
> basic_block bb)
>    edge e;
>    edge_iterator ei;
>
> -  gcc_checking_assert (dom_computed[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]);
>
>    if (dir == CDI_DOMINATORS)
>      {
> @@ -1409,7 +1409,8 @@ iterate_fix_dominators (enum cdi_direction dir, 
> vec<basic_block> &bbs,
>       problems would be unused, untested, and almost surely buggy.  We keep
>       the DIR argument for consistency with the rest of the dominator analysis
>       interface.  */
> -  gcc_checking_assert (dir == CDI_DOMINATORS && dom_computed[dir_index]);
> +  gcc_checking_assert (dir == CDI_DOMINATORS
> +                      && cfun->cfg->x_dom_computed[dir_index]);
>
>    /* The algorithm we use takes inspiration from the following papers, 
> although
>       the details are quite different from any of them:
> @@ -1558,14 +1559,15 @@ add_to_dominance_info (enum cdi_direction dir, 
> basic_block bb)
>  {
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> -  gcc_checking_assert (dom_computed[dir_index] && !bb->dom[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]
> +                      && !bb->dom[dir_index]);
>
> -  n_bbs_in_dom_tree[dir_index]++;
> +  cfun->cfg->x_n_bbs_in_dom_tree[dir_index]++;
>
>    bb->dom[dir_index] = et_new_tree (bb);
>
> -  if (dom_computed[dir_index] == DOM_OK)
> -    dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)
> +    cfun->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
>  }
>
>  void
> @@ -1573,14 +1575,14 @@ delete_from_dominance_info (enum cdi_direction dir, 
> basic_block bb)
>  {
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> -  gcc_checking_assert (dom_computed[dir_index]);
> +  gcc_checking_assert (cfun->cfg->x_dom_computed[dir_index]);
>
>    et_free_tree (bb->dom[dir_index]);
>    bb->dom[dir_index] = NULL;
> -  n_bbs_in_dom_tree[dir_index]--;
> +  cfun->cfg->x_n_bbs_in_dom_tree[dir_index]--;
>
> -  if (dom_computed[dir_index] == DOM_OK)
> -    dom_computed[dir_index] = DOM_NO_FAST_QUERY;
> +  if (cfun->cfg->x_dom_computed[dir_index] == DOM_OK)
> +    cfun->cfg->x_dom_computed[dir_index] = DOM_NO_FAST_QUERY;
>  }
>
>  /* Returns the first son of BB in the dominator or postdominator tree
> @@ -1632,7 +1634,7 @@ set_dom_info_availability (enum cdi_direction dir, enum 
> dom_state new_state)
>  {
>    unsigned int dir_index = dom_convert_dir_to_idx (dir);
>
> -  dom_computed[dir_index] = new_state;
> +  cfun->cfg->x_dom_computed[dir_index] = new_state;
>  }
>
>  /* Returns true if dominance information for direction DIR is available.  */
> diff --git a/gcc/function.h b/gcc/function.h
> index c0ba6cc1531a..e56de1195b5f 100644
> --- a/gcc/function.h
> +++ b/gcc/function.h
> @@ -535,10 +535,7 @@ get_new_clique (function *fn)
>
>  /* For backward compatibility... eventually these should all go away.  */
>  #define current_function_funcdef_no (cfun->funcdef_no)
> -
>  #define current_loops (cfun->x_current_loops)
> -#define dom_computed (cfun->cfg->x_dom_computed)
> -#define n_bbs_in_dom_tree (cfun->cfg->x_n_bbs_in_dom_tree)
>  #define VALUE_HISTOGRAMS(fun) (fun)->value_histograms
>
>  /* A pointer to a function to create target specific, per-function
> --
> 2.26.3
>

Reply via email to