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 is what I have currently in bootstrapping and testing.  As the patch
> got larger anyway I took the opportunity to move the if (init == 1) check
> first and not re-emit it for each priority.
> 
> Ok for mainline if testing succeeds?  What about 4.0 and 3.4?

The overall structure looks good now.

> ! static void do_static_initialization_or_destruction (tree, int);

Use bool, not int.  And, in the callers, please do like so:

  /*initp=*/false

That way, it's obvious what the value means.  (The existing code uses
int because it's old...)

Please factor:

                TREE_PUBLIC (decl) && (DECL_COMMON (decl)
> ! 				       || DECL_ONE_ONLY (decl)
> ! 				       || DECL_WEAK (decl));

Into a NEEDS_GUARD_P macro, and use it in your new code and in
start_static_initialization_or_destruction.  Similarly for:

!       if (DECL_HAS_INIT_PRIORITY_P (decl))
!         priority = DECL_INIT_PRIORITY (decl);
!       if (!priority)
!         priority = DEFAULT_INIT_PRIORITY;

Let's make that DECL_EFFECTIVE_INIT_PRIORITY.

> ! 	/* Advance to the next node.  */
> ! 	do {
> !           node = TREE_CHAIN (node);
> ! 	} while (node && !initp
> ! 		 && TYPE_HAS_TRIVIAL_DESTRUCTOR (TREE_TYPE (TREE_VALUE (node))));

I think this would be clearer if you moved this stuff:

!   init_if_stmt = begin_if_stmt ();
!   init_cond = initp ? integer_one_node : integer_zero_node;
!   init_cond = cp_build_binary_op (EQ_EXPR,
! 				  initialize_p_decl,
! 				  init_cond);
!   finish_if_stmt_cond (init_cond, init_if_stmt);

inside the loop.  Like:

  prev_node = NULL_TREE;

  while (node) {
    if (prev_node && NEEDS_GUARD_P (prev_node))
      {
         finish_then_clause ();
         finish_if_stmt ();
      }
    if (!prev_node
        || NEEDS_GUARD_P (prev_node) || NEEDS_GUARD_P (node)
        || DECL_INIT_PRIORITY (prev_node) != DECL_INIT_PRIORITY (node))
      {
       /* Build if statement.  */
      }

    /* Do initialization or destruction.  */

    prev_node = node;
    node = TREE_CHAIN (node);
  }

  if (prev_node && NEEDS_GUARD_P (prev_node))
    {
      finish_then_clause ();
      finish_if_stmt ();
     }

-- 
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]