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][2/n] Make TODO_verify_il handle TODO_verify_stmts and TODO_verify_ssa


This is step two - do GIMPLE stmt and SSA verification when the IL
is in such state.  It needs extra conditionals for IPA pass
contexts which may run on inconsistent IL until fixup_cfg had
a chance to run and adjust the IL for noreturn and nothrow
changes (done only by ipa-pure-const).

Bootstrapped on x86_64-unknown-linux-gnu, hopefully testing
succeeds this time ;)  (see the bug in tree-eh.c this catched)

Any comments?

Thanks,
Richard.

2014-04-29  Richard Biener  <rguenther@suse.de>

	* passes.c (execute_function_todo): Move TODO_verify_stmts
	and TODO_verify_ssa under the TODO_verify_il umbrella.
	* tree-ssa.h (verify_ssa): Adjust prototype.
	* tree-ssa.c (verify_ssa): Add parameter to tell whether
	we should verify SSA operands.
	* tree-cfg.h (verify_gimple_in_cfg): Adjust prototype.
	* tree-cfg.c (verify_gimple_in_cfg): Add parameter to tell
	whether we should verify whether not throwing stmts have EH info.
	* graphite-scop-detection.c (create_sese_edges): Adjust.
	* tree-ssa-loop-manip.c (verify_loop_closed_ssa): Likewise.
	* tree-eh.c (lower_try_finally_switch): Do not add the
	default case label twice.

