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] Add debug counters to more RTL passes


	This patch adds debug counters to a number of additional RTL
passes.  This is in preparation for a project to investigate the
effectiveness / usefulness of some of the existing RTL passes for possible
removal.

	While this patch does not fix any regressions, the additional
instrumentation can help investigate bugs in mainline and the forthcoming
GCC 4.3 release, so I am proposing it now.

Bootstrapped on powerpc-ibm-aix5.3.0.0.

Thanks, David


	* dbgcnt.def (cfg_cleanup, cprop1, cprop2, dce_fast, dce_ud, dse1,
	dse2, gcse, if_conversion, if_after_combine, if_after_reload,
	jump_bypass): New counters.
	* cfgcleanup.c (cleanup_cfg): Add dbg_cnt.
	* dce.c (gate_ud_dce): Same.
	(gate_fast_dce): Same.
	* dse.c (gate_dse1): New function.
	(gate_dse2): New function.
	(gate_dse): Merge results of new gate functions.
	* gcse.c (gcse_main): Bracket cprop1 and cprop2 with dbg_cnt.
	(gate_handle_jump_bypass): Add dbg_cnt.
	(gate_handle_gcse): Add dbg_cnt.
	* ifcvt.c (gate_handle_if_conversion): Same.
	(gate_handle_if_after_combine): Same.
	(gate_handle_if_after_reload): Same.

Index: dbgcnt.def
===================================================================
*** dbgcnt.def	(revision 131011)
--- dbgcnt.def	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 65,76 ****
--- 65,90 ----
  
  /* Debug counter definitions.  */
  DEBUG_COUNTER (auto_inc_dec)
+ DEBUG_COUNTER (cfg_cleanup)
  DEBUG_COUNTER (cse2_move2add)
+ DEBUG_COUNTER (cprop1)
+ DEBUG_COUNTER (cprop2)
  DEBUG_COUNTER (dce)
+ DEBUG_COUNTER (dce_fast)
+ DEBUG_COUNTER (dce_ud)
  DEBUG_COUNTER (delete_trivial_dead)
  DEBUG_COUNTER (dse)
+ DEBUG_COUNTER (dse1)
+ DEBUG_COUNTER (dse2)
+ DEBUG_COUNTER (gcse)
  DEBUG_COUNTER (gcse2_delete)
+ DEBUG_COUNTER (global_alloc_at_func)
+ DEBUG_COUNTER (global_alloc_at_reg)
  DEBUG_COUNTER (ia64_sched2)
+ DEBUG_COUNTER (if_conversion)
+ DEBUG_COUNTER (if_after_combine)
+ DEBUG_COUNTER (if_after_reload)
+ DEBUG_COUNTER (jump_bypass)
  DEBUG_COUNTER (local_alloc_for_sched)
  DEBUG_COUNTER (postreload_cse)
  DEBUG_COUNTER (pre_insn)
*************** DEBUG_COUNTER (sched_block)
*** 79,86 ****
  DEBUG_COUNTER (sched_func)
  DEBUG_COUNTER (sched_insn)
  DEBUG_COUNTER (sched_region)
  DEBUG_COUNTER (split_for_sched2)
  DEBUG_COUNTER (tail_call)
! DEBUG_COUNTER (global_alloc_at_func)
! DEBUG_COUNTER (global_alloc_at_reg)
! DEBUG_COUNTER (sms_sched_loop)
--- 93,99 ----
  DEBUG_COUNTER (sched_func)
  DEBUG_COUNTER (sched_insn)
  DEBUG_COUNTER (sched_region)
+ DEBUG_COUNTER (sms_sched_loop)
  DEBUG_COUNTER (split_for_sched2)
  DEBUG_COUNTER (tail_call)
! 
Index: cfgcleanup.c
===================================================================
*** cfgcleanup.c	(revision 131011)
--- cfgcleanup.c	(working copy)
*************** along with GCC; see the file COPYING3.  
*** 54,59 ****
--- 54,60 ----
  #include "cfgloop.h"
  #include "expr.h"
  #include "df.h"
+ #include "dbgcnt.h"
  
  #define FORWARDER_BLOCK_P(BB) ((BB)->flags & BB_FORWARDER_BLOCK)
  
