Skip to content
Snippets Groups Projects
Commit c7f5d117 authored by rguenth's avatar rguenth
Browse files

2006-02-10 Richard Guenther <rguenther@suse.de>

        * tree-dfa.c (get_ref_base_and_extent): When computing maxsize
        deal with structures that end in implicitly variable sized arrays.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110834 138bc75d-0d04-0410-961f-82ee72b054a4
parent bdae5484
No related branches found
No related tags found
No related merge requests found
2006-02-10 Richard Guenther <rguenther@suse.de>
* tree-dfa.c (get_ref_base_and_extent): When computing maxsize
deal with structures that end in implicitly variable sized arrays.
2006-02-09 Zdenek Dvorak <dvorakz@suse.cz> 2006-02-09 Zdenek Dvorak <dvorakz@suse.cz>
PR rtl-optimization/24762 PR rtl-optimization/24762
......
...@@ -913,6 +913,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, ...@@ -913,6 +913,7 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
HOST_WIDE_INT maxsize = -1; HOST_WIDE_INT maxsize = -1;
tree size_tree = NULL_TREE; tree size_tree = NULL_TREE;
tree bit_offset = bitsize_zero_node; tree bit_offset = bitsize_zero_node;
bool seen_variable_array_ref = false;
gcc_assert (!SSA_VAR_P (exp)); gcc_assert (!SSA_VAR_P (exp));
...@@ -1004,6 +1005,11 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, ...@@ -1004,6 +1005,11 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
fold_convert (bitsizetype, index), fold_convert (bitsizetype, index),
bitsize_unit_node); bitsize_unit_node);
bit_offset = size_binop (PLUS_EXPR, bit_offset, index); bit_offset = size_binop (PLUS_EXPR, bit_offset, index);
/* An array ref with a constant index up in the structure
hierarchy will constrain the size of any variable array ref
lower in the access hierarchy. */
seen_variable_array_ref = false;
} }
else else
{ {
...@@ -1019,6 +1025,10 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, ...@@ -1019,6 +1025,10 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
} }
else else
maxsize = -1; maxsize = -1;
/* Remember that we have seen an array ref with a variable
index. */
seen_variable_array_ref = true;
} }
} }
break; break;
...@@ -1043,6 +1053,21 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset, ...@@ -1043,6 +1053,21 @@ get_ref_base_and_extent (tree exp, HOST_WIDE_INT *poffset,
} }
done: done:
/* We need to deal with variable arrays ending structures such as
struct { int length; int a[1]; } x; x.a[d]
struct { struct { int a; int b; } a[1]; } x; x.a[d].a
struct { struct { int a[1]; } a[1]; } x; x.a[0][d], x.a[d][0]
where we do not know maxsize for variable index accesses to
the array. The simplest way to conservatively deal with this
is to punt in the case that offset + maxsize reaches the
base type boundary. */
if (seen_variable_array_ref
&& maxsize != -1
&& host_integerp (TYPE_SIZE (TREE_TYPE (exp)), 1)
&& TREE_INT_CST_LOW (bit_offset) + maxsize
== TREE_INT_CST_LOW (TYPE_SIZE (TREE_TYPE (exp))))
maxsize = -1;
/* ??? Due to negative offsets in ARRAY_REF we can end up with /* ??? Due to negative offsets in ARRAY_REF we can end up with
negative bit_offset here. We might want to store a zero offset negative bit_offset here. We might want to store a zero offset
in this case. */ in this case. */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment