aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2012-01-04 21:34:27 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2012-01-04 21:34:27 +0000
commit8594273a73ffb731659f16b9d469112dc0e4c113 (patch)
treedf4e13bc1032827ddaf7fb13c5db9c196bb5ffa6 /gcc
parent5dc28f42b4522c1ba7446174282496a3e54014d2 (diff)
downloadgcc-8594273a73ffb731659f16b9d469112dc0e4c113.zip
gcc-8594273a73ffb731659f16b9d469112dc0e4c113.tar.gz
gcc-8594273a73ffb731659f16b9d469112dc0e4c113.tar.bz2
re PR tree-optimization/51624 (Assert_Failure atree.adb:808 during stage 3)
PR tree-optimization/51624 * tree-sra.c (build_ref_for_model): When replicating a chain of COMPONENT_REFs, stop as soon as the offset would become negative. From-SVN: r182889
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-sra.c11
2 files changed, 14 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fc64179..3d9bc63 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2012-01-04 Eric Botcazou <ebotcazou@adacore.com>
+
+ PR tree-optimization/51624
+ * tree-sra.c (build_ref_for_model): When replicating a chain of
+ COMPONENT_REFs, stop as soon as the offset would become negative.
+
2012-01-04 Jakub Jelinek <jakub@redhat.com>
PR debug/51695
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index db9b9bf..accbc1e 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1520,11 +1520,16 @@ build_ref_for_model (location_t loc, tree base, HOST_WIDE_INT offset,
do {
tree field = TREE_OPERAND (expr, 1);
tree cr_offset = component_ref_field_offset (expr);
- gcc_assert (cr_offset && host_integerp (cr_offset, 1));
+ HOST_WIDE_INT bit_pos
+ = tree_low_cst (cr_offset, 1) * BITS_PER_UNIT
+ + TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field));
- offset -= TREE_INT_CST_LOW (cr_offset) * BITS_PER_UNIT;
- offset -= TREE_INT_CST_LOW (DECL_FIELD_BIT_OFFSET (field));
+ /* We can be called with a model different from the one associated
+ with BASE so we need to avoid going up the chain too far. */
+ if (offset - bit_pos < 0)
+ break;
+ offset -= bit_pos;
VEC_safe_push (tree, stack, cr_stack, expr);
expr = TREE_OPERAND (expr, 0);