* [PATCH 0/4] Move pass-creation logic into a passes.def file @ 2013-07-18 1:18 David Malcolm 2013-07-18 1:18 ` [PATCH 4/4] Add contrib/check_passes.py script David Malcolm ` (4 more replies) 0 siblings, 5 replies; 25+ messages in thread From: David Malcolm @ 2013-07-18 1:18 UTC (permalink / raw) To: gcc-patches; +Cc: David Malcolm The following patch series moves the logic for creating the pipeline of optimization passes out from passes.c and into a new passes.def file (patches 1 and 2). It then explicitly numbers those passes that have multiple instances, by using a NEXT_PASS_NUM macro in place of NEXT_PASS (patch 3) The motivation for this is subsequent work towards removing global variables from GCC's internals: by numbering the instances it becomes possible to create a "class pipeline" and have the fields be declared via suitable use of passes.def. See: http://dmalcolm.fedorapeople.org/gcc/global-state/new-classes.html#pass-classes The final patch in the sequence adds a script which sanity-checks passes.def, and prints some stats about the passes. You can see output from the script at: http://dmalcolm.fedorapeople.org/gcc/2013-07-17/pass-stats.txt Specifically, it lists single-instanced passes, then all multi-instance passes, giving the number of instances of each (alphabetically within each list). I've successfully bootstrapped and tested the sequence of patches on x86_64-unknown-linux-gnu: all testcases show the same results as an unpatched build (relative to r201011). OK to commit these to trunk? David Malcolm (4): Introduce macros when constructing the tree of passes Move the construction of the pass hierarchy into a new passes.def file. Introduce NEXT_PASS_NUM macro Add contrib/check_passes.py script contrib/check_passes.py | 58 +++++++ gcc/Makefile.in | 2 +- gcc/passes.c | 401 ++--------------------------------------------- gcc/passes.def | 406 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 481 insertions(+), 386 deletions(-) create mode 100644 contrib/check_passes.py create mode 100644 gcc/passes.def -- 1.7.11.7 ^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 4/4] Add contrib/check_passes.py script 2013-07-18 1:18 [PATCH 0/4] Move pass-creation logic into a passes.def file David Malcolm @ 2013-07-18 1:18 ` David Malcolm 2013-07-18 16:29 ` Jeff Law 2013-07-18 1:18 ` [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file David Malcolm ` (3 subsequent siblings) 4 siblings, 1 reply; 25+ messages in thread From: David Malcolm @ 2013-07-18 1:18 UTC (permalink / raw) To: gcc-patches; +Cc: David Malcolm contrib/ * check_passes.py: New. --- contrib/check_passes.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 contrib/check_passes.py diff --git a/contrib/check_passes.py b/contrib/check_passes.py new file mode 100755 index 0000000..34d18b7 --- /dev/null +++ b/contrib/check_passes.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# Script to verify passes.def and print statistics about it +# Requires Python 2.7+ (for collections.Counter) + +from collections import Counter +import re +import sys + +num_errors = 0 + +def validate(filename): + with open(filename) as f: + linenum = 1 + def error(msg): + print('%s:%i: %s' % (filename, linenum, msg)) + global num_errors + num_errors += 1 + singles = set() + count = Counter() + for line in f: + m = re.match(r'^\s+NEXT_PASS \((.+)\);$', line) + if m: + name = m.group(1) + if ',' in name: + error('malformed NEXT_PASS: %s' % name) + if name in count or name in singles: + error('duplicate pass: %s' % name) + singles.add(name) + m = re.match(r'^\s+NEXT_PASS_NUM \((.+), (.+)\);$', line) + if m: + name, num = m.group(1), int(m.group(2)) + count[name] += 1 + if count[name] != num: + error('bad index for %s' % name) + linenum += 1 + + for name in count: + if count[name] == 1: + error('only one instance of %s' % name) + + def line(): + print('-' * 72) + def heading(text): + line() + print(text) + line() + + heading('Single-instanced passes (%i)' % len(singles)) + for name in sorted(singles): + print(name) + + heading('Multi-instanced passes (%i)' % len(count)) + for name in sorted(count): + print('%s %i' % (name, count[name])) + +validate('../gcc/passes.def') +if num_errors > 0: + sys.exit(1) -- 1.7.11.7 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 4/4] Add contrib/check_passes.py script 2013-07-18 1:18 ` [PATCH 4/4] Add contrib/check_passes.py script David Malcolm @ 2013-07-18 16:29 ` Jeff Law 0 siblings, 0 replies; 25+ messages in thread From: Jeff Law @ 2013-07-18 16:29 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches On 07/17/2013 07:18 PM, David Malcolm wrote: > contrib/ > > * check_passes.py: New. OK for the trunk. jeff ^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file. 2013-07-18 1:18 [PATCH 0/4] Move pass-creation logic into a passes.def file David Malcolm 2013-07-18 1:18 ` [PATCH 4/4] Add contrib/check_passes.py script David Malcolm @ 2013-07-18 1:18 ` David Malcolm 2013-07-18 16:25 ` Jeff Law 2013-07-18 16:25 ` Jakub Jelinek 2013-07-18 1:18 ` [PATCH 1/4] Introduce macros when constructing the tree of passes David Malcolm ` (2 subsequent siblings) 4 siblings, 2 replies; 25+ messages in thread From: David Malcolm @ 2013-07-18 1:18 UTC (permalink / raw) To: gcc-patches; +Cc: David Malcolm gcc/ * passes.def: New. * passes.c (init_optimization_passes): Move the construction of the pass hierarchy into a new passes.def file. * Makefile.in (passes.o): Add dependency on passes.def. --- gcc/Makefile.in | 2 +- gcc/passes.c | 378 +--------------------------------------------------- gcc/passes.def | 405 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 407 insertions(+), 378 deletions(-) create mode 100644 gcc/passes.def diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 5bc0f0b..966c38a 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -2743,7 +2743,7 @@ passes.o : passes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \ hosthooks.h $(CGRAPH_H) $(COVERAGE_H) $(TREE_PASS_H) $(TREE_DUMP_H) \ $(GGC_H) $(OPTS_H) $(TREE_FLOW_H) $(TREE_INLINE_H) \ gt-passes.h $(DF_H) $(PREDICT_H) $(LTO_STREAMER_H) \ - $(PLUGIN_H) $(IPA_UTILS_H) + $(PLUGIN_H) $(IPA_UTILS_H) passes.def plugin.o : plugin.c $(PLUGIN_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h \ $(HASH_TABLE_H) $(DIAGNOSTIC_CORE_H) $(TREE_H) $(TREE_PASS_H) \ diff --git a/gcc/passes.c b/gcc/passes.c index 6ca4134..94fb586 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -1297,383 +1297,7 @@ init_optimization_passes (void) #define TERMINATE_PASS_LIST() \ *p = NULL; - /* All passes needed to lower the function into shape optimizers can - operate on. These passes are always run first on the function, but - backend might produce already lowered functions that are not processed - by these passes. */ - INSERT_PASSES_AFTER (all_lowering_passes) - NEXT_PASS (pass_warn_unused_result); - NEXT_PASS (pass_diagnose_omp_blocks); - NEXT_PASS (pass_diagnose_tm_blocks); - NEXT_PASS (pass_mudflap_1); - NEXT_PASS (pass_lower_omp); - NEXT_PASS (pass_lower_cf); - NEXT_PASS (pass_lower_tm); - NEXT_PASS (pass_refactor_eh); - NEXT_PASS (pass_lower_eh); - NEXT_PASS (pass_build_cfg); - NEXT_PASS (pass_warn_function_return); - NEXT_PASS (pass_expand_omp); - NEXT_PASS (pass_build_cgraph_edges); - TERMINATE_PASS_LIST () - - /* Interprocedural optimization passes. */ - INSERT_PASSES_AFTER (all_small_ipa_passes) - NEXT_PASS (pass_ipa_free_lang_data); - 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 (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 (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); - /* After CCP we rewrite no longer addressed locals into SSA - form if possible. */ - NEXT_PASS (pass_forwprop); - /* 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 (pass_early_ipa_sra); - NEXT_PASS (pass_tail_recursion); - NEXT_PASS (pass_convert_switch); - NEXT_PASS (pass_cleanup_eh); - NEXT_PASS (pass_profile); - NEXT_PASS (pass_local_pure_const); - /* 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); - POP_INSERT_PASSES () - NEXT_PASS (pass_ipa_free_inline_summary); - NEXT_PASS (pass_ipa_tree_profile); - PUSH_INSERT_PASSES_WITHIN (pass_ipa_tree_profile) - NEXT_PASS (pass_feedback_split_functions); - POP_INSERT_PASSES () - NEXT_PASS (pass_ipa_increase_alignment); - NEXT_PASS (pass_ipa_tm); - NEXT_PASS (pass_ipa_lower_emutls); - TERMINATE_PASS_LIST () - - INSERT_PASSES_AFTER (all_regular_ipa_passes) - NEXT_PASS (pass_ipa_whole_program_visibility); - NEXT_PASS (pass_ipa_profile); - NEXT_PASS (pass_ipa_cp); - NEXT_PASS (pass_ipa_cdtor_merge); - NEXT_PASS (pass_ipa_inline); - NEXT_PASS (pass_ipa_pure_const); - NEXT_PASS (pass_ipa_reference); - TERMINATE_PASS_LIST () - - INSERT_PASSES_AFTER (all_lto_gen_passes) - NEXT_PASS (pass_ipa_lto_gimple_out); - NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */ - TERMINATE_PASS_LIST () - - /* Simple IPA passes executed after the regular passes. In WHOPR mode the - passes are executed after partitioning and thus see just parts of the - compiled unit. */ - INSERT_PASSES_AFTER (all_late_ipa_passes) - NEXT_PASS (pass_ipa_pta); - TERMINATE_PASS_LIST () - - /* 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 (pass_lower_eh_dispatch); - NEXT_PASS (pass_all_optimizations); - PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations) - NEXT_PASS (pass_remove_cgraph_callee_edges); - /* 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 (pass_complete_unrolli); - NEXT_PASS (pass_ccp); - /* After CCP we rewrite no longer addressed locals into SSA - form if possible. */ - NEXT_PASS (pass_phiprop); - NEXT_PASS (pass_forwprop); - /* 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 (pass_call_cdce); - NEXT_PASS (pass_cselim); - NEXT_PASS (pass_tree_ifcombine); - NEXT_PASS (pass_phiopt); - NEXT_PASS (pass_tail_recursion); - NEXT_PASS (pass_ch); - NEXT_PASS (pass_stdarg); - NEXT_PASS (pass_lower_complex); - NEXT_PASS (pass_sra); - NEXT_PASS (pass_rename_ssa_copies); - /* 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); - /* 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 (pass_strlen); - NEXT_PASS (pass_ccp); - /* After CCP we rewrite no longer addressed locals into SSA - form if possible. */ - NEXT_PASS (pass_copy_prop); - 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 (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 (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 (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); - 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); - 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 (pass_tree_loop_done); - POP_INSERT_PASSES () - NEXT_PASS (pass_lower_vector_ssa); - NEXT_PASS (pass_cse_reciprocals); - NEXT_PASS (pass_reassoc); - NEXT_PASS (pass_strength_reduction); - NEXT_PASS (pass_dominator); - /* 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 (pass_tracer); - - /* FIXME: If DCE is not run before checking for uninitialized uses, - we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c). - However, this also causes us to misdiagnose cases that should be - real warnings (e.g., testsuite/gcc.dg/pr18501.c). - - To fix the false positives in uninit-5.c, we would have to - 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 (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); - 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); - /* Lower remaining pieces of GIMPLE. */ - NEXT_PASS (pass_lower_complex); - NEXT_PASS (pass_lower_vector_ssa); - /* Perform simple scalar cleanup which is constant/copy propagation. */ - NEXT_PASS (pass_ccp); - NEXT_PASS (pass_object_sizes); - /* Fold remaining builtins. */ - NEXT_PASS (pass_fold_builtins); - /* 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); - /* ??? 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); - POP_INSERT_PASSES () - NEXT_PASS (pass_tm_init); - PUSH_INSERT_PASSES_WITHIN (pass_tm_init) - NEXT_PASS (pass_tm_mark); - NEXT_PASS (pass_tm_memopt); - NEXT_PASS (pass_tm_edges); - POP_INSERT_PASSES () - NEXT_PASS (pass_lower_vector); - NEXT_PASS (pass_lower_complex_O0); - NEXT_PASS (pass_asan_O0); - NEXT_PASS (pass_tsan_O0); - NEXT_PASS (pass_cleanup_eh); - NEXT_PASS (pass_lower_resx); - NEXT_PASS (pass_nrv); - NEXT_PASS (pass_mudflap_2); - NEXT_PASS (pass_cleanup_cfg_post_optimizing); - NEXT_PASS (pass_warn_function_noreturn); - - NEXT_PASS (pass_expand); - - NEXT_PASS (pass_rest_of_compilation); - PUSH_INSERT_PASSES_WITHIN (pass_rest_of_compilation) - NEXT_PASS (pass_instantiate_virtual_regs); - NEXT_PASS (pass_into_cfg_layout_mode); - NEXT_PASS (pass_jump); - NEXT_PASS (pass_lower_subreg); - NEXT_PASS (pass_df_initialize_opt); - NEXT_PASS (pass_cse); - NEXT_PASS (pass_rtl_fwprop); - NEXT_PASS (pass_rtl_cprop); - NEXT_PASS (pass_rtl_pre); - NEXT_PASS (pass_rtl_hoist); - NEXT_PASS (pass_rtl_cprop); - NEXT_PASS (pass_rtl_store_motion); - NEXT_PASS (pass_cse_after_global_opts); - NEXT_PASS (pass_rtl_ifcvt); - NEXT_PASS (pass_reginfo_init); - /* Perform loop optimizations. It might be better to do them a bit - sooner, but we want the profile feedback to work more - efficiently. */ - NEXT_PASS (pass_loop2); - PUSH_INSERT_PASSES_WITHIN (pass_loop2) - NEXT_PASS (pass_rtl_loop_init); - NEXT_PASS (pass_rtl_move_loop_invariants); - NEXT_PASS (pass_rtl_unswitch); - NEXT_PASS (pass_rtl_unroll_and_peel_loops); - NEXT_PASS (pass_rtl_doloop); - NEXT_PASS (pass_rtl_loop_done); - TERMINATE_PASS_LIST () - POP_INSERT_PASSES () - NEXT_PASS (pass_web); - NEXT_PASS (pass_rtl_cprop); - NEXT_PASS (pass_cse2); - NEXT_PASS (pass_rtl_dse1); - NEXT_PASS (pass_rtl_fwprop_addr); - NEXT_PASS (pass_inc_dec); - NEXT_PASS (pass_initialize_regs); - NEXT_PASS (pass_ud_rtl_dce); - NEXT_PASS (pass_combine); - NEXT_PASS (pass_if_after_combine); - NEXT_PASS (pass_partition_blocks); - NEXT_PASS (pass_regmove); - NEXT_PASS (pass_outof_cfg_layout_mode); - NEXT_PASS (pass_split_all_insns); - NEXT_PASS (pass_lower_subreg2); - NEXT_PASS (pass_df_initialize_no_opt); - NEXT_PASS (pass_stack_ptr_mod); - NEXT_PASS (pass_mode_switching); - NEXT_PASS (pass_match_asm_constraints); - NEXT_PASS (pass_sms); - NEXT_PASS (pass_sched); - NEXT_PASS (pass_ira); - NEXT_PASS (pass_reload); - NEXT_PASS (pass_postreload); - PUSH_INSERT_PASSES_WITHIN (pass_postreload) - NEXT_PASS (pass_postreload_cse); - NEXT_PASS (pass_gcse2); - NEXT_PASS (pass_split_after_reload); - NEXT_PASS (pass_ree); - NEXT_PASS (pass_compare_elim_after_reload); - NEXT_PASS (pass_branch_target_load_optimize1); - NEXT_PASS (pass_thread_prologue_and_epilogue); - NEXT_PASS (pass_rtl_dse2); - NEXT_PASS (pass_stack_adjustments); - NEXT_PASS (pass_jump2); - NEXT_PASS (pass_peephole2); - NEXT_PASS (pass_if_after_reload); - NEXT_PASS (pass_regrename); - NEXT_PASS (pass_cprop_hardreg); - NEXT_PASS (pass_fast_rtl_dce); - NEXT_PASS (pass_reorder_blocks); - NEXT_PASS (pass_branch_target_load_optimize2); - NEXT_PASS (pass_leaf_regs); - NEXT_PASS (pass_split_before_sched2); - NEXT_PASS (pass_sched2); - NEXT_PASS (pass_stack_regs); - PUSH_INSERT_PASSES_WITHIN (pass_stack_regs) - NEXT_PASS (pass_split_before_regstack); - NEXT_PASS (pass_stack_regs_run); - POP_INSERT_PASSES () - NEXT_PASS (pass_compute_alignments); - NEXT_PASS (pass_duplicate_computed_gotos); - NEXT_PASS (pass_variable_tracking); - NEXT_PASS (pass_free_cfg); - NEXT_PASS (pass_machine_reorg); - NEXT_PASS (pass_cleanup_barriers); - NEXT_PASS (pass_delay_slots); - NEXT_PASS (pass_split_for_shorten_branches); - NEXT_PASS (pass_convert_to_eh_region_ranges); - NEXT_PASS (pass_shorten_branches); - NEXT_PASS (pass_set_nothrow_function_flags); - NEXT_PASS (pass_dwarf2_frame); - NEXT_PASS (pass_final); - POP_INSERT_PASSES () - NEXT_PASS (pass_df_finish); - POP_INSERT_PASSES () - NEXT_PASS (pass_clean_state); - TERMINATE_PASS_LIST () +#include "passes.def" #undef INSERT_PASSES_AFTER #undef PUSH_INSERT_PASSES_WITHIN diff --git a/gcc/passes.def b/gcc/passes.def new file mode 100644 index 0000000..fa03d16 --- /dev/null +++ b/gcc/passes.def @@ -0,0 +1,405 @@ +/* Description of pass structure + Copyright (C) 2013 Free Software Foundation, Inc. + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 3, or (at your option) any later +version. + +GCC is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +<http://www.gnu.org/licenses/>. */ + +/* + Macros that should be defined when using this file: + INSERT_PASSES_AFTER (PASS) + PUSH_INSERT_PASSES_WITHIN (PASS) + POP_INSERT_PASSES () + NEXT_PASS (PASS) + TERMINATE_PASS_LIST () + */ + + /* All passes needed to lower the function into shape optimizers can + operate on. These passes are always run first on the function, but + backend might produce already lowered functions that are not processed + by these passes. */ + INSERT_PASSES_AFTER (all_lowering_passes) + NEXT_PASS (pass_warn_unused_result); + NEXT_PASS (pass_diagnose_omp_blocks); + NEXT_PASS (pass_diagnose_tm_blocks); + NEXT_PASS (pass_mudflap_1); + NEXT_PASS (pass_lower_omp); + NEXT_PASS (pass_lower_cf); + NEXT_PASS (pass_lower_tm); + NEXT_PASS (pass_refactor_eh); + NEXT_PASS (pass_lower_eh); + NEXT_PASS (pass_build_cfg); + NEXT_PASS (pass_warn_function_return); + NEXT_PASS (pass_expand_omp); + NEXT_PASS (pass_build_cgraph_edges); + TERMINATE_PASS_LIST () + + /* Interprocedural optimization passes. */ + INSERT_PASSES_AFTER (all_small_ipa_passes) + NEXT_PASS (pass_ipa_free_lang_data); + 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 (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 (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); + /* After CCP we rewrite no longer addressed locals into SSA + form if possible. */ + NEXT_PASS (pass_forwprop); + /* 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 (pass_early_ipa_sra); + NEXT_PASS (pass_tail_recursion); + NEXT_PASS (pass_convert_switch); + NEXT_PASS (pass_cleanup_eh); + NEXT_PASS (pass_profile); + NEXT_PASS (pass_local_pure_const); + /* 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); + POP_INSERT_PASSES () + NEXT_PASS (pass_ipa_free_inline_summary); + NEXT_PASS (pass_ipa_tree_profile); + PUSH_INSERT_PASSES_WITHIN (pass_ipa_tree_profile) + NEXT_PASS (pass_feedback_split_functions); + POP_INSERT_PASSES () + NEXT_PASS (pass_ipa_increase_alignment); + NEXT_PASS (pass_ipa_tm); + NEXT_PASS (pass_ipa_lower_emutls); + TERMINATE_PASS_LIST () + + INSERT_PASSES_AFTER (all_regular_ipa_passes) + NEXT_PASS (pass_ipa_whole_program_visibility); + NEXT_PASS (pass_ipa_profile); + NEXT_PASS (pass_ipa_cp); + NEXT_PASS (pass_ipa_cdtor_merge); + NEXT_PASS (pass_ipa_inline); + NEXT_PASS (pass_ipa_pure_const); + NEXT_PASS (pass_ipa_reference); + TERMINATE_PASS_LIST () + + INSERT_PASSES_AFTER (all_lto_gen_passes) + NEXT_PASS (pass_ipa_lto_gimple_out); + NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */ + TERMINATE_PASS_LIST () + + /* Simple IPA passes executed after the regular passes. In WHOPR mode the + passes are executed after partitioning and thus see just parts of the + compiled unit. */ + INSERT_PASSES_AFTER (all_late_ipa_passes) + NEXT_PASS (pass_ipa_pta); + TERMINATE_PASS_LIST () + + /* 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 (pass_lower_eh_dispatch); + NEXT_PASS (pass_all_optimizations); + PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations) + NEXT_PASS (pass_remove_cgraph_callee_edges); + /* 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 (pass_complete_unrolli); + NEXT_PASS (pass_ccp); + /* After CCP we rewrite no longer addressed locals into SSA + form if possible. */ + NEXT_PASS (pass_phiprop); + NEXT_PASS (pass_forwprop); + /* 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 (pass_call_cdce); + NEXT_PASS (pass_cselim); + NEXT_PASS (pass_tree_ifcombine); + NEXT_PASS (pass_phiopt); + NEXT_PASS (pass_tail_recursion); + NEXT_PASS (pass_ch); + NEXT_PASS (pass_stdarg); + NEXT_PASS (pass_lower_complex); + NEXT_PASS (pass_sra); + NEXT_PASS (pass_rename_ssa_copies); + /* 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); + /* 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 (pass_strlen); + NEXT_PASS (pass_ccp); + /* After CCP we rewrite no longer addressed locals into SSA + form if possible. */ + NEXT_PASS (pass_copy_prop); + 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 (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 (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 (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); + 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); + 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 (pass_tree_loop_done); + POP_INSERT_PASSES () + NEXT_PASS (pass_lower_vector_ssa); + NEXT_PASS (pass_cse_reciprocals); + NEXT_PASS (pass_reassoc); + NEXT_PASS (pass_strength_reduction); + NEXT_PASS (pass_dominator); + /* 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 (pass_tracer); + + /* FIXME: If DCE is not run before checking for uninitialized uses, + we may get false warnings (e.g., testsuite/gcc.dg/uninit-5.c). + However, this also causes us to misdiagnose cases that should be + real warnings (e.g., testsuite/gcc.dg/pr18501.c). + + To fix the false positives in uninit-5.c, we would have to + 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 (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); + 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); + /* Lower remaining pieces of GIMPLE. */ + NEXT_PASS (pass_lower_complex); + NEXT_PASS (pass_lower_vector_ssa); + /* Perform simple scalar cleanup which is constant/copy propagation. */ + NEXT_PASS (pass_ccp); + NEXT_PASS (pass_object_sizes); + /* Fold remaining builtins. */ + NEXT_PASS (pass_fold_builtins); + /* 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); + /* ??? 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); + POP_INSERT_PASSES () + NEXT_PASS (pass_tm_init); + PUSH_INSERT_PASSES_WITHIN (pass_tm_init) + NEXT_PASS (pass_tm_mark); + NEXT_PASS (pass_tm_memopt); + NEXT_PASS (pass_tm_edges); + POP_INSERT_PASSES () + NEXT_PASS (pass_lower_vector); + NEXT_PASS (pass_lower_complex_O0); + NEXT_PASS (pass_asan_O0); + NEXT_PASS (pass_tsan_O0); + NEXT_PASS (pass_cleanup_eh); + NEXT_PASS (pass_lower_resx); + NEXT_PASS (pass_nrv); + NEXT_PASS (pass_mudflap_2); + NEXT_PASS (pass_cleanup_cfg_post_optimizing); + NEXT_PASS (pass_warn_function_noreturn); + + NEXT_PASS (pass_expand); + + NEXT_PASS (pass_rest_of_compilation); + PUSH_INSERT_PASSES_WITHIN (pass_rest_of_compilation) + NEXT_PASS (pass_instantiate_virtual_regs); + NEXT_PASS (pass_into_cfg_layout_mode); + NEXT_PASS (pass_jump); + NEXT_PASS (pass_lower_subreg); + NEXT_PASS (pass_df_initialize_opt); + NEXT_PASS (pass_cse); + NEXT_PASS (pass_rtl_fwprop); + NEXT_PASS (pass_rtl_cprop); + NEXT_PASS (pass_rtl_pre); + NEXT_PASS (pass_rtl_hoist); + NEXT_PASS (pass_rtl_cprop); + NEXT_PASS (pass_rtl_store_motion); + NEXT_PASS (pass_cse_after_global_opts); + NEXT_PASS (pass_rtl_ifcvt); + NEXT_PASS (pass_reginfo_init); + /* Perform loop optimizations. It might be better to do them a bit + sooner, but we want the profile feedback to work more + efficiently. */ + NEXT_PASS (pass_loop2); + PUSH_INSERT_PASSES_WITHIN (pass_loop2) + NEXT_PASS (pass_rtl_loop_init); + NEXT_PASS (pass_rtl_move_loop_invariants); + NEXT_PASS (pass_rtl_unswitch); + NEXT_PASS (pass_rtl_unroll_and_peel_loops); + NEXT_PASS (pass_rtl_doloop); + NEXT_PASS (pass_rtl_loop_done); + TERMINATE_PASS_LIST () + POP_INSERT_PASSES () + NEXT_PASS (pass_web); + NEXT_PASS (pass_rtl_cprop); + NEXT_PASS (pass_cse2); + NEXT_PASS (pass_rtl_dse1); + NEXT_PASS (pass_rtl_fwprop_addr); + NEXT_PASS (pass_inc_dec); + NEXT_PASS (pass_initialize_regs); + NEXT_PASS (pass_ud_rtl_dce); + NEXT_PASS (pass_combine); + NEXT_PASS (pass_if_after_combine); + NEXT_PASS (pass_partition_blocks); + NEXT_PASS (pass_regmove); + NEXT_PASS (pass_outof_cfg_layout_mode); + NEXT_PASS (pass_split_all_insns); + NEXT_PASS (pass_lower_subreg2); + NEXT_PASS (pass_df_initialize_no_opt); + NEXT_PASS (pass_stack_ptr_mod); + NEXT_PASS (pass_mode_switching); + NEXT_PASS (pass_match_asm_constraints); + NEXT_PASS (pass_sms); + NEXT_PASS (pass_sched); + NEXT_PASS (pass_ira); + NEXT_PASS (pass_reload); + NEXT_PASS (pass_postreload); + PUSH_INSERT_PASSES_WITHIN (pass_postreload) + NEXT_PASS (pass_postreload_cse); + NEXT_PASS (pass_gcse2); + NEXT_PASS (pass_split_after_reload); + NEXT_PASS (pass_ree); + NEXT_PASS (pass_compare_elim_after_reload); + NEXT_PASS (pass_branch_target_load_optimize1); + NEXT_PASS (pass_thread_prologue_and_epilogue); + NEXT_PASS (pass_rtl_dse2); + NEXT_PASS (pass_stack_adjustments); + NEXT_PASS (pass_jump2); + NEXT_PASS (pass_peephole2); + NEXT_PASS (pass_if_after_reload); + NEXT_PASS (pass_regrename); + NEXT_PASS (pass_cprop_hardreg); + NEXT_PASS (pass_fast_rtl_dce); + NEXT_PASS (pass_reorder_blocks); + NEXT_PASS (pass_branch_target_load_optimize2); + NEXT_PASS (pass_leaf_regs); + NEXT_PASS (pass_split_before_sched2); + NEXT_PASS (pass_sched2); + NEXT_PASS (pass_stack_regs); + PUSH_INSERT_PASSES_WITHIN (pass_stack_regs) + NEXT_PASS (pass_split_before_regstack); + NEXT_PASS (pass_stack_regs_run); + POP_INSERT_PASSES () + NEXT_PASS (pass_compute_alignments); + NEXT_PASS (pass_duplicate_computed_gotos); + NEXT_PASS (pass_variable_tracking); + NEXT_PASS (pass_free_cfg); + NEXT_PASS (pass_machine_reorg); + NEXT_PASS (pass_cleanup_barriers); + NEXT_PASS (pass_delay_slots); + NEXT_PASS (pass_split_for_shorten_branches); + NEXT_PASS (pass_convert_to_eh_region_ranges); + NEXT_PASS (pass_shorten_branches); + NEXT_PASS (pass_set_nothrow_function_flags); + NEXT_PASS (pass_dwarf2_frame); + NEXT_PASS (pass_final); + POP_INSERT_PASSES () + NEXT_PASS (pass_df_finish); + POP_INSERT_PASSES () + NEXT_PASS (pass_clean_state); + TERMINATE_PASS_LIST () -- 1.7.11.7 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file. 2013-07-18 1:18 ` [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file David Malcolm @ 2013-07-18 16:25 ` Jeff Law 2013-07-18 19:34 ` David Malcolm 2013-07-18 16:25 ` Jakub Jelinek 1 sibling, 1 reply; 25+ messages in thread From: Jeff Law @ 2013-07-18 16:25 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches On 07/17/2013 07:18 PM, David Malcolm wrote: > gcc/ > * passes.def: New. > > * passes.c (init_optimization_passes): Move the construction of > the pass hierarchy into a new passes.def file. > > * Makefile.in (passes.o): Add dependency on passes.def. OK for the trunk. I'm assuming you just cut-n-pasted the bits from passes.c into passes.def without changing the ordering/nesting. If that's not the case, speak up. Jeff ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file. 2013-07-18 16:25 ` Jeff Law @ 2013-07-18 19:34 ` David Malcolm 0 siblings, 0 replies; 25+ messages in thread From: David Malcolm @ 2013-07-18 19:34 UTC (permalink / raw) To: Jeff Law; +Cc: gcc-patches On Thu, 2013-07-18 at 10:21 -0600, Jeff Law wrote: > On 07/17/2013 07:18 PM, David Malcolm wrote: > > gcc/ > > * passes.def: New. > > > > * passes.c (init_optimization_passes): Move the construction of > > the pass hierarchy into a new passes.def file. > > > > * Makefile.in (passes.o): Add dependency on passes.def. > OK for the trunk. > > I'm assuming you just cut-n-pasted the bits from passes.c into > passes.def without changing the ordering/nesting. If that's not the > case, speak up. Yes; sorry for not spelling that out more clearly. I double-checked that passes.def was indeed a direct copy of the appropriate fragment of passes.c, fixed up the copyright header as per Jakub's email, and smoke-tested that it still compiles after the copyright header edit. I've committed the result to svn trunk as r201038. (I'll hold off on the rest for now as I've only got a few hours connectivity before being about to be offline for a few days) Thanks Dave ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file. 2013-07-18 1:18 ` [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file David Malcolm 2013-07-18 16:25 ` Jeff Law @ 2013-07-18 16:25 ` Jakub Jelinek 1 sibling, 0 replies; 25+ messages in thread From: Jakub Jelinek @ 2013-07-18 16:25 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches On Wed, Jul 17, 2013 at 09:18:21PM -0400, David Malcolm wrote: > --- /dev/null > +++ b/gcc/passes.def > @@ -0,0 +1,405 @@ > +/* Description of pass structure > + Copyright (C) 2013 Free Software Foundation, Inc. Shouldn't this be 1987-2013 instead? I mean, it isn't really a new file, the content comes from passes.c whose stuff dates up to 1987. Jakub ^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 1/4] Introduce macros when constructing the tree of passes 2013-07-18 1:18 [PATCH 0/4] Move pass-creation logic into a passes.def file David Malcolm 2013-07-18 1:18 ` [PATCH 4/4] Add contrib/check_passes.py script David Malcolm 2013-07-18 1:18 ` [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file David Malcolm @ 2013-07-18 1:18 ` David Malcolm 2013-07-18 16:21 ` Jeff Law 2013-07-18 1:32 ` [PATCH 3/4] Introduce NEXT_PASS_NUM macro David Malcolm 2013-07-18 7:26 ` [PATCH 0/4] Move pass-creation logic into a passes.def file Andrew Pinski 4 siblings, 1 reply; 25+ messages in thread From: David Malcolm @ 2013-07-18 1:18 UTC (permalink / raw) To: gcc-patches; +Cc: David Malcolm gcc/ * passes.c (init_optimization_passes): Introduce macros for constructing the tree of passes (INSERT_PASSES_AFTER, PUSH_INSERT_PASSES_WITHIN, POP_INSERT_PASSES, TERMINATE_PASS_LIST). --- gcc/passes.c | 108 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 56 insertions(+), 52 deletions(-) diff --git a/gcc/passes.c b/gcc/passes.c index 761f030..6ca4134 100644 --- a/gcc/passes.c +++ b/gcc/passes.c @@ -1282,13 +1282,26 @@ init_optimization_passes (void) { struct opt_pass **p; +#define INSERT_PASSES_AFTER(PASS) \ + p = &(PASS); + +#define PUSH_INSERT_PASSES_WITHIN(PASS) \ + { \ + struct opt_pass **p = &(PASS).pass.sub; + +#define POP_INSERT_PASSES() \ + } + #define NEXT_PASS(PASS) (p = next_pass_1 (p, &((PASS).pass))) +#define TERMINATE_PASS_LIST() \ + *p = NULL; + /* All passes needed to lower the function into shape optimizers can operate on. These passes are always run first on the function, but backend might produce already lowered functions that are not processed by these passes. */ - p = &all_lowering_passes; + INSERT_PASSES_AFTER (all_lowering_passes) NEXT_PASS (pass_warn_unused_result); NEXT_PASS (pass_diagnose_omp_blocks); NEXT_PASS (pass_diagnose_tm_blocks); @@ -1302,15 +1315,14 @@ init_optimization_passes (void) NEXT_PASS (pass_warn_function_return); NEXT_PASS (pass_expand_omp); NEXT_PASS (pass_build_cgraph_edges); - *p = NULL; + TERMINATE_PASS_LIST () /* Interprocedural optimization passes. */ - p = &all_small_ipa_passes; + INSERT_PASSES_AFTER (all_small_ipa_passes) NEXT_PASS (pass_ipa_free_lang_data); NEXT_PASS (pass_ipa_function_and_variable_visibility); NEXT_PASS (pass_early_local_passes); - { - struct opt_pass **p = &pass_early_local_passes.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_early_local_passes) NEXT_PASS (pass_fixup_cfg); NEXT_PASS (pass_init_datastructures); @@ -1320,8 +1332,7 @@ init_optimization_passes (void) NEXT_PASS (pass_inline_parameters); NEXT_PASS (pass_early_inline); NEXT_PASS (pass_all_early_optimizations); - { - struct opt_pass **p = &pass_all_early_optimizations.pass.sub; + 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); @@ -1346,23 +1357,22 @@ init_optimization_passes (void) 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); - } + POP_INSERT_PASSES () NEXT_PASS (pass_ipa_free_inline_summary); NEXT_PASS (pass_ipa_tree_profile); - { - struct opt_pass **p = &pass_ipa_tree_profile.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_ipa_tree_profile) NEXT_PASS (pass_feedback_split_functions); - } + POP_INSERT_PASSES () NEXT_PASS (pass_ipa_increase_alignment); NEXT_PASS (pass_ipa_tm); NEXT_PASS (pass_ipa_lower_emutls); - *p = NULL; + TERMINATE_PASS_LIST () - p = &all_regular_ipa_passes; + INSERT_PASSES_AFTER (all_regular_ipa_passes) NEXT_PASS (pass_ipa_whole_program_visibility); NEXT_PASS (pass_ipa_profile); NEXT_PASS (pass_ipa_cp); @@ -1370,28 +1380,27 @@ init_optimization_passes (void) NEXT_PASS (pass_ipa_inline); NEXT_PASS (pass_ipa_pure_const); NEXT_PASS (pass_ipa_reference); - *p = NULL; + TERMINATE_PASS_LIST () - p = &all_lto_gen_passes; + INSERT_PASSES_AFTER (all_lto_gen_passes) NEXT_PASS (pass_ipa_lto_gimple_out); NEXT_PASS (pass_ipa_lto_finish_out); /* This must be the last LTO pass. */ - *p = NULL; + TERMINATE_PASS_LIST () /* Simple IPA passes executed after the regular passes. In WHOPR mode the passes are executed after partitioning and thus see just parts of the compiled unit. */ - p = &all_late_ipa_passes; + INSERT_PASSES_AFTER (all_late_ipa_passes) NEXT_PASS (pass_ipa_pta); - *p = NULL; + TERMINATE_PASS_LIST () /* These passes are run after IPA passes on every function that is being output to the assembler file. */ - p = &all_passes; + INSERT_PASSES_AFTER (all_passes) NEXT_PASS (pass_fixup_cfg); NEXT_PASS (pass_lower_eh_dispatch); NEXT_PASS (pass_all_optimizations); - { - struct opt_pass **p = &pass_all_optimizations.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations) NEXT_PASS (pass_remove_cgraph_callee_edges); /* Initial scalar cleanups before alias computation. They ensure memory accesses are not indirect wherever possible. */ @@ -1454,8 +1463,7 @@ init_optimization_passes (void) NEXT_PASS (pass_asan); NEXT_PASS (pass_tsan); NEXT_PASS (pass_tree_loop); - { - struct opt_pass **p = &pass_tree_loop.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_tree_loop) NEXT_PASS (pass_tree_loop_init); NEXT_PASS (pass_lim); NEXT_PASS (pass_copy_prop); @@ -1467,21 +1475,19 @@ init_optimization_passes (void) NEXT_PASS (pass_loop_distribution); NEXT_PASS (pass_copy_prop); NEXT_PASS (pass_graphite); - { - struct opt_pass **p = &pass_graphite.pass.sub; + 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); - } + POP_INSERT_PASSES () NEXT_PASS (pass_iv_canon); NEXT_PASS (pass_parallelize_loops); NEXT_PASS (pass_if_conversion); NEXT_PASS (pass_vectorize); - { - struct opt_pass **p = &pass_vectorize.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_vectorize) NEXT_PASS (pass_dce_loop); - } + POP_INSERT_PASSES () NEXT_PASS (pass_predcom); NEXT_PASS (pass_complete_unroll); NEXT_PASS (pass_slp_vectorize); @@ -1489,7 +1495,7 @@ init_optimization_passes (void) NEXT_PASS (pass_iv_optimize); NEXT_PASS (pass_lim); NEXT_PASS (pass_tree_loop_done); - } + POP_INSERT_PASSES () NEXT_PASS (pass_lower_vector_ssa); NEXT_PASS (pass_cse_reciprocals); NEXT_PASS (pass_reassoc); @@ -1524,10 +1530,9 @@ init_optimization_passes (void) NEXT_PASS (pass_rename_ssa_copies); NEXT_PASS (pass_uncprop); NEXT_PASS (pass_local_pure_const); - } + POP_INSERT_PASSES () NEXT_PASS (pass_all_optimizations_g); - { - struct opt_pass **p = &pass_all_optimizations_g.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_all_optimizations_g) NEXT_PASS (pass_remove_cgraph_callee_edges); NEXT_PASS (pass_strip_predict_hints); /* Lower remaining pieces of GIMPLE. */ @@ -1551,14 +1556,13 @@ init_optimization_passes (void) NEXT_PASS (pass_late_warn_uninitialized); NEXT_PASS (pass_uncprop); NEXT_PASS (pass_local_pure_const); - } + POP_INSERT_PASSES () NEXT_PASS (pass_tm_init); - { - struct opt_pass **p = &pass_tm_init.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_tm_init) NEXT_PASS (pass_tm_mark); NEXT_PASS (pass_tm_memopt); NEXT_PASS (pass_tm_edges); - } + POP_INSERT_PASSES () NEXT_PASS (pass_lower_vector); NEXT_PASS (pass_lower_complex_O0); NEXT_PASS (pass_asan_O0); @@ -1573,8 +1577,7 @@ init_optimization_passes (void) NEXT_PASS (pass_expand); NEXT_PASS (pass_rest_of_compilation); - { - struct opt_pass **p = &pass_rest_of_compilation.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_rest_of_compilation) NEXT_PASS (pass_instantiate_virtual_regs); NEXT_PASS (pass_into_cfg_layout_mode); NEXT_PASS (pass_jump); @@ -1594,16 +1597,15 @@ init_optimization_passes (void) sooner, but we want the profile feedback to work more efficiently. */ NEXT_PASS (pass_loop2); - { - struct opt_pass **p = &pass_loop2.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_loop2) NEXT_PASS (pass_rtl_loop_init); NEXT_PASS (pass_rtl_move_loop_invariants); NEXT_PASS (pass_rtl_unswitch); NEXT_PASS (pass_rtl_unroll_and_peel_loops); NEXT_PASS (pass_rtl_doloop); NEXT_PASS (pass_rtl_loop_done); - *p = NULL; - } + TERMINATE_PASS_LIST () + POP_INSERT_PASSES () NEXT_PASS (pass_web); NEXT_PASS (pass_rtl_cprop); NEXT_PASS (pass_cse2); @@ -1628,8 +1630,7 @@ init_optimization_passes (void) NEXT_PASS (pass_ira); NEXT_PASS (pass_reload); NEXT_PASS (pass_postreload); - { - struct opt_pass **p = &pass_postreload.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_postreload) NEXT_PASS (pass_postreload_cse); NEXT_PASS (pass_gcse2); NEXT_PASS (pass_split_after_reload); @@ -1651,11 +1652,10 @@ init_optimization_passes (void) NEXT_PASS (pass_split_before_sched2); NEXT_PASS (pass_sched2); NEXT_PASS (pass_stack_regs); - { - struct opt_pass **p = &pass_stack_regs.pass.sub; + PUSH_INSERT_PASSES_WITHIN (pass_stack_regs) NEXT_PASS (pass_split_before_regstack); NEXT_PASS (pass_stack_regs_run); - } + POP_INSERT_PASSES () NEXT_PASS (pass_compute_alignments); NEXT_PASS (pass_duplicate_computed_gotos); NEXT_PASS (pass_variable_tracking); @@ -1669,13 +1669,17 @@ init_optimization_passes (void) NEXT_PASS (pass_set_nothrow_function_flags); NEXT_PASS (pass_dwarf2_frame); NEXT_PASS (pass_final); - } + POP_INSERT_PASSES () NEXT_PASS (pass_df_finish); - } + POP_INSERT_PASSES () NEXT_PASS (pass_clean_state); - *p = NULL; + TERMINATE_PASS_LIST () +#undef INSERT_PASSES_AFTER +#undef PUSH_INSERT_PASSES_WITHIN +#undef POP_INSERT_PASSES #undef NEXT_PASS +#undef TERMINATE_PASS_LIST /* Register the passes with the tree dump code. */ register_dump_files (all_lowering_passes, PROP_gimple_any); -- 1.7.11.7 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 1/4] Introduce macros when constructing the tree of passes 2013-07-18 1:18 ` [PATCH 1/4] Introduce macros when constructing the tree of passes David Malcolm @ 2013-07-18 16:21 ` Jeff Law 2013-07-18 18:33 ` David Malcolm 0 siblings, 1 reply; 25+ messages in thread From: Jeff Law @ 2013-07-18 16:21 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches On 07/17/2013 07:18 PM, David Malcolm wrote: > gcc/ > * passes.c (init_optimization_passes): Introduce macros for > constructing the tree of passes (INSERT_PASSES_AFTER, > PUSH_INSERT_PASSES_WITHIN, POP_INSERT_PASSES, > TERMINATE_PASS_LIST). > --- > gcc/passes.c | 108 +++++++++++++++++++++++++++++++---------------------------- > 1 file changed, 56 insertions(+), 52 deletions(-) > > diff --git a/gcc/passes.c b/gcc/passes.c > index 761f030..6ca4134 100644 > --- a/gcc/passes.c > +++ b/gcc/passes.c > @@ -1282,13 +1282,26 @@ init_optimization_passes (void) > { > struct opt_pass **p; > > +#define INSERT_PASSES_AFTER(PASS) \ > + p = &(PASS); > + > +#define PUSH_INSERT_PASSES_WITHIN(PASS) \ > + { \ > + struct opt_pass **p = &(PASS).pass.sub; > + > +#define POP_INSERT_PASSES() \ > + } > + I've never been a fan of having unmatched braces inside macros; though I guess I can live with it particularly since it'll help catch an unmatched push/pop. OK for the trunk. jeff ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 1/4] Introduce macros when constructing the tree of passes 2013-07-18 16:21 ` Jeff Law @ 2013-07-18 18:33 ` David Malcolm 0 siblings, 0 replies; 25+ messages in thread From: David Malcolm @ 2013-07-18 18:33 UTC (permalink / raw) To: Jeff Law; +Cc: gcc-patches On Thu, 2013-07-18 at 10:18 -0600, Jeff Law wrote: > On 07/17/2013 07:18 PM, David Malcolm wrote: > > gcc/ > > * passes.c (init_optimization_passes): Introduce macros for > > constructing the tree of passes (INSERT_PASSES_AFTER, > > PUSH_INSERT_PASSES_WITHIN, POP_INSERT_PASSES, > > TERMINATE_PASS_LIST). > > --- > > gcc/passes.c | 108 +++++++++++++++++++++++++++++++---------------------------- > > 1 file changed, 56 insertions(+), 52 deletions(-) > > > > diff --git a/gcc/passes.c b/gcc/passes.c > > index 761f030..6ca4134 100644 > > --- a/gcc/passes.c > > +++ b/gcc/passes.c > > @@ -1282,13 +1282,26 @@ init_optimization_passes (void) > > { > > struct opt_pass **p; > > > > +#define INSERT_PASSES_AFTER(PASS) \ > > + p = &(PASS); > > + > > +#define PUSH_INSERT_PASSES_WITHIN(PASS) \ > > + { \ > > + struct opt_pass **p = &(PASS).pass.sub; > > + > > +#define POP_INSERT_PASSES() \ > > + } > > + > I've never been a fan of having unmatched braces inside macros; though I > guess I can live with it particularly since it'll help catch an > unmatched push/pop. > > > OK for the trunk. Thanks; committed to svn trunk as r201037. ^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 1:18 [PATCH 0/4] Move pass-creation logic into a passes.def file David Malcolm ` (2 preceding siblings ...) 2013-07-18 1:18 ` [PATCH 1/4] Introduce macros when constructing the tree of passes David Malcolm @ 2013-07-18 1:32 ` David Malcolm 2013-07-18 7:10 ` Andrew Pinski ` (2 more replies) 2013-07-18 7:26 ` [PATCH 0/4] Move pass-creation logic into a passes.def file Andrew Pinski 4 siblings, 3 replies; 25+ messages in thread From: David Malcolm @ 2013-07-18 1:32 UTC (permalink / raw) To: gcc-patches; +Cc: David Malcolm 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(-) 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 1:32 ` [PATCH 3/4] Introduce NEXT_PASS_NUM macro David Malcolm @ 2013-07-18 7:10 ` Andrew Pinski 2013-07-18 11:40 ` David Malcolm 2013-07-18 16:25 ` Jeff Law 2013-07-22 18:45 ` Martin Jambor 2 siblings, 1 reply; 25+ messages in thread From: Andrew Pinski @ 2013-07-18 7:10 UTC (permalink / raw) To: David Malcolm; +Cc: GCC Patches 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 > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 7:10 ` Andrew Pinski @ 2013-07-18 11:40 ` David Malcolm 2013-07-18 14:58 ` Andrew Pinski 2013-07-18 16:03 ` Tom Tromey 0 siblings, 2 replies; 25+ messages in thread From: David Malcolm @ 2013-07-18 11:40 UTC (permalink / raw) To: Andrew Pinski; +Cc: GCC Patches 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). ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 11:40 ` David Malcolm @ 2013-07-18 14:58 ` Andrew Pinski 2013-07-29 16:06 ` David Malcolm 2013-07-18 16:03 ` Tom Tromey 1 sibling, 1 reply; 25+ messages in thread From: Andrew Pinski @ 2013-07-18 14:58 UTC (permalink / raw) To: David Malcolm; +Cc: GCC Patches 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 14:58 ` Andrew Pinski @ 2013-07-29 16:06 ` David Malcolm 0 siblings, 0 replies; 25+ messages in thread From: David Malcolm @ 2013-07-29 16:06 UTC (permalink / raw) To: Andrew Pinski; +Cc: GCC Patches 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 11:40 ` David Malcolm 2013-07-18 14:58 ` Andrew Pinski @ 2013-07-18 16:03 ` Tom Tromey 1 sibling, 0 replies; 25+ messages in thread From: Tom Tromey @ 2013-07-18 16:03 UTC (permalink / raw) To: David Malcolm; +Cc: Andrew Pinski, GCC Patches >>>>> "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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 1:32 ` [PATCH 3/4] Introduce NEXT_PASS_NUM macro David Malcolm 2013-07-18 7:10 ` Andrew Pinski @ 2013-07-18 16:25 ` Jeff Law 2013-07-29 19:42 ` David Malcolm 2013-07-22 18:45 ` Martin Jambor 2 siblings, 1 reply; 25+ messages in thread From: Jeff Law @ 2013-07-18 16:25 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 16:25 ` Jeff Law @ 2013-07-29 19:42 ` David Malcolm 2013-07-29 20:01 ` Jeff Law 0 siblings, 1 reply; 25+ messages in thread From: David Malcolm @ 2013-07-29 19:42 UTC (permalink / raw) To: Jeff Law; +Cc: gcc-patches 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-29 19:42 ` David Malcolm @ 2013-07-29 20:01 ` Jeff Law 0 siblings, 0 replies; 25+ messages in thread From: Jeff Law @ 2013-07-29 20:01 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-18 1:32 ` [PATCH 3/4] Introduce NEXT_PASS_NUM macro David Malcolm 2013-07-18 7:10 ` Andrew Pinski 2013-07-18 16:25 ` Jeff Law @ 2013-07-22 18:45 ` Martin Jambor 2013-07-22 19:36 ` David Malcolm 2 siblings, 1 reply; 25+ messages in thread From: Martin Jambor @ 2013-07-22 18:45 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-22 18:45 ` Martin Jambor @ 2013-07-22 19:36 ` David Malcolm 2013-07-23 15:28 ` Martin Jambor 0 siblings, 1 reply; 25+ messages in thread From: David Malcolm @ 2013-07-22 19:36 UTC (permalink / raw) To: Martin Jambor; +Cc: gcc-patches 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/ ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-22 19:36 ` David Malcolm @ 2013-07-23 15:28 ` Martin Jambor 2013-07-23 15:46 ` David Malcolm 0 siblings, 1 reply; 25+ messages in thread From: Martin Jambor @ 2013-07-23 15:28 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-23 15:28 ` Martin Jambor @ 2013-07-23 15:46 ` David Malcolm 2013-07-24 15:18 ` Martin Jambor 0 siblings, 1 reply; 25+ messages in thread From: David Malcolm @ 2013-07-23 15:46 UTC (permalink / raw) To: Martin Jambor; +Cc: gcc-patches 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 ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 3/4] Introduce NEXT_PASS_NUM macro 2013-07-23 15:46 ` David Malcolm @ 2013-07-24 15:18 ` Martin Jambor 0 siblings, 0 replies; 25+ messages in thread From: Martin Jambor @ 2013-07-24 15:18 UTC (permalink / raw) To: David Malcolm; +Cc: gcc-patches 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 > > ^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 0/4] Move pass-creation logic into a passes.def file 2013-07-18 1:18 [PATCH 0/4] Move pass-creation logic into a passes.def file David Malcolm ` (3 preceding siblings ...) 2013-07-18 1:32 ` [PATCH 3/4] Introduce NEXT_PASS_NUM macro David Malcolm @ 2013-07-18 7:26 ` Andrew Pinski 4 siblings, 0 replies; 25+ messages in thread From: Andrew Pinski @ 2013-07-18 7:26 UTC (permalink / raw) To: David Malcolm; +Cc: GCC Patches On Wed, Jul 17, 2013 at 6:18 PM, David Malcolm <dmalcolm@redhat.com> wrote: > The following patch series moves the logic for creating the > pipeline of optimization passes out from passes.c and into a new > passes.def file (patches 1 and 2). > > It then explicitly numbers those passes that have multiple instances, by > using a NEXT_PASS_NUM macro in place of NEXT_PASS (patch 3) This is not useful in itself and is one of the reasons why we added the ability to have a pass multiple times without much code. > > The motivation for this is subsequent work towards removing global > variables from GCC's internals: by numbering the instances it becomes > possible to create a "class pipeline" and have the fields be declared > via suitable use of passes.def. See: > http://dmalcolm.fedorapeople.org/gcc/global-state/new-classes.html#pass-classes > > The final patch in the sequence adds a script which sanity-checks > passes.def, and prints some stats about the passes. You can see output > from the script at: > > http://dmalcolm.fedorapeople.org/gcc/2013-07-17/pass-stats.txt > > Specifically, it lists single-instanced passes, then all multi-instance > passes, giving the number of instances of each (alphabetically within > each list). > > I've successfully bootstrapped and tested the sequence of patches on > x86_64-unknown-linux-gnu: all testcases show the same results as an > unpatched build (relative to r201011). Besides patch 3 for reasons mentioned above and mentioned in the reply directly to that patch, I like this set of patches. Thanks, Andrew Pinski > > OK to commit these to trunk? > > David Malcolm (4): > Introduce macros when constructing the tree of passes > Move the construction of the pass hierarchy into a new passes.def > file. > Introduce NEXT_PASS_NUM macro > Add contrib/check_passes.py script > > contrib/check_passes.py | 58 +++++++ > gcc/Makefile.in | 2 +- > gcc/passes.c | 401 ++--------------------------------------------- > gcc/passes.def | 406 ++++++++++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 481 insertions(+), 386 deletions(-) > create mode 100644 contrib/check_passes.py > create mode 100644 gcc/passes.def > > -- > 1.7.11.7 > ^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2013-07-29 20:00 UTC | newest] Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-07-18 1:18 [PATCH 0/4] Move pass-creation logic into a passes.def file David Malcolm 2013-07-18 1:18 ` [PATCH 4/4] Add contrib/check_passes.py script David Malcolm 2013-07-18 16:29 ` Jeff Law 2013-07-18 1:18 ` [PATCH 2/4] Move the construction of the pass hierarchy into a new passes.def file David Malcolm 2013-07-18 16:25 ` Jeff Law 2013-07-18 19:34 ` David Malcolm 2013-07-18 16:25 ` Jakub Jelinek 2013-07-18 1:18 ` [PATCH 1/4] Introduce macros when constructing the tree of passes David Malcolm 2013-07-18 16:21 ` Jeff Law 2013-07-18 18:33 ` David Malcolm 2013-07-18 1:32 ` [PATCH 3/4] Introduce NEXT_PASS_NUM macro David Malcolm 2013-07-18 7:10 ` Andrew Pinski 2013-07-18 11:40 ` David Malcolm 2013-07-18 14:58 ` Andrew Pinski 2013-07-29 16:06 ` David Malcolm 2013-07-18 16:03 ` Tom Tromey 2013-07-18 16:25 ` Jeff Law 2013-07-29 19:42 ` David Malcolm 2013-07-29 20:01 ` Jeff Law 2013-07-22 18:45 ` Martin Jambor 2013-07-22 19:36 ` David Malcolm 2013-07-23 15:28 ` Martin Jambor 2013-07-23 15:46 ` David Malcolm 2013-07-24 15:18 ` Martin Jambor 2013-07-18 7:26 ` [PATCH 0/4] Move pass-creation logic into a passes.def file Andrew Pinski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).