public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Make gsi_remove return whether EH cleanup is required
@ 2012-04-04 13:57 Richard Guenther
  2012-04-05 11:21 ` Rainer Orth
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Guenther @ 2012-04-04 13:57 UTC (permalink / raw)
  To: gcc-patches


Several passes needlessly cleanup EH after gsi_remove because they do
not know whether the stmt was removed from EH regions.  The following
patch returns this information from gsi_remove and adjusts all users
I could find appropriately.

Bootstrapped and tested on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2012-04-04  Richard Guenther  <rguenther@suse.de>

	* gimple-iterator.c (gsi_remove): Return whether EH edges need to be
	cleanup.
	* gimple.h (gsi_remove): Adjust.
	* tree-ssa-operands.c (unlink_stmt_vdef): Optimize.
	* tree-ssa-dom.c (optimize_stmt): Use gsi_remove result.
	* tree-ssa-dse.c (dse_optimize_stmt): Likewise.
	* tree-ssa-forwprop.c (remove_prop_source_from_use): Likewise.
	* tree-ssa-math-opts.c (execute_optimize_widening_mul): Likewise.
	* tree-ssa-pre.c (eliminate): Likewise.

Index: gcc/gimple.h
===================================================================
*** gcc/gimple.h.orig	2012-04-04 14:57:38.000000000 +0200
--- gcc/gimple.h	2012-04-04 14:58:20.633570347 +0200
*************** void gsi_insert_seq_after (gimple_stmt_i
*** 5095,5101 ****
  			   enum gsi_iterator_update);
  void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
                                            enum gsi_iterator_update);
! void gsi_remove (gimple_stmt_iterator *, bool);
  gimple_stmt_iterator gsi_for_stmt (gimple);
  void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
  void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
--- 5095,5101 ----
  			   enum gsi_iterator_update);
  void gsi_insert_seq_after_without_update (gimple_stmt_iterator *, gimple_seq,
                                            enum gsi_iterator_update);
! bool gsi_remove (gimple_stmt_iterator *, bool);
  gimple_stmt_iterator gsi_for_stmt (gimple);
  void gsi_move_after (gimple_stmt_iterator *, gimple_stmt_iterator *);
  void gsi_move_before (gimple_stmt_iterator *, gimple_stmt_iterator *);
Index: gcc/gimple-iterator.c
===================================================================
*** gcc/gimple-iterator.c.orig	2012-04-04 14:57:38.000000000 +0200
--- gcc/gimple-iterator.c	2012-04-04 14:58:56.661952844 +0200
*************** gsi_insert_after (gimple_stmt_iterator *
*** 499,511 ****
     REMOVE_PERMANENTLY is true when the statement is going to be removed
     from the IL and not reinserted elsewhere.  In that case we remove the
     statement pointed to by iterator I from the EH tables, and free its
!    operand caches.  Otherwise we do not modify this information.  */
  
! void
  gsi_remove (gimple_stmt_iterator *i, bool remove_permanently)
  {
    gimple_seq_node cur, next, prev;
    gimple stmt = gsi_stmt (*i);
  
    if (gimple_code (stmt) != GIMPLE_PHI)
      insert_debug_temps_for_defs (i);
--- 499,513 ----
     REMOVE_PERMANENTLY is true when the statement is going to be removed
     from the IL and not reinserted elsewhere.  In that case we remove the
     statement pointed to by iterator I from the EH tables, and free its
!    operand caches.  Otherwise we do not modify this information.  Returns
!    true whether EH edge cleanup is required.  */
  
! bool
  gsi_remove (gimple_stmt_iterator *i, bool remove_permanently)
  {
    gimple_seq_node cur, next, prev;
    gimple stmt = gsi_stmt (*i);
+   bool require_eh_edge_purge = false;
  
    if (gimple_code (stmt) != GIMPLE_PHI)
      insert_debug_temps_for_defs (i);
*************** gsi_remove (gimple_stmt_iterator *i, boo
*** 517,523 ****
  
    if (remove_permanently)
      {
!       remove_stmt_from_eh_lp (stmt);
        gimple_remove_stmt_histograms (cfun, stmt);
      }
  
--- 519,525 ----
  
    if (remove_permanently)
      {
!       require_eh_edge_purge = remove_stmt_from_eh_lp (stmt);
        gimple_remove_stmt_histograms (cfun, stmt);
      }
  
*************** gsi_remove (gimple_stmt_iterator *i, boo
*** 537,542 ****
--- 539,546 ----
      gimple_seq_set_last (i->seq, prev);
  
    i->ptr = next;
+ 
+   return require_eh_edge_purge;
  }
  
  
Index: gcc/tree-ssa-operands.c
===================================================================
*** gcc/tree-ssa-operands.c.orig	2012-04-04 14:57:38.000000000 +0200
--- gcc/tree-ssa-operands.c	2012-04-04 14:58:20.634570358 +0200
*************** unlink_stmt_vdef (gimple stmt)
*** 1475,1492 ****
    imm_use_iterator iter;
    gimple use_stmt;
    tree vdef = gimple_vdef (stmt);
  
    if (!vdef
        || TREE_CODE (vdef) != SSA_NAME)
      return;
  
!   FOR_EACH_IMM_USE_STMT (use_stmt, iter, gimple_vdef (stmt))
      {
        FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
! 	SET_USE (use_p, gimple_vuse (stmt));
      }
  
!   if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_vdef (stmt)))
!     SSA_NAME_OCCURS_IN_ABNORMAL_PHI (gimple_vuse (stmt)) = 1;
  }
  
--- 1475,1493 ----
    imm_use_iterator iter;
    gimple use_stmt;
    tree vdef = gimple_vdef (stmt);
+   tree vuse = gimple_vuse (stmt);
  
    if (!vdef
        || TREE_CODE (vdef) != SSA_NAME)
      return;
  
!   FOR_EACH_IMM_USE_STMT (use_stmt, iter, vdef)
      {
        FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
! 	SET_USE (use_p, vuse);
      }
  
!   if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vdef))
!     SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vuse) = 1;
  }
  
Index: gcc/tree-ssa-dom.c
===================================================================
*** gcc/tree-ssa-dom.c.orig	2012-04-04 14:57:38.000000000 +0200
--- gcc/tree-ssa-dom.c	2012-04-04 15:02:16.055069581 +0200
*************** optimize_stmt (basic_block bb, gimple_st
*** 2294,2303 ****
  	      && rhs == cached_lhs)
  	    {
  	      basic_block bb = gimple_bb (stmt);
- 	      int lp_nr = lookup_stmt_eh_lp (stmt);
  	      unlink_stmt_vdef (stmt);
! 	      gsi_remove (&si, true);
! 	      if (lp_nr != 0)
  		{
  		  bitmap_set_bit (need_eh_cleanup, bb->index);
  		  if (dump_file && (dump_flags & TDF_DETAILS))
--- 2294,2301 ----
  	      && rhs == cached_lhs)
  	    {
  	      basic_block bb = gimple_bb (stmt);
  	      unlink_stmt_vdef (stmt);
! 	      if (gsi_remove (&si, true))
  		{
  		  bitmap_set_bit (need_eh_cleanup, bb->index);
  		  if (dump_file && (dump_flags & TDF_DETAILS))
Index: gcc/tree-ssa-dse.c
===================================================================
*** gcc/tree-ssa-dse.c.orig	2012-04-04 14:57:38.000000000 +0200
--- gcc/tree-ssa-dse.c	2012-04-04 15:02:35.819279426 +0200
*************** dse_optimize_stmt (gimple_stmt_iterator
*** 257,266 ****
  	  /* Then we need to fix the operand of the consuming stmt.  */
  	  unlink_stmt_vdef (stmt);
  
- 	  bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
- 
  	  /* Remove the dead store.  */
! 	  gsi_remove (&gsi, true);
  
  	  /* And release any SSA_NAMEs set in this statement back to the
  	     SSA_NAME manager.  */
--- 257,265 ----
  	  /* Then we need to fix the operand of the consuming stmt.  */
  	  unlink_stmt_vdef (stmt);
  
  	  /* Remove the dead store.  */
! 	  if (gsi_remove (&gsi, true))
! 	    bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
  
  	  /* And release any SSA_NAMEs set in this statement back to the
  	     SSA_NAME manager.  */
Index: gcc/tree-ssa-forwprop.c
===================================================================
*** gcc/tree-ssa-forwprop.c.orig	2012-04-04 14:57:38.000000000 +0200
--- gcc/tree-ssa-forwprop.c	2012-04-04 14:59:18.350183049 +0200
*************** remove_prop_source_from_use (tree name)
*** 325,333 ****
      bb = gimple_bb (stmt);
      gsi = gsi_for_stmt (stmt);
      unlink_stmt_vdef (stmt);
!     gsi_remove (&gsi, true);
      release_defs (stmt);
-     cfg_changed |= gimple_purge_dead_eh_edges (bb);
  
      name = is_gimple_assign (stmt) ? gimple_assign_rhs1 (stmt) : NULL_TREE;
    } while (name && TREE_CODE (name) == SSA_NAME);
--- 325,333 ----
      bb = gimple_bb (stmt);
      gsi = gsi_for_stmt (stmt);
      unlink_stmt_vdef (stmt);
!     if (gsi_remove (&gsi, true))
!       cfg_changed |= gimple_purge_dead_eh_edges (bb);
      release_defs (stmt);
  
      name = is_gimple_assign (stmt) ? gimple_assign_rhs1 (stmt) : NULL_TREE;
    } while (name && TREE_CODE (name) == SSA_NAME);
Index: gcc/tree-ssa-math-opts.c
===================================================================
*** gcc/tree-ssa-math-opts.c.orig	2012-04-04 14:57:38.000000000 +0200
--- gcc/tree-ssa-math-opts.c	2012-04-04 15:03:35.227910166 +0200
*************** execute_optimize_widening_mul (void)
*** 2658,2667 ****
  						    gimple_call_arg (stmt, 0)))
  			  {
  			    unlink_stmt_vdef (stmt);
! 			    gsi_remove (&gsi, true);
! 			    release_defs (stmt);
! 			    if (gimple_purge_dead_eh_edges (bb))
  			      cfg_changed = true;
  			    continue;
  			  }
  			  break;
--- 2658,2667 ----
  						    gimple_call_arg (stmt, 0)))
  			  {
  			    unlink_stmt_vdef (stmt);
! 			    if (gsi_remove (&gsi, true)
! 				&& gimple_purge_dead_eh_edges (bb))
  			      cfg_changed = true;
+ 			    release_defs (stmt);
  			    continue;
  			  }
  			  break;
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c.orig	2012-04-04 14:57:38.000000000 +0200
--- gcc/tree-ssa-pre.c	2012-04-04 15:04:00.221175331 +0200
*************** eliminate (void)
*** 4629,4639 ****
  	  basic_block bb = gimple_bb (stmt);
  	  gsi = gsi_for_stmt (stmt);
  	  unlink_stmt_vdef (stmt);
! 	  gsi_remove (&gsi, true);
! 	  /* ???  gsi_remove doesn't tell us whether the stmt was
! 	     in EH tables and thus whether we need to purge EH edges.
! 	     Simply schedule the block for a cleanup.  */
! 	  bitmap_set_bit (need_eh_cleanup, bb->index);
  	  if (TREE_CODE (lhs) == SSA_NAME)
  	    bitmap_clear_bit (inserted_exprs, SSA_NAME_VERSION (lhs));
  	  release_defs (stmt);
--- 4629,4636 ----
  	  basic_block bb = gimple_bb (stmt);
  	  gsi = gsi_for_stmt (stmt);
  	  unlink_stmt_vdef (stmt);
! 	  if (gsi_remove (&gsi, true))
! 	    bitmap_set_bit (need_eh_cleanup, bb->index);
  	  if (TREE_CODE (lhs) == SSA_NAME)
  	    bitmap_clear_bit (inserted_exprs, SSA_NAME_VERSION (lhs));
  	  release_defs (stmt);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Make gsi_remove return whether EH cleanup is required
  2012-04-04 13:57 [PATCH] Make gsi_remove return whether EH cleanup is required Richard Guenther
@ 2012-04-05 11:21 ` Rainer Orth
  2012-04-05 11:30   ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Rainer Orth @ 2012-04-05 11:21 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

