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]

[PATCH] move timevars for traces and bb-reorder out of toplev


Hi,

This patch moves the timevar_{push,pop} calls for TV_TRACER and
TV_REORDER_BLOCKS to tracer and reorder_basic_blocks.

The bb reorder and tracer toplevel routines are called from many places in
toplev.c, and the time spent in these passes was added to whatever called
them.  For example, reg stack calls reorder_basic_blocks and the time spent
there was counted under TV_REG_STACK.

This leads to some strange timings.  Mainline without this patch shows for Bug
12322 that reg stack is consuming a lot of compile time:

reg stack ? ? ? ? ? ? : 370.89 (92%) usr ? 1.10 (67%) sys 387.49 (92%) wall

Hence, in "http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00107.html";, Roger
Sayle concluded that reg stack was a problem for 12322 (and of course it
is ;-).  But with this patch, you see:

reorder blocks ? ? ? ?: 363.15 (91%) usr ? 1.08 (68%) sys 374.62 (91%) wall
reg stack             :   3.23 ( 1%) usr   0.01 ( 1%) sys   3.29 ( 1%) wall

So in fact, somehow it is reordering basic blocks after reg stack that is the
bottleneck here.  I believe we should be able to see this in the time report.

Bootstrapped and tested on i686-pc-linux-gnu, OK for mainline?

Gr.
Steven


	* Makefile.in (tracer.o, bb-reorder.o): Depend on timevar.h
	* toplev.c (rest_of_handle_reorder_blocks, rest_of_handle_tracer):
	Don't push and pop TV_REORDER_BLOCKStimevars, do it...
	* bb-reorder.c (reorder_basic_blocks): ...here, and...
	* tracer.c (tracer): here.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1210
diff -c -3 -p -r1.1210 Makefile.in
*** Makefile.in	18 Dec 2003 02:45:14 -0000	1.1210
--- Makefile.in	18 Dec 2003 09:39:29 -0000
*************** predict.o: predict.c $(CONFIG_H) $(SYSTE
*** 1815,1824 ****
     $(PARAMS_H) $(TARGET_H) cfgloop.h $(COVERAGE_H)
  lists.o: lists.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) toplev.h $(RTL_H) $(GGC_H)
  bb-reorder.o : bb-reorder.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
!    $(RTL_H) $(BASIC_BLOCK_H) flags.h output.h cfglayout.h $(FIBHEAP_H) \
     $(TARGET_H)
  tracer.o : tracer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
!    $(BASIC_BLOCK_H) hard-reg-set.h output.h cfglayout.h flags.h \
     $(PARAMS_H) $(COVERAGE_H)
  cfglayout.o : cfglayout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(RTL_H) $(TREE_H) insn-config.h $(BASIC_BLOCK_H) hard-reg-set.h output.h \
--- 1815,1824 ----
     $(PARAMS_H) $(TARGET_H) cfgloop.h $(COVERAGE_H)
  lists.o: lists.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) toplev.h $(RTL_H) $(GGC_H)
  bb-reorder.o : bb-reorder.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
!    $(RTL_H) $(BASIC_BLOCK_H) flags.h timevar.h output.h cfglayout.h $(FIBHEAP_H) \
     $(TARGET_H)
  tracer.o : tracer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(TREE_H) \
!    $(BASIC_BLOCK_H) hard-reg-set.h output.h cfglayout.h flags.h timevar.h \
     $(PARAMS_H) $(COVERAGE_H)
  cfglayout.o : cfglayout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
     $(RTL_H) $(TREE_H) insn-config.h $(BASIC_BLOCK_H) hard-reg-set.h output.h \
Index: bb-reorder.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/bb-reorder.c,v
retrieving revision 1.61
diff -c -3 -p -r1.61 bb-reorder.c
*** bb-reorder.c	11 Dec 2003 00:20:35 -0000	1.61
--- bb-reorder.c	18 Dec 2003 09:39:31 -0000
***************
*** 72,77 ****
--- 72,78 ----
  #include "rtl.h"
  #include "basic-block.h"
  #include "flags.h"
+ #include "timevar.h"
  #include "output.h"
  #include "cfglayout.h"
  #include "fibheap.h"
*************** reorder_basic_blocks (void)
*** 1064,1069 ****
--- 1065,1072 ----
    if ((* targetm.cannot_modify_jumps_p) ())
      return;
  
+   timevar_push (TV_REORDER_BLOCKS);
+ 
    cfg_layout_initialize ();
  
    set_edge_can_fallthru_flag ();
*************** reorder_basic_blocks (void)
*** 1096,1099 ****
--- 1099,1104 ----
      dump_flow_info (rtl_dump_file);
  
    cfg_layout_finalize ();
+ 
+   timevar_pop (TV_REORDER_BLOCKS);
  }
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.850
diff -c -3 -p -r1.850 toplev.c
*** toplev.c	16 Dec 2003 00:11:47 -0000	1.850
--- toplev.c	18 Dec 2003 09:39:39 -0000
*************** rest_of_handle_regrename (tree decl, rtx
*** 2298,2304 ****
  static void
  rest_of_handle_reorder_blocks (tree decl, rtx insns)
  {
-   timevar_push (TV_REORDER_BLOCKS);
    open_dump_file (DFI_bbro, decl);
  
    /* Last attempt to optimize CFG, as scheduling, peepholing and insn
--- 2298,2303 ----
*************** rest_of_handle_reorder_blocks (tree decl
*** 2315,2321 ****
      cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
  
    close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
-   timevar_pop (TV_REORDER_BLOCKS);
  }
  
  #ifdef INSN_SCHEDULING
--- 2314,2319 ----
*************** rest_of_handle_regmove (tree decl, rtx i
*** 2394,2400 ****
  static void
  rest_of_handle_tracer (tree decl, rtx insns)
  {
-   timevar_push (TV_TRACER);
    open_dump_file (DFI_tracer, decl);
    if (rtl_dump_file)
      dump_flow_info (rtl_dump_file);
--- 2392,2397 ----
*************** rest_of_handle_tracer (tree decl, rtx in
*** 2402,2408 ****
    cleanup_cfg (CLEANUP_EXPENSIVE);
    reg_scan (insns, max_reg_num (), 0);
    close_dump_file (DFI_tracer, print_rtl_with_bb, get_insns ());
-   timevar_pop (TV_TRACER);
  }
  
  /* If-conversion and CFG cleanup.  */
--- 2399,2404 ----
Index: tracer.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tracer.c,v
retrieving revision 1.15
diff -c -3 -p -r1.15 tracer.c
*** tracer.c	11 Dec 2003 00:20:48 -0000	1.15
--- tracer.c	18 Dec 2003 09:39:40 -0000
***************
*** 45,50 ****
--- 45,51 ----
  #include "cfglayout.h"
  #include "fibheap.h"
  #include "flags.h"
+ #include "timevar.h"
  #include "params.h"
  #include "coverage.h"
  
*************** layout_superblocks (void)
*** 358,363 ****
--- 359,365 ----
  void
  tracer (void)
  {
+   timevar_push (TV_TRACER);
    if (n_basic_blocks <= 1)
      return;
    cfg_layout_initialize ();
*************** tracer (void)
*** 371,374 ****
--- 373,377 ----
    cfg_layout_finalize ();
    /* Merge basic blocks in duplicated traces.  */
    cleanup_cfg (CLEANUP_EXPENSIVE);
+   timevar_pop (TV_TRACER);
  }




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