This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ PATCH] PR 30225 Improve adding of builtins memory usage


The C++ front while adding the builtins to the global namespace and the
std namespace if needed, copies the builtin for adding it to the std
namespace except in some cases it does not add it to the std namespace.
So we just wasted a copy of the node.  This patch fixes that problem by
only doing the copy if we are going to add the builtin to the std
namespace.

OK?  Bootstrapped and tested on powerpc-darwin with no regressions.

Thanks,
Andrew Pinski

ChangeLog:


	* decl.c (cxx_builtin_function): Only copy the decl if adding
	it to the std namespace.
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 120139)
+++ cp/decl.c	(working copy)
@@ -3402,17 +3402,17 @@
 {
   tree          id = DECL_NAME (decl);
   const char *name = IDENTIFIER_POINTER (id);
-  tree       decl2 = copy_node(decl);
   /* All builtins that don't begin with an '_' should additionally
      go in the 'std' namespace.  */
   if (name[0] != '_')
     {
+      tree decl2 = copy_node(decl);
       push_namespace (std_identifier);
-      builtin_function_1 (decl, std_node);
+      builtin_function_1 (decl2, std_node);
       pop_namespace ();
     }
 
-  return builtin_function_1 (decl2, NULL_TREE);
+  return builtin_function_1 (decl, NULL_TREE);
 }
 
 /* Generate a FUNCTION_DECL with the typical flags for a runtime library

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]