Patchwork [asan] Small cleanups

login
register
mail settings
Submitter Jakub Jelinek
Date Oct. 12, 2012, 4:19 p.m.
Message ID <20121012161928.GN584@tucnak.redhat.com>
Download mbox | patch
Permalink /patch/191154/
State New
Headers show

Comments

Jakub Jelinek - Oct. 12, 2012, 4:19 p.m.
Hi!

Just tiny cleanup and -fasan support for -O0.  Ok for asan?

2012-10-12  Jakub Jelinek  <jakub@redhat.com>

	* asan.c (build_check_stmt): Rename join_bb variable to else_bb.
	(gate_asan_O0): New function.
	(pass_asan_O0): New variable.
	* passes.c (init_optimization_passes): Add pass_asan_O0.
	* tree-pass.h (pass_asan_O0): New declaration.


	Jakub
Diego Novillo - Oct. 12, 2012, 4:37 p.m.
On 2012-10-12 12:19 , Jakub Jelinek wrote:

> 2012-10-12  Jakub Jelinek  <jakub@redhat.com>
>
> 	* asan.c (build_check_stmt): Rename join_bb variable to else_bb.
> 	(gate_asan_O0): New function.
> 	(pass_asan_O0): New variable.
> 	* passes.c (init_optimization_passes): Add pass_asan_O0.
> 	* tree-pass.h (pass_asan_O0): New declaration.

OK.  Thanks.


> --- gcc/passes.c.jj	2012-10-11 19:10:39.000000000 +0200
> +++ gcc/passes.c	2012-10-12 10:03:18.523456291 +0200
> @@ -1545,6 +1545,7 @@ init_optimization_passes (void)
>         NEXT_PASS (pass_tm_edges);
>       }
>     NEXT_PASS (pass_lower_complex_O0);
> +  NEXT_PASS (pass_asan_O0);

Any particular reason to place it here?  Not that it matters much.  Just 
curious.



Diego.
Jakub Jelinek - Oct. 12, 2012, 9:31 p.m.
On Fri, Oct 12, 2012 at 12:37:09PM -0400, Diego Novillo wrote:
> >--- gcc/passes.c.jj	2012-10-11 19:10:39.000000000 +0200
> >+++ gcc/passes.c	2012-10-12 10:03:18.523456291 +0200
> >@@ -1545,6 +1545,7 @@ init_optimization_passes (void)
> >        NEXT_PASS (pass_tm_edges);
> >      }
> >    NEXT_PASS (pass_lower_complex_O0);
> >+  NEXT_PASS (pass_asan_O0);
> 
> Any particular reason to place it here?  Not that it matters much.
> Just curious.

Just some location after IPA (so that it is performed even for -flto -O0)
and before final, picked a spot close to another -O0 only pass...

	Jakub

Patch

