On Sun, 4 Dec 2011, Richard Guenther wrote:

> On Sat, Dec 3, 2011 at 7:56 PM, Richard Henderson <r...@redhat.com> wrote:
> > On 12/03/2011 06:30 AM, Richard Guenther wrote:
> >> Not if you look at the respective gimple level dependency routines
> >> in tree-ssa-alias.c, OTOH tree-data-ref.c simply refuses to handle
> >> volatile references at all.
> >
> > That's something we'd better fix, then, regardless of whether
> > some pass currently refuses to handle them.
> 
> I'll prepare a patch.

Like the following.

Bootstrap/regtest pending on x86_64-unknown-linux-gnu.

Richard.

2011-12-05  Richard Guenther  <rguent...@suse.de>

        * tree-ssa-alias.h (struct ao_ref_s): Add volatile_p field.
        * tree-ssa-alias.c (ao_ref_init): Initialize it.
        (ao_ref_init_from_ptr_and_size): Likewise.
        (refs_may_alias_p_1): Two volatile accesses conflict.
        (ref_maybe_used_by_call_p_1): Likewise.
        (call_may_clobber_ref_p_1): Likewise.
        * tree-ssa-sccvn.c (ao_ref_init_from_vn_reference): Initialize
        volatile_p field.

Index: gcc/tree-ssa-alias.h
===================================================================
*** gcc/tree-ssa-alias.h        (revision 182001)
--- gcc/tree-ssa-alias.h        (working copy)
*************** typedef struct ao_ref_s
*** 86,91 ****
--- 86,94 ----
  
    /* The alias set of the base object or -1 if not yet computed.  */
    alias_set_type base_alias_set;
+ 
+   /* Whether the memory is considered a volatile access.  */
+   bool volatile_p;
  } ao_ref;
  
  
Index: gcc/tree-ssa-alias.c
===================================================================
*** gcc/tree-ssa-alias.c        (revision 182001)
--- gcc/tree-ssa-alias.c        (working copy)
*************** ao_ref_init (ao_ref *r, tree ref)
*** 456,461 ****
--- 456,462 ----
    r->max_size = -1;
    r->ref_alias_set = -1;
    r->base_alias_set = -1;
+   r->volatile_p = ref ? TREE_THIS_VOLATILE (ref) : false;
  }
  
  /* Returns the base object of the memory reference *REF.  */
*************** ao_ref_init_from_ptr_and_size (ao_ref *r
*** 525,530 ****
--- 526,532 ----
      ref->max_size = ref->size = -1;
    ref->ref_alias_set = 0;
    ref->base_alias_set = 0;
+   ref->volatile_p = false;
  }
  
  /* Return 1 if TYPE1 and TYPE2 are to be considered equivalent for the
*************** refs_may_alias_p_1 (ao_ref *ref1, ao_ref
*** 1021,1026 ****
--- 1023,1033 ----
        || TREE_CODE (base2) == LABEL_DECL)
      return true;
  
+   /* Two volatile accesses always conflict.  */
+   if (ref1->volatile_p
+       && ref2->volatile_p)
+     return true;
+ 
    /* Defer to simple offset based disambiguation if we have
       references based on two decls.  Do this before defering to
       TBAA to handle must-alias cases in conformance with the
*************** ref_maybe_used_by_call_p_1 (gimple call,
*** 1144,1149 ****
--- 1151,1161 ----
    if (!base)
      return true;
  
+   /* A call that is not without side-effects might involve volatile
+      accesses and thus conflicts with all other volatile accesses.  */
+   if (ref->volatile_p)
+     return true;
+ 
    /* If the reference is based on a decl that is not aliased the call
       cannot possibly use it.  */
    if (DECL_P (base)
*************** call_may_clobber_ref_p_1 (gimple call, a
*** 1477,1482 ****
--- 1489,1499 ----
        || CONSTANT_CLASS_P (base))
      return false;
  
+   /* A call that is not without side-effects might involve volatile
+      accesses and thus conflicts with all other volatile accesses.  */
+   if (ref->volatile_p)
+     return true;
+ 
    /* If the reference is based on a decl that is not aliased the call
       cannot possibly clobber it.  */
    if (DECL_P (base)
Index: gcc/tree-ssa-sccvn.c
===================================================================
*** gcc/tree-ssa-sccvn.c        (revision 182001)
--- gcc/tree-ssa-sccvn.c        (working copy)
*************** ao_ref_init_from_vn_reference (ao_ref *r
*** 918,923 ****
--- 918,925 ----
      ref->base_alias_set = base_alias_set;
    else
      ref->base_alias_set = get_alias_set (base);
+   /* We discount volatiles from value-numbering elsewhere.  */
+   ref->volatile_p = false;
  
    return true;
  }

Reply via email to