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]

Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro


On Wed, Jul 17, 2013 at 6:18 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> gcc/
>
>         Explicitly number the instances of passes within passes.def.
>
>         This is needed by a subsequent patch so that we can create
>         fields within the pipeline class for each pass instance (to help
>         locate pass instances when debugging).
>
>         * passes.c (NEXT_PASS_NUM): Define.
>
>         * passes.def (NEXT_PASS, NEXT_PASS_NUM): Replace uses of
>         NEXT_PASS on passes that have multiple instances with uses of
>         NEXT_PASS_NUM.


I don't like this patch at all.  Mainly because the numbers can get
out of sync very quickly especially when it comes to internal versions
of the compiler where it is normal to reorder passes and add another
pass a few times.

Thanks,
Andrew

> ---
>  gcc/passes.c   |   3 +
>  gcc/passes.def | 173 +++++++++++++++++++++++++++++----------------------------
>  2 files changed, 90 insertions(+), 86 deletions(-)
>
> diff --git a/gcc/passes.c b/gcc/passes.c
> index 94fb586..f140330 100644
> --- a/gcc/passes.c
> +++ b/gcc/passes.c
> @@ -1294,6 +1294,8 @@ init_optimization_passes (void)
>
>  #define NEXT_PASS(PASS)  (p = next_pass_1 (p, &((PASS).pass)))
>
> +#define NEXT_PASS_NUM(PASS, NUM)  (p = next_pass_1 (p, &((PASS).pass)))
> +
>  #define TERMINATE_PASS_LIST() \
>    *p = NULL;
>
> @@ -1303,6 +1305,7 @@ init_optimization_passes (void)
>  #undef PUSH_INSERT_PASSES_WITHIN
>  #undef POP_INSERT_PASSES
>  #undef NEXT_PASS
> +#undef NEXT_PASS_NUM
>  #undef TERMINATE_PASS_LIST
>
>    /* Register the passes with the tree dump code.  */
> diff --git a/gcc/passes.def b/gcc/passes.def
> index fa03d16..f142d31 100644
> --- a/gcc/passes.def
> +++ b/gcc/passes.def
> @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
>     PUSH_INSERT_PASSES_WITHIN (PASS)
>     POP_INSERT_PASSES ()
>     NEXT_PASS (PASS)
> +   NEXT_PASS_NUM (PASS, NUM)
>     TERMINATE_PASS_LIST ()
>   */
>
> @@ -52,44 +53,44 @@ along with GCC; see the file COPYING3.  If not see
>    NEXT_PASS (pass_ipa_function_and_variable_visibility);
>    NEXT_PASS (pass_early_local_passes);
>    PUSH_INSERT_PASSES_WITHIN (pass_early_local_passes)
> -      NEXT_PASS (pass_fixup_cfg);
> +      NEXT_PASS_NUM (pass_fixup_cfg, 1);
>        NEXT_PASS (pass_init_datastructures);
>
>        NEXT_PASS (pass_build_ssa);
>        NEXT_PASS (pass_early_warn_uninitialized);
> -      NEXT_PASS (pass_rebuild_cgraph_edges);
> -      NEXT_PASS (pass_inline_parameters);
> +      NEXT_PASS_NUM (pass_rebuild_cgraph_edges, 1);
> +      NEXT_PASS_NUM (pass_inline_parameters, 1);
>        NEXT_PASS (pass_early_inline);
>        NEXT_PASS (pass_all_early_optimizations);
>        PUSH_INSERT_PASSES_WITHIN (pass_all_early_optimizations)
> -         NEXT_PASS (pass_remove_cgraph_callee_edges);
> -         NEXT_PASS (pass_rename_ssa_copies);
> -         NEXT_PASS (pass_ccp);
> +         NEXT_PASS_NUM (pass_remove_cgraph_callee_edges, 1);
> +         NEXT_PASS_NUM (pass_rename_ssa_copies, 1);
> +         NEXT_PASS_NUM (pass_ccp, 1);
>           /* After CCP we rewrite no longer addressed locals into SSA
>              form if possible.  */
> -         NEXT_PASS (pass_forwprop);
> +         NEXT_PASS_NUM (pass_forwprop, 1);
>           /* pass_build_ealias is a dummy pass that ensures that we
>              execute TODO_rebuild_alias at this point.  */
>           NEXT_PASS (pass_build_ealias);
>           NEXT_PASS (pass_sra_early);
> -         NEXT_PASS (pass_fre);
> -         NEXT_PASS (pass_copy_prop);
> -         NEXT_PASS (pass_merge_phi);
> -         NEXT_PASS (pass_cd_dce);
> +         NEXT_PASS_NUM (pass_fre, 1);
> +         NEXT_PASS_NUM (pass_copy_prop, 1);
> +         NEXT_PASS_NUM (pass_merge_phi, 1);
> +         NEXT_PASS_NUM (pass_cd_dce, 1);
>           NEXT_PASS (pass_early_ipa_sra);
> -         NEXT_PASS (pass_tail_recursion);
> +         NEXT_PASS_NUM (pass_tail_recursion, 1);
>           NEXT_PASS (pass_convert_switch);
> -          NEXT_PASS (pass_cleanup_eh);
> +          NEXT_PASS_NUM (pass_cleanup_eh, 1);
>            NEXT_PASS (pass_profile);
> -          NEXT_PASS (pass_local_pure_const);
> +          NEXT_PASS_NUM (pass_local_pure_const, 1);
>           /* Split functions creates parts that are not run through
>              early optimizations again.  It is thus good idea to do this
>              late.  */
>            NEXT_PASS (pass_split_functions);
>        POP_INSERT_PASSES ()
>        NEXT_PASS (pass_release_ssa_names);
> -      NEXT_PASS (pass_rebuild_cgraph_edges);
> -      NEXT_PASS (pass_inline_parameters);
> +      NEXT_PASS_NUM (pass_rebuild_cgraph_edges, 2);
> +      NEXT_PASS_NUM (pass_inline_parameters, 2);
>    POP_INSERT_PASSES ()
>    NEXT_PASS (pass_ipa_free_inline_summary);
>    NEXT_PASS (pass_ipa_tree_profile);
> @@ -126,118 +127,118 @@ along with GCC; see the file COPYING3.  If not see
>    /* These passes are run after IPA passes on every function that is being
>       output to the assembler file.  */
>    INSERT_PASSES_AFTER (all_passes)
> -  NEXT_PASS (pass_fixup_cfg);
> +  NEXT_PASS_NUM (pass_fixup_cfg, 2);
>    NEXT_PASS (pass_lower_eh_dispatch);
>    NEXT_PASS (pass_all_optimizations);
>    PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations)
> -      NEXT_PASS (pass_remove_cgraph_callee_edges);
> +      NEXT_PASS_NUM (pass_remove_cgraph_callee_edges, 2);
>        /* Initial scalar cleanups before alias computation.
>          They ensure memory accesses are not indirect wherever possible.  */
> -      NEXT_PASS (pass_strip_predict_hints);
> -      NEXT_PASS (pass_rename_ssa_copies);
> -      NEXT_PASS (pass_copy_prop);
> +      NEXT_PASS_NUM (pass_strip_predict_hints, 1);
> +      NEXT_PASS_NUM (pass_rename_ssa_copies, 2);
> +      NEXT_PASS_NUM (pass_copy_prop, 2);
>        NEXT_PASS (pass_complete_unrolli);
> -      NEXT_PASS (pass_ccp);
> +      NEXT_PASS_NUM (pass_ccp, 2);
>        /* After CCP we rewrite no longer addressed locals into SSA
>          form if possible.  */
>        NEXT_PASS (pass_phiprop);
> -      NEXT_PASS (pass_forwprop);
> +      NEXT_PASS_NUM (pass_forwprop, 2);
>        /* pass_build_alias is a dummy pass that ensures that we
>          execute TODO_rebuild_alias at this point.  */
>        NEXT_PASS (pass_build_alias);
>        NEXT_PASS (pass_return_slot);
> -      NEXT_PASS (pass_fre);
> -      NEXT_PASS (pass_copy_prop);
> -      NEXT_PASS (pass_merge_phi);
> -      NEXT_PASS (pass_vrp);
> -      NEXT_PASS (pass_dce);
> +      NEXT_PASS_NUM (pass_fre, 2);
> +      NEXT_PASS_NUM (pass_copy_prop, 3);
> +      NEXT_PASS_NUM (pass_merge_phi, 2);
> +      NEXT_PASS_NUM (pass_vrp, 1);
> +      NEXT_PASS_NUM (pass_dce, 1);
>        NEXT_PASS (pass_call_cdce);
>        NEXT_PASS (pass_cselim);
>        NEXT_PASS (pass_tree_ifcombine);
> -      NEXT_PASS (pass_phiopt);
> -      NEXT_PASS (pass_tail_recursion);
> +      NEXT_PASS_NUM (pass_phiopt, 1);
> +      NEXT_PASS_NUM (pass_tail_recursion, 2);
>        NEXT_PASS (pass_ch);
>        NEXT_PASS (pass_stdarg);
> -      NEXT_PASS (pass_lower_complex);
> +      NEXT_PASS_NUM (pass_lower_complex, 1);
>        NEXT_PASS (pass_sra);
> -      NEXT_PASS (pass_rename_ssa_copies);
> +      NEXT_PASS_NUM (pass_rename_ssa_copies, 3);
>        /* The dom pass will also resolve all __builtin_constant_p calls
>           that are still there to 0.  This has to be done after some
>          propagations have already run, but before some more dead code
>          is removed, and this place fits nicely.  Remember this when
>          trying to move or duplicate pass_dominator somewhere earlier.  */
> -      NEXT_PASS (pass_dominator);
> +      NEXT_PASS_NUM (pass_dominator, 1);
>        /* The only const/copy propagation opportunities left after
>          DOM should be due to degenerate PHI nodes.  So rather than
>          run the full propagators, run a specialized pass which
>          only examines PHIs to discover const/copy propagation
>          opportunities.  */
> -      NEXT_PASS (pass_phi_only_cprop);
> -      NEXT_PASS (pass_dse);
> -      NEXT_PASS (pass_reassoc);
> -      NEXT_PASS (pass_dce);
> -      NEXT_PASS (pass_forwprop);
> -      NEXT_PASS (pass_phiopt);
> -      NEXT_PASS (pass_object_sizes);
> +      NEXT_PASS_NUM (pass_phi_only_cprop, 1);
> +      NEXT_PASS_NUM (pass_dse, 1);
> +      NEXT_PASS_NUM (pass_reassoc, 1);
> +      NEXT_PASS_NUM (pass_dce, 2);
> +      NEXT_PASS_NUM (pass_forwprop, 3);
> +      NEXT_PASS_NUM (pass_phiopt, 2);
> +      NEXT_PASS_NUM (pass_object_sizes, 1);
>        NEXT_PASS (pass_strlen);
> -      NEXT_PASS (pass_ccp);
> +      NEXT_PASS_NUM (pass_ccp, 3);
>        /* After CCP we rewrite no longer addressed locals into SSA
>          form if possible.  */
> -      NEXT_PASS (pass_copy_prop);
> +      NEXT_PASS_NUM (pass_copy_prop, 4);
>        NEXT_PASS (pass_cse_sincos);
>        NEXT_PASS (pass_optimize_bswap);
>        NEXT_PASS (pass_split_crit_edges);
>        NEXT_PASS (pass_pre);
>        NEXT_PASS (pass_sink_code);
> -      NEXT_PASS (pass_asan);
> -      NEXT_PASS (pass_tsan);
> +      NEXT_PASS_NUM (pass_asan, 1);
> +      NEXT_PASS_NUM (pass_tsan, 1);
>        NEXT_PASS (pass_tree_loop);
>        PUSH_INSERT_PASSES_WITHIN (pass_tree_loop)
>           NEXT_PASS (pass_tree_loop_init);
> -         NEXT_PASS (pass_lim);
> -         NEXT_PASS (pass_copy_prop);
> -         NEXT_PASS (pass_dce_loop);
> +         NEXT_PASS_NUM (pass_lim, 1);
> +         NEXT_PASS_NUM (pass_copy_prop, 5);
> +         NEXT_PASS_NUM (pass_dce_loop, 1);
>           NEXT_PASS (pass_tree_unswitch);
>           NEXT_PASS (pass_scev_cprop);
>           NEXT_PASS (pass_record_bounds);
>           NEXT_PASS (pass_check_data_deps);
>           NEXT_PASS (pass_loop_distribution);
> -         NEXT_PASS (pass_copy_prop);
> +         NEXT_PASS_NUM (pass_copy_prop, 6);
>           NEXT_PASS (pass_graphite);
>           PUSH_INSERT_PASSES_WITHIN (pass_graphite)
>               NEXT_PASS (pass_graphite_transforms);
> -             NEXT_PASS (pass_lim);
> -             NEXT_PASS (pass_copy_prop);
> -             NEXT_PASS (pass_dce_loop);
> +             NEXT_PASS_NUM (pass_lim, 2);
> +             NEXT_PASS_NUM (pass_copy_prop, 7);
> +             NEXT_PASS_NUM (pass_dce_loop, 2);
>           POP_INSERT_PASSES ()
>           NEXT_PASS (pass_iv_canon);
>           NEXT_PASS (pass_parallelize_loops);
>           NEXT_PASS (pass_if_conversion);
>           NEXT_PASS (pass_vectorize);
>            PUSH_INSERT_PASSES_WITHIN (pass_vectorize)
> -             NEXT_PASS (pass_dce_loop);
> +             NEXT_PASS_NUM (pass_dce_loop, 3);
>            POP_INSERT_PASSES ()
>            NEXT_PASS (pass_predcom);
>           NEXT_PASS (pass_complete_unroll);
>           NEXT_PASS (pass_slp_vectorize);
>           NEXT_PASS (pass_loop_prefetch);
>           NEXT_PASS (pass_iv_optimize);
> -         NEXT_PASS (pass_lim);
> +         NEXT_PASS_NUM (pass_lim, 3);
>           NEXT_PASS (pass_tree_loop_done);
>        POP_INSERT_PASSES ()
> -      NEXT_PASS (pass_lower_vector_ssa);
> +      NEXT_PASS_NUM (pass_lower_vector_ssa, 1);
>        NEXT_PASS (pass_cse_reciprocals);
> -      NEXT_PASS (pass_reassoc);
> +      NEXT_PASS_NUM (pass_reassoc, 2);
>        NEXT_PASS (pass_strength_reduction);
> -      NEXT_PASS (pass_dominator);
> +      NEXT_PASS_NUM (pass_dominator, 2);
>        /* The only const/copy propagation opportunities left after
>          DOM should be due to degenerate PHI nodes.  So rather than
>          run the full propagators, run a specialized pass which
>          only examines PHIs to discover const/copy propagation
>          opportunities.  */
> -      NEXT_PASS (pass_phi_only_cprop);
> -      NEXT_PASS (pass_vrp);
> -      NEXT_PASS (pass_cd_dce);
> +      NEXT_PASS_NUM (pass_phi_only_cprop, 2);
> +      NEXT_PASS_NUM (pass_vrp, 2);
> +      NEXT_PASS_NUM (pass_cd_dce, 2);
>        NEXT_PASS (pass_tracer);
>
>        /* FIXME: If DCE is not run before checking for uninitialized uses,
> @@ -249,42 +250,42 @@ along with GCC; see the file COPYING3.  If not see
>          account for the predicates protecting the set and the use of each
>          variable.  Using a representation like Gated Single Assignment
>          may help.  */
> -      NEXT_PASS (pass_late_warn_uninitialized);
> -      NEXT_PASS (pass_dse);
> -      NEXT_PASS (pass_forwprop);
> -      NEXT_PASS (pass_phiopt);
> -      NEXT_PASS (pass_fold_builtins);
> +      NEXT_PASS_NUM (pass_late_warn_uninitialized, 1);
> +      NEXT_PASS_NUM (pass_dse, 2);
> +      NEXT_PASS_NUM (pass_forwprop, 4);
> +      NEXT_PASS_NUM (pass_phiopt, 3);
> +      NEXT_PASS_NUM (pass_fold_builtins, 1);
>        NEXT_PASS (pass_optimize_widening_mul);
>        NEXT_PASS (pass_tail_calls);
> -      NEXT_PASS (pass_rename_ssa_copies);
> -      NEXT_PASS (pass_uncprop);
> -      NEXT_PASS (pass_local_pure_const);
> +      NEXT_PASS_NUM (pass_rename_ssa_copies, 4);
> +      NEXT_PASS_NUM (pass_uncprop, 1);
> +      NEXT_PASS_NUM (pass_local_pure_const, 2);
>    POP_INSERT_PASSES ()
>    NEXT_PASS (pass_all_optimizations_g);
>    PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations_g)
> -      NEXT_PASS (pass_remove_cgraph_callee_edges);
> -      NEXT_PASS (pass_strip_predict_hints);
> +      NEXT_PASS_NUM (pass_remove_cgraph_callee_edges, 3);
> +      NEXT_PASS_NUM (pass_strip_predict_hints, 2);
>        /* Lower remaining pieces of GIMPLE.  */
> -      NEXT_PASS (pass_lower_complex);
> -      NEXT_PASS (pass_lower_vector_ssa);
> +      NEXT_PASS_NUM (pass_lower_complex, 2);
> +      NEXT_PASS_NUM (pass_lower_vector_ssa, 2);
>        /* Perform simple scalar cleanup which is constant/copy propagation.  */
> -      NEXT_PASS (pass_ccp);
> -      NEXT_PASS (pass_object_sizes);
> +      NEXT_PASS_NUM (pass_ccp, 4);
> +      NEXT_PASS_NUM (pass_object_sizes, 2);
>        /* Fold remaining builtins.  */
> -      NEXT_PASS (pass_fold_builtins);
> +      NEXT_PASS_NUM (pass_fold_builtins, 2);
>        /* Copy propagation also copy-propagates constants, this is necessary
>           to forward object-size and builtin folding results properly.  */
> -      NEXT_PASS (pass_copy_prop);
> -      NEXT_PASS (pass_dce);
> -      NEXT_PASS (pass_asan);
> -      NEXT_PASS (pass_tsan);
> -      NEXT_PASS (pass_rename_ssa_copies);
> +      NEXT_PASS_NUM (pass_copy_prop, 8);
> +      NEXT_PASS_NUM (pass_dce, 3);
> +      NEXT_PASS_NUM (pass_asan, 2);
> +      NEXT_PASS_NUM (pass_tsan, 2);
> +      NEXT_PASS_NUM (pass_rename_ssa_copies, 5);
>        /* ???  We do want some kind of loop invariant motion, but we possibly
>           need to adjust LIM to be more friendly towards preserving accurate
>          debug information here.  */
> -      NEXT_PASS (pass_late_warn_uninitialized);
> -      NEXT_PASS (pass_uncprop);
> -      NEXT_PASS (pass_local_pure_const);
> +      NEXT_PASS_NUM (pass_late_warn_uninitialized, 2);
> +      NEXT_PASS_NUM (pass_uncprop, 2);
> +      NEXT_PASS_NUM (pass_local_pure_const, 3);
>    POP_INSERT_PASSES ()
>    NEXT_PASS (pass_tm_init);
>    PUSH_INSERT_PASSES_WITHIN (pass_tm_init)
> @@ -296,7 +297,7 @@ along with GCC; see the file COPYING3.  If not see
>    NEXT_PASS (pass_lower_complex_O0);
>    NEXT_PASS (pass_asan_O0);
>    NEXT_PASS (pass_tsan_O0);
> -  NEXT_PASS (pass_cleanup_eh);
> +  NEXT_PASS_NUM (pass_cleanup_eh, 2);
>    NEXT_PASS (pass_lower_resx);
>    NEXT_PASS (pass_nrv);
>    NEXT_PASS (pass_mudflap_2);
> @@ -314,10 +315,10 @@ along with GCC; see the file COPYING3.  If not see
>        NEXT_PASS (pass_df_initialize_opt);
>        NEXT_PASS (pass_cse);
>        NEXT_PASS (pass_rtl_fwprop);
> -      NEXT_PASS (pass_rtl_cprop);
> +      NEXT_PASS_NUM (pass_rtl_cprop, 1);
>        NEXT_PASS (pass_rtl_pre);
>        NEXT_PASS (pass_rtl_hoist);
> -      NEXT_PASS (pass_rtl_cprop);
> +      NEXT_PASS_NUM (pass_rtl_cprop, 2);
>        NEXT_PASS (pass_rtl_store_motion);
>        NEXT_PASS (pass_cse_after_global_opts);
>        NEXT_PASS (pass_rtl_ifcvt);
> @@ -336,7 +337,7 @@ along with GCC; see the file COPYING3.  If not see
>           TERMINATE_PASS_LIST ()
>        POP_INSERT_PASSES ()
>        NEXT_PASS (pass_web);
> -      NEXT_PASS (pass_rtl_cprop);
> +      NEXT_PASS_NUM (pass_rtl_cprop, 3);
>        NEXT_PASS (pass_cse2);
>        NEXT_PASS (pass_rtl_dse1);
>        NEXT_PASS (pass_rtl_fwprop_addr);
> --
> 1.7.11.7
>


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