diff mbox

[3/4] Introduce NEXT_PASS_NUM macro

Message ID 1374110303-9758-4-git-send-email-dmalcolm@redhat.com
State New
Headers show

Commit Message

David Malcolm July 18, 2013, 1:18 a.m. UTC
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.
---
 gcc/passes.c   |   3 +
 gcc/passes.def | 173 +++++++++++++++++++++++++++++----------------------------
 2 files changed, 90 insertions(+), 86 deletions(-)

Comments

Andrew Pinski July 18, 2013, 7:08 a.m. UTC | #1
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
>
David Malcolm July 18, 2013, 11:33 a.m. UTC | #2
On Thu, 2013-07-18 at 00:08 -0700, Andrew Pinski wrote:
> 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.

How would you feel about a "passes.def.in" and having that be what's in
svn, with some kind of preprocessing step that builds a passes.def from
it?  That way we get the flexibility of before, but gain the ability I'm
looking for to make a class holding the passes, and have easy access in
gdb to the various instances of the class (rather than just the last
instance of each that was created).

If so, what tools are blessed for usage at build time? (I'd prefer
Python, but I don't think that's a build-time dep yet).
Andrew Pinski July 18, 2013, 2:56 p.m. UTC | #3
On Thu, Jul 18, 2013 at 4:33 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> On Thu, 2013-07-18 at 00:08 -0700, Andrew Pinski wrote:
>> 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.
>
> How would you feel about a "passes.def.in" and having that be what's in
> svn, with some kind of preprocessing step that builds a passes.def from
> it?  That way we get the flexibility of before, but gain the ability I'm
> looking for to make a class holding the passes, and have easy access in
> gdb to the various instances of the class (rather than just the last
> instance of each that was created).

That would work and would be ok with me.

> If so, what tools are blessed for usage at build time? (I'd prefer
> Python, but I don't think that's a build-time dep yet).

So far awk and shell and C programming are the blessed processing
tools.  Awk in this case seems like the best for this though.  I don't
think Python is a good solution only because it does add another build
dependency that is not there already though I would not complain about
it if it gets added.

Thanks,
Andrew Pinski
Tom Tromey July 18, 2013, 3:11 p.m. UTC | #4
>>>>> "David" == David Malcolm <dmalcolm@redhat.com> writes:

David> If so, what tools are blessed for usage at build time? (I'd prefer
David> Python, but I don't think that's a build-time dep yet).

http://www.gnu.org/prep/standards/html_node/Utilities-in-Makefiles.html#Utilities-in-Makefiles

Tom
Jeff Law July 18, 2013, 4:25 p.m. UTC | #5
On 07/17/2013 07:18 PM, David Malcolm 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.
So this means we have to track down the instance number if we add a 
duplicate pass in the pipeline.  I can see positives and negatives of 
doing that.  I'll go along as I'm a proponent of the goal of having the 
passes be a first class object.

Ok for the trunk.

Jeff
Martin Jambor July 22, 2013, 6:25 p.m. UTC | #6
Hi,

On Wed, Jul 17, 2013 at 09:18:22PM -0400, David Malcolm 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).
> 

I don't really understand what you want to achieve.  Are you sure the
benefits are worth the work necessary to implement the processing of
passes.def.in?  Especially given that we already initialize
static_pass_number at run time and copy stuff around in
make_pass_instance when it is already set.  I assume this would
somehow allow us to directly dump data of say forwprop3 as apposed to
forwprop2 to but that would require constant awareness of the sequence
number of the currently running pass, which I think is also unpleasant
and error-prone.

I mean, you may have perfectly legitimate reasons for doing this, I'm
just wondering whether we are perhaps over-engineering this a bit.

Thanks,

Martin
David Malcolm July 22, 2013, 7:22 p.m. UTC | #7
On Mon, 2013-07-22 at 20:25 +0200, Martin Jambor wrote:
> Hi,
> 
> On Wed, Jul 17, 2013 at 09:18:22PM -0400, David Malcolm 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).
> > 
> 
> I don't really understand what you want to achieve.  Are you sure the
> benefits are worth the work necessary to implement the processing of
> passes.def.in?  Especially given that we already initialize
> static_pass_number at run time and copy stuff around in
> make_pass_instance when it is already set.  I assume this would
> somehow allow us to directly dump data of say forwprop3 as apposed to
> forwprop2 to but that would require constant awareness of the sequence
> number of the currently running pass, which I think is also unpleasant
> and error-prone.
> 
> I mean, you may have perfectly legitimate reasons for doing this, I'm
> just wondering whether we are perhaps over-engineering this a bit.

