Re: [PATCH 2/6] use auto_sbitmap in various places
On 07/25/2016 07:55 PM, Trevor Saunders wrote: On Mon, Jul 25, 2016 at 11:18:07AM -0600, Jeff Law wrote: On 07/24/2016 05:44 AM, tbsaunde+...@tbsaunde.org wrote: From: Trevor Saundersgcc/ChangeLog: 2016-07-24 Trevor Saunders * bt-load.c (compute_out): Use auto_sbitmap class. (link_btr_uses): Likewise. * cfganal.c (mark_dfs_back_edges): Likewise. (post_order_compute): Likewise. (inverted_post_order_compute): Likewise. (pre_and_rev_post_order_compute_fn): Likewise. (single_pred_before_succ_order): Likewise. * cfgexpand.c (pass_expand::execute): Likewise. * cfgloop.c (verify_loop_structure): Likewise. * cfgloopmanip.c (fix_bb_placements): Likewise. (remove_path): Likewise. (update_dominators_in_loop): Likewise. * cfgrtl.c (break_superblocks): Likewise. * ddg.c (check_sccs): Likewise. (create_ddg_all_sccs): Likewise. * df-core.c (df_worklist_dataflow): Likewise. * dse.c (dse_step3): Likewise. * except.c (eh_region_outermost): Likewise. * function.c (thread_prologue_and_epilogue_insns): Likewise. * gcse.c (prune_expressions): Likewise. (prune_insertions_deletions): Likewise. * gimple-ssa-backprop.c (backprop::~backprop): Likewise. * graph.c (draw_cfg_nodes_no_loops): Likewise. * ira-lives.c (remove_some_program_points_and_update_live_ranges): Likewise. * lcm.c (compute_earliest): Likewise. (compute_farthest): Likewise. * loop-unroll.c (unroll_loop_constant_iterations): Likewise. (unroll_loop_runtime_iterations): Likewise. (unroll_loop_stupid): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * lra-lives.c: Likewise. * lra.c (lra): Likewise. * modulo-sched.c (schedule_reg_moves): Likewise. (optimize_sc): Likewise. (get_sched_window): Likewise. (sms_schedule_by_order): Likewise. (check_nodes_order): Likewise. (order_nodes_of_sccs): Likewise. (order_nodes_in_scc): Likewise. * recog.c (split_all_insns): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * reload1.c (reload): Likewise. * sched-rgn.c (haifa_find_rgns): Likewise. (split_edges): Likewise. (compute_trg_info): Likewise. * sel-sched.c (init_seqno): Likewise. * store-motion.c (remove_reachable_equiv_notes): Likewise. * tree-into-ssa.c (update_ssa): Likewise. * tree-ssa-live.c (live_worklist): Likewise. * tree-ssa-loop-im.c (fill_always_executed_in): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): * Likewise. (try_peel_loop): Likewise. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): * Likewise. * tree-ssa-pre.c (compute_antic): Likewise. * tree-ssa-reassoc.c (undistribute_ops_list): Likewise. * tree-stdarg.c (reachable_at_most_once): Likewise. * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Likewise. * var-tracking.c (vt_find_locations): Likewise. While looking at this, I noticed some more. Check the local sbitmaps in ddg.c::find_nodes_on_paths. yeah, there was a couple places like that which I left for the time being mostly because they swapped bitmaps and I wanted to add a way of doing that first. I wonder if building a plugin to help find this kind of thing would help. Essentially what we want is TYPE which we're considering converting to an auto_TYPE. We want to see the declaration, possibly an allocation and an explicit release. All paths have to pass through an explicit release. The object must not escape. We can have a whitelist of routines where the object can be passed in as a parameter. Given that kind of infrastructure we ought to be able to look at a type and say, yes, this seems to make sense to turn into an auto and here's all the places that need twiddling for that change. That infrastructure could also do things like say "X escaped via call Y" or a path doesn't release which can further guide the process, or show leaks. yeah, that would definitely be nice, and I've considered doing it before, but been afraid it would be a bit of work. I suppose though if it took work it would be because I learned some things so maybe its worth doing for bitmap and all the uses of malloc / free. It also would likely to be extendable to other uses as well. There's a ton of parallels between this and doing things like double-free, use-after-free, leaked resource detection. diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index a5f3f71..6247a4c 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2451,7 +2451,7 @@ compute_antic (void) has_abnormal_preds seems ripe for a similar change in this function. unfortunately its a
Re: [PATCH 2/6] use auto_sbitmap in various places
On Mon, Jul 25, 2016 at 11:18:07AM -0600, Jeff Law wrote: > On 07/24/2016 05:44 AM, tbsaunde+...@tbsaunde.org wrote: > > From: Trevor Saunders> > > > gcc/ChangeLog: > > > > 2016-07-24 Trevor Saunders > > > > * bt-load.c (compute_out): Use auto_sbitmap class. > > (link_btr_uses): Likewise. > > * cfganal.c (mark_dfs_back_edges): Likewise. > > (post_order_compute): Likewise. > > (inverted_post_order_compute): Likewise. > > (pre_and_rev_post_order_compute_fn): Likewise. > > (single_pred_before_succ_order): Likewise. > > * cfgexpand.c (pass_expand::execute): Likewise. > > * cfgloop.c (verify_loop_structure): Likewise. > > * cfgloopmanip.c (fix_bb_placements): Likewise. > > (remove_path): Likewise. > > (update_dominators_in_loop): Likewise. > > * cfgrtl.c (break_superblocks): Likewise. > > * ddg.c (check_sccs): Likewise. > > (create_ddg_all_sccs): Likewise. > > * df-core.c (df_worklist_dataflow): Likewise. > > * dse.c (dse_step3): Likewise. > > * except.c (eh_region_outermost): Likewise. > > * function.c (thread_prologue_and_epilogue_insns): Likewise. > > * gcse.c (prune_expressions): Likewise. > > (prune_insertions_deletions): Likewise. > > * gimple-ssa-backprop.c (backprop::~backprop): Likewise. > > * graph.c (draw_cfg_nodes_no_loops): Likewise. > > * ira-lives.c (remove_some_program_points_and_update_live_ranges): > > Likewise. > > * lcm.c (compute_earliest): Likewise. > > (compute_farthest): Likewise. > > * loop-unroll.c (unroll_loop_constant_iterations): Likewise. > > (unroll_loop_runtime_iterations): Likewise. > > (unroll_loop_stupid): Likewise. > > * lower-subreg.c (decompose_multiword_subregs): Likewise. > > * lra-lives.c: Likewise. > > * lra.c (lra): Likewise. > > * modulo-sched.c (schedule_reg_moves): Likewise. > > (optimize_sc): Likewise. > > (get_sched_window): Likewise. > > (sms_schedule_by_order): Likewise. > > (check_nodes_order): Likewise. > > (order_nodes_of_sccs): Likewise. > > (order_nodes_in_scc): Likewise. > > * recog.c (split_all_insns): Likewise. > > * regcprop.c (pass_cprop_hardreg::execute): Likewise. > > * reload1.c (reload): Likewise. > > * sched-rgn.c (haifa_find_rgns): Likewise. > > (split_edges): Likewise. > > (compute_trg_info): Likewise. > > * sel-sched.c (init_seqno): Likewise. > > * store-motion.c (remove_reachable_equiv_notes): Likewise. > > * tree-into-ssa.c (update_ssa): Likewise. > > * tree-ssa-live.c (live_worklist): Likewise. > > * tree-ssa-loop-im.c (fill_always_executed_in): Likewise. > > * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): > > * Likewise. > > (try_peel_loop): Likewise. > > * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): > > * Likewise. > > * tree-ssa-pre.c (compute_antic): Likewise. > > * tree-ssa-reassoc.c (undistribute_ops_list): Likewise. > > * tree-stdarg.c (reachable_at_most_once): Likewise. > > * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Likewise. > > * var-tracking.c (vt_find_locations): Likewise. > While looking at this, I noticed some more. Check the local sbitmaps in > ddg.c::find_nodes_on_paths. yeah, there was a couple places like that which I left for the time being mostly because they swapped bitmaps and I wanted to add a way of doing that first. > I wonder if building a plugin to help find this kind of thing would help. > Essentially what we want is TYPE which we're considering converting to an > auto_TYPE. We want to see the declaration, possibly an allocation and an > explicit release. All paths have to pass through an explicit release. The > object must not escape. We can have a whitelist of routines where the > object can be passed in as a parameter. > > Given that kind of infrastructure we ought to be able to look at a type and > say, yes, this seems to make sense to turn into an auto and here's all the > places that need twiddling for that change. > > That infrastructure could also do things like say "X escaped via call Y" or > a path doesn't release which can further guide the process, or show leaks. yeah, that would definitely be nice, and I've considered doing it before, but been afraid it would be a bit of work. I suppose though if it took work it would be because I learned some things so maybe its worth doing for bitmap and all the uses of malloc / free. > > diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c > > index 5dde66c..6e87a6f 100644 > > --- a/gcc/modulo-sched.c > > +++ b/gcc/modulo-sched.c > So I got a bit lost tracking some of these through the call chains. I could > try again, taking notes along the way to make sure I properly verified the > children don't make a copy MUST_FOLLOW. But I'm going to assume you did > this correctly. yeah, I believe so. > > diff --git
Re: [PATCH 2/6] use auto_sbitmap in various places
On 07/24/2016 05:44 AM, tbsaunde+...@tbsaunde.org wrote: From: Trevor Saundersgcc/ChangeLog: 2016-07-24 Trevor Saunders * bt-load.c (compute_out): Use auto_sbitmap class. (link_btr_uses): Likewise. * cfganal.c (mark_dfs_back_edges): Likewise. (post_order_compute): Likewise. (inverted_post_order_compute): Likewise. (pre_and_rev_post_order_compute_fn): Likewise. (single_pred_before_succ_order): Likewise. * cfgexpand.c (pass_expand::execute): Likewise. * cfgloop.c (verify_loop_structure): Likewise. * cfgloopmanip.c (fix_bb_placements): Likewise. (remove_path): Likewise. (update_dominators_in_loop): Likewise. * cfgrtl.c (break_superblocks): Likewise. * ddg.c (check_sccs): Likewise. (create_ddg_all_sccs): Likewise. * df-core.c (df_worklist_dataflow): Likewise. * dse.c (dse_step3): Likewise. * except.c (eh_region_outermost): Likewise. * function.c (thread_prologue_and_epilogue_insns): Likewise. * gcse.c (prune_expressions): Likewise. (prune_insertions_deletions): Likewise. * gimple-ssa-backprop.c (backprop::~backprop): Likewise. * graph.c (draw_cfg_nodes_no_loops): Likewise. * ira-lives.c (remove_some_program_points_and_update_live_ranges): Likewise. * lcm.c (compute_earliest): Likewise. (compute_farthest): Likewise. * loop-unroll.c (unroll_loop_constant_iterations): Likewise. (unroll_loop_runtime_iterations): Likewise. (unroll_loop_stupid): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * lra-lives.c: Likewise. * lra.c (lra): Likewise. * modulo-sched.c (schedule_reg_moves): Likewise. (optimize_sc): Likewise. (get_sched_window): Likewise. (sms_schedule_by_order): Likewise. (check_nodes_order): Likewise. (order_nodes_of_sccs): Likewise. (order_nodes_in_scc): Likewise. * recog.c (split_all_insns): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * reload1.c (reload): Likewise. * sched-rgn.c (haifa_find_rgns): Likewise. (split_edges): Likewise. (compute_trg_info): Likewise. * sel-sched.c (init_seqno): Likewise. * store-motion.c (remove_reachable_equiv_notes): Likewise. * tree-into-ssa.c (update_ssa): Likewise. * tree-ssa-live.c (live_worklist): Likewise. * tree-ssa-loop-im.c (fill_always_executed_in): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): * Likewise. (try_peel_loop): Likewise. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): * Likewise. * tree-ssa-pre.c (compute_antic): Likewise. * tree-ssa-reassoc.c (undistribute_ops_list): Likewise. * tree-stdarg.c (reachable_at_most_once): Likewise. * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Likewise. * var-tracking.c (vt_find_locations): Likewise. While looking at this, I noticed some more. Check the local sbitmaps in ddg.c::find_nodes_on_paths. I wonder if building a plugin to help find this kind of thing would help. Essentially what we want is TYPE which we're considering converting to an auto_TYPE. We want to see the declaration, possibly an allocation and an explicit release. All paths have to pass through an explicit release. The object must not escape. We can have a whitelist of routines where the object can be passed in as a parameter. Given that kind of infrastructure we ought to be able to look at a type and say, yes, this seems to make sense to turn into an auto and here's all the places that need twiddling for that change. That infrastructure could also do things like say "X escaped via call Y" or a path doesn't release which can further guide the process, or show leaks. diff --git a/gcc/modulo-sched.c b/gcc/modulo-sched.c index 5dde66c..6e87a6f 100644 --- a/gcc/modulo-sched.c +++ b/gcc/modulo-sched.c So I got a bit lost tracking some of these through the call chains. I could try again, taking notes along the way to make sure I properly verified the children don't make a copy MUST_FOLLOW. But I'm going to assume you did this correctly. diff --git a/gcc/store-motion.c b/gcc/store-motion.c index 6d7d37f..1d504e7 100644 --- a/gcc/store-motion.c +++ b/gcc/store-motion.c Ick. Who wrote remove_unreachable_equiv_notes?!? OK, you don't need to answer that, I just needed to vent a little. diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index a5f3f71..6247a4c 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2451,7 +2451,7 @@ compute_antic (void) has_abnormal_preds seems ripe for a similar change in this function. diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c index 5d09879..9088978 100644 ---
[PATCH 2/6] use auto_sbitmap in various places
From: Trevor Saundersgcc/ChangeLog: 2016-07-24 Trevor Saunders * bt-load.c (compute_out): Use auto_sbitmap class. (link_btr_uses): Likewise. * cfganal.c (mark_dfs_back_edges): Likewise. (post_order_compute): Likewise. (inverted_post_order_compute): Likewise. (pre_and_rev_post_order_compute_fn): Likewise. (single_pred_before_succ_order): Likewise. * cfgexpand.c (pass_expand::execute): Likewise. * cfgloop.c (verify_loop_structure): Likewise. * cfgloopmanip.c (fix_bb_placements): Likewise. (remove_path): Likewise. (update_dominators_in_loop): Likewise. * cfgrtl.c (break_superblocks): Likewise. * ddg.c (check_sccs): Likewise. (create_ddg_all_sccs): Likewise. * df-core.c (df_worklist_dataflow): Likewise. * dse.c (dse_step3): Likewise. * except.c (eh_region_outermost): Likewise. * function.c (thread_prologue_and_epilogue_insns): Likewise. * gcse.c (prune_expressions): Likewise. (prune_insertions_deletions): Likewise. * gimple-ssa-backprop.c (backprop::~backprop): Likewise. * graph.c (draw_cfg_nodes_no_loops): Likewise. * ira-lives.c (remove_some_program_points_and_update_live_ranges): Likewise. * lcm.c (compute_earliest): Likewise. (compute_farthest): Likewise. * loop-unroll.c (unroll_loop_constant_iterations): Likewise. (unroll_loop_runtime_iterations): Likewise. (unroll_loop_stupid): Likewise. * lower-subreg.c (decompose_multiword_subregs): Likewise. * lra-lives.c: Likewise. * lra.c (lra): Likewise. * modulo-sched.c (schedule_reg_moves): Likewise. (optimize_sc): Likewise. (get_sched_window): Likewise. (sms_schedule_by_order): Likewise. (check_nodes_order): Likewise. (order_nodes_of_sccs): Likewise. (order_nodes_in_scc): Likewise. * recog.c (split_all_insns): Likewise. * regcprop.c (pass_cprop_hardreg::execute): Likewise. * reload1.c (reload): Likewise. * sched-rgn.c (haifa_find_rgns): Likewise. (split_edges): Likewise. (compute_trg_info): Likewise. * sel-sched.c (init_seqno): Likewise. * store-motion.c (remove_reachable_equiv_notes): Likewise. * tree-into-ssa.c (update_ssa): Likewise. * tree-ssa-live.c (live_worklist): Likewise. * tree-ssa-loop-im.c (fill_always_executed_in): Likewise. * tree-ssa-loop-ivcanon.c (try_unroll_loop_completely): * Likewise. (try_peel_loop): Likewise. * tree-ssa-loop-manip.c (tree_transform_and_unroll_loop): * Likewise. * tree-ssa-pre.c (compute_antic): Likewise. * tree-ssa-reassoc.c (undistribute_ops_list): Likewise. * tree-stdarg.c (reachable_at_most_once): Likewise. * tree-vect-slp.c (vect_attempt_slp_rearrange_stmts): Likewise. * var-tracking.c (vt_find_locations): Likewise. --- gcc/bt-load.c | 9 ++ gcc/cfganal.c | 19 +++ gcc/cfgexpand.c | 4 +-- gcc/cfgloop.c | 8 ++--- gcc/cfgloopmanip.c | 13 ++-- gcc/cfgrtl.c| 5 +-- gcc/ddg.c | 12 +++ gcc/df-core.c | 3 +- gcc/dse.c | 3 +- gcc/except.c| 5 +-- gcc/function.c | 3 +- gcc/gcse.c | 9 ++ gcc/gimple-ssa-backprop.c | 5 ++- gcc/graph.c | 5 +-- gcc/ira-lives.c | 11 +++ gcc/lcm.c | 16 ++ gcc/loop-unroll.c | 16 ++ gcc/lower-subreg.c | 5 +-- gcc/lra-lives.c | 10 ++ gcc/lra.c | 4 +-- gcc/modulo-sched.c | 78 ++--- gcc/recog.c | 5 +-- gcc/regcprop.c | 4 +-- gcc/reload1.c | 4 +-- gcc/sched-rgn.c | 36 ++--- gcc/sel-sched.c | 4 +-- gcc/store-motion.c | 3 +- gcc/tree-into-ssa.c | 3 +- gcc/tree-ssa-live.c | 4 +-- gcc/tree-ssa-loop-im.c | 4 +-- gcc/tree-ssa-loop-ivcanon.c | 10 ++ gcc/tree-ssa-loop-manip.c | 4 +-- gcc/tree-ssa-pre.c | 3 +- gcc/tree-ssa-reassoc.c | 12 ++- gcc/tree-stdarg.c | 4 +-- gcc/tree-vect-slp.c | 20 +++- gcc/var-tracking.c | 5 ++- 37 files changed, 99 insertions(+), 269 deletions(-) diff --git a/gcc/bt-load.c b/gcc/bt-load.c index aa02f64..5b1bcec 100644 --- a/gcc/bt-load.c +++ b/gcc/bt-load.c @@ -626,7 +626,7 @@ compute_out (sbitmap *bb_out, sbitmap *bb_gen, sbitmap *bb_kill, int max_uid) Iterate until the bb_out sets stop growing. */ int i; int changed; - sbitmap bb_in = sbitmap_alloc