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]

[PATCH] WITH_CLEANUP_EXPR ggc fix.



I've been working on an optimization patch for the Java front-end that
stresses memory usage in such a way that WITH_CLEANUP_EXPRs are
eventually collected.

Here's a patch to make it work. I'm not entirely sure that creating a
new RTL_EXPR_RTL2 macro is the right thing to do...

This patch doesn't trigger regressions with the C, C++ and Java
front-ends. I verified that it fixes the problem I originally
encountered with the Java front-end.

Are the C and C++ parts OK?

./A

gcc:

2001-07-31  Alexandre Petit-Bianco  <apbianco@redhat.com>

	* expr.c (safe_from_p): Use RTL_EXPR_RTL2 instead of RTL_EXPR_RTL
	while handling WITH_CLEANUP_EXPR nodes.
	(expand_expr): Use RTL_EXPR_RTL2 instead of RTL_EXPR_RTL while
	handling WITH_CLEANUP_EXPR node. Use second operand calling
	expand_decl_cleanup.
	* tree.c (firt_rtl_op): The third operand of WITH_CLEANUP_EXPR is
	the first RTX.
	(simple_cst_equal): WITH_CLEANUP_EXPR node to use its second
	operand while calling simple_cst_equal.
	* tree.def (WITH_CLEANUP_EXPR): Switched operands: the second
	operand is the cleanup expression, the third is the RTL_EXPR.
	* tree.h (RTL_EXPR_RTL2): New macro.	

gcc/cp:

2001-07-31  Alexandre Petit-Bianco  <apbianco@redhat.com>

	* tree.c (cp_tree_equal): WITH_CLEANUP_EXPR node to use its second
	operand while calling cp_tree_equal.

gcc/java:

2001-07-31  Alexandre Petit-Bianco  <apbianco@redhat.com>

	* check-init.c (check_init): WITH_CLEANUP_EXPR node to use its
	second operand calling check_init.
	* decl.c (complete_start_java_method): Swaped second and third
	arguments while creating WITH_CLEANUP_EXPR node.
	* jcf-write.c (generate_bytecode_insns): Use second operand
	instead of third when handling WITH_CLEANUP_EXPR.
	* parse.y (java_complete_lhs): Expand second operand of
	WITH_CLEANUP_EXPR nodes.
	(patch_synchronized_statement): Swaped second and third arguments
	while creating WITH_CLEANUP_EXPR node.

Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.340
diff -u -p -r1.340 expr.c
--- expr.c	2001/07/20 20:07:58	1.340
+++ expr.c	2001/07/31 17:53:47
@@ -5858,7 +5858,7 @@ safe_from_p (x, exp, top_p)
 	  break;
 
 	case WITH_CLEANUP_EXPR:
-	  exp_rtl = RTL_EXPR_RTL (exp);
+	  exp_rtl = RTL_EXPR_RTL2 (exp);
 	  break;
 
 	case CLEANUP_POINT_EXPR:
@@ -7376,16 +7376,16 @@ expand_expr (exp, target, tmode, modifie
       }
 
     case WITH_CLEANUP_EXPR:
-      if (RTL_EXPR_RTL (exp) == 0)
+      if (RTL_EXPR_RTL2 (exp) == 0)
 	{
-	  RTL_EXPR_RTL (exp)
+	  RTL_EXPR_RTL2 (exp)
 	    = expand_expr (TREE_OPERAND (exp, 0), target, tmode, ro_modifier);
-	  expand_decl_cleanup (NULL_TREE, TREE_OPERAND (exp, 2));
+	  expand_decl_cleanup (NULL_TREE, TREE_OPERAND (exp, 1));
 
 	  /* That's it for this cleanup.  */
-	  TREE_OPERAND (exp, 2) = 0;
+	  TREE_OPERAND (exp, 1) = 0;
 	}
-      return RTL_EXPR_RTL (exp);
+      return RTL_EXPR_RTL2 (exp);
 
     case CLEANUP_POINT_EXPR:
       {
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.202
diff -u -p -r1.202 tree.c
--- tree.c	2001/07/08 20:05:08	1.202
+++ tree.c	2001/07/31 17:53:57
@@ -1628,8 +1628,7 @@ first_rtl_op (code)
     case RTL_EXPR:
       return 0;
     case WITH_CLEANUP_EXPR:
-      /* Should be defined to be 2.  */
-      return 1;
+      return 2;
     case METHOD_CALL_EXPR:
       return 3;
     default:
@@ -3679,7 +3678,7 @@ simple_cst_equal (t1, t2)
       if (cmp <= 0)
 	return cmp;
 
-      return simple_cst_equal (TREE_OPERAND (t1, 2), TREE_OPERAND (t1, 2));
+      return simple_cst_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
 
     case COMPONENT_REF:
       if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1))