The main goal here is part of eliminating global variables from gcc [1],
to be able to create:

class pipeline
{
  /* omitting various other fields for clarity */

  opt_pass *pass_warn_unused_result;
  opt_pass *pass_diagnose_omp_blocks;
  opt_pass *pass_diagnose_tm_blocks;
  opt_pass *pass_mudflap_1;
  opt_pass *pass_lower_omp;
  opt_pass *pass_lower_cf;
  opt_pass *pass_lower_tm;
  opt_pass *pass_refactor_eh;
  opt_pass *pass_lower_eh;
  opt_pass *pass_build_cfg;
  opt_pass *pass_warn_function_return;
  opt_pass *pass_expand_omp;
  opt_pass *pass_build_cgraph_edges;
  opt_pass *pass_ipa_free_lang_data;
  opt_pass *pass_ipa_function_and_variable_visibility;
  opt_pass *pass_early_local_passes;
  opt_pass *pass_fixup_cfg;
  opt_pass *pass_init_datastructures;
  /* etc */
  opt_pass *pass_clean_state;
};

without having to list all of the pass kinds again, thus reusing the
pass description from passes.def.  Without the numbering, I couldn't see
a good way to avoid duplicate field names in the class.  So the
numbering gives us uniqueness of field names in that class (and also
makes debugging slightly easier, but that's a minor side-benefit).

Hope that makes sense

[BTW I've just spent much of the day fighting awk trying to write a
script to generate a pass-instances.def from passes.def, but have given
up in frustration for now (how hard can it be to capture a group from a
regex, track it in a dictionary, and print a substitution with a key and
dict lookup?  hard for me in awk, it seems); am working on fixing the
bad interaction of PCH with GTY-marking of per-pass data in the
meantime].

[1] http://dmalcolm.fedorapeople.org/gcc/global-state/
Martin Jambor July 23, 2013, 2:46 p.m. UTC | #8
Hi,

On Mon, Jul 22, 2013 at 03:22:33PM -0400, David Malcolm wrote:
> On Mon, 2013-07-22 at 20:25 +0200, Martin Jambor wrote:
> > On Wed, Jul 17, 2013 at 09:18:22PM -0400, David Malcolm 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).
> > > 
> > 
> > I don't really understand what you want to achieve.  Are you sure the
> > benefits are worth the work necessary to implement the processing of
> > passes.def.in?  Especially given that we already initialize
> > static_pass_number at run time and copy stuff around in
> > make_pass_instance when it is already set.  I assume this would
> > somehow allow us to directly dump data of say forwprop3 as apposed to
> > forwprop2 to but that would require constant awareness of the sequence
> > number of the currently running pass, which I think is also unpleasant
> > and error-prone.
> > 
> > I mean, you may have perfectly legitimate reasons for doing this, I'm
> > just wondering whether we are perhaps over-engineering this a bit.
> 
> The main goal here is part of eliminating global variables from gcc [1],
> to be able to create:
> 
> class pipeline
> {
>   /* omitting various other fields for clarity */
> 
>   opt_pass *pass_warn_unused_result;
>   opt_pass *pass_diagnose_omp_blocks;
>   opt_pass *pass_diagnose_tm_blocks;
>   opt_pass *pass_mudflap_1;
>   opt_pass *pass_lower_omp;
>   opt_pass *pass_lower_cf;
>   opt_pass *pass_lower_tm;
>   opt_pass *pass_refactor_eh;
>   opt_pass *pass_lower_eh;
>   opt_pass *pass_build_cfg;
>   opt_pass *pass_warn_function_return;
>   opt_pass *pass_expand_omp;
>   opt_pass *pass_build_cgraph_edges;
>   opt_pass *pass_ipa_free_lang_data;
>   opt_pass *pass_ipa_function_and_variable_visibility;
>   opt_pass *pass_early_local_passes;
>   opt_pass *pass_fixup_cfg;
>   opt_pass *pass_init_datastructures;
>   /* etc */
>   opt_pass *pass_clean_state;
> };
> 
> without having to list all of the pass kinds again, thus reusing the
> pass description from passes.def.  Without the numbering, I couldn't see
> a good way to avoid duplicate field names in the class.  So the
> numbering gives us uniqueness of field names in that class (and also
> makes debugging slightly easier, but that's a minor side-benefit).
> 

I really think the easier debugging benefit is really very small, if
any.  Is there another one?  Otherwise, I wouldn't bother with
explicit static fields for each pass but just have a linked list of
them.  If we ever make the pass manager to really be a manager of some
sort, this will happen anyway.

And as far as gdb is concerned, I'd rather avoid typing:

p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[1]->stuff
p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[2]->stuff
p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[3]->stuff

and instead do

set $d = (my_great_pass_class *) current_context->current_pass
p $d->my_array[1]->stuff
p $d->my_array[2]->stuff
p $d->my_array[3]->stuff

Or am I missing something?  Otherwise I'd just say don't bother with awk.

Thanks,

Martin
David Malcolm July 23, 2013, 3:43 p.m. UTC | #9
On Tue, 2013-07-23 at 16:46 +0200, Martin Jambor wrote:
> Hi,
> 
> On Mon, Jul 22, 2013 at 03:22:33PM -0400, David Malcolm wrote:
> > On Mon, 2013-07-22 at 20:25 +0200, Martin Jambor wrote:
> > > On Wed, Jul 17, 2013 at 09:18:22PM -0400, David Malcolm 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).
> > > > 
> > > 
> > > I don't really understand what you want to achieve.  Are you sure the
> > > benefits are worth the work necessary to implement the processing of
> > > passes.def.in?  Especially given that we already initialize
> > > static_pass_number at run time and copy stuff around in
> > > make_pass_instance when it is already set.  I assume this would
> > > somehow allow us to directly dump data of say forwprop3 as apposed to
> > > forwprop2 to but that would require constant awareness of the sequence
> > > number of the currently running pass, which I think is also unpleasant
> > > and error-prone.
> > > 
> > > I mean, you may have perfectly legitimate reasons for doing this, I'm
> > > just wondering whether we are perhaps over-engineering this a bit.
> > 
> > The main goal here is part of eliminating global variables from gcc [1],
> > to be able to create:
> > 
> > class pipeline
> > {
> >   /* omitting various other fields for clarity */
> > 
> >   opt_pass *pass_warn_unused_result;
> >   opt_pass *pass_diagnose_omp_blocks;
> >   opt_pass *pass_diagnose_tm_blocks;
> >   opt_pass *pass_mudflap_1;
> >   opt_pass *pass_lower_omp;
> >   opt_pass *pass_lower_cf;
> >   opt_pass *pass_lower_tm;
> >   opt_pass *pass_refactor_eh;
> >   opt_pass *pass_lower_eh;
> >   opt_pass *pass_build_cfg;
> >   opt_pass *pass_warn_function_return;
> >   opt_pass *pass_expand_omp;
> >   opt_pass *pass_build_cgraph_edges;
> >   opt_pass *pass_ipa_free_lang_data;
> >   opt_pass *pass_ipa_function_and_variable_visibility;
> >   opt_pass *pass_early_local_passes;
> >   opt_pass *pass_fixup_cfg;
> >   opt_pass *pass_init_datastructures;
> >   /* etc */
> >   opt_pass *pass_clean_state;
> > };
> > 
> > without having to list all of the pass kinds again, thus reusing the
> > pass description from passes.def.  Without the numbering, I couldn't see
> > a good way to avoid duplicate field names in the class.  So the
> > numbering gives us uniqueness of field names in that class (and also
> > makes debugging slightly easier, but that's a minor side-benefit).
> > 
> 
> I really think the easier debugging benefit is really very small, if
> any.  Is there another one?  Otherwise, I wouldn't bother with
> explicit static fields for each pass but just have a linked list of
> them.  If we ever make the pass manager to really be a manager of some
> sort, this will happen anyway.
> 
> And as far as gdb is concerned, I'd rather avoid typing:
> 
> p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[1]->stuff
> p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[2]->stuff
> p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[3]->stuff

Thanks - yes - I completely agree, having spent a lot of time in gdb
with this lately :)

