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]

Fix compilation time problem in PR middle-end/37448


Hi,
PR middle-end/37448 makes inliner to spend a lot of time in
add_lexical_block that walks to the end of long block list.
Since we don't keep blocksin any particular order, we can just
insert instead.
Bootstrapped/regtested i686-linux, OK?

Honza

	PR middle-end/37448
	* tree-inline.c (add_lexical_block): Replace with ...
	(insert_lexical_block): ... insert at begginig.
	(remap_blocks): Use it and reverse later.
	(expand_call_inline): Use insert_lexical_block.
Index: tree-inline.c
===================================================================
*** tree-inline.c	(revision 140271)
--- tree-inline.c	(working copy)
*************** static void unsave_expr_1 (tree);
*** 129,135 ****
  static tree unsave_r (tree *, int *, void *);
  static void declare_inline_vars (tree, tree);
  static void remap_save_expr (tree *, void *, int *);
! static void add_lexical_block (tree current_block, tree new_block);
  static tree copy_decl_to_var (tree, copy_body_data *);
  static tree copy_result_decl_to_var (tree, copy_body_data *);
  static tree copy_decl_maybe_to_var (tree, copy_body_data *);
--- 129,135 ----
  static tree unsave_r (tree *, int *, void *);
  static void declare_inline_vars (tree, tree);
  static void remap_save_expr (tree *, void *, int *);
! static void insert_lexical_block (tree current_block, tree new_block);
  static tree copy_decl_to_var (tree, copy_body_data *);
  static tree copy_result_decl_to_var (tree, copy_body_data *);
  static tree copy_decl_maybe_to_var (tree, copy_body_data *);
*************** remap_blocks (tree block, copy_body_data
*** 512,518 ****
    remap_block (&new_tree, id);
    gcc_assert (new_tree != block);
    for (t = BLOCK_SUBBLOCKS (block); t ; t = BLOCK_CHAIN (t))
!     add_lexical_block (new_tree, remap_blocks (t, id));
    return new_tree;
  }
  
--- 512,521 ----
    remap_block (&new_tree, id);
    gcc_assert (new_tree != block);
    for (t = BLOCK_SUBBLOCKS (block); t ; t = BLOCK_CHAIN (t))
!     insert_lexical_block (new_tree, remap_blocks (t, id));
!   /* Blocks are in arbitrary order, but make things slightly prettier and do
!      not swap order when producing a copy.  */
!   BLOCK_SUBBLOCKS (new_tree) = blocks_nreverse (BLOCK_SUBBLOCKS (new_tree));
    return new_tree;
  }
  
*************** count_insns_seq (gimple_seq seq, eni_wei
*** 3032,3047 ****
  /* Install new lexical TREE_BLOCK underneath 'current_block'.  */
  
  static void
! add_lexical_block (tree current_block, tree new_block)
  {
!   tree *blk_p;
! 
!   /* Walk to the last sub-block.  */
!   for (blk_p = &BLOCK_SUBBLOCKS (current_block);
!        *blk_p;
!        blk_p = &BLOCK_CHAIN (*blk_p))
!     ;
!   *blk_p = new_block;
    BLOCK_SUPERCONTEXT (new_block) = current_block;
  }
  
--- 3038,3047 ----
  /* Install new lexical TREE_BLOCK underneath 'current_block'.  */
  
  static void
! insert_lexical_block (tree current_block, tree new_block)
  {
!   BLOCK_CHAIN (new_block) = BLOCK_SUBBLOCKS (current_block);
!   BLOCK_SUBBLOCKS (current_block) = new_block;
    BLOCK_SUPERCONTEXT (new_block) = current_block;
  }
  
*************** expand_call_inline (basic_block bb, gimp
*** 3222,3228 ****
    id->block = make_node (BLOCK);
    BLOCK_ABSTRACT_ORIGIN (id->block) = fn;
    BLOCK_SOURCE_LOCATION (id->block) = input_location;
!   add_lexical_block (gimple_block (stmt), id->block);
  
    /* Local declarations will be replaced by their equivalents in this
       map.  */
--- 3222,3228 ----
    id->block = make_node (BLOCK);
    BLOCK_ABSTRACT_ORIGIN (id->block) = fn;
    BLOCK_SOURCE_LOCATION (id->block) = input_location;
!   insert_lexical_block (gimple_block (stmt), id->block);
  
    /* Local declarations will be replaced by their equivalents in this
       map.  */
*************** expand_call_inline (basic_block bb, gimp
*** 3248,3254 ****
    initialize_inlined_parameters (id, stmt, fn, bb);
  
    if (DECL_INITIAL (fn))
!     add_lexical_block (id->block, remap_blocks (DECL_INITIAL (fn), id));
  
    /* Return statements in the function body will be replaced by jumps
       to the RET_LABEL.  */
--- 3248,3254 ----
    initialize_inlined_parameters (id, stmt, fn, bb);
  
    if (DECL_INITIAL (fn))
!     insert_lexical_block (id->block, remap_blocks (DECL_INITIAL (fn), id));
  
    /* Return statements in the function body will be replaced by jumps
       to the RET_LABEL.  */


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