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]

Re: [PATCH][C++] Improve PR15855 (compile-time/memory hog)


Richard Guenther wrote:
> This patch makes the C++ frontend emit static initializers and
> destructors with exposing less jump-threading opportunities to DOM,
> which otherwise uses a gazillion amount of memory and compile-time.

The idea of this patch is OK.

> !   do {
> !     tree next = TREE_CHAIN (node);
> !     tree ndecl;
> !     int npriority = 0;
> ! 
> !     /* Perform the destruction if necessary.  */
> !     if (!TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (decl)))
> !       finish_expr_stmt (build_cleanup (decl));
> ! 
> !     if (guard_p || !next)
> !       break;
> !     /* Check, if we can stick the next destructor in the same
> !        if-stmt body.  */
> !     ndecl = TREE_VALUE (next);
> !     if (DECL_HAS_INIT_PRIORITY_P (ndecl))
> !       npriority = DECL_INIT_PRIORITY (ndecl);
> !     if (!npriority)
> !       npriority = DEFAULT_INIT_PRIORITY;
> !     if (npriority != priority)
> ! 	break;
> !     node = next;
> !     decl = TREE_VALUE (node);
> !   } while (1);

Please factor this code so that it's shared between the construction and
destruction case.  Also, rather than keeping the
do_static_initialization loop:

	  for (v = vars; v; v = TREE_CHAIN (v))
	    do_static_initialization (TREE_VALUE (v),
				      TREE_PURPOSE (v));

but updating "v", just move the entire loop into
do_static_initialization, so that it is:

  do_static_initialization (vars);

and similarly for do_static_destruction.

Thanks,

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(916) 791-8304


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