Note that there is only one "pipeline" per context, and I've kept the
existing pass struct names (meaning "pass_vrp" rather than "vrp").

BTW, you mentioned dumping in an earlier post, sorry for not clarifying
that aspect.  I haven't changed how dumping works, and I've taken some
care to ensure that the numbering of the pass instances isn't disturbed
(an earlier version of my patches broke that, leading to some of the
test suite failing).   So whatever static_pass_number the 2nd instance
of vrp ended up with before, it will continue to end up with after my
patches.

> and instead do
> 
> set $d = (my_great_pass_class *) current_context->current_pass
> p $d->my_array[1]->stuff
> p $d->my_array[2]->stuff
> p $d->my_array[3]->stuff
> 
> Or am I missing something?  Otherwise I'd just say don't bother with awk.

To give you a flavor of what I'm aiming at, here's a transcript from gdb
on a build with some further patches, with some comments added inline:

The global "current context" variable is simply "g", for ease of typing
- and my hope is that eventually this will be the *only* global variable
[1]:

(gdb) p g
$1 = (gcc::context *) 0x15652a0

In the talk I gave at Cauldron [2], this was a (universe*), but I've
changed my mind again, and prefer (gcc::context*) i.e. it's now a
"context" within a "gcc" namespace.  The namespace is confusing
gengtype, so I'm not sure about that aspect.

