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: [tuples][patch] Recording vars whose address is taken in phi nodes


patch attached

On Tue, Mar 11, 2008 at 6:34 PM, Oleg Ryjkov <olegr@google.com> wrote:
> Hello,
>
>  This patch adds the code to record variables, whose address is taken
>  within phi nodes.
>  Tested on i686-linux, no regressions.
>
>  2008-03-11  Diego Novillo <dnovillo@google.com>
>
>         * tree-ssa-operands.h: Added declaration of add_to_addressable_set.
>         * tree-ssa-operands.h (add_to_addressable_set): New function.
>         (gimple_add_to_addresses_taken): Moved most of the logic to
>         add_addressable_set.
>         * tree-ssa-structalias.c (update_alias_info): Record the variables
>         whose address is taken inside a phi node.
>
Index: tree-ssa-operands.h
===================================================================
--- tree-ssa-operands.h	(revision 133121)
+++ tree-ssa-operands.h	(working copy)
@@ -216,6 +216,7 @@ extern bool ssa_operands_active (void);
 extern void push_stmt_changes (gimple *);
 extern void pop_stmt_changes (gimple *);
 extern void discard_stmt_changes (gimple *);
+void add_to_addressable_set (tree, bitmap *);
 
 enum ssa_op_iter_type {
   ssa_op_iter_none = 0,
Index: ChangeLog.tuples
===================================================================
--- ChangeLog.tuples	(revision 133121)
+++ ChangeLog.tuples	(working copy)
@@ -1,3 +1,12 @@
+2008-03-11  Diego Novillo <dnovillo@google.com>
+
+	* tree-ssa-operands.h: Added declaration of add_to_addressable_set.
+	* tree-ssa-operands.h (add_to_addressable_set): New function.
+	(gimple_add_to_addresses_taken): Moved most of the logic to
+	add_addressable_set.
+	* tree-ssa-structalias.c (update_alias_info): Record the variables
+	whose address is taken inside a phi node.
+
 2008-03-11  Aldy Hernandez  <aldyh@redhat.com>
 
 	* tree-phinodes.c (allocate_phi_node): Update for tuples.
Index: tree-ssa-structalias.c
===================================================================
--- tree-ssa-structalias.c	(revision 133121)
+++ tree-ssa-structalias.c	(working copy)
@@ -3273,6 +3273,26 @@ update_alias_info (gimple stmt, struct a
 
       op = USE_FROM_PTR (use_p);
 
+      /* If STMT is a PHI node, OP may be an ADDR_EXPR.  If so, add it
+	 to the set of addressable variables.  */
+      if (TREE_CODE (op) == ADDR_EXPR)
+	{
+	  bitmap addressable_vars = gimple_addressable_vars (cfun);
+
+	  gcc_assert (gimple_code (stmt) == GIMPLE_PHI);
+	  gcc_assert (addressable_vars);
+
+	  /* PHI nodes don't have annotations for pinning the set
+	     of addresses taken, so we collect them here.
+
+	     FIXME, should we allow PHI nodes to have annotations
+	     so that they can be treated like regular statements?
+	     Currently, they are treated as second-class
+	     statements.  */
+	  add_to_addressable_set (TREE_OPERAND (op, 0), &addressable_vars);
+	  continue;
+	}
+
       /* Ignore constants (they may occur in PHI node arguments).  */
       if (TREE_CODE (op) != SSA_NAME)
 	continue;
Index: tree-ssa-operands.c
===================================================================
--- tree-ssa-operands.c	(revision 133121)
+++ tree-ssa-operands.c	(working copy)
@@ -2657,15 +2657,10 @@ swap_tree_operands (gimple stmt, tree *e
   *exp1 = op0;
 }
 
-
-/* Add the base address of REF to the set of addresses taken by STMT.
-   REF may be a single variable whose address has been taken or any
-   other valid GIMPLE memory reference (structure reference, array,
-   etc).  If the base address of REF is a decl that has sub-variables,
-   also add all of its sub-variables.  */
+/* Add the base address of REF to SET.  */
 
 void
-gimple_add_to_addresses_taken (gimple stmt, tree ref)
+add_to_addressable_set (tree ref, bitmap *set)
 {
   tree var;
   subvar_t svars;
@@ -2680,10 +2675,10 @@ gimple_add_to_addresses_taken (gimple st
     {
       bitmap b;
 
-      if (gimple_addresses_taken (stmt) == NULL)
-	stmt->with_ops.addresses_taken = BITMAP_ALLOC (&operands_bitmap_obstack);
+      if (*set == NULL)
+	*set = BITMAP_ALLOC (&operands_bitmap_obstack);
 
-      b = gimple_addresses_taken (stmt);
+      b = *set;
 
       if (var_can_have_subvars (var)
 	  && (svars = get_subvars_for_var (var)))
@@ -2705,6 +2700,20 @@ gimple_add_to_addresses_taken (gimple st
 }
 
 
+/* Add the base address of REF to the set of addresses taken by STMT.
+   REF may be a single variable whose address has been taken or any
+   other valid GIMPLE memory reference (structure reference, array,
+   etc).  If the base address of REF is a decl that has sub-variables,
+   also add all of its sub-variables.  */
+
+void
+gimple_add_to_addresses_taken (gimple stmt, tree ref)
+{
+  gcc_assert (gimple_has_ops (stmt));
+  add_to_addressable_set (ref, &stmt->with_ops.addresses_taken);
+}
+
+
 /* Scan the immediate_use list for VAR making sure its linked properly.
    Return TRUE if there is a problem and emit an error message to F.  */
 

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