summaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-28 02:57:25 +0000
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-28 02:57:25 +0000
commitdfab9d64112c643cefeb4155dbfee20f54544afa (patch)
tree432043fe02c6f21c03f14c1b57a23835a373a7d0 /gcc/gimplify.c
parent713eba072c5903a401778afb174de08cbd11a77d (diff)
downloadgcc-dfab9d64112c643cefeb4155dbfee20f54544afa.tar.gz
* gimplify.c (maybe_with_size_expr): If already have WITH_SIZE_EXPR,
don't make another one. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85249 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index fc260c8ce4d..304a20b1082 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1746,20 +1746,25 @@ gimplify_self_mod_expr (tree *expr_p, tree *pre_p, tree *post_p,
static void
maybe_with_size_expr (tree *expr_p)
{
- tree expr, type, size;
+ tree expr = *expr_p;
+ tree type = TREE_TYPE (expr);
+ tree size;
- expr = *expr_p;
- type = TREE_TYPE (expr);
- if (type == error_mark_node)
+ /* If we've already wrapped this or the type is error_mark_node, we can't do
+ anything. */
+ if (TREE_CODE (expr) == WITH_SIZE_EXPR
+ || type == error_mark_node)
return;
+ /* If the size isn't known or is a constant, we have nothing to do. */
size = TYPE_SIZE_UNIT (type);
- if (size && TREE_CODE (size) != INTEGER_CST)
- {
- size = unshare_expr (size);
- size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, expr);
- *expr_p = build2 (WITH_SIZE_EXPR, type, expr, size);
- }
+ if (!size || TREE_CODE (size) == INTEGER_CST)
+ return;
+
+ /* Otherwise, make a WITH_SIZE_EXPR. */
+ size = unshare_expr (size);
+ size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, expr);
+ *expr_p = build2 (WITH_SIZE_EXPR, type, expr, size);
}
/* Subroutine of gimplify_call_expr: Gimplify a single argument. */