On Mon, Apr 18, 2011 at 12:56 AM, Eric Botcazou <ebotca...@adacore.com> wrote: > 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?
Ok. I've run into similar issues when trying to do constant folding of initializers on debug-stmts - sometimes they refer to optimized out vars which have a error-mark initializer but the constant folding code then happily thinks their initializer is zero, giving wrong debug info ... Thanks, Richard. > > 2011-04-17 Eric Botcazou <ebotca...@adacore.com> > > PR lto/48492 > * cfgexpand.c (expand_debug_expr) <VAR_DECL>: Return NULL for a > DECL_IN_CONSTANT_POOL without RTL. > > > -- > Eric Botcazou >