------- Additional Comments From dnovillo at gcc dot gnu dot org  2005-01-07 
15:09 -------

BTW, the original case is no longer reproducible on mainline, but the test in
#35 still fails.

This happens when a pointer to volatile storage takes the address of a variable.
 One way to fix this is by marking variables that have been aliased with
volatile tags.  When adding operands for these variables, we mark the statement
as having volatile operands.  While correct, this tends to pessimize code.  I'm
working on a variant of this patch that would only mark variables whose address
is taken by a pointer pointing to volatile memory.

Jeff has been working on the idea of exposing volatile operands to the
optimizers and make the optimizers responsible for dealing with them properly. 
This has the advantage that we would not have any magic operands hidden from us,
but it requires auditing all the optimizers to make sure that they don't mess
things up.

Given the stage that we are for 4.0, it may be better to go with the simpler
solution.  But perhaps we can finish the other approach in time.


Diego.


Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.75
diff -d -c -p -u -r2.75 tree-flow.h
--- tree-flow.h 10 Dec 2004 21:54:41 -0000      2.75
+++ tree-flow.h 5 Jan 2005 00:06:23 -0000
@@ -174,6 +174,9 @@ struct var_ann_d GTY(())
      in the v_may_def list.  */
   unsigned in_v_may_def_list : 1;
 
+  /* Nonzero if this variable is aliased to a volatile variable.  */
+  unsigned aliased_with_volatile : 1;
+
   /* An artificial variable representing the memory location pointed-to by
      all the pointers that TBAA (type-based alias analysis) considers
      to be aliased.  If the variable is not a pointer or if it is never
Index: tree-ssa-alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-alias.c,v
retrieving revision 2.64
diff -d -c -p -u -r2.64 tree-ssa-alias.c
--- tree-ssa-alias.c    20 Dec 2004 18:18:28 -0000      2.64
+++ tree-ssa-alias.c    5 Jan 2005 00:06:24 -0000
@@ -1668,6 +1668,9 @@ add_may_alias (tree var, tree alias)
   else if (is_call_clobbered (alias))
     mark_call_clobbered (var);
 
+  if (TREE_THIS_VOLATILE (var))
+    a_ann->aliased_with_volatile = 1;
+
   VARRAY_PUSH_TREE (v_ann->may_aliases, alias);
   a_ann->is_alias_tag = 1;
 }
Index: tree-ssa-operands.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-operands.c,v
retrieving revision 2.60
diff -d -c -p -u -r2.60 tree-ssa-operands.c
--- tree-ssa-operands.c 10 Dec 2004 17:28:32 -0000      2.60
+++ tree-ssa-operands.c 5 Jan 2005 00:06:24 -0000
@@ -1528,6 +1528,9 @@ add_stmt_operand (tree *var_p, stmt_ann_
       return;
     }
 
+  if (v_ann->aliased_with_volatile && s_ann)
+    s_ann->has_volatile_ops = true;
+
   if (is_real_op)
     {
       /* The variable is a GIMPLE register.  Add it to real operands.  */


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|dnovillo at gcc dot gnu dot |
                   |org                         |
         AssignedTo|unassigned at gcc dot gnu   |dnovillo at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18241

Reply via email to