This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Fix ICE with -O -flto and -g
- From: Eric Botcazou <ebotcazou at adacore dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Jun 2012 18:57:16 +0200
- Subject: [patch] Fix ICE with -O -flto and -g
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.
--
Eric Botcazou
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;
package Lto15 is
type Arr is array (Positive range <>) of Integer;
type R(Size : Positive) is record
Data : Arr (1 .. Size);
end record;
function Proc (Data : Arr) return R;
end Lto15;
-- { dg-do compile }
-- { dg-options "-O -flto -g" }
package body Lto15 is
function Proc (Data : Arr) return R is
begin
return (Data'Length, Data);
end;
end Lto15;