diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-20 11:02:40 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-20 11:02:40 +0000 |
commit | 85cea2e300bb24c3736eb946ae0af0fb711705f3 (patch) | |
tree | 56cb2bd757966e0e9eda82f1ae634cee00c709ee /gcc/stor-layout.c | |
parent | 36db6e56b6e38e2e5d01d7d9be7652db43025dd3 (diff) | |
download | gcc-85cea2e300bb24c3736eb946ae0af0fb711705f3.tar.gz |
* stor-layout.c (skip_simple_constant_arithmetic): New function.
(self_referential_size): Use it instead of skip_simple_arithmetic.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@165716 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stor-layout.c')
-rw-r--r-- | gcc/stor-layout.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 5796ea1f09a..f3663185e68 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -173,6 +173,32 @@ variable_size (tree size) /* An array of functions used for self-referential size computation. */ static GTY(()) VEC (tree, gc) *size_functions; +/* Look inside EXPR into simple arithmetic operations involving constants. + Return the outermost non-arithmetic or non-constant node. */ + +static tree +skip_simple_constant_arithmetic (tree expr) +{ + while (true) + { + if (UNARY_CLASS_P (expr)) + expr = TREE_OPERAND (expr, 0); + else if (BINARY_CLASS_P (expr)) + { + if (TREE_CONSTANT (TREE_OPERAND (expr, 1))) + expr = TREE_OPERAND (expr, 0); + else if (TREE_CONSTANT (TREE_OPERAND (expr, 0))) + expr = TREE_OPERAND (expr, 1); + else + break; + } + else + break; + } + + return expr; +} + /* Similar to copy_tree_r but do not copy component references involving PLACEHOLDER_EXPRs. These nodes are spotted in find_placeholder_in_expr and substituted in substitute_in_expr. */ @@ -241,7 +267,7 @@ self_referential_size (tree size) VEC(tree,gc) *args = NULL; /* Do not factor out simple operations. */ - t = skip_simple_arithmetic (size); + t = skip_simple_constant_arithmetic (size); if (TREE_CODE (t) == CALL_EXPR) return size; |