Richard Guenther <rguenther@suse.de> writes:

> Several passes needlessly cleanup EH after gsi_remove because they do
> not know whether the stmt was removed from EH regions.  The following
> patch returns this information from gsi_remove and adjusts all users
> I could find appropriately.

I suspect this patch caused a go1 SEGV compiling the non-PIC
libgo/exp/norm.o on i386-pc-solaris2.10:

> /var/gcc/regression/trunk/10-gcc-gld/build/./gcc/gccgo -B/var/gcc/regression/trunk/10-gcc-gld/build/./gcc/ -B/vol/gcc/i386-pc-solaris2.10/bin/ -B/vol/gcc/i386-pc-solaris2.10/lib/ -isystem /vol/gcc/i386-pc-solaris2.10/include -isystem /vol/gcc/i386-pc-solaris2.10/sys-include -minline-all-stringops -g -O2 -I . -c -fgo-prefix=libgo_exp /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/composition.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/forminfo.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/input.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/iter.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/normalize.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/readwriter.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/tables.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/trie.go -o exp/norm.o -save-temps
/vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/normalize.go: In function 'norm.decomposeToLastBoundary':
/vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/normalize.go:429:1: internal compiler error: Segmentation Fault

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x0852aefc in dse_optimize_stmt (gsi=...) at /vol/gcc/src/hg/trunk/local/gcc/tree-ssa-dse.c:262
(gdb) where
#0  0x0852aefc in dse_optimize_stmt (gsi=...) at /vol/gcc/src/hg/trunk/local/gcc/tree-ssa-dse.c:262
#1  dse_enter_block (walk_data=0x8046ed0, bb=0xfe2c6640) at /vol/gcc/src/hg/trunk/local/gcc/tree-ssa-dse.c:278
#2  0x08875e85 in walk_dominator_tree (walk_data=0x8046ed0, bb=0xfe2c6640) at /vol/gcc/src/hg/trunk/local/gcc/domwalk.c:188
#3  0x0852a757 in tree_ssa_dse () at /vol/gcc/src/hg/trunk/local/gcc/tree-ssa-dse.c:313
#4  0x0840cb64 in execute_one_pass (pass=pass@entry=0x8dbe8a0) at /vol/gcc/src/hg/trunk/local/gcc/passes.c:2079
#5  0x0840cebd in execute_pass_list (pass=0x8dbe8a0) at /vol/gcc/src/hg/trunk/local/gcc/passes.c:2134
#6  0x0840ced0 in execute_pass_list (pass=0x8dbe4e0) at /vol/gcc/src/hg/trunk/local/gcc/passes.c:2135
#7  0x084ea0f6 in tree_rest_of_compilation (fndecl=0xfeb9d300) at /vol/gcc/src/hg/trunk/local/gcc/tree-optimize.c:422
#8  0x08283417 in cgraph_expand_function (node=0xfebb599c) at /vol/gcc/src/hg/trunk/local/gcc/cgraphunit.c:1784
#9  0x08284c55 in cgraph_expand_all_functions () at /vol/gcc/src/hg/trunk/local/gcc/cgraphunit.c:1851
#10 cgraph_optimize () at /vol/gcc/src/hg/trunk/local/gcc/cgraphunit.c:2542
#11 0x0828518f in cgraph_finalize_compilation_unit () at /vol/gcc/src/hg/trunk/local/gcc/cgraphunit.c:2628
#12 0x081d117d in Gogo::write_globals (this=0x8f2f170) at /vol/gcc/src/hg/trunk/local/gcc/go/gofrontend/gogo-tree.cc:934
#13 0x081cb343 in go_write_globals () at /vol/gcc/src/hg/trunk/local/gcc/go/gofrontend/go.cc:154
#14 0x084a432b in compile_file () at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:572
#15 do_compile () at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:1936
#16 toplev_main (argc=26, argv=0x80471cc) at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:2012
#17 0x0819f3bb in main (argc=26, argv=0x80471cc) at /vol/gcc/src/hg/trunk/local/gcc/main.c:36

