diff mbox

Fix ICE with -O -flto and -g

Message ID 201206211857.16489.ebotcazou@adacore.com
State New
Headers show

Commit Message

Eric Botcazou June 21, 2012, 4:57 p.m. UTC
Hi,

this is a regression present on the mainline and 4.7 branch with -O -flto -g.
Starting with 4.7.x, the Ada compiler implements a form of NRV optimization on 
the GENERIC representation (like C++ but more powerful) and, in some cases, it 
replaces a returned variable with a new one, disconnecting the former as much 
as possible, i.e. removing the DECL_EXPR and setting DECL_IGNORED_P on it.

Since there is no more DECL_EXPR, the old variable isn't gimplified but, since 
DECL_IGNORED_P is set, it should be dropped from its BLOCK at -O.  It turns 
out that it isn't dropped at -g, leading to the ICE as there is a CALL_EXPR in 
the non-gimplified DECL_SIZE, because of a 4.6-ish patch of Jakub:

2011-01-21  Jakub Jelinek  <jakub@redhat.com>

	* tree-ssa-live.c (remove_unused_scope_block_p): Don't remove
	DECL_IGNORED_P non-reg vars if they are used.

My understanding is that this patch is now obsolete because of the new layout 
algorithm in cfgexpand.c, so the attached patch reverts it.

Bootstrapped/regtested on x86_64-suse-linux, OK for mainline and 4.7 branch?


2012-06-21  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-ssa-live.c (remove_unused_scope_block_p): Remove again
	DECL_IGNORED_P non-reg vars even if they are used.


2012-06-21  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/lto15.ad[sb]: New test.

Comments

Jakub Jelinek June 21, 2012, 7:13 p.m. UTC | #1
On Thu, Jun 21, 2012 at 06:57:16PM +0200, Eric Botcazou wrote:
> Bootstrapped/regtested on x86_64-suse-linux, OK for mainline and 4.7 branch?
> 
> 
> 2012-06-21  Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	* tree-ssa-live.c (remove_unused_scope_block_p): Remove again
> 	DECL_IGNORED_P non-reg vars even if they are used.
> 
> 
> 2012-06-21  Eric Botcazou  <ebotcazou@adacore.com>
> 
> 	* gnat.dg/lto15.ad[sb]: New test.

Ok.

	Jakub
diff mbox

Patch

Index: tree-ssa-live.c
===================================================================
--- tree-ssa-live.c	(revision 188855)
+++ tree-ssa-live.c	(working copy)
@@ -458,11 +458,8 @@  remove_unused_scope_block_p (tree scope,
       else if (TREE_CODE (*t) == VAR_DECL && DECL_HAS_VALUE_EXPR_P (*t))
 	unused = false;
 
-      /* Remove everything we don't generate debug info for.
-	 Don't remove larger vars though, because BLOCK_VARS are
-	 used also during expansion to determine which variables
-	 might share stack space.  */
-      else if (DECL_IGNORED_P (*t) && is_gimple_reg (*t))
+      /* Remove everything we don't generate debug info for.  */
+      else if (DECL_IGNORED_P (*t))
 	{
 	  *t = DECL_CHAIN (*t);
 	  next = t;