*************** cleanup_cfg (int mode)
*** 2235,2240 ****
--- 2236,2244 ----
  
    compact_blocks ();
  
+   if (!dbg_cnt (cfg_cleanup))
+     return changed;
+ 
    while (try_optimize_cfg (mode))
      {
        delete_unreachable_blocks (), changed = true;
Index: dce.c
===================================================================
*** dce.c	(revision 131011)
--- dce.c	(working copy)
*************** rest_of_handle_ud_dce (void)
*** 563,569 ****
  static bool
  gate_ud_dce (void)
  {
!   return optimize > 1 && flag_dce;
  }
  
  struct tree_opt_pass pass_ud_rtl_dce =
--- 563,570 ----
  static bool
  gate_ud_dce (void)
  {
!   return optimize > 1 && flag_dce
!     && dbg_cnt (dce_ud);
  }
  
  struct tree_opt_pass pass_ud_rtl_dce =
*************** run_fast_dce (void)
*** 848,854 ****
  static bool
  gate_fast_dce (void)
  {
!   return optimize > 0 && flag_dce;
  }
  
  struct tree_opt_pass pass_fast_rtl_dce =
--- 849,856 ----
  static bool
  gate_fast_dce (void)
  {
!   return optimize > 0 && flag_dce
!     && dbg_cnt (dce_fast);
  }
  
  struct tree_opt_pass pass_fast_rtl_dce =
Index: dse.c
===================================================================
*** dse.c	(revision 131011)
--- dse.c	(working copy)
*************** static unsigned int current_position;
*** 540,545 ****
--- 540,547 ----
  
  
  static bool gate_dse (void);
+ static bool gate_dse1 (void);
+ static bool gate_dse2 (void);
  
  
  /*----------------------------------------------------------------------------
*************** rest_of_handle_dse (void)
*** 3284,3296 ****
  static bool
  gate_dse (void)
  {
!   return optimize > 0 && flag_dse;
  }
  
  struct tree_opt_pass pass_rtl_dse1 =
  {
    "dse1",                               /* name */
!   gate_dse,                             /* gate */
    rest_of_handle_dse,                   /* execute */
    NULL,                                 /* sub */
    NULL,                                 /* next */
--- 3286,3312 ----
  static bool
  gate_dse (void)
  {
!   return gate_dse1 () || gate_dse2 ();
! }
! 
! static bool
! gate_dse1 (void)
! {
!   return optimize > 0 && flag_dse
!     && dbg_cnt (dse1);
! }
! 
! static bool
! gate_dse2 (void)
! {
!   return optimize > 0 && flag_dse
!     && dbg_cnt (dse2);
  }
  
  struct tree_opt_pass pass_rtl_dse1 =
  {
    "dse1",                               /* name */
!   gate_dse1,                            /* gate */
    rest_of_handle_dse,                   /* execute */
    NULL,                                 /* sub */
    NULL,                                 /* next */
*************** struct tree_opt_pass pass_rtl_dse1 =
*** 3309,3315 ****
  struct tree_opt_pass pass_rtl_dse2 =
  {
    "dse2",                               /* name */
!   gate_dse,                             /* gate */
    rest_of_handle_dse,                   /* execute */
    NULL,                                 /* sub */
    NULL,                                 /* next */
--- 3325,3331 ----
  struct tree_opt_pass pass_rtl_dse2 =
  {
    "dse2",                               /* name */
!   gate_dse2,                            /* gate */
    rest_of_handle_dse,                   /* execute */
    NULL,                                 /* sub */
    NULL,                                 /* next */
Index: gcse.c
===================================================================
*** gcse.c	(revision 131011)
--- gcse.c	(working copy)
*************** gcse_main (rtx f ATTRIBUTE_UNUSED)
*** 718,726 ****
  
        /* Don't allow constant propagation to modify jumps
  	 during this pass.  */
!       timevar_push (TV_CPROP1);
!       changed = one_cprop_pass (pass + 1, false, false);
!       timevar_pop (TV_CPROP1);
  
        if (optimize_size)
  	/* Do nothing.  */ ;
--- 718,729 ----
  
        /* Don't allow constant propagation to modify jumps
  	 during this pass.  */
!       if (dbg_cnt (cprop1))
! 	{
! 	  timevar_push (TV_CPROP1);
! 	  changed = one_cprop_pass (pass + 1, false, false);
! 	  timevar_pop (TV_CPROP1);
! 	}
  
        if (optimize_size)
  	/* Do nothing.  */ ;
*************** gcse_main (rtx f ATTRIBUTE_UNUSED)
*** 783,795 ****
    /* Do one last pass of copy propagation, including cprop into
       conditional jumps.  */
  
!   max_gcse_regno = max_reg_num ();
!   alloc_gcse_mem ();
!   /* This time, go ahead and allow cprop to alter jumps.  */
!   timevar_push (TV_CPROP2);
!   one_cprop_pass (pass + 1, true, true);
!   timevar_pop (TV_CPROP2);
!   free_gcse_mem ();
  
    if (dump_file)
      {
--- 786,802 ----
    /* Do one last pass of copy propagation, including cprop into
       conditional jumps.  */
  
!   if (dbg_cnt (cprop2))
!     {
!       max_gcse_regno = max_reg_num ();
!       alloc_gcse_mem ();
! 
!       /* This time, go ahead and allow cprop to alter jumps.  */
!       timevar_push (TV_CPROP2);
!       one_cprop_pass (pass + 1, true, true);
!       timevar_pop (TV_CPROP2);
!       free_gcse_mem ();
!     }
  
    if (dump_file)
      {
*************** is_too_expensive (const char *pass)
*** 6666,6672 ****
  static bool
  gate_handle_jump_bypass (void)
  {
!   return optimize > 0 && flag_gcse;
  }
  
  /* Perform jump bypassing and control flow optimizations.  */
--- 6673,6680 ----
  static bool
  gate_handle_jump_bypass (void)
  {
!   return optimize > 0 && flag_gcse
!     && dbg_cnt (jump_bypass);
  }
  
  /* Perform jump bypassing and control flow optimizations.  */
*************** struct tree_opt_pass pass_jump_bypass =
*** 6705,6711 ****
  static bool
  gate_handle_gcse (void)
  {
!   return optimize > 0 && flag_gcse;
  }
  
  
--- 6713,6720 ----
  static bool
  gate_handle_gcse (void)
  {
!   return optimize > 0 && flag_gcse
!     && dbg_cnt (gcse);
  }
  
  
Index: ifcvt.c
===================================================================
*** ifcvt.c	(revision 131011)
--- ifcvt.c	(working copy)
***************
*** 45,50 ****
--- 45,51 ----
  #include "df.h"
  #include "vec.h"
  #include "vecprim.h"
+ #include "dbgcnt.h"
  
  #ifndef HAVE_conditional_execution
  #define HAVE_conditional_execution 0
*************** if_convert (void)
*** 4109,4115 ****
  static bool
  gate_handle_if_conversion (void)
  {
!   return (optimize > 0);
  }
  
  /* If-conversion and CFG cleanup.  */
--- 4110,4117 ----
  static bool
  gate_handle_if_conversion (void)
  {
!   return (optimize > 0)
!     && dbg_cnt (if_conversion);
  }
  
  /* If-conversion and CFG cleanup.  */
*************** struct tree_opt_pass pass_rtl_ifcvt =
*** 4149,4155 ****
  static bool
  gate_handle_if_after_combine (void)
  {
!   return (optimize > 0 && flag_if_conversion);
  }
  
  
--- 4151,4158 ----
  static bool
  gate_handle_if_after_combine (void)
  {
!   return optimize > 0 && flag_if_conversion
!     && dbg_cnt (if_after_combine);
  }
  
  
*************** struct tree_opt_pass pass_if_after_combi
*** 4185,4191 ****
  static bool
  gate_handle_if_after_reload (void)
  {
!   return (optimize > 0 && flag_if_conversion2);
  }
  
  static unsigned int
--- 4188,4195 ----
  static bool
  gate_handle_if_after_reload (void)
  {
!   return optimize > 0 && flag_if_conversion2
!     && dbg_cnt (if_after_reload);
  }
  
  static unsigned int


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