public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR 90273
@ 2019-04-29 13:24 Richard Biener
  2019-04-29 18:29 ` Richard Biener
  2019-04-30  3:59 ` Alexandre Oliva
  0 siblings, 2 replies; 3+ messages in thread
From: Richard Biener @ 2019-04-29 13:24 UTC (permalink / raw)
  To: gcc-patches; +Cc: aoliva, Jakub Jelinek


The following fixes PR90273 where the testcase exhibits an excessive
number of debug stmts after the recent fixes to CFG cleanup to not
throw away debug stmts it cannot move but instead move and reset them.
This excessiveness causes compile-time and memory-usage to go through the
roof.

The fix is to deploy a simple debug-stmt DCE eliminating all but the
last debug-bind (of non-DEBUG_EXPR_DECL vars) in a series of
debug-bind-only stmts.  This simple DCE is hooked into the DCE
pass and implemented BB-local.

Bootstrapped / tested a slightly older version, re-bootstrap/regtest
in progress on x86_64-unknown-linux-gnu.

OK for trunk and branch?

Thanks,
Richard.

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

	PR tree-optimization/90273
	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Eliminate
	useless debug stmts.

Index: gcc/tree-ssa-dce.c
===================================================================
--- gcc/tree-ssa-dce.c	(revision 270640)
+++ gcc/tree-ssa-dce.c	(working copy)
@@ -1237,6 +1237,7 @@ eliminate_unnecessary_stmts (void)
       bb = h.pop ();
 
       /* Remove dead statements.  */
+      auto_bitmap debug_seen;
       for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi = psi)
 	{
 	  stmt = gsi_stmt (gsi);
@@ -1282,11 +1283,15 @@ eliminate_unnecessary_stmts (void)
 			}
 		    }
 		  if (!dead)
-		    continue;
+		    {
+		      bitmap_clear (debug_seen);
+		      continue;
+		    }
 		}
 	      if (!is_gimple_debug (stmt))
 		something_changed = true;
 	      remove_dead_stmt (&gsi, bb, to_remove_edges);
+	      continue;
 	    }
 	  else if (is_gimple_call (stmt))
 	    {
@@ -1352,6 +1357,18 @@ eliminate_unnecessary_stmts (void)
 		    break;
 		  }
 	    }
+	  else if (gimple_debug_bind_p (stmt))
+	    {
+	      /* We are only keeping the last debug-bind of a
+	         non-DEBUG_EXPR_DECL variable in a series of
+		 debug-bind stmts.  */
+	      tree var = gimple_debug_bind_get_var (stmt);
+	      if (TREE_CODE (var) != DEBUG_EXPR_DECL
+		  && !bitmap_set_bit (debug_seen, DECL_UID (var)))
+		remove_dead_stmt (&gsi, bb, to_remove_edges);
+	      continue;
+	    }
+	  bitmap_clear (debug_seen);
 	}
 
       /* Remove dead PHI nodes.  */

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

* Re: [PATCH] Fix PR 90273
  2019-04-29 13:24 [PATCH] Fix PR 90273 Richard Biener
@ 2019-04-29 18:29 ` Richard Biener
  2019-04-30  3:59 ` Alexandre Oliva
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Biener @ 2019-04-29 18:29 UTC (permalink / raw)
  To: gcc-patches; +Cc: aoliva, Jakub Jelinek

[-- Attachment #1: Type: text/plain, Size: 2584 bytes --]

On Mon, 29 Apr 2019, Richard Biener wrote:

> 
> The following fixes PR90273 where the testcase exhibits an excessive
> number of debug stmts after the recent fixes to CFG cleanup to not
> throw away debug stmts it cannot move but instead move and reset them.
> This excessiveness causes compile-time and memory-usage to go through the
> roof.
> 
> The fix is to deploy a simple debug-stmt DCE eliminating all but the
> last debug-bind (of non-DEBUG_EXPR_DECL vars) in a series of
> debug-bind-only stmts.  This simple DCE is hooked into the DCE
> pass and implemented BB-local.
> 
> Bootstrapped / tested a slightly older version, re-bootstrap/regtest
> in progress on x86_64-unknown-linux-gnu.

Testing went OK.

> OK for trunk and branch?
> 
> Thanks,
> Richard.
> 
> 2019-04-29  Richard Biener  <rguenther@suse.de>
> 
> 	PR tree-optimization/90273
> 	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Eliminate
> 	useless debug stmts.
> 
> Index: gcc/tree-ssa-dce.c
> ===================================================================
> --- gcc/tree-ssa-dce.c	(revision 270640)
> +++ gcc/tree-ssa-dce.c	(working copy)
> @@ -1237,6 +1237,7 @@ eliminate_unnecessary_stmts (void)
>        bb = h.pop ();
>  
>        /* Remove dead statements.  */
> +      auto_bitmap debug_seen;
>        for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi = psi)
>  	{
>  	  stmt = gsi_stmt (gsi);
> @@ -1282,11 +1283,15 @@ eliminate_unnecessary_stmts (void)
>  			}
>  		    }
>  		  if (!dead)
> -		    continue;
> +		    {
> +		      bitmap_clear (debug_seen);
> +		      continue;
> +		    }
>  		}
>  	      if (!is_gimple_debug (stmt))
>  		something_changed = true;
>  	      remove_dead_stmt (&gsi, bb, to_remove_edges);
> +	      continue;
>  	    }
>  	  else if (is_gimple_call (stmt))
>  	    {
> @@ -1352,6 +1357,18 @@ eliminate_unnecessary_stmts (void)
>  		    break;
>  		  }
>  	    }
> +	  else if (gimple_debug_bind_p (stmt))
> +	    {
> +	      /* We are only keeping the last debug-bind of a
> +	         non-DEBUG_EXPR_DECL variable in a series of
> +		 debug-bind stmts.  */
> +	      tree var = gimple_debug_bind_get_var (stmt);
> +	      if (TREE_CODE (var) != DEBUG_EXPR_DECL
> +		  && !bitmap_set_bit (debug_seen, DECL_UID (var)))
> +		remove_dead_stmt (&gsi, bb, to_remove_edges);
> +	      continue;
> +	    }
> +	  bitmap_clear (debug_seen);
>  	}
>  
>        /* Remove dead PHI nodes.  */
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Linux GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany;
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah; HRB 21284 (AG NÌrnberg)

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

* Re: [PATCH] Fix PR 90273
  2019-04-29 13:24 [PATCH] Fix PR 90273 Richard Biener
  2019-04-29 18:29 ` Richard Biener
@ 2019-04-30  3:59 ` Alexandre Oliva
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2019-04-30  3:59 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, Jakub Jelinek

On Apr 29, 2019, Richard Biener <rguenther@suse.de> wrote:

> OK for trunk and branch?

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

> 	PR tree-optimization/90273
> 	* tree-ssa-dce.c (eliminate_unnecessary_stmts): Eliminate
> 	useless debug stmts.

LGTM, thanks

-- 
Alexandre Oliva, freedom fighter   https://FSFLA.org/blogs/lxo
Be the change, be Free!         FSF Latin America board member
GNU Toolchain Engineer                Free Software Evangelist
Hay que enGNUrecerse, pero sin perder la terGNUra jamás-GNUChe

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

end of thread, other threads:[~2019-04-30  3:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29 13:24 [PATCH] Fix PR 90273 Richard Biener
2019-04-29 18:29 ` Richard Biener
2019-04-30  3:59 ` Alexandre Oliva

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).