Unfortunately, I cannot look into most of the variables used since gdb
just shows them as `optimized out'.

I'm just running a x86_64-unknown-linux-gnu bootstrap to check if it
also occurs there.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Make gsi_remove return whether EH cleanup is required
  2012-04-05 11:21 ` Rainer Orth
@ 2012-04-05 11:30   ` Richard Guenther
  2012-04-05 11:55     ` Rainer Orth
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Guenther @ 2012-04-05 11:30 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Richard Guenther, gcc-patches

On Thu, Apr 5, 2012 at 1:20 PM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> Richard Guenther <rguenther@suse.de> writes:
>
>> Several passes needlessly cleanup EH after gsi_remove because they do
>> not know whether the stmt was removed from EH regions.  The following
>> patch returns this information from gsi_remove and adjusts all users
>> I could find appropriately.
>
> I suspect this patch caused a go1 SEGV compiling the non-PIC
> libgo/exp/norm.o on i386-pc-solaris2.10:

Ah.  Try

Index: gcc/tree-ssa-dse.c
===================================================================
--- gcc/tree-ssa-dse.c  (revision 186161)
+++ gcc/tree-ssa-dse.c  (working copy)
@@ -232,6 +232,8 @@ dse_optimize_stmt (gimple_stmt_iterator
                                gimple_get_lhs (use_stmt), 0)))
          || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt)))
        {
+         basic_block bb;
+
          /* If use_stmt is or might be a nop assignment, e.g. for
             struct { ... } S a, b, *p; ...
             b = a; b = b;
@@ -258,8 +260,9 @@ dse_optimize_stmt (gimple_stmt_iterator
          unlink_stmt_vdef (stmt);

          /* Remove the dead store.  */
+         bb = gimple_bb (stmt);
          if (gsi_remove (&gsi, true))
-           bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
+           bitmap_set_bit (need_eh_cleanup, bb->index);

          /* And release any SSA_NAMEs set in this statement back to the
             SSA_NAME manager.  */


>> /var/gcc/regression/trunk/10-gcc-gld/build/./gcc/gccgo -B/var/gcc/regression/trunk/10-gcc-gld/build/./gcc/ -B/vol/gcc/i386-pc-solaris2.10/bin/ -B/vol/gcc/i386-pc-solaris2.10/lib/ -isystem /vol/gcc/i386-pc-solaris2.10/include -isystem /vol/gcc/i386-pc-solaris2.10/sys-include -minline-all-stringops -g -O2 -I . -c -fgo-prefix=libgo_exp /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/composition.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/forminfo.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/input.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/iter.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/normalize.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/readwriter.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/tables.go /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/trie.go -o exp/norm.o -save-temps
> /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/normalize.go: In function 'norm.decomposeToLastBoundary':
> /vol/gcc/src/hg/trunk/local/libgo/go/exp/norm/normalize.go:429:1: internal compiler error: Segmentation Fault
>
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1 (LWP 1)]
> 0x0852aefc in dse_optimize_stmt (gsi=...) at /vol/gcc/src/hg/trunk/local/gcc/tree-ssa-dse.c:262
> (gdb) where
> #0  0x0852aefc in dse_optimize_stmt (gsi=...) at /vol/gcc/src/hg/trunk/local/gcc/tree-ssa-dse.c:262
> #1  dse_enter_block (walk_data=0x8046ed0, bb=0xfe2c6640) at /vol/gcc/src/hg/trunk/local/gcc/tree-ssa-dse.c:278
> #2  0x08875e85 in walk_dominator_tree (walk_data=0x8046ed0, bb=0xfe2c6640) at /vol/gcc/src/hg/trunk/local/gcc/domwalk.c:188
> #3  0x0852a757 in tree_ssa_dse () at /vol/gcc/src/hg/trunk/local/gcc/tree-ssa-dse.c:313
> #4  0x0840cb64 in execute_one_pass (pass=pass@entry=0x8dbe8a0) at /vol/gcc/src/hg/trunk/local/gcc/passes.c:2079
> #5  0x0840cebd in execute_pass_list (pass=0x8dbe8a0) at /vol/gcc/src/hg/trunk/local/gcc/passes.c:2134
> #6  0x0840ced0 in execute_pass_list (pass=0x8dbe4e0) at /vol/gcc/src/hg/trunk/local/gcc/passes.c:2135
> #7  0x084ea0f6 in tree_rest_of_compilation (fndecl=0xfeb9d300) at /vol/gcc/src/hg/trunk/local/gcc/tree-optimize.c:422
> #8  0x08283417 in cgraph_expand_function (node=0xfebb599c) at /vol/gcc/src/hg/trunk/local/gcc/cgraphunit.c:1784
> #9  0x08284c55 in cgraph_expand_all_functions () at /vol/gcc/src/hg/trunk/local/gcc/cgraphunit.c:1851
> #10 cgraph_optimize () at /vol/gcc/src/hg/trunk/local/gcc/cgraphunit.c:2542
> #11 0x0828518f in cgraph_finalize_compilation_unit () at /vol/gcc/src/hg/trunk/local/gcc/cgraphunit.c:2628
> #12 0x081d117d in Gogo::write_globals (this=0x8f2f170) at /vol/gcc/src/hg/trunk/local/gcc/go/gofrontend/gogo-tree.cc:934
> #13 0x081cb343 in go_write_globals () at /vol/gcc/src/hg/trunk/local/gcc/go/gofrontend/go.cc:154
> #14 0x084a432b in compile_file () at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:572
> #15 do_compile () at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:1936
> #16 toplev_main (argc=26, argv=0x80471cc) at /vol/gcc/src/hg/trunk/local/gcc/toplev.c:2012
> #17 0x0819f3bb in main (argc=26, argv=0x80471cc) at /vol/gcc/src/hg/trunk/local/gcc/main.c:36
>
> Unfortunately, I cannot look into most of the variables used since gdb
> just shows them as `optimized out'.
>
> I'm just running a x86_64-unknown-linux-gnu bootstrap to check if it
> also occurs there.
>
>        Rainer
>
> --
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Make gsi_remove return whether EH cleanup is required
  2012-04-05 11:30   ` Richard Guenther
