From d26f8097a31ff6a47d4b0861677ba44a8a25efec Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 12 Nov 1999 16:52:08 +0000 Subject: [PATCH] tree.h (SAVE_EXPR_PERSISTENT_P): New macro. * 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 | 9 +++++++++ gcc/stor-layout.c | 11 +++++++++++ gcc/tree.c | 28 +++------------------------- gcc/tree.h | 5 +++++ 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f1606c9313e..fd093775536 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +Fri Nov 12 08:54:22 1999 Mark Mitchell + + * 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 * defaults.h (ASM_OUTPUT_ALTERNATE_LABEL_NAME): Use diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 3663293f56d..1433e8b439d 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -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)) diff --git a/gcc/tree.c b/gcc/tree.c index ea5c1bfce76..a96d5c3e9fd 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -2236,10 +2236,7 @@ int_size_in_bytes (type) } /* 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: diff --git a/gcc/tree.h b/gcc/tree.h index 42760c868ef..1aa72d725e2 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -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]) -- 2.30.2