public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix GC ICE during simd clone creation (PR middle-end/68339)
@ 2015-11-20 20:03 Jakub Jelinek
  2015-11-23  9:57 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2015-11-20 20:03 UTC (permalink / raw)
  To: gcc-patches

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  <jakub@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix GC ICE during simd clone creation (PR middle-end/68339)
  2015-11-20 20:03 [PATCH] Fix GC ICE during simd clone creation (PR middle-end/68339) Jakub Jelinek
@ 2015-11-23  9:57 ` Richard Biener
  2015-11-23 16:50   ` Jan Hubicka
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2015-11-23  9:57 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC Patches, Jan Hubicka

On Fri, Nov 20, 2015 at 9:03 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> node->get_body () can run various IPA passes and ggc_collect in them

Aww.  Looks like we never implemented that ggc_defer_collecting idea
(don't remember the context this popped up, maybe it was when we
introduced TODO_do_not_ggc_collect).  At least late IPA passes
might be affected by this issue as well.

Richard.

>, 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  <jakub@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix GC ICE during simd clone creation (PR middle-end/68339)
  2015-11-23  9:57 ` Richard Biener
@ 2015-11-23 16:50   ` Jan Hubicka
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Hubicka @ 2015-11-23 16:50 UTC (permalink / raw)
  To: Richard Biener; +Cc: Jakub Jelinek, GCC Patches, Jan Hubicka

> On Fri, Nov 20, 2015 at 9:03 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > Hi!
> >
> > node->get_body () can run various IPA passes and ggc_collect in them
> 
> Aww.  Looks like we never implemented that ggc_defer_collecting idea
> (don't remember the context this popped up, maybe it was when we
> introduced TODO_do_not_ggc_collect).  At least late IPA passes
> might be affected by this issue as well.

We used to have way to push/pop ggc context, but that was removed eventually.
I agree that get_ody doing random ggc_collect is not the best idea.  What get_body
is doing is application of transform passes of individual IPA passes.  We could
probably just not do ggc_collect between these? Those are not full bloat
passes, just transform methods.

Honza
> 
> Richard.
> 
> >, 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  <jakub@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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-11-23 16:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-20 20:03 [PATCH] Fix GC ICE during simd clone creation (PR middle-end/68339) Jakub Jelinek
2015-11-23  9:57 ` Richard Biener
2015-11-23 16:50   ` Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).