From patchwork Sun Dec 16 16:33:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Fix Infinite loop in pointer_set_insert Date: Sun, 16 Dec 2012 06:33:22 -0000 From: John David Anglin X-Patchwork-Id: 206681 Message-Id: <20121216163322.GA23093@hiauly1.hia.nrc.ca> To: gcc-patches@gcc.gnu.org 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 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);