aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2011-05-11 12:23:12 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2011-05-11 12:23:12 +0000
commit41a58a92c3be093fd963d1fdea1231631e06fc32 (patch)
tree4421880e85e5367fb727c8c2d5ff7e080dd0161c /gcc
parente9f8dcf9b3bd2972c947d793443a83a78104ae87 (diff)
downloadgcc-41a58a92c3be093fd963d1fdea1231631e06fc32.zip
gcc-41a58a92c3be093fd963d1fdea1231631e06fc32.tar.gz
gcc-41a58a92c3be093fd963d1fdea1231631e06fc32.tar.bz2
re PR middle-end/48953 (ICE: verify_gimple failed: type mismatch in array reference with -flto and struct with vararray)
2011-05-11 Richard Guenther <rguenther@suse.de> PR middle-end/48953 * tree-inline.c (remap_gimple_op_r): Also remap types of MEM_REFs. * gcc.dg/torture/pr48953.c: New testcase. From-SVN: r173653
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr48953.c17
-rw-r--r--gcc/tree-inline.c20
4 files changed, 38 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cbe38aa..a439ef8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-11 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/48953
+ * tree-inline.c (remap_gimple_op_r): Also remap types of MEM_REFs.
+
2011-05-11 Joseph Myers <joseph@codesourcery.com>
* opts.c (finish_options): Move warning settings from
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index becc978..5cfb9f2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2011-05-11 Richard Guenther <rguenther@suse.de>
+ PR middle-end/48953
+ * gcc.dg/torture/pr48953.c: New testcase.
+
+2011-05-11 Richard Guenther <rguenther@suse.de>
+
PR tree-optimization/18041
* gcc.dg/tree-ssa/forwprop-13.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/torture/pr48953.c b/gcc/testsuite/gcc.dg/torture/pr48953.c
new file mode 100644
index 0000000..41a3d7b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr48953.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-fno-tree-dce" } */
+
+static inline int foo (int n, int k)
+{
+ struct S
+ {
+ int i[n];
+ int value;
+ } s[2];
+ return s[k].value = 0;
+}
+
+int main ()
+{
+ return foo (2, 0);
+}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 46855a1..fc8c88f 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -811,9 +811,15 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data)
{
/* Otherwise, just copy the node. Note that copy_tree_r already
knows not to copy VAR_DECLs, etc., so this is safe. */
+
+ /* We should never have TREE_BLOCK set on non-statements. */
+ if (EXPR_P (*tp))
+ gcc_assert (!TREE_BLOCK (*tp));
+
if (TREE_CODE (*tp) == MEM_REF)
{
tree ptr = TREE_OPERAND (*tp, 0);
+ tree type = remap_type (TREE_TYPE (*tp), id);
tree old = *tp;
tree tem;
@@ -824,7 +830,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data)
if ((tem = maybe_fold_offset_to_reference (EXPR_LOCATION (*tp),
ptr,
TREE_OPERAND (*tp, 1),
- TREE_TYPE (*tp)))
+ type))
&& TREE_THIS_VOLATILE (tem) == TREE_THIS_VOLATILE (old))
{
tree *tem_basep = &tem;
@@ -846,7 +852,7 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data)
}
else
{
- *tp = fold_build2 (MEM_REF, TREE_TYPE (*tp),
+ *tp = fold_build2 (MEM_REF, type,
ptr, TREE_OPERAND (*tp, 1));
TREE_THIS_VOLATILE (*tp) = TREE_THIS_VOLATILE (old);
TREE_THIS_NOTRAP (*tp) = TREE_THIS_NOTRAP (old);
@@ -860,6 +866,9 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data)
tweak some special cases. */
copy_tree_r (tp, walk_subtrees, NULL);
+ if (TREE_CODE (*tp) != OMP_CLAUSE)
+ TREE_TYPE (*tp) = remap_type (TREE_TYPE (*tp), id);
+
/* Global variables we haven't seen yet need to go into referenced
vars. If not referenced from types only. */
if (gimple_in_ssa_p (cfun)
@@ -868,13 +877,6 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data)
&& !processing_debug_stmt)
add_referenced_var (*tp);
- /* We should never have TREE_BLOCK set on non-statements. */
- if (EXPR_P (*tp))
- gcc_assert (!TREE_BLOCK (*tp));
-
- if (TREE_CODE (*tp) != OMP_CLAUSE)
- TREE_TYPE (*tp) = remap_type (TREE_TYPE (*tp), id);
-
if (TREE_CODE (*tp) == TARGET_EXPR && TREE_OPERAND (*tp, 3))
{
/* The copied TARGET_EXPR has never been expanded, even if the