Patchwork "Fix" PR47822

login
register
mail settings
Submitter Richard Guenther
Date Feb. 20, 2011, 5:15 p.m.
Message ID <alpine.LNX.2.00.1102201814180.17230@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/83745/
State New
Headers show

Comments

Richard Guenther - Feb. 20, 2011, 5:15 p.m.
This fixes PR47822 by re-instatiating the previous pruning of
builtin decls from the file-scope BLOCK.

Bootstrapped and tested on x86_64-darwin, applied.

Richard.

2011-02-20  Richard Guenther  <rguenther@suse.de>

	PR lto/47822
	* tree.c (free_lang_data_in_decl): Clean builtins from
	the TU decl BLOCK_VARS.

Patch

Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 170336)
+++ gcc/tree.c	(working copy)
@@ -4577,6 +4577,25 @@ 
     }
   else if (TREE_CODE (decl) == TYPE_DECL)
     DECL_INITIAL (decl) = NULL_TREE;
+  else if (TREE_CODE (decl) == TRANSLATION_UNIT_DECL
+           && DECL_INITIAL (decl)
+           && TREE_CODE (DECL_INITIAL (decl)) == BLOCK)
+    {
+      /* Strip builtins from the translation-unit BLOCK.  We still have
+	 targets without builtin_decl support and also builtins are
+	 shared nodes and thus we can't use TREE_CHAIN in multiple
+	 lists.  */
+      tree *nextp = &BLOCK_VARS (DECL_INITIAL (decl));
+      while (*nextp)
+        {
+          tree var = *nextp;
+          if (TREE_CODE (var) == FUNCTION_DECL
+              && DECL_BUILT_IN (var))
+	    *nextp = TREE_CHAIN (var);
+	  else
+	    nextp = &TREE_CHAIN (var);
+        }
+    }
 }