The pipeline of passes is simply the "passes_" field of the context;
here's an example of tab-completion:

(gdb) p g->passes_->
Display all 291 possibilities? (y or n)

Typing a pass name, and tab-completing to see the 8 instances of it
(copy_prop has the most instances):

(gdb) p g->passes_->pass_copy_prop_
pass_copy_prop_1  pass_copy_prop_2  pass_copy_prop_3  pass_copy_prop_4
pass_copy_prop_5  pass_copy_prop_6  pass_copy_prop_7  pass_copy_prop_8  

and viewing one:

(gdb) p g->passes_->pass_copy_prop_1
$2 = (opt_pass *) 0x1588940
(gdb) p *g->passes_->pass_copy_prop_1
$3 = {<pass_data> = {type = GIMPLE_PASS, name = 0xef7fe7 "copyprop",
optinfo_flags = 0, has_gate = true, has_execute = true, tv_id =
TV_TREE_COPY_PROP, properties_required = 40, properties_provided = 0, 
    properties_destroyed = 0, todo_flags_start = 524288,
todo_flags_finish = 2084}, _vptr.opt_pass = 0xef8410, sub = 0x0, next =
0x15889a0, static_pass_number = 30, ctxt_ = 0x15652a0}

and here's a view of the top of the struct showing some of the other
globals that I've moved to there:
(gdb) p *g->passes_
$4 = {all_passes = 0x15896f0, all_small_ipa_passes = 0x1588280,
all_lowering_passes = 0x157e000, all_regular_ipa_passes = 0x1589060,
all_lto_gen_passes = 0x1589530, all_late_ipa_passes = 0x1589690, 
  passes_by_id = 0x15a9df0, passes_by_id_size = 251, pass_lists =
{0x1587590, 0x1587588, 0x1587598, 0x15875a0, 0x1587580}, ctxt_ =
0x15652a0, pass_warn_unused_result = 0x157e000, 
  pass_diagnose_omp_blocks = 0x157e060, 
(...etc)

Note that we do need access to certain specific passes from various
places in the compiler.  For example, config/i386/i386.c invokes
pass_mode_switching within its target-specific "vzeroupper" pass.  Hence
it's useful to be able to store the pass and access it - so it's not
just about debugging the pass creation.  In my local copy I'm doing this
within the relevant place in i386.c:

   g->get_passes ().execute_pass_mode_switching ();

The only passes I've found so far needing this are these, with these
methods in my local copy:

class pipeline
{
public:
  /* ...snip...*/

  /* Access to two specific passes, so that the majority can be
     private.  */
  void execute_early_local_passes ();
     // ^^ used in 3 places in cgraphunit.c

  unsigned int execute_pass_mode_switching ();
     // ^^ used by i386.c

  /* ...snip...*/

private:
  /* Macros using passes.def to supply fields for the various pass
     instances; edited for clarity; the other macros have empty
     expansions.  */
#define NEXT_PASS(PASS) opt_pass *PASS
#define NEXT_PASS_NUM(PASS, NUM) opt_pass *PASS ## _ ## NUM

#include "passes.def"

};  // class pipeline

I'm sorry that this may not make sense without seeing the relevant
patches.  I'm currently blocked by gengtype issues with putting things
into a "gcc" namespace; if I don't make progress on that, I guess I can
get rid of the namespace and bootstrap and post what I've got.

Hope this is helpful.

Dave
[1] so "g" can stand for either "the global", "gcc", or "gnu" as people
prefer :)
[2]
https://raw.github.com/davidmalcolm/2013-cauldron-talk/master/2013-cauldron-talk.txt
Martin Jambor July 24, 2013, 3:16 p.m. UTC | #10
Hi,

