tree.h (SAVE_EXPR_PERSISTENT_P): New macro.
authorMark Mitchell <mark@codesourcery.com>
Fri, 12 Nov 1999 16:52:08 +0000 (16:52 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 12 Nov 1999 16:52:08 +0000 (16:52 +0000)
* tree.h (SAVE_EXPR_PERSISTENT_P): New macro.
* tree.c (array_type_nelts): Don't handle SAVE_EXPRs specially.
(unsave_expr_now): Don't unsave SAVE_EXPR_PERSISTENT_P
expressions.
* stor-layout.c (variable_size): Set SAVE_EXPR_PERSISTENT_P on
variable-sized array bounds.

From-SVN: r30503

gcc/ChangeLog
gcc/stor-layout.c
gcc/tree.c
gcc/tree.h

index f1606c9313e97e70983131ea8fc403f74944a5c8..fd09377553641b674a125d81ac42a277ad3fa631 100644 (file)
@@ -1,3 +1,12 @@
+Fri Nov 12 08:54:22 1999  Mark Mitchell  <mark@codesourcery.com>
+
+       * tree.h (SAVE_EXPR_PERSISTENT_P): New macro.
+       * tree.c (array_type_nelts): Don't handle SAVE_EXPRs specially.
+       (unsave_expr_now): Don't unsave SAVE_EXPR_PERSISTENT_P
+       expressions.
+       * stor-layout.c (variable_size): Set SAVE_EXPR_PERSISTENT_P on
+       variable-sized array bounds.
+       
 Fri Nov 12 08:04:45 1999  Catherine Moore  <clm@cygnus.com>
 
        * defaults.h (ASM_OUTPUT_ALTERNATE_LABEL_NAME):  Use
index 3663293f56dd687bb7b75fcaf4bbf81818d51e4b..1433e8b439d96bfec5123f2bb7cb51ddc88b7ee9 100644 (file)
@@ -97,6 +97,17 @@ variable_size (size)
 
   size = save_expr (size);
 
+  /* If an array with a variable number of elements is declared, and
+     the elements require destruction, we will emit a cleanup for the
+     array.  That cleanup is run both on normal exit from the block
+     and in the exception-handler for the block.  Normally, when code
+     is used in both ordinary code and in an exception handler it is
+     `unsaved', i.e., all SAVE_EXPRs are recalculated.  However, we do
+     not wish to do that here; the array-size is the same in both
+     places.  */
+  if (TREE_CODE (size) == SAVE_EXPR)
+    SAVE_EXPR_PERSISTENT_P (size) = 1;
+
   if (global_bindings_p ())
     {
       if (TREE_CONSTANT (size))
index ea5c1bfce767ee2f3c802cdb8770eadecda997fe..a96d5c3e9fd4bf32612981d04e8c74482b7ea405 100644 (file)
@@ -2236,10 +2236,7 @@ int_size_in_bytes (type)
 }
 \f
 /* Return, as a tree node, the number of elements for TYPE (which is an
-   ARRAY_TYPE) minus one. This counts only elements of the top array.
-
-   Don't let any SAVE_EXPRs escape; if we are called as part of a cleanup
-   action, they would get unsaved.  */
+   ARRAY_TYPE) minus one. This counts only elements of the top array.  */
 
 tree
 array_type_nelts (type)
@@ -2256,26 +2253,6 @@ array_type_nelts (type)
   min = TYPE_MIN_VALUE (index_type);
   max = TYPE_MAX_VALUE (index_type);
 
-  if (! TREE_CONSTANT (min))
-    {
-      STRIP_NOPS (min);
-      if (TREE_CODE (min) == SAVE_EXPR && SAVE_EXPR_RTL (min))
-       min = build (RTL_EXPR, TREE_TYPE (TYPE_MIN_VALUE (index_type)), 0,
-                    SAVE_EXPR_RTL (min));
-      else
-       min = TYPE_MIN_VALUE (index_type);
-    }
-
-  if (! TREE_CONSTANT (max))
-    {
-      STRIP_NOPS (max);
-      if (TREE_CODE (max) == SAVE_EXPR && SAVE_EXPR_RTL (max))
-       max = build (RTL_EXPR, TREE_TYPE (TYPE_MAX_VALUE (index_type)), 0,
-                    SAVE_EXPR_RTL (max));
-      else
-       max = TYPE_MAX_VALUE (index_type);
-    }
-
   return (integer_zerop (min)
          ? max
          : fold (build (MINUS_EXPR, TREE_TYPE (max), max, min)));
@@ -2465,7 +2442,8 @@ unsave_expr_now (expr)
   switch (code)
     {
     case SAVE_EXPR:
-      SAVE_EXPR_RTL (expr) = 0;
+      if (!SAVE_EXPR_PERSISTENT_P (expr))
+       SAVE_EXPR_RTL (expr) = 0;
       break;
 
     case TARGET_EXPR:
index 42760c868efa400abf50c040d83db1229eff616d..1aa72d725e2f72f54678757534dc218e4f1523e4 100644 (file)
@@ -717,6 +717,11 @@ struct tree_vec
 #define SAVE_EXPR_CONTEXT(NODE) TREE_OPERAND(NODE, 1)
 #define SAVE_EXPR_RTL(NODE) (*(struct rtx_def **) &EXPR_CHECK (NODE)->exp.operands[2])
 #define SAVE_EXPR_NOPLACEHOLDER(NODE) TREE_UNSIGNED (NODE)
+/* Nonzero if the SAVE_EXPRs value should be kept, even if it occurs
+   both in normal code and in a handler.  (Normally, in a handler, all
+   SAVE_EXPRs are unsaved, meaning that there values are
+   recalculated.)  */
+#define SAVE_EXPR_PERSISTENT_P(NODE) TREE_ASM_WRITTEN (NODE)
 
 /* In a RTL_EXPR node.  */
 #define RTL_EXPR_SEQUENCE(NODE) (*(struct rtx_def **) &EXPR_CHECK (NODE)->exp.operands[0])