On Mon, Jan 23, 2017 at 10:19:33AM +0100, Martin Liška wrote:
> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> index 2777a23eb93..1b076fdf45c 100644
> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -1206,8 +1206,19 @@ asan_poison_variables (hash_set<tree> *variables, bool 
> poison, gimple_seq *seq_p
>  
>    sorted_variables.qsort (sort_by_decl_uid);
>  
> -  for (unsigned i = 0; i < sorted_variables.length (); i++)
> -    asan_poison_variable (sorted_variables[i], poison, seq_p);
> +  unsigned i;
> +  tree var;
> +  FOR_EACH_VEC_ELT (sorted_variables, i, var)
> +    {
> +      asan_poison_variable (var, poison, seq_p);
> +
> +      /* Add use_after_scope_memory attribute for the variable in order
> +      to prevent re-written into SSA.  */
> +      DECL_ATTRIBUTES (var)
> +     = tree_cons (get_identifier ("use_after_scope_memory"),

Please use "use after scope memory" to make it clear it is internal
only attribute users can't specify.
Also, can't asan_poison_variables be performed on the same var
multiple times (multiple labels, or switches, ...)?
If yes, then the addition of the attribute should be guarded
with if (!lookup_attribute ("use after scope memory", DECL_ATTRIBUTES (vars)))
so that you don't add the attributes many times.

> +                  build_int_cst (integer_type_node, 1),
> +                  DECL_ATTRIBUTES (var));

Please use:
                     integer_one_node, DECL_ATTRIBUTES (var));
instead.

> --- a/gcc/tree-ssa.c
> +++ b/gcc/tree-ssa.c
> @@ -1565,6 +1565,10 @@ is_asan_mark_p (gimple *stmt)
>        && VAR_P (TREE_OPERAND (addr, 0)))
>      {
>        tree var = TREE_OPERAND (addr, 0);
> +      if (lookup_attribute ("use_after_scope_memory",
> +                         DECL_ATTRIBUTES (var)))
> +     return false;

See above.

Patchset is ok for trunk with these nits fixed, thanks.

        Jakub

Reply via email to