On Tue, Jul 23, 2013 at 11:43:04AM -0400, David Malcolm wrote:
> On Tue, 2013-07-23 at 16:46 +0200, Martin Jambor wrote:
> > Hi,
> > 
> > On Mon, Jul 22, 2013 at 03:22:33PM -0400, David Malcolm wrote:
> > > On Mon, 2013-07-22 at 20:25 +0200, Martin Jambor wrote:
> > > > On Wed, Jul 17, 2013 at 09:18:22PM -0400, David Malcolm 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).
> > > > > 
> > > > 
> > > > I don't really understand what you want to achieve.  Are you sure the
> > > > benefits are worth the work necessary to implement the processing of
> > > > passes.def.in?  Especially given that we already initialize
> > > > static_pass_number at run time and copy stuff around in
> > > > make_pass_instance when it is already set.  I assume this would
> > > > somehow allow us to directly dump data of say forwprop3 as apposed to
> > > > forwprop2 to but that would require constant awareness of the sequence
> > > > number of the currently running pass, which I think is also unpleasant
> > > > and error-prone.
> > > > 
> > > > I mean, you may have perfectly legitimate reasons for doing this, I'm
> > > > just wondering whether we are perhaps over-engineering this a bit.
> > > 
> > > The main goal here is part of eliminating global variables from gcc [1],
> > > to be able to create:
> > > 
> > > class pipeline
> > > {
> > >   /* omitting various other fields for clarity */
> > > 
> > >   opt_pass *pass_warn_unused_result;
> > >   opt_pass *pass_diagnose_omp_blocks;
> > >   opt_pass *pass_diagnose_tm_blocks;
> > >   opt_pass *pass_mudflap_1;
> > >   opt_pass *pass_lower_omp;
> > >   opt_pass *pass_lower_cf;
> > >   opt_pass *pass_lower_tm;
> > >   opt_pass *pass_refactor_eh;
> > >   opt_pass *pass_lower_eh;
> > >   opt_pass *pass_build_cfg;
> > >   opt_pass *pass_warn_function_return;
> > >   opt_pass *pass_expand_omp;
> > >   opt_pass *pass_build_cgraph_edges;
> > >   opt_pass *pass_ipa_free_lang_data;
> > >   opt_pass *pass_ipa_function_and_variable_visibility;
> > >   opt_pass *pass_early_local_passes;
> > >   opt_pass *pass_fixup_cfg;
> > >   opt_pass *pass_init_datastructures;
> > >   /* etc */
> > >   opt_pass *pass_clean_state;
> > > };
> > > 
> > > without having to list all of the pass kinds again, thus reusing the
> > > pass description from passes.def.  Without the numbering, I couldn't see
> > > a good way to avoid duplicate field names in the class.  So the
> > > numbering gives us uniqueness of field names in that class (and also
> > > makes debugging slightly easier, but that's a minor side-benefit).
> > > 
> > 
> > I really think the easier debugging benefit is really very small, if
> > any.  Is there another one?  Otherwise, I wouldn't bother with
> > explicit static fields for each pass but just have a linked list of
> > them.  If we ever make the pass manager to really be a manager of some
> > sort, this will happen anyway.
> > 
> > And as far as gdb is concerned, I'd rather avoid typing:
> > 
> > p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[1]->stuff
> > p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[2]->stuff
> > p current_context->pipeline_for_Ox_except_Og->my_great_pass_with_long_name_number_2->my_array[3]->stuff
> 
> Thanks - yes - I completely agree, having spent a lot of time in gdb
> with this lately :)
> 
> Note that there is only one "pipeline" per context, and I've kept the
> existing pass struct names (meaning "pass_vrp" rather than "vrp").
> 
> BTW, you mentioned dumping in an earlier post, sorry for not clarifying
> that aspect.  I haven't changed how dumping works, and I've taken some
> care to ensure that the numbering of the pass instances isn't disturbed
> (an earlier version of my patches broke that, leading to some of the
> test suite failing).   So whatever static_pass_number the 2nd instance
> of vrp ended up with before, it will continue to end up with after my
> patches.
> 
> > and instead do
> > 
> > set $d = (my_great_pass_class *) current_context->current_pass
> > p $d->my_array[1]->stuff
> > p $d->my_array[2]->stuff
> > p $d->my_array[3]->stuff
> > 
> > Or am I missing something?  Otherwise I'd just say don't bother with awk.
> 
> To give you a flavor of what I'm aiming at, here's a transcript from gdb
> on a build with some further patches, with some comments added inline:
> 
> The global "current context" variable is simply "g", for ease of typing
> - and my hope is that eventually this will be the *only* global variable
> [1]:
> 
> (gdb) p g
> $1 = (gcc::context *) 0x15652a0
> 
> In the talk I gave at Cauldron [2], this was a (universe*), but I've
> changed my mind again, and prefer (gcc::context*) i.e. it's now a
> "context" within a "gcc" namespace.  The namespace is confusing
> gengtype, so I'm not sure about that aspect.
> 
> The pipeline of passes is simply the "passes_" field of the context;
> here's an example of tab-completion:
> 
> (gdb) p g->passes_->
> Display all 291 possibilities? (y or n)
> 
> Typing a pass name, and tab-completing to see the 8 instances of it
> (copy_prop has the most instances):
> 
> (gdb) p g->passes_->pass_copy_prop_
> pass_copy_prop_1  pass_copy_prop_2  pass_copy_prop_3  pass_copy_prop_4
> pass_copy_prop_5  pass_copy_prop_6  pass_copy_prop_7  pass_copy_prop_8  
> 
> and viewing one:
> 
> (gdb) p g->passes_->pass_copy_prop_1
> $2 = (opt_pass *) 0x1588940
> (gdb) p *g->passes_->pass_copy_prop_1
> $3 = {<pass_data> = {type = GIMPLE_PASS, name = 0xef7fe7 "copyprop",
> optinfo_flags = 0, has_gate = true, has_execute = true, tv_id =
> TV_TREE_COPY_PROP, properties_required = 40, properties_provided = 0, 
>     properties_destroyed = 0, todo_flags_start = 524288,
> todo_flags_finish = 2084}, _vptr.opt_pass = 0xef8410, sub = 0x0, next =
> 0x15889a0, static_pass_number = 30, ctxt_ = 0x15652a0}

