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] Move Asan instrumentation to sanopt pass


On Fri, Jul 18, 2014 at 05:36:30PM +0400, Yury Gribov wrote:
> The patch was bootstrapped, regtested and asan-bootstrapped on x64.

Thanks for working on this.

For formatting, can you please just replace 8 spaces with tabs
in the ^+ lines in the patch?
sed '/^+/s/        /\t/g' or so.
Can you avoid using // comments in code that uses /* */ comments?

If all the ifns have a bitmask argument, one question is if we really
want ASAN_LOAD vs. ASAN_STORE, instead of a single ASAN_CHECK that
would actually have ASAN_CHECK_IS_STORE as one of the flags.

>  pass_sanopt::execute (function *fun)
>  {
>    basic_block bb;
> +  gimple_stmt_iterator gsi;
>  
> +  int asan_num_accesses = 0;

IMHO you should guard this with if (flag_sanitize & SANITIZE_ADDRESS),
to avoid the cost for -fsanitize=undefined, thread etc.

> +  FOR_EACH_BB_FN (bb, fun)
> +    for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
> +      {
> + 	gimple stmt = gsi_stmt (gsi);
> +	if (is_gimple_call (stmt) && gimple_call_internal_p (stmt))
> +	  {
> +	    enum internal_fn ifn = gimple_call_internal_fn (stmt);
> +	    switch (ifn)
> +	      {
> +	      case IFN_ASAN_LOAD:
> +	      case IFN_ASAN_STORE:
> +		{
> +		  ++asan_num_accesses;
> +		  break;
> +		}
> +	      default:
> +		break;
> +	      }
> +	    }
> +        }
> +
> +  bool use_calls = ASAN_INSTRUMENTATION_WITH_CALL_THRESHOLD < INT_MAX
> +    && asan_num_accesses >= ASAN_INSTRUMENTATION_WITH_CALL_THRESHOLD;
> +    

> --- a/gcc/gimple-iterator.h
> +++ b/gcc/gimple-iterator.h
> @@ -116,6 +116,7 @@ gsi_start_bb (basic_block bb)
>    gimple_seq *seq;
>  
>    seq = bb_seq_addr (bb);
> +  gcc_assert (seq);
>    i.ptr = gimple_seq_first (*seq);
>    i.seq = seq;
>    i.bb = bb;

Uh.  Can you please explain this?  That sounds weird.

	Jakub


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