]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
inliner: Don't ICE on NULL TYPE_DOMAIN [PR94621]
authorJakub Jelinek <jakub@redhat.com>
Fri, 17 Apr 2020 07:07:49 +0000 (09:07 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 17 Apr 2020 07:24:03 +0000 (09:24 +0200)
When I've added the VLA tweak for OpenMP to avoid error_mark_nodes in the IL in
type, I forgot that TYPE_DOMAIN could be NULL.  Furthermore, as an optimization,
this patch checks the hopefully cheapest condition that is very likely false
most of the time (enabled only during OpenMP handling) first.

2020-04-17  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/94621
* tree-inline.c (remap_type_1): Don't dereference NULL TYPE_DOMAIN.
Move id->adjust_array_error_bounds check first in the condition.

* gcc.c-torture/compile/pr94621.c: New test.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr94621.c [new file with mode: 0644]
gcc/tree-inline.c

index 80a37618d75346943c6a85ac84143aab8cd262d0..80b0534ba51f3b60c4d12a9a8c5d4ef5e45067dd 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/94621
+       * tree-inline.c (remap_type_1): Don't dereference NULL TYPE_DOMAIN.
+       Move id->adjust_array_error_bounds check first in the condition.
+
 2020-04-17  Martin Liska  <mliska@suse.cz>
            Jonathan Yong <10walls@gmail.com>
 
index 1341eb2745adb83027de7cc15b112cb2e53a453e..64181e4e532f0dc57c9f74264a7d4d011b01ba0e 100644 (file)
@@ -1,5 +1,8 @@
 2020-04-17  Jakub Jelinek  <jakub@redhat.com>
 
+       PR tree-optimization/94621
+       * gcc.c-torture/compile/pr94621.c: New test.
+
        PR c++/94314
        * g++.dg/pr94314-4.C: Require c++14 rather than c++11.
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr94621.c b/gcc/testsuite/gcc.c-torture/compile/pr94621.c
new file mode 100644 (file)
index 0000000..0d98dfd
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR tree-optimization/94621 */
+
+struct S { int c, e[]; };
+
+static inline int
+foo (struct S *m, int r, int c)
+{
+  int (*a)[][m->c] = (int (*)[][m->c])&m->e;
+  return (*a)[r][c];
+}
+
+void
+bar (struct S *a)
+{
+  foo (a, 0, 0);
+}
index f095795f06f9fc839557a7d868dd8ef64b2285d1..26c23f504be9c2d6cdf474d42d2ee1d1cf116dbb 100644 (file)
@@ -556,8 +556,9 @@ remap_type_1 (tree type, copy_body_data *id)
          /* For array bounds where we have decided not to copy over the bounds
             variable which isn't used in OpenMP/OpenACC region, change them to
             an uninitialized VAR_DECL temporary.  */
-         if (TYPE_MAX_VALUE (TYPE_DOMAIN (new_tree)) == error_mark_node
-             && id->adjust_array_error_bounds
+         if (id->adjust_array_error_bounds
+             && TYPE_DOMAIN (new_tree)
+             && TYPE_MAX_VALUE (TYPE_DOMAIN (new_tree)) == error_mark_node
              && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != error_mark_node)
            {
              tree v = create_tmp_var (TREE_TYPE (TYPE_DOMAIN (new_tree)));