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: [tree-ssa] fix latent & real bugs in BIT_FIELD_REFs


Attached is a revised patch including what we discussed earlier today. 
I won't commit it until we can figure out why the test case you had
originally added doesn't trigger on an unpatched compiler.

Bootstrapped and tested on x86-64.


Diego.


2004-03-24  Paolo Bonzini  <bonzini@gnu.org>

	* tree-alias-common.c (find_func_aliases): Support
	assigning to BIT_FIELD_REFs.
	* tree-cfg.c (verify_expr): Don't allow assign to
	a register with BIT_FIELD_REF.
	* tree-dfa.c (get_virtual_var): Go through BIT_FIELD_REFs
	if they access a non-register.
	(discover_nonconstant_array_refs_r): Go through BIT_FIELD_REFs.
	* tree-simple.c: Document that BIT_FIELD_REFs are valid lvalues.
	* tree-ssa.c (set_is_used): Go through BIT_FIELD_REFs.

2004-03-24  Diego Novillo  <dnovillo@redhat.com>

	* tree-ssa-operands.c (get_expr_operands): Don't call
	add_stmt_operand on VA_ARG_EXPR.  Mark the statement as having
	volatile operands.
	(add_stmt_operand): Add sanity checks.

Index: tree-alias-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-common.c,v
retrieving revision 1.1.2.53
diff -d -c -p -d -u -p -r1.1.2.53 tree-alias-common.c
--- tree-alias-common.c	12 Mar 2004 17:49:52 -0000	1.1.2.53
+++ tree-alias-common.c	24 Mar 2004 21:29:28 -0000
@@ -629,7 +629,8 @@ find_func_aliases (tree stp)
       else
 	{
 	  /* x.f = y  or x->f = y */
-	  if (TREE_CODE (op0) == COMPONENT_REF 
+	  if ((TREE_CODE (op0) == COMPONENT_REF 
+	       || TREE_CODE (op0) == BIT_FIELD_REF)
 	      && is_gimple_variable (op1))
 	    {
 	      if (rhsAV != NULL)
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.278
diff -d -c -p -d -u -p -r1.1.4.278 tree-cfg.c
--- tree-cfg.c	16 Mar 2004 22:31:55 -0000	1.1.4.278
+++ tree-cfg.c	24 Mar 2004 21:29:28 -0000
@@ -2938,6 +2938,16 @@ verify_expr (tree *tp, int *walk_subtree
 	}
       break;
 
+    case MODIFY_EXPR:
+      x = TREE_OPERAND (t, 0);
+      if (TREE_CODE (x) == BIT_FIELD_REF
+	  && is_gimple_reg (TREE_OPERAND (x, 0)))
+	{
+	  error ("GIMPLE register modified with BIT_FIELD_REF");
+	  return *tp;
+	}
+      break;
+
     case ADDR_EXPR:
       x = TREE_OPERAND (t, 0);
       while (TREE_CODE (x) == ARRAY_REF
Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.222
diff -d -c -p -d -u -p -r1.1.4.222 tree-dfa.c
--- tree-dfa.c	19 Mar 2004 17:51:45 -0000	1.1.4.222
+++ tree-dfa.c	24 Mar 2004 21:29:28 -0000
@@ -1222,6 +1222,7 @@ discover_nonconstant_array_refs_r (tree 
       while ((TREE_CODE (t) == ARRAY_REF
 	      && is_gimple_min_invariant (TREE_OPERAND (t, 1)))
 	     || (TREE_CODE (t) == COMPONENT_REF
+		 || TREE_CODE (t) == BIT_FIELD_REF
 		 || TREE_CODE (t) == REALPART_EXPR
 		 || TREE_CODE (t) == IMAGPART_EXPR))
 	t = TREE_OPERAND (t, 0);
Index: tree-simple.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-simple.c,v
retrieving revision 1.1.4.74
diff -d -c -p -d -u -p -r1.1.4.74 tree-simple.c
--- tree-simple.c	12 Mar 2004 04:19:06 -0000	1.1.4.74
+++ tree-simple.c	24 Mar 2004 21:29:28 -0000
@@ -113,8 +113,13 @@ Boston, MA 02111-1307, USA.  */
      op1 -> arglist
 
    addr-expr-arg : compref | ID
-   lhs: addr-expr-arg | '*' ID
+   lhs: addr-expr-arg | '*' ID | bitfieldref
    min-lval: ID | '*' ID
+   bitfieldref :
+     BIT_FIELD_REF
+       op0 -> compref | min-lval
+       op1 -> CONST
+       op2 -> CONST
    compref :
      COMPONENT_REF
        op0 -> compref | min-lval
Index: tree-ssa-operands.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-operands.c,v
retrieving revision 1.1.2.17
diff -d -c -p -d -u -p -r1.1.2.17 tree-ssa-operands.c
--- tree-ssa-operands.c	16 Mar 2004 22:31:56 -0000	1.1.2.17
+++ tree-ssa-operands.c	24 Mar 2004 21:29:28 -0000
@@ -1077,11 +1077,12 @@ get_expr_operands (tree stmt, tree *expr
       return;
     }
 
-  /* VA_ARG_EXPR nodes read and modify the argument pointer.  Add it to
-     VOPS to avoid optimizations messing it up.  */
+  /* Mark VA_ARG_EXPR nodes as making volatile references.  FIXME,
+     this is needed because we currently do not gimplify VA_ARG_EXPR
+     properly.  */
   if (code == VA_ARG_EXPR)
     {
-      add_stmt_operand (&TREE_OPERAND (expr, 0), stmt, opf_is_def, prev_vops);
+      stmt_ann (stmt)->has_volatile_ops = true;
       return;
     }
 
@@ -1134,6 +1135,16 @@ add_stmt_operand (tree *var_p, tree stmt
 
   var = *var_p;
   STRIP_NOPS (var);
+
+#if defined ENABLE_CHECKING
+  if (!SSA_VAR_P (var)
+      && TREE_CODE (var) != ARRAY_REF
+      && TREE_CODE (var) != COMPONENT_REF
+      && TREE_CODE (var) != REALPART_EXPR
+      && TREE_CODE (var) != IMAGPART_EXPR
+      && TREE_CODE (var) != ADDR_EXPR)
+    abort ();
+#endif
 
   s_ann = stmt_ann (stmt);
 
Index: tree-ssa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa.c,v
retrieving revision 1.1.4.216
diff -d -c -p -d -u -p -r1.1.4.216 tree-ssa.c
--- tree-ssa.c	19 Mar 2004 02:07:25 -0000	1.1.4.216
+++ tree-ssa.c	24 Mar 2004 21:29:29 -0000
@@ -435,6 +435,7 @@ set_is_used (tree t)
 	case COMPONENT_REF:
 	case REALPART_EXPR:
 	case IMAGPART_EXPR:
+	case BIT_FIELD_REF:
 	case INDIRECT_REF:
 	  t = TREE_OPERAND (t, 0);
 	  break;



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