Hi!

node->get_body () can run various IPA passes and ggc_collect in them, so
it is undesirable to hold pointers to GC memory in automatic vars over it.
While I could store those vars (clone_info, clone and id) into special GTY
vars just to avoid collecting them, it seems easier to call node->get_body
() earlier.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
and 5 branch.

2015-11-20  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/68339
        * omp-low.c (expand_simd_clones): Call node->get_body () before
        allocating stuff in GC.

        * gcc.dg/vect/pr68339.c: New test.

--- gcc/omp-low.c.jj    2015-11-18 11:19:19.000000000 +0100
+++ gcc/omp-low.c       2015-11-20 12:56:17.075193601 +0100
@@ -18319,6 +18319,10 @@ expand_simd_clones (struct cgraph_node *
       && TYPE_ARG_TYPES (TREE_TYPE (node->decl)) == NULL_TREE)
     return;
 
+  /* Call this before creating clone_info, as it might ggc_collect.  */
+  if (node->definition && node->has_gimple_body_p ())
+    node->get_body ();
+
   do
     {
       /* Start with parsing the "omp declare simd" attribute(s).  */
--- gcc/testsuite/gcc.dg/vect/pr68339.c.jj      2015-11-20 13:10:47.756905395 
+0100
+++ gcc/testsuite/gcc.dg/vect/pr68339.c 2015-11-20 13:08:13.000000000 +0100
@@ -0,0 +1,17 @@
+/* PR middle-end/68339 */
+/* { dg-do compile } */
+/* { dg-options "--param ggc-min-heapsize=0 --param ggc-min-expand=0 
-fopenmp-simd" } */
+
+#pragma omp declare simd notinbranch
+int
+f1 (int x)
+{
+  return x;
+}
+
+#pragma omp declare simd notinbranch
+int
+f2 (int x)
+{
+  return x;
+}

        Jakub

Reply via email to