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] Fix get_expr_operands for volatile BIT_FIELD_REFs (PR middle-end/38428)


On Sat, Dec 6, 2008 at 8:09 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> When only some fields of a structure are volatile, BIT_FIELD_REF
> can be TREE_THIS_VOLATILE/TREE_SIDE_EFFECTS, but the first operand
> of the BIT_FIELD_REF might be non-volatile.  In that case
> stmts having this on one side weren't marked as having volatile ops,
> and the new in 4.4 assert in gimple_rhs_has_side_effects was failing.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux, ok for trunk?

Huh, certainly a fragile situation.  Ok.

Thanks,
Richard.

> 2008-12-06  Jakub Jelinek  <jakub@redhat.com>
>
>        PR middle-end/38428
>        * tree-ssa-operands.c (get_expr_operands) <case BIT_FIELD_REF>: Set
>        gimple_set_has_volatile_ops if the BIT_FIELD_REF is volatile.
>
>        * gcc.c-torture/compile/pr38428.c: New test.
>
> --- gcc/tree-ssa-operands.c.jj  2008-11-14 09:50:14.000000000 +0100
> +++ gcc/tree-ssa-operands.c     2008-12-06 17:59:55.000000000 +0100
> @@ -2010,6 +2010,10 @@ get_expr_operands (gimple stmt, tree *ex
>       }
>
>     case BIT_FIELD_REF:
> +      if (TREE_THIS_VOLATILE (expr))
> +       gimple_set_has_volatile_ops (stmt, true);
> +      /* FALLTHRU */
> +
>     case TRUTH_NOT_EXPR:
>     case VIEW_CONVERT_EXPR:
>     do_unary:
> --- gcc/testsuite/gcc.c-torture/compile/pr38428.c.jj    2008-12-06 18:03:35.000000000 +0100
> +++ gcc/testsuite/gcc.c-torture/compile/pr38428.c       2008-12-06 18:03:10.000000000 +0100
> @@ -0,0 +1,20 @@
> +/* PR middle-end/38428 */
> +
> +struct S
> +{
> +  volatile struct
> +  {
> +    unsigned int t : 1;
> +  } s;
> +};
> +
> +int
> +foo (struct S *x)
> +{
> +  int ret;
> +  if (x->s.t)
> +    ret = 0;
> +  else
> +    ret = 10;
> +  return ret;
> +}
>
>        Jakub
>


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