Right,tabs might help a lot but I still think that using current_pass
is OK, especially considering the required effort.

> 
> and here's a view of the top of the struct showing some of the other
> globals that I've moved to there:
> (gdb) p *g->passes_
> $4 = {all_passes = 0x15896f0, all_small_ipa_passes = 0x1588280,
> all_lowering_passes = 0x157e000, all_regular_ipa_passes = 0x1589060,
> all_lto_gen_passes = 0x1589530, all_late_ipa_passes = 0x1589690, 
>   passes_by_id = 0x15a9df0, passes_by_id_size = 251, pass_lists =
> {0x1587590, 0x1587588, 0x1587598, 0x15875a0, 0x1587580}, ctxt_ =
> 0x15652a0, pass_warn_unused_result = 0x157e000, 
>   pass_diagnose_omp_blocks = 0x157e060, 
> (...etc)
> 
> Note that we do need access to certain specific passes from various
> places in the compiler.  For example, config/i386/i386.c invokes
> pass_mode_switching within its target-specific "vzeroupper" pass.  Hence
> it's useful to be able to store the pass and access it - so it's not
> just about debugging the pass creation.  In my local copy I'm doing this
> within the relevant place in i386.c:
> 
>    g->get_passes ().execute_pass_mode_switching ();
> 
> The only passes I've found so far needing this are these, with these
> methods in my local copy:
> 
> class pipeline
> {
> public:
>   /* ...snip...*/
> 
>   /* Access to two specific passes, so that the majority can be
>      private.  */
>   void execute_early_local_passes ();

early_local_passes are really a special list of passes rather than an
actual pass and I'd say that an interface like this is actually
preferable to what we have now.

>      // ^^ used in 3 places in cgraphunit.c
> 
>   unsigned int execute_pass_mode_switching ();
>      // ^^ used by i386.c

Well, I do not know what this is for but I remain unconvinced.  I
think that eventually someone will work on making our pass pipeline
more dynamic (in fact if you succeed with your task, it will be more
compelling than now) and that person will have to remove all the
static stuff you plan to add.  So I'd still suggest that you do not
bother with it and rather hack around these two cases separately.  The
early passes case will actually be a cleanup, not a hack.

Good luck with GC,

Martin


> 
>   /* ...snip...*/
> 
> private:
>   /* Macros using passes.def to supply fields for the various pass
>      instances; edited for clarity; the other macros have empty
>      expansions.  */
> #define NEXT_PASS(PASS) opt_pass *PASS
> #define NEXT_PASS_NUM(PASS, NUM) opt_pass *PASS ## _ ## NUM
> 
> #include "passes.def"
> 
> };  // class pipeline
> 
> I'm sorry that this may not make sense without seeing the relevant
> patches.  I'm currently blocked by gengtype issues with putting things
> into a "gcc" namespace; if I don't make progress on that, I guess I can
> get rid of the namespace and bootstrap and post what I've got.
> 
> Hope this is helpful.
> 
> Dave
> [1] so "g" can stand for either "the global", "gcc", or "gnu" as people
> prefer :)
> [2]
> https://raw.github.com/davidmalcolm/2013-cauldron-talk/master/2013-cauldron-talk.txt
> 
>
David Malcolm July 29, 2013, 3:47 p.m. UTC | #11
On Thu, 2013-07-18 at 07:56 -0700, Andrew Pinski wrote:
> On Thu, Jul 18, 2013 at 4:33 AM, David Malcolm <dmalcolm@redhat.com> wrote:
> > On Thu, 2013-07-18 at 00:08 -0700, Andrew Pinski wrote:
> >> 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.
> >
> > How would you feel about a "passes.def.in" and having that be what's in
> > svn, with some kind of preprocessing step that builds a passes.def from
> > it?  That way we get the flexibility of before, but gain the ability I'm
> > looking for to make a class holding the passes, and have easy access in
> > gdb to the various instances of the class (rather than just the last
> > instance of each that was created).
> 
> That would work and would be ok with me.
> 
> > If so, what tools are blessed for usage at build time? (I'd prefer
> > Python, but I don't think that's a build-time dep yet).
> 
> So far awk and shell and C programming are the blessed processing
> tools.  Awk in this case seems like the best for this though.  I don't
> think Python is a good solution only because it does add another build
> dependency that is not there already though I would not complain about
> it if it gets added.

