On Thu, Aug 14, 2014 at 09:46:46AM +0400, Yury Gribov wrote:
> --- a/gcc/asan.c
> +++ b/gcc/asan.c
> @@ -1690,22 +1690,21 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t,
>    int volatilep = 0, unsignedp = 0;
>    tree inner = get_inner_reference (t, &bitsize, &bitpos, &offset,
>                                   &mode, &unsignedp, &volatilep, false);
> -  if (((size_in_bytes & (size_in_bytes - 1)) == 0
> -       && (bitpos % (size_in_bytes * BITS_PER_UNIT)))
> -      || bitsize != size_in_bytes * BITS_PER_UNIT)
> +
> +  if (TREE_CODE (t) == COMPONENT_REF)
>      {
> -      if (TREE_CODE (t) == COMPONENT_REF
> -       && DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1)) != NULL_TREE)
> +      if (DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1)) != NULL_TREE)
>       {
>         tree repr = DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1));
>         instrument_derefs (iter, build3 (COMPONENT_REF, TREE_TYPE (repr),
>                                          TREE_OPERAND (t, 0), repr,
>                                          NULL_TREE), location, is_store);
> +       return;
>       }
> -      return;

> +      else if (bitpos % BITS_PER_UNIT
> +            || bitsize != size_in_bytes * BITS_PER_UNIT)
> +     return;

No, this should be if, not else if, and be after the } below.
We really can't handle it otherwise.
Generally, the bitfield COMPONENT_REFs should have
DECL_BIT_FIELD_REPRESENTATIVE which is not a bitfield, therefore the common
case will be handled.

As for BIT_FIELD_REFs, the question is what access to use instead of them.

        Jakub

Reply via email to