This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 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+gcc@tbsaunde.org wrote:
From: Trevor Saunders <tbsaunde+gcc@tbsaunde.org>

gcc/ChangeLog:

2016-07-24  Trevor Saunders  <tbsaunde+gcc@tbsaunde.org>

	* 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 file static, so that needs work first.
Ah. Missed that. I wasn't really looking at those other cases as close as the ones you changed.


jeff


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