Index: gcc/passes.c
===================================================================
*** gcc/passes.c	(revision 209892)
--- gcc/passes.c	(working copy)
*************** pass_manager::dump_profile_report () con
*** 1716,1721 ****
--- 1716,1722 ----
  static void
  execute_function_todo (function *fn, void *data)
  {
+   bool from_ipa_pass = (cfun == NULL);
    unsigned int flags = (size_t)data;
    flags &= ~fn->last_verified;
    if (!flags)
*************** execute_function_todo (function *fn, voi
*** 1767,1792 ****
        dom_state pre_verify_state = dom_info_state (fn, CDI_DOMINATORS);
        dom_state pre_verify_pstate = dom_info_state (fn, CDI_POST_DOMINATORS);
  
!       if (flags & TODO_verify_ssa)
  	{
! 	  verify_gimple_in_cfg (cfun);
! 	  verify_ssa (true);
  	}
-       else if (flags & TODO_verify_stmts)
- 	verify_gimple_in_cfg (cfun);
        if (flags & TODO_verify_flow)
  	verify_flow_info ();
        if (flags & TODO_verify_il)
  	{
  	  if (current_loops
  	      && loops_state_satisfies_p (LOOP_CLOSED_SSA))
! 	    {
! 	      if (!(flags & (TODO_verify_stmts|TODO_verify_ssa)))
! 		verify_gimple_in_cfg (cfun);
! 	      if (!(flags & TODO_verify_ssa))
! 		verify_ssa (true);
! 	      verify_loop_closed_ssa (false);
! 	    }
  	}
        if (flags & TODO_verify_rtl_sharing)
  	verify_rtl_sharing ();
--- 1768,1796 ----
        dom_state pre_verify_state = dom_info_state (fn, CDI_DOMINATORS);
        dom_state pre_verify_pstate = dom_info_state (fn, CDI_POST_DOMINATORS);
  
!       if (flags & TODO_verify_il)
  	{
! 	  if (cfun->curr_properties & PROP_trees)
! 	    {
! 	      if (cfun->curr_properties & PROP_cfg)
! 		/* IPA passes leave stmts to be fixed up, so make sure to
! 		   not verify stmts really throw.  */
! 		verify_gimple_in_cfg (cfun, !from_ipa_pass);
! 	      else
! 		verify_gimple_in_seq (gimple_body (cfun->decl));
! 	    }
! 	  if (cfun->curr_properties & PROP_ssa)
! 	    /* IPA passes leave stmts to be fixed up, so make sure to
! 	       not verify SSA operands whose verifier will choke on that.  */
! 	    verify_ssa (true, !from_ipa_pass);
  	}
        if (flags & TODO_verify_flow)
  	verify_flow_info ();
        if (flags & TODO_verify_il)
  	{
  	  if (current_loops
  	      && loops_state_satisfies_p (LOOP_CLOSED_SSA))
! 	    verify_loop_closed_ssa (false);
  	}
        if (flags & TODO_verify_rtl_sharing)
  	verify_rtl_sharing ();
*************** execute_function_todo (function *fn, voi
*** 1803,1809 ****
  
    /* For IPA passes make sure to release dominator info, it can be
       computed by non-verifying TODOs.  */
!   if (!cfun)
      {
        free_dominance_info (fn, CDI_DOMINATORS);
        free_dominance_info (fn, CDI_POST_DOMINATORS);
--- 1807,1813 ----
  
    /* For IPA passes make sure to release dominator info, it can be
       computed by non-verifying TODOs.  */
!   if (from_ipa_pass)
      {
        free_dominance_info (fn, CDI_DOMINATORS);
        free_dominance_info (fn, CDI_POST_DOMINATORS);
Index: gcc/tree-ssa.h
===================================================================
*** gcc/tree-ssa.h	(revision 209891)
--- gcc/tree-ssa.h	(working copy)
*************** extern void insert_debug_temp_for_var_de
*** 45,51 ****
  extern void insert_debug_temps_for_defs (gimple_stmt_iterator *);
  extern void reset_debug_uses (gimple);
  extern void release_defs_bitset (bitmap toremove);
! extern void verify_ssa (bool);
  extern void init_tree_ssa (struct function *);
  extern void delete_tree_ssa (void);
  extern bool tree_ssa_useless_type_conversion (tree);
--- 45,51 ----
  extern void insert_debug_temps_for_defs (gimple_stmt_iterator *);
  extern void reset_debug_uses (gimple);
  extern void release_defs_bitset (bitmap toremove);
! extern void verify_ssa (bool, bool);
  extern void init_tree_ssa (struct function *);
  extern void delete_tree_ssa (void);
  extern bool tree_ssa_useless_type_conversion (tree);
Index: gcc/tree-ssa.c
===================================================================
*** gcc/tree-ssa.c	(revision 209891)
--- gcc/tree-ssa.c	(working copy)
*************** error:
*** 959,965 ****
     TODO: verify the variable annotations.  */
  
  DEBUG_FUNCTION void
! verify_ssa (bool check_modified_stmt)
  {
    size_t i;
    basic_block bb;
--- 959,965 ----
     TODO: verify the variable annotations.  */
  
  DEBUG_FUNCTION void
! verify_ssa (bool check_modified_stmt, bool check_ssa_operands)
  {
    size_t i;
    basic_block bb;
*************** verify_ssa (bool check_modified_stmt)
*** 1042,1048 ****
  	      goto err;
  	    }
  
! 	  if (verify_ssa_operands (cfun, stmt))
  	    {
  	      print_gimple_stmt (stderr, stmt, 0, TDF_VOPS);
  	      goto err;
--- 1042,1048 ----
  	      goto err;
  	    }
  
! 	  if (check_ssa_operands && verify_ssa_operands (cfun, stmt))
  	    {
  	      print_gimple_stmt (stderr, stmt, 0, TDF_VOPS);
  	      goto err;
Index: gcc/tree-cfg.h
===================================================================
*** gcc/tree-cfg.h	(revision 209891)
--- gcc/tree-cfg.h	(working copy)
*************** extern gimple first_stmt (basic_block);
*** 58,64 ****
  extern gimple last_stmt (basic_block);
  extern gimple last_and_only_stmt (basic_block);
  extern void verify_gimple_in_seq (gimple_seq);
! extern void verify_gimple_in_cfg (struct function *);
  extern tree gimple_block_label (basic_block);
  extern void add_phi_args_after_copy_bb (basic_block);
  extern void add_phi_args_after_copy (basic_block *, unsigned, edge);
--- 58,64 ----
  extern gimple last_stmt (basic_block);
  extern gimple last_and_only_stmt (basic_block);
  extern void verify_gimple_in_seq (gimple_seq);
! extern void verify_gimple_in_cfg (struct function *, bool);
  extern tree gimple_block_label (basic_block);
  extern void add_phi_args_after_copy_bb (basic_block);
  extern void add_phi_args_after_copy (basic_block *, unsigned, edge);
Index: gcc/tree-cfg.c
===================================================================
*** gcc/tree-cfg.c	(revision 209891)
--- gcc/tree-cfg.c	(working copy)
*************** collect_subblocks (pointer_set_t *blocks
*** 4785,4791 ****
  /* Verify the GIMPLE statements in the CFG of FN.  */
  
  DEBUG_FUNCTION void
! verify_gimple_in_cfg (struct function *fn)
  {
    basic_block bb;
    bool err = false;
--- 4785,4791 ----
  /* Verify the GIMPLE statements in the CFG of FN.  */
  
  DEBUG_FUNCTION void
! verify_gimple_in_cfg (struct function *fn, bool verify_nothrow)
  {
    basic_block bb;
    bool err = false;
*************** verify_gimple_in_cfg (struct function *f
*** 4921,4936 ****
  	     that they cannot throw, that we update other data structures
  	     to match.  */
  	  lp_nr = lookup_stmt_eh_lp (stmt);
! 	  if (lp_nr != 0)
  	    {
  	      if (!stmt_could_throw_p (stmt))
  		{
! 		  error ("statement marked for throw, but doesn%'t");
! 		  err2 |= true;
  		}
! 	      else if (lp_nr > 0
! 		       && !gsi_one_before_end_p (gsi)
! 		       && stmt_can_throw_internal (stmt))
  		{
  		  error ("statement marked for throw in middle of block");
  		  err2 |= true;
--- 4921,4937 ----
  	     that they cannot throw, that we update other data structures
  	     to match.  */
  	  lp_nr = lookup_stmt_eh_lp (stmt);
! 	  if (lp_nr > 0)
  	    {
  	      if (!stmt_could_throw_p (stmt))
  		{
! 		  if (verify_nothrow)
! 		    {
! 		      error ("statement marked for throw, but doesn%'t");
! 		      err2 |= true;
! 		    }
  		}
! 	      else if (!gsi_one_before_end_p (gsi))
  		{
  		  error ("statement marked for throw in middle of block");
  		  err2 |= true;
Index: gcc/graphite-scop-detection.c
===================================================================
*** gcc/graphite-scop-detection.c	(revision 209891)
--- gcc/graphite-scop-detection.c	(working copy)
*************** create_sese_edges (vec<sd_region> region
*** 1056,1062 ****
  
  #ifdef ENABLE_CHECKING
    verify_loop_structure ();
!   verify_ssa (false);
  #endif
  }
  
--- 1056,1062 ----
  
  #ifdef ENABLE_CHECKING
    verify_loop_structure ();
!   verify_ssa (false, true);
  #endif
  }
  
Index: gcc/tree-ssa-loop-manip.c
===================================================================
*** gcc/tree-ssa-loop-manip.c	(revision 209891)
--- gcc/tree-ssa-loop-manip.c	(working copy)
*************** verify_loop_closed_ssa (bool verify_ssa_
*** 598,604 ****
      return;
  
    if (verify_ssa_p)
!     verify_ssa (false);
  
    timevar_push (TV_VERIFY_LOOP_CLOSED);
  
--- 598,604 ----
      return;
  
    if (verify_ssa_p)
!     verify_ssa (false, true);
  
    timevar_push (TV_VERIFY_LOOP_CLOSED);
  
Index: gcc/tree-eh.c
===================================================================
*** gcc/tree-eh.c	(revision 209891)
--- gcc/tree-eh.c	(working copy)
*************** lower_try_finally_switch (struct leh_sta
*** 1550,1555 ****
--- 1550,1557 ----
    /* Make sure that the last case is the default label, as one is required.
       Then sort the labels, which is also required in GIMPLE.  */
    CASE_LOW (last_case) = NULL;
+   tree tem = case_label_vec.pop ();
+   gcc_assert (tem == last_case);
    sort_case_labels (case_label_vec);
  
    /* Build the switch statement, setting last_case to be the default


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