aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-10-29 09:42:12 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2024-10-29 11:25:07 +0100
commit0e99b22aa666f107c4035d32bfb5ab11534a9d2f (patch)
treeb9fd6c31b3b53b614864d7b5edaec81e08493ca0
parent5e247ac0c28b9a2662f99c4a5420c5f7c2d0c6bd (diff)
downloadgcc-0e99b22aa666f107c4035d32bfb5ab11534a9d2f.zip
gcc-0e99b22aa666f107c4035d32bfb5ab11534a9d2f.tar.gz
gcc-0e99b22aa666f107c4035d32bfb5ab11534a9d2f.tar.bz2
tree-optimization/117333 - ICE with NULL access size DR
dr_may_alias_p ICEs when TYPE_SIZE of DR->ref is NULL but this is valid IL when the access size of an aggregate copy can be infered from the RHS. PR tree-optimization/117333 * tree-data-ref.cc (dr_may_alias_p): Guard against NULL access size. * gcc.dg/torture/pr117333.c: New testcase.
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr117333.c29
-rw-r--r--gcc/tree-data-ref.cc2
2 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/pr117333.c b/gcc/testsuite/gcc.dg/torture/pr117333.c
new file mode 100644
index 0000000..38c1b54
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117333.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+
+struct s
+{
+ unsigned long ul;
+ int i;
+ char ac[];
+};
+
+const struct s gs = { 3, -4, "abcdef" };
+
+void copy_s(struct s*d, const struct s*s)
+{
+ *d = *s;
+}
+
+unsigned test(struct s*ps, _Bool direct)
+{
+ if(direct)
+ *ps = gs;
+ else
+ copy_s(ps, &gs);
+ return sizeof(*ps);
+}
+
+unsigned size(void)
+{
+ return sizeof(gs);
+}
diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index de234c6..1fdfef2 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -3004,6 +3004,8 @@ dr_may_alias_p (const struct data_reference *a, const struct data_reference *b,
&& DR_BASE_ADDRESS (b)
&& operand_equal_p (DR_BASE_ADDRESS (a), DR_BASE_ADDRESS (b))
&& operand_equal_p (DR_OFFSET (a), DR_OFFSET (b))
+ && tree_size_a
+ && tree_size_b
&& poly_int_tree_p (tree_size_a)
&& poly_int_tree_p (tree_size_b)
&& !ranges_maybe_overlap_p (wi::to_poly_widest (DR_INIT (a)),