aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Dvorak <rakdver@gcc.gnu.org>2006-06-20 10:26:45 +0000
committerZdenek Dvorak <rakdver@gcc.gnu.org>2006-06-20 10:26:45 +0000
commit8fdbc9c6eb3bea037982fba616d96c6288f177f9 (patch)
tree8accfb5818191f82ed0722bcd3e7a5510b332100
parentfe5568e99010574916f5b2607a173a34f2340891 (diff)
downloadgcc-8fdbc9c6eb3bea037982fba616d96c6288f177f9.zip
gcc-8fdbc9c6eb3bea037982fba616d96c6288f177f9.tar.gz
gcc-8fdbc9c6eb3bea037982fba616d96c6288f177f9.tar.bz2
re PR tree-optimization/27331 (segfault in fold_convert with -ftree-vectorize)
PR tree-optimization/27331 * tree-data-ref.c (free_data_ref): New function. (create_data_ref): Fail if the data reference has unknown access function. (free_data_refs): Use free_data_ref. * gcc.dg/pr27331.c: New test. From-SVN: r114810
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/pr27331.c56
-rw-r--r--gcc/tree-data-ref.c33
4 files changed, 95 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 3948911..aec8a3f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2006-06-20 Zdenek Dvorak <dvorakz@suse.cz>
+
+ PR tree-optimization/27331
+ * tree-data-ref.c (free_data_ref): New function.
+ (create_data_ref): Fail if the data reference has unknown access
+ function.
+ (free_data_refs): Use free_data_ref.
+
2006-06-19 Andrew Pinski <pinskia@gmail.com>
PR middle-end/28075
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 71bd235..5491dbe 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
+2006-06-20 Zdenek Dvorak <dvorakz@suse.cz>
+
+ PR tree-optimization/27331
+ * gcc.dg/pr27331.c: New test.
+
2006-06-20 James A. Morrison <phython@gcc.gnu.org>
- Eric Botcazou <ebotcazou@adacore.com>
+ Eric Botcazou <ebotcazou@adacore.com>
PR ada/18692
* lib/gnat.exp: New file.
diff --git a/gcc/testsuite/gcc.dg/pr27331.c b/gcc/testsuite/gcc.dg/pr27331.c
new file mode 100644
index 0000000..9b5c71e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr27331.c
@@ -0,0 +1,56 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize" } */
+
+struct funny_match
+{
+ int this, other;
+};
+
+typedef struct rtx {
+ int code;
+} *rtx;
+
+extern rtx recog_operand[];
+extern int which_alternative;
+extern int nalternatives;
+
+int
+constrain_operands (insn_code_num, strict)
+ int insn_code_num;
+ int strict;
+{
+ char *constraints[10];
+ struct funny_match funny_match[10];
+ register int c;
+ int funny_match_index;
+
+ which_alternative = 0;
+
+ while (which_alternative < nalternatives)
+ {
+ register int opno;
+ register char *p = constraints[opno];
+ int lose = 0;
+ funny_match_index = 0;
+
+ while (*p && (c = *p++) != ',')
+ funny_match[funny_match_index++].other = c - '0';
+
+ if ((((recog_operand[opno])->code) == 12))
+ lose = 1;
+
+ if (!lose)
+ {
+ while (--funny_match_index >= 0)
+ recog_operand[funny_match[funny_match_index].other]
+ = recog_operand[funny_match[funny_match_index].this];
+ return 1;
+ }
+ which_alternative++;
+ }
+
+ if (strict == 0)
+ return constrain_operands (insn_code_num, -1);
+ return 0;
+}
+
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 57b1ac0..d3758ef 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -1854,6 +1854,18 @@ analyze_offset (tree offset, tree *invariant, tree *constant)
*invariant = invariant_0 ? invariant_0 : invariant_1;
}
+/* Free the memory used by the data reference DR. */
+
+static void
+free_data_ref (data_reference_p dr)
+{
+ if (DR_TYPE(dr) == ARRAY_REF_TYPE)
+ VEC_free (tree, heap, dr->object_info.access_fns);
+ else
+ VEC_free (tree, heap, dr->first_location.access_fns);
+
+ free (dr);
+}
/* Function create_data_ref.
@@ -1954,11 +1966,23 @@ create_data_ref (tree memref, tree stmt, bool is_read)
/* Update access function. */
access_fn = DR_ACCESS_FN (dr, 0);
+ if (automatically_generated_chrec_p (access_fn))
+ {
+ free_data_ref (dr);
+ return NULL;
+ }
+
new_step = size_binop (TRUNC_DIV_EXPR,
fold_convert (ssizetype, step), type_size);
init_cond = chrec_convert (chrec_type (access_fn), init_cond, stmt);
new_step = chrec_convert (chrec_type (access_fn), new_step, stmt);
+ if (automatically_generated_chrec_p (init_cond)
+ || automatically_generated_chrec_p (new_step))
+ {
+ free_data_ref (dr);
+ return NULL;
+ }
access_fn = chrec_replace_initial_condition (access_fn, init_cond);
access_fn = reset_evolution_in_loop (loop->num, access_fn, new_step);
@@ -4373,14 +4397,7 @@ free_data_refs (VEC (data_reference_p, heap) *datarefs)
struct data_reference *dr;
for (i = 0; VEC_iterate (data_reference_p, datarefs, i, dr); i++)
- {
- if (DR_TYPE(dr) == ARRAY_REF_TYPE)
- VEC_free (tree, heap, (dr)->object_info.access_fns);
- else
- VEC_free (tree, heap, (dr)->first_location.access_fns);
-
- free (dr);
- }
+ free_data_ref (dr);
VEC_free (data_reference_p, heap, datarefs);
}