FWIW I implemented this approach, and the result can be seen in:
  http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01263.html
in the patch series I sent for review on Friday.

Thanks
Dave
David Malcolm July 29, 2013, 7:32 p.m. UTC | #12
On Thu, 2013-07-18 at 10:25 -0600, Jeff Law wrote:
> On 07/17/2013 07:18 PM, David Malcolm 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.
> So this means we have to track down the instance number if we add a 
> duplicate pass in the pipeline.  I can see positives and negatives of 
> doing that.  I'll go along as I'm a proponent of the goal of having the 
> passes be a first class object.
> 
> Ok for the trunk.

Thanks.  Out of interest, what do you see as the positives and
negatives?

Given Andrew's objections to managing pass instance numbers by hand, I
went with an alternate approach, and wrote an awk script to generate a
pass-instances.def from passes.def at build time:
  http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01263.html
in the patch series I sent for review on Friday.

This approach would give us the uniqueness I was looking for (so that
the pass_manager class can have fields tracking all the pass instances),
avoids having to maintain the numbers by hand, and also gives us an easy
way of e.g. seeing how many pass_copy_prop instances we have, and what
their instance numbers are (see the example of the result at:
http://dmalcolm.fedorapeople.org/gcc/2013-07-25/pass-instances.def )

Dave
Jeff Law July 29, 2013, 7:59 p.m. UTC | #13
On 07/29/2013 01:32 PM, David Malcolm wrote:
> On Thu, 2013-07-18 at 10:25 -0600, Jeff Law wrote:
>> On 07/17/2013 07:18 PM, David Malcolm 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.
>> So this means we have to track down the instance number if we add a
>> duplicate pass in the pipeline.  I can see positives and negatives of
>> doing that.  I'll go along as I'm a proponent of the goal of having the
>> passes be a first class object.
>>
>> Ok for the trunk.
>
> Thanks.  Out of interest, what do you see as the positives and
> negatives?
Positives being the uniqueness (which you need).  Negatives are 
maintenance as we add passes, in particular if a pass is run more than once.

>
> Given Andrew's objections to managing pass instance numbers by hand, I
> went with an alternate approach, and wrote an awk script to generate a
> pass-instances.def from passes.def at build time:
>    http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01263.html
> in the patch series I sent for review on Friday.
Which is even better.

jeff
diff mbox

Patch

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);