@ 2012-04-05 11:55     ` Rainer Orth
  2012-04-05 12:37       ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Rainer Orth @ 2012-04-05 11:55 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Richard Guenther, gcc-patches

Richard Guenther <richard.guenther@gmail.com> writes:

> On Thu, Apr 5, 2012 at 1:20 PM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
>> Richard Guenther <rguenther@suse.de> writes:
>>
>>> Several passes needlessly cleanup EH after gsi_remove because they do
>>> not know whether the stmt was removed from EH regions.  The following
>>> patch returns this information from gsi_remove and adjusts all users
>>> I could find appropriately.
>>
>> I suspect this patch caused a go1 SEGV compiling the non-PIC
>> libgo/exp/norm.o on i386-pc-solaris2.10:
>
> Ah.  Try
>
> Index: gcc/tree-ssa-dse.c
> ===================================================================
> --- gcc/tree-ssa-dse.c  (revision 186161)
> +++ gcc/tree-ssa-dse.c  (working copy)
> @@ -232,6 +232,8 @@ dse_optimize_stmt (gimple_stmt_iterator
>                                 gimple_get_lhs (use_stmt), 0)))
>           || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt)))
>         {
> +         basic_block bb;
> +
>           /* If use_stmt is or might be a nop assignment, e.g. for
>              struct { ... } S a, b, *p; ...
>              b = a; b = b;
> @@ -258,8 +260,9 @@ dse_optimize_stmt (gimple_stmt_iterator
>           unlink_stmt_vdef (stmt);
>
>           /* Remove the dead store.  */
> +         bb = gimple_bb (stmt);
>           if (gsi_remove (&gsi, true))
> -           bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
> +           bitmap_set_bit (need_eh_cleanup, bb->index);
>
>           /* And release any SSA_NAMEs set in this statement back to the
>              SSA_NAME manager.  */
>

Works fine on x86_64-unknown-linux-gnu, where the failure happened as
well.

Thanks.
        Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Make gsi_remove return whether EH cleanup is required
  2012-04-05 11:55     ` Rainer Orth
