[patch] Fix PR lto/48492 (partially)

Eric Botcazou ebotcazou@adacore.com
Mon Apr 18 00:50:00 GMT 2011


Hi,

this (partially) fixes the LTO bootstrap failure with Ada enabled on the 
mainline.  The problem is an ICE whose origin is as follows:
  1. during LTO stage, copy-prop eliminates a DECL_IN_CONSTANT_POOL variable
from the GIMPLE IR, except for a reference in a GIMPLE_DEBUG statement
(ADDR_EXPR of the variable is the debug value),
  2. the variable is streamed out in the object file, as well as its associated
varpool entry,
  3. during WPA stage, both are streamed in, then reachability analysis is run
and computes that the variable is unreachable so removes the varpool entry.
As a consequence, when the variable is streamed out again, its initializer gets
replaced with ERROR_MARK.
  4. during LTRANS stage, the variable is again streamed in, with ERROR_MARK as
initializer and this blows up when the GIMPLE_DEBUG statement is processed.

So the root problem is in the reachability analysis during the WPA stage but, 
as pointed out by Jakub, this is so by design for GIMPLE_DEBUG statements.

There are already cases for which expand_debug_expr simply gives up:

    case VAR_DECL:
    case PARM_DECL:
    case FUNCTION_DECL:
    case LABEL_DECL:
    case CONST_DECL:
    case RESULT_DECL:
      op0 = DECL_RTL_IF_SET (exp);

      /* This decl was probably optimized away.  */
      if (!op0)
	{
	  if (TREE_CODE (exp) != VAR_DECL
	      || DECL_EXTERNAL (exp)
	      || !TREE_STATIC (exp)
	      || !DECL_NAME (exp)
	      || DECL_HARD_REGISTER (exp)
	      || DECL_IN_CONSTANT_POOL (exp)
	      || mode == VOIDmode)
	    return NULL;

the attached patch adds DECL_IN_CONSTANT_POOL to them.  This makes it possible 
to eliminate the ICE (but LTO bootstrap still fails because of an unrelated 
ICE in dwarf2out.c later).  OK for the mainline?


2011-04-17  Eric Botcazou  <ebotcazou@adacore.com>

	PR lto/48492
	* cfgexpand.c (expand_debug_expr) <VAR_DECL>: Return NULL for a
	DECL_IN_CONSTANT_POOL without RTL.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-diff
Size: 386 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20110418/e68895d7/attachment.bin>


More information about the Gcc-patches mailing list