From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26232 invoked by alias); 18 Apr 2011 09:27:07 -0000 Received: (qmail 26223 invoked by uid 22791); 18 Apr 2011 09:27:06 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,TW_TM X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 18 Apr 2011 09:26:32 +0000 Received: by wwf26 with SMTP id 26so5116567wwf.8 for ; Mon, 18 Apr 2011 02:26:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.30.164 with SMTP id u36mr4666204wbc.118.1303118790813; Mon, 18 Apr 2011 02:26:30 -0700 (PDT) Received: by 10.227.0.140 with HTTP; Mon, 18 Apr 2011 02:26:30 -0700 (PDT) In-Reply-To: <201104180056.51119.ebotcazou@adacore.com> References: <201104180056.51119.ebotcazou@adacore.com> Date: Mon, 18 Apr 2011 09:39:00 -0000 Message-ID: Subject: Re: [patch] Fix PR lto/48492 (partially) From: Richard Guenther To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-04/txt/msg01362.txt.bz2 On Mon, Apr 18, 2011 at 12:56 AM, Eric Botcazou wro= te: > Hi, > > this (partially) fixes the LTO bootstrap failure with Ada enabled on the > mainline. =A0The problem is an ICE whose origin is as follows: > =A01. during LTO stage, copy-prop eliminates a DECL_IN_CONSTANT_POOL vari= able > from the GIMPLE IR, except for a reference in a GIMPLE_DEBUG statement > (ADDR_EXPR of the variable is the debug value), > =A02. the variable is streamed out in the object file, as well as its ass= ociated > varpool entry, > =A03. during WPA stage, both are streamed in, then reachability analysis = is run > and computes that the variable is unreachable so removes the varpool entr= y. > As a consequence, when the variable is streamed out again, its initialize= r gets > replaced with ERROR_MARK. > =A04. during LTRANS stage, the variable is again streamed in, with ERROR_= MARK as > initializer and this blows up when the GIMPLE_DEBUG statement is processe= d. > > 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: > > =A0 =A0case VAR_DECL: > =A0 =A0case PARM_DECL: > =A0 =A0case FUNCTION_DECL: > =A0 =A0case LABEL_DECL: > =A0 =A0case CONST_DECL: > =A0 =A0case RESULT_DECL: > =A0 =A0 =A0op0 =3D DECL_RTL_IF_SET (exp); > > =A0 =A0 =A0/* This decl was probably optimized away. =A0*/ > =A0 =A0 =A0if (!op0) > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0if (TREE_CODE (exp) !=3D VAR_DECL > =A0 =A0 =A0 =A0 =A0 =A0 =A0|| DECL_EXTERNAL (exp) > =A0 =A0 =A0 =A0 =A0 =A0 =A0|| !TREE_STATIC (exp) > =A0 =A0 =A0 =A0 =A0 =A0 =A0|| !DECL_NAME (exp) > =A0 =A0 =A0 =A0 =A0 =A0 =A0|| DECL_HARD_REGISTER (exp) > =A0 =A0 =A0 =A0 =A0 =A0 =A0|| DECL_IN_CONSTANT_POOL (exp) > =A0 =A0 =A0 =A0 =A0 =A0 =A0|| mode =3D=3D VOIDmode) > =A0 =A0 =A0 =A0 =A0 =A0return NULL; > > the attached patch adds DECL_IN_CONSTANT_POOL to them. =A0This makes it p= ossible > to eliminate the ICE (but LTO bootstrap still fails because of an unrelat= ed > ICE in dwarf2out.c later). =A0OK for the mainline? Ok. I've run into similar issues when trying to do constant folding of initiali= zers 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 =A0Eric Botcazou =A0 > > =A0 =A0 =A0 =A0PR lto/48492 > =A0 =A0 =A0 =A0* cfgexpand.c (expand_debug_expr) : Return NULL = for a > =A0 =A0 =A0 =A0DECL_IN_CONSTANT_POOL without RTL. > > > -- > Eric Botcazou >