Index: tree.def
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.def,v
retrieving revision 1.42
diff -u -p -r1.42 tree.def
--- tree.def	2001/07/19 18:33:30	1.42
+++ tree.def	2001/07/31 17:54:00
@@ -472,8 +472,8 @@ DEFTREECODE (METHOD_CALL_EXPR, "method_c
 
 /* Specify a value to compute along with its corresponding cleanup.
    Operand 0 argument is an expression whose value needs a cleanup.
-   Operand 1 is an RTL_EXPR which will eventually represent that value.
-   Operand 2 is the cleanup expression for the object.
+   Operand 1 is the cleanup expression for the object.
+   Operand 2 is an RTL_EXPR which will eventually represent that value.
      The RTL_EXPR is used in this expression, which is how the expression
      manages to act on the proper value.
    The cleanup is executed by the first enclosing CLEANUP_POINT_EXPR, if
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.258
diff -u -p -r1.258 tree.h
--- tree.h	2001/07/29 02:10:42	1.258
+++ tree.h	2001/07/31 17:54:09
@@ -791,6 +791,7 @@ struct tree_vec
 /* In a RTL_EXPR node.  */
 #define RTL_EXPR_SEQUENCE(NODE) (*(struct rtx_def **) &EXPR_CHECK (NODE)->exp.operands[0])
 #define RTL_EXPR_RTL(NODE) (*(struct rtx_def **) &EXPR_CHECK (NODE)->exp.operands[1])
+#define RTL_EXPR_RTL2(NODE) (*(struct rtx_def **) &EXPR_CHECK (NODE)->exp.operands[2])
 
 /* In a CONSTRUCTOR node.  */
 #define CONSTRUCTOR_ELTS(NODE) TREE_OPERAND (NODE, 1)
Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.246
diff -u -p -r1.246 tree.c
--- tree.c	2001/07/24 14:55:07	1.246
+++ tree.c	2001/07/31 17:54:17
@@ -1958,7 +1958,7 @@ cp_tree_equal (t1, t2)
       cmp = cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
       if (cmp <= 0)
 	return cmp;
-      return cp_tree_equal (TREE_OPERAND (t1, 2), TREE_OPERAND (t1, 2));
+      return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
 
     case COMPONENT_REF:
       if (TREE_OPERAND (t1, 1) == TREE_OPERAND (t2, 1))
Index: java/check-init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/check-init.c,v
retrieving revision 1.31
diff -u -p -r1.31 check-init.c
--- check-init.c	2001/07/15 02:16:35	1.31
+++ check-init.c	2001/07/31 17:54:55
@@ -537,7 +537,7 @@ check_init (exp, before)
 #endif
 	check_init (TREE_OPERAND (exp, 0), before);
 	UNION (alt->combined, alt->combined, before);
-	check_init (TREE_OPERAND (exp, 2), alt->combined);
+	check_init (TREE_OPERAND (exp, 1), alt->combined);
 	return;
       }
 
Index: java/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.103
diff -u -p -r1.103 decl.c
--- decl.c	2001/06/10 18:24:53	1.103
+++ decl.c	2001/07/31 17:55:05
@@ -1738,7 +1738,7 @@ complete_start_java_method (fndecl)
 	  tree function_body = DECL_FUNCTION_BODY (fndecl);
 	  tree body = BLOCK_EXPR_BODY (function_body);
 	  lock = build (WITH_CLEANUP_EXPR, void_type_node,
-			enter,  NULL_TREE, exit);
+			enter, exit, NULL_TREE);
 	  TREE_SIDE_EFFECTS (lock) = 1;
 	  lock = build (COMPOUND_EXPR, TREE_TYPE (body), lock, body);
 	  TREE_SIDE_EFFECTS (lock) = 1;
Index: java/jcf-write.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-write.c,v
retrieving revision 1.81
diff -u -p -r1.81 jcf-write.c
--- jcf-write.c	2001/05/13 04:59:32	1.81
+++ jcf-write.c	2001/07/31 17:55:19
@@ -2293,7 +2293,7 @@ generate_bytecode_insns (exp, target, st
 	label->next = state->labeled_blocks;
 	state->labeled_blocks = label;
 	state->num_finalizers++;
-	label->u.labeled_block = TREE_OPERAND (exp, 2);
+	label->u.labeled_block = TREE_OPERAND (exp, 1);
 	label->v.start_label = get_jcf_label_here (state);
 	if (target != IGNORE_TARGET)
 	  abort ();
@@ -11301,7 +11326,7 @@ java_complete_lhs (node)
 
     case WITH_CLEANUP_EXPR:
       COMPLETE_CHECK_OP_0 (node);
-      COMPLETE_CHECK_OP_2 (node);
+      COMPLETE_CHECK_OP_1 (node);
       CAN_COMPLETE_NORMALLY (node) = 
 	CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
       TREE_TYPE (node) = void_type_node;
@@ -15299,7 +15326,7 @@ patch_synchronized_statement (node, wfl_
 			build (WITH_CLEANUP_EXPR, NULL_TREE,
 			       build (COMPOUND_EXPR, NULL_TREE,
 				      assignment, enter),
-			       NULL_TREE, exit),
+			       exit, NULL_TREE),
 			block));
   node = build_expr_block (node, expr_decl);
 


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