--- gcc/asan.c.jj	2012-10-11 20:16:06.000000000 +0200
+++ gcc/asan.c	2012-10-12 10:02:10.079908968 +0200
@@ -137,7 +137,7 @@  build_check_stmt (tree base,
                   location_t location, bool is_store, int size_in_bytes)
 {
   gimple_stmt_iterator gsi;
-  basic_block cond_bb, then_bb, join_bb;
+  basic_block cond_bb, then_bb, else_bb;
   edge e;
   tree t, base_addr, shadow;
   gimple g;
@@ -158,23 +158,23 @@  build_check_stmt (tree base,
   else
     e = split_block_after_labels (cond_bb);
   cond_bb = e->src;
-  join_bb = e->dest;
+  else_bb = e->dest;
 
-  /* A recap at this point: join_bb is the basic block at whose head
+  /* A recap at this point: else_bb is the basic block at whose head
      is the gimple statement for which this check expression is being
      built.  cond_bb is the (possibly new, synthetic) basic block the
      end of which will contain the cache-lookup code, and a
      conditional that jumps to the cache-miss code or, much more
-     likely, over to join_bb.  */
+     likely, over to else_bb.  */
 
   /* Create the bb that contains the crash block.  */
   then_bb = create_empty_bb (cond_bb);
   e = make_edge (cond_bb, then_bb, EDGE_TRUE_VALUE);
   e->probability = PROB_VERY_UNLIKELY;
-  make_single_succ_edge (then_bb, join_bb, EDGE_FALLTHRU);
+  make_single_succ_edge (then_bb, else_bb, EDGE_FALLTHRU);
 
-  /* Mark the pseudo-fallthrough edge from cond_bb to join_bb.  */
-  e = find_edge (cond_bb, join_bb);
+  /* Mark the pseudo-fallthrough edge from cond_bb to else_bb.  */
+  e = find_edge (cond_bb, else_bb);
   e->flags = EDGE_FALSE_VALUE;
   e->count = cond_bb->count;
   e->probability = PROB_ALWAYS - PROB_VERY_UNLIKELY;
@@ -184,7 +184,7 @@  build_check_stmt (tree base,
   if (dom_info_available_p (CDI_DOMINATORS))
     {
       set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
-      set_immediate_dominator (CDI_DOMINATORS, join_bb, cond_bb);
+      set_immediate_dominator (CDI_DOMINATORS, else_bb, cond_bb);
     }
 
   gsi = gsi_last_bb (cond_bb);
@@ -305,7 +305,7 @@  build_check_stmt (tree base,
   gimple_set_location (g, location);
   gsi_insert_after (&gsi, g, GSI_NEW_STMT);
 
-  *iter = gsi_start_bb (join_bb);
+  *iter = gsi_start_bb (else_bb);
 }
 
 /* If T represents a memory access, add instrumentation code before ITER.
@@ -445,6 +445,32 @@  struct gimple_opt_pass pass_asan =
   TODO_verify_flow | TODO_verify_stmts
   | TODO_update_ssa			/* todo_flags_finish  */
  }
+};
+
+static bool
+gate_asan_O0 (void)
+{
+  return flag_asan != 0 && !optimize;
+}
+
+struct gimple_opt_pass pass_asan_O0 =
+{
+ {
+  GIMPLE_PASS,
+  "asan0",				/* name  */
+  gate_asan_O0,				/* gate  */
+  asan_instrument,			/* execute  */
+  NULL,					/* sub  */
+  NULL,					/* next  */
+  0,					/* static_pass_number  */
+  TV_NONE,				/* tv_id  */
+  PROP_ssa | PROP_cfg | PROP_gimple_leh,/* properties_required  */
+  0,					/* properties_provided  */
+  0,					/* properties_destroyed  */
+  0,					/* todo_flags_start  */
+  TODO_verify_flow | TODO_verify_stmts
+  | TODO_update_ssa			/* todo_flags_finish  */
+ }
 };
 
 #include "gt-asan.h"
--- gcc/passes.c.jj	2012-10-11 19:10:39.000000000 +0200
+++ gcc/passes.c	2012-10-12 10:03:18.523456291 +0200
@@ -1545,6 +1545,7 @@  init_optimization_passes (void)
       NEXT_PASS (pass_tm_edges);
     }
   NEXT_PASS (pass_lower_complex_O0);
+  NEXT_PASS (pass_asan_O0);
   NEXT_PASS (pass_cleanup_eh);
   NEXT_PASS (pass_lower_resx);
   NEXT_PASS (pass_nrv);
--- gcc/tree-pass.h.jj	2012-10-11 18:44:38.000000000 +0200
+++ gcc/tree-pass.h	2012-10-12 10:02:43.977684699 +0200
@@ -257,6 +257,7 @@  struct register_pass_info
 extern struct gimple_opt_pass pass_mudflap_1;
 extern struct gimple_opt_pass pass_mudflap_2;
 extern struct gimple_opt_pass pass_asan;
+extern struct gimple_opt_pass pass_asan_O0;
 extern struct gimple_opt_pass pass_lower_cf;
 extern struct gimple_opt_pass pass_refactor_eh;
 extern struct gimple_opt_pass pass_lower_eh;