@ 2012-04-05 12:37       ` Richard Guenther
  0 siblings, 0 replies; 5+ messages in thread
From: Richard Guenther @ 2012-04-05 12:37 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Richard Guenther, gcc-patches

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2977 bytes --]

On Thu, 5 Apr 2012, Rainer Orth wrote:

> Richard Guenther <richard.guenther@gmail.com> writes:
> 
> > On Thu, Apr 5, 2012 at 1:20 PM, Rainer Orth <ro@cebitec.uni-bielefeld.de> wrote:
> >> Richard Guenther <rguenther@suse.de> writes:
> >>
> >>> Several passes needlessly cleanup EH after gsi_remove because they do
> >>> not know whether the stmt was removed from EH regions.  The following
> >>> patch returns this information from gsi_remove and adjusts all users
> >>> I could find appropriately.
> >>
> >> I suspect this patch caused a go1 SEGV compiling the non-PIC
> >> libgo/exp/norm.o on i386-pc-solaris2.10:
> >
> > Ah.  Try
> >
> > Index: gcc/tree-ssa-dse.c
> > ===================================================================
> > --- gcc/tree-ssa-dse.c  (revision 186161)
> > +++ gcc/tree-ssa-dse.c  (working copy)
> > @@ -232,6 +232,8 @@ dse_optimize_stmt (gimple_stmt_iterator
> >                                 gimple_get_lhs (use_stmt), 0)))
> >           || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt)))
> >         {
> > +         basic_block bb;
> > +
> >           /* If use_stmt is or might be a nop assignment, e.g. for
> >              struct { ... } S a, b, *p; ...
> >              b = a; b = b;
> > @@ -258,8 +260,9 @@ dse_optimize_stmt (gimple_stmt_iterator
> >           unlink_stmt_vdef (stmt);
> >
> >           /* Remove the dead store.  */
> > +         bb = gimple_bb (stmt);
> >           if (gsi_remove (&gsi, true))
> > -           bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
> > +           bitmap_set_bit (need_eh_cleanup, bb->index);
> >
> >           /* And release any SSA_NAMEs set in this statement back to the
> >              SSA_NAME manager.  */
> >
> 
> Works fine on x86_64-unknown-linux-gnu, where the failure happened as
> well.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2012-04-05  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-dse.c (dse_optimize_stmt): Remember the stmt
	basic-block before removing it.

Index: gcc/tree-ssa-dse.c
===================================================================
--- gcc/tree-ssa-dse.c	(revision 186161)
+++ gcc/tree-ssa-dse.c	(working copy)
@@ -232,6 +232,8 @@ dse_optimize_stmt (gimple_stmt_iterator
 				gimple_get_lhs (use_stmt), 0)))
 	  || stmt_kills_ref_p (use_stmt, gimple_assign_lhs (stmt)))
 	{
+	  basic_block bb;
+
 	  /* If use_stmt is or might be a nop assignment, e.g. for
 	     struct { ... } S a, b, *p; ...
 	     b = a; b = b;
@@ -258,8 +260,9 @@ dse_optimize_stmt (gimple_stmt_iterator
 	  unlink_stmt_vdef (stmt);
 
 	  /* Remove the dead store.  */
+	  bb = gimple_bb (stmt);
 	  if (gsi_remove (&gsi, true))
-	    bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
+	    bitmap_set_bit (need_eh_cleanup, bb->index);
 
 	  /* And release any SSA_NAMEs set in this statement back to the
 	     SSA_NAME manager.  */

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-04-05 12:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-04 13:57 [PATCH] Make gsi_remove return whether EH cleanup is required Richard Guenther
2012-04-05 11:21 ` Rainer Orth
2012-04-05 11:30   ` Richard Guenther
2012-04-05 11:55     ` Rainer Orth
2012-04-05 12:37       ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).