Patchwork Fix Infinite loop in pointer_set_insert

login
register
mail settings
Submitter John David Anglin
Date Dec. 16, 2012, 4:33 p.m.
Message ID <20121216163322.GA23093@hiauly1.hia.nrc.ca>
Download mbox | patch
Permalink /patch/206681/
State New
Headers show

Comments

John David Anglin - Dec. 16, 2012, 4:33 p.m.
The attached patch fixes a regression introduced on the trunk to
fix PR middle-end/52640.  The fix was previously applied to the 4.6
and 4.7 branches.

Tested on hppa-unknown-linux-gnu with full bootstrap.

OK for trunk?

Dave
Richard Guenther - Dec. 16, 2012, 5:11 p.m.
On Sun, Dec 16, 2012 at 5:33 PM, John David Anglin
<dave@hiauly1.hia.nrc.ca> wrote:
> The attached patch fixes a regression introduced on the trunk to
> fix PR middle-end/52640.  The fix was previously applied to the 4.6
> and 4.7 branches.
>
> Tested on hppa-unknown-linux-gnu with full bootstrap.
>
> OK for trunk?

Ok.

Thanks,
Richard.

> Dave
> --
> J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
> National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)
>
> 2012-12-16  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
>
>         PR middle-end/55709
>         Forward port from 4.7 branch:
>         2012-04-10  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
>
>         PR middle-end/52894
>         * varasm.c (process_pending_assemble_externals): Set
>         pending_assemble_externals_processed true.
>         (assemble_external): Call assemble_external_real if the pending
>         assemble externals have been processed.
>
> Index: varasm.c
> ===================================================================
> --- varasm.c    (revision 194441)
> +++ varasm.c    (working copy)
> @@ -2088,6 +2088,11 @@
>     it all the way to final.  See PR 17982 for further discussion.  */
>  static GTY(()) tree pending_assemble_externals;
>
> +/* Some targets delay some output to final using TARGET_ASM_FILE_END.
> +   As a result, assemble_external can be called after the list of externals
> +   is processed and the pointer set destroyed.  */
> +static bool pending_assemble_externals_processed;
> +
>  #ifdef ASM_OUTPUT_EXTERNAL
>  /* Avoid O(external_decls**2) lookups in the pending_assemble_externals
>     TREE_LIST in assemble_external.  */
> @@ -2144,6 +2149,7 @@
>      assemble_external_real (TREE_VALUE (list));
>
>    pending_assemble_externals = 0;
> +  pending_assemble_externals_processed = true;
>    pointer_set_destroy (pending_assemble_externals_set);
>  #endif
>  }
> @@ -2196,6 +2202,12 @@
>      weak_decls = tree_cons (NULL, decl, weak_decls);
>
>  #ifdef ASM_OUTPUT_EXTERNAL
> +  if (pending_assemble_externals_processed)
> +    {
> +      assemble_external_real (decl);
> +      return;
> +    }
> +
>    if (! pointer_set_insert (pending_assemble_externals_set, decl))
>      pending_assemble_externals = tree_cons (NULL, decl,
>                                             pending_assemble_externals);

Patch

Index: varasm.c
===================================================================
--- varasm.c	(revision 194441)
+++ varasm.c	(working copy)
@@ -2088,6 +2088,11 @@ 
    it all the way to final.  See PR 17982 for further discussion.  */
 static GTY(()) tree pending_assemble_externals;
 
+/* Some targets delay some output to final using TARGET_ASM_FILE_END.
+   As a result, assemble_external can be called after the list of externals
+   is processed and the pointer set destroyed.  */
+static bool pending_assemble_externals_processed;
+
 #ifdef ASM_OUTPUT_EXTERNAL
 /* Avoid O(external_decls**2) lookups in the pending_assemble_externals
    TREE_LIST in assemble_external.  */
@@ -2144,6 +2149,7 @@ 
     assemble_external_real (TREE_VALUE (list));
 
   pending_assemble_externals = 0;
+  pending_assemble_externals_processed = true;
   pointer_set_destroy (pending_assemble_externals_set);
 #endif
 }
@@ -2196,6 +2202,12 @@ 
     weak_decls = tree_cons (NULL, decl, weak_decls);
 
 #ifdef ASM_OUTPUT_EXTERNAL
+  if (pending_assemble_externals_processed)
+    {
+      assemble_external_real (decl);
+      return;
+    }
+
   if (! pointer_set_insert (pending_assemble_externals_set, decl))
     pending_assemble_externals = tree_cons (NULL, decl,
 					    pending_assemble_externals);