On Sat, May 31, 2025 at 4:17 AM Andrew Pinski <quic_apin...@quicinc.com> wrote:
>
> This is a follow up to the patch set starting at 
> https://gcc.gnu.org/pipermail/gcc-patches/2014-April/386650.html.
>
> Currently TODO_verify_{il,all} is set by a few passes as TODOs afterwards but
> we don't need to do that any more. Those were mostly removed back in
> https://gcc.gnu.org/pipermail/gcc-patches/2014-May/387647.html
>
> And now since TODO_verify_all is no longer used, remove it too.
> Removes last_verified from the function structure since it is always 0 before 
> the
> call to execute_todo that has TODO_verify_all set on it.
>
> Also this removes the ability for good to use TODO_verify_il from the passes 
> and reserves
> bit 31 of the TODO for the verfification and internally only the passes.cc 
> code.
>
> Bootstrapped and tested on x86_64-linux-gnu.
>
> gcc/ChangeLog:
>
>         * function.h (struct function): Remove last_verified.
>         * gimple-harden-conditionals.cc (pass_data_harden_compares): Remove
>         TODO_verify_il.
>         (pass_data_harden_conditional_branches): Likewise.
>         * gimple-harden-control-flow.cc 
> (pass_harden_control_flow_redundancy::execute):
>         Don't return TODO_verify_il.
>         * ipa-strub.cc (pass_data_ipa_strub): Remove TODO_verify_il.
>         * passes.cc (TODO_verify_il): Define.
>         (execute_function_todo): Don't use or set last_verified.
>         (clear_last_verified): Remove.
>         (execute_one_ipa_transform_pass): Update comment before execute_todo.
>         Assert that none of the todos have TODO_verify_il set on it.
>         (execute_one_pass): Don't call clear_last_verified on all functions.
>         Assert that none of the todos have TODO_verify_il set on it.
>         * tree-inline.cc (initialize_cfun): Don't copy last_verified.
>         * tree-pass.h (TODO_verify_all): Remove.
>         * tree-vrp.cc (pass_data_early_vrp): Remove TODO_verify_all.
>         (pass_data_fast_vrp): Likewise.
>
> Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>
> ---
>  gcc/function.h                    |  1 -
>  gcc/gimple-harden-conditionals.cc |  6 ++----
>  gcc/gimple-harden-control-flow.cc |  3 +--
>  gcc/ipa-strub.cc                  |  3 +--
>  gcc/passes.cc                     | 23 +++++++++--------------
>  gcc/tree-inline.cc                |  1 -
>  gcc/tree-pass.h                   |  4 +---
>  gcc/tree-vrp.cc                   |  4 ++--
>  8 files changed, 16 insertions(+), 29 deletions(-)
>
> diff --git a/gcc/function.h b/gcc/function.h
> index 2260d6704ec..370629f4de2 100644
> --- a/gcc/function.h
> +++ b/gcc/function.h
> @@ -333,7 +333,6 @@ struct GTY(()) function {
>
>    /* Properties used by the pass manager.  */
>    unsigned int curr_properties;
> -  unsigned int last_verified;
>
>    /* Different from normal TODO_flags which are handled right at the
>       beginning or the end of one pass execution, the pending_TODOs
> diff --git a/gcc/gimple-harden-conditionals.cc 
> b/gcc/gimple-harden-conditionals.cc
> index 3ad3bb98edd..d4a418d481a 100644
> --- a/gcc/gimple-harden-conditionals.cc
> +++ b/gcc/gimple-harden-conditionals.cc
> @@ -61,8 +61,7 @@ const pass_data pass_data_harden_compares = {
>    0,       // properties_destroyed
>    0,       // properties_start
>    TODO_update_ssa
> -  | TODO_cleanup_cfg
> -  | TODO_verify_il, // properties_finish
> +  | TODO_cleanup_cfg, // properties_finish
>  };
>
>  class pass_harden_compares : public gimple_opt_pass
> @@ -96,8 +95,7 @@ const pass_data pass_data_harden_conditional_branches = {
>    0,       // properties_destroyed
>    0,       // properties_start
>    TODO_update_ssa
> -  | TODO_cleanup_cfg
> -  | TODO_verify_il, // properties_finish
> +  | TODO_cleanup_cfg, // properties_finish
>  };
>
>  class pass_harden_conditional_branches : public gimple_opt_pass
> diff --git a/gcc/gimple-harden-control-flow.cc 
> b/gcc/gimple-harden-control-flow.cc
> index e46acafbae4..f129ff1e077 100644
> --- a/gcc/gimple-harden-control-flow.cc
> +++ b/gcc/gimple-harden-control-flow.cc
> @@ -1549,8 +1549,7 @@ pass_harden_control_flow_redundancy::execute (function 
> *fun)
>
>    return
>      TODO_update_ssa
> -    | TODO_cleanup_cfg
> -    | TODO_verify_il;
> +    | TODO_cleanup_cfg;
>  }
>
>  /* Instantiate a hardcfr pass.  */
> diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
> index 99cc9d930d8..d7c0a928600 100644
> --- a/gcc/ipa-strub.cc
> +++ b/gcc/ipa-strub.cc
> @@ -1770,8 +1770,7 @@ const pass_data pass_data_ipa_strub = {
>    0,       // properties_start
>    TODO_update_ssa
>    | TODO_cleanup_cfg
> -  | TODO_rebuild_cgraph_edges
> -  | TODO_verify_il, // properties_finish
> +  | TODO_rebuild_cgraph_edges, // properties_finish
>  };
>
>  class pass_ipa_strub : public simple_ipa_opt_pass
> diff --git a/gcc/passes.cc b/gcc/passes.cc
> index e86aa1f2d1b..6c67ffe56ba 100644
> --- a/gcc/passes.cc
> +++ b/gcc/passes.cc
> @@ -64,6 +64,9 @@ along with GCC; see the file COPYING3.  If not see
>  #include "stringpool.h"
>  #include "attribs.h"
>
> +/* Reserved TODOs */
> +#define TODO_verify_il                 (1u << 31)
> +
>  using namespace gcc;
>
>  /* This is used for debugging.  It allows the current pass to printed
> @@ -2059,7 +2062,6 @@ execute_function_todo (function *fn, void *data)
>  {
>    bool from_ipa_pass = (cfun == NULL);
>    unsigned int flags = (size_t)data;
> -  flags &= ~fn->last_verified;
>    if (!flags)
>      return;
>
> @@ -2127,8 +2129,6 @@ execute_function_todo (function *fn, void *data)
>        gcc_assert (dom_info_state (fn, CDI_POST_DOMINATORS) == 
> pre_verify_pstate);
>      }
>
> -  fn->last_verified = flags & TODO_verify_all;
> -
>    pop_cfun ();
>
>    /* For IPA passes make sure to release dominator info, it can be
> @@ -2193,14 +2193,6 @@ verify_interpass_invariants (void)
>    gcc_checking_assert (!fold_deferring_overflow_warnings_p ());
>  }
>
> -/* Clear the last verified flag.  */
> -
> -static void
> -clear_last_verified (function *fn, void *data ATTRIBUTE_UNUSED)
> -{
> -  fn->last_verified = 0;
> -}
> -
>  /* Helper function. Verify that the properties has been turn into the
>     properties expected by the pass.  */
>
> @@ -2339,13 +2331,15 @@ execute_one_ipa_transform_pass (struct cgraph_node 
> *node,
>    if (pass->tv_id != TV_NONE)
>      timevar_push (pass->tv_id);
>
> +  gcc_checking_assert (!(ipa_pass->function_transform_todo_flags_start & 
> TODO_verify_il));
>    /* Run pre-pass verification.  */
>    execute_todo (ipa_pass->function_transform_todo_flags_start);
>
>    /* Do it!  */
>    todo_after = ipa_pass->function_transform (node);
>
> -  /* Run post-pass cleanup and verification.  */
> +  /* Run post-pass cleanup.  */
> +  gcc_checking_assert (!(todo_after & TODO_verify_il));
>    execute_todo (todo_after);
>    verify_interpass_invariants ();
>
> @@ -2649,6 +2643,7 @@ execute_one_pass (opt_pass *pass)
>
>
>    /* Run pre-pass verification.  */
> +  gcc_checking_assert (!(pass->todo_flags_start & TODO_verify_il));
>    execute_todo (pass->todo_flags_start);
>
>    if (flag_checking)
> @@ -2697,11 +2692,11 @@ execute_one_pass (opt_pass *pass)
>        return true;
>      }
>
> -  do_per_function (clear_last_verified, NULL);
> -
>    do_per_function (update_properties_after_pass, pass);
>
>    /* Run post-pass cleanup and verification.  */
> +  gcc_checking_assert (!(todo_after & TODO_verify_il));
> +  gcc_checking_assert (!(pass->todo_flags_finish & TODO_verify_il));
>    execute_todo (todo_after | pass->todo_flags_finish | TODO_verify_il);
>    if (profile_report)
>      {
> diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
> index 3289b4f6d05..1a72e31b06c 100644
> --- a/gcc/tree-inline.cc
> +++ b/gcc/tree-inline.cc
> @@ -2866,7 +2866,6 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, 
> profile_count count)
>    cfun->nonlocal_goto_save_area = src_cfun->nonlocal_goto_save_area;
>    cfun->function_end_locus = src_cfun->function_end_locus;
>    cfun->curr_properties = src_cfun->curr_properties;
> -  cfun->last_verified = src_cfun->last_verified;
>    cfun->va_list_gpr_size = src_cfun->va_list_gpr_size;
>    cfun->va_list_fpr_size = src_cfun->va_list_fpr_size;
>    cfun->has_nonlocal_label = src_cfun->has_nonlocal_label;
> diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
> index 7cb5a128899..8fc3849773e 100644
> --- a/gcc/tree-pass.h
> +++ b/gcc/tree-pass.h
> @@ -236,9 +236,9 @@ protected:
>    (PROP_gimple_any | PROP_gimple_lcf | PROP_gimple_leh | PROP_gimple_lomp)
>
>  /* To-do flags.  */
> +/* Note (1ul << 31) is reserved for TODO_verify_il. */
>  #define TODO_do_not_ggc_collect                (1 << 1)
>  #define TODO_cleanup_cfg               (1 << 5)
> -#define TODO_verify_il                 (1 << 6)
>  #define TODO_dump_symtab               (1 << 7)
>  #define TODO_remove_functions          (1 << 8)

Can you add a comment at the end that 1u << 31 is reserved for internal use?

OK with that change.
Thanks,
Richard.

>
> @@ -315,8 +315,6 @@ protected:
>       | TODO_update_ssa_full_phi                \
>       | TODO_update_ssa_only_virtuals)
>
> -#define TODO_verify_all TODO_verify_il
> -
>  /* To-do flags for pending_TODOs.  */
>
>  /* Tell the next scalar cleanup pass that there is
> diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
> index 5aeb1e066cf..cad1a24ab33 100644
> --- a/gcc/tree-vrp.cc
> +++ b/gcc/tree-vrp.cc
> @@ -1297,7 +1297,7 @@ const pass_data pass_data_early_vrp =
>    0, /* properties_provided */
>    0, /* properties_destroyed */
>    0, /* todo_flags_start */
> -  ( TODO_cleanup_cfg | TODO_update_ssa | TODO_verify_all ),
> +  ( TODO_cleanup_cfg | TODO_update_ssa ),
>  };
>
>  const pass_data pass_data_fast_vrp =
> @@ -1310,7 +1310,7 @@ const pass_data pass_data_fast_vrp =
>    0, /* properties_provided */
>    0, /* properties_destroyed */
>    0, /* todo_flags_start */
> -  ( TODO_cleanup_cfg | TODO_update_ssa | TODO_verify_all ),
> +  ( TODO_cleanup_cfg | TODO_update_ssa ),
>  };
>
>
> --
> 2.43.0
>

Reply via email to