From patchwork Thu Jun 17 19:07:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 56082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 293361007D2 for ; Fri, 18 Jun 2010 05:08:07 +1000 (EST) Received: (qmail 8832 invoked by alias); 17 Jun 2010 19:08:04 -0000 Received: (qmail 8798 invoked by uid 22791); 17 Jun 2010 19:08:02 -0000 X-SWARE-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 17 Jun 2010 19:07:56 +0000 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5HJ7rMi018633 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 17 Jun 2010 15:07:53 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5HJ7pjB008472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 17 Jun 2010 15:07:53 -0400 Received: from livre.localdomain (livre.oliva.athome.lsd.ic.unicamp.br [172.31.160.2]) by localhost.localdomain (8.14.3/8.14.3) with ESMTP id o5HJ7pen026116; Thu, 17 Jun 2010 16:07:51 -0300 Received: from livre.localdomain (aoliva@localhost [127.0.0.1]) by livre.localdomain (8.14.3/8.14.3/Debian-5+lenny1) with ESMTP id o5HJ7oD6025815; Thu, 17 Jun 2010 16:07:50 -0300 Received: (from aoliva@localhost) by livre.localdomain (8.14.3/8.14.3/Submit) id o5HJ7nnd025813; Thu, 17 Jun 2010 16:07:49 -0300 From: Alexandre Oliva To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: Re: [PR44248] Fix lto/whopr -g link-time -fcompare-debug failure References: Date: Thu, 17 Jun 2010 16:07:49 -0300 In-Reply-To: (Richard Guenther's message of "Tue, 15 Jun 2010 10:31:45 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On Jun 15, 2010, Richard Guenther wrote: > On Tue, Jun 15, 2010 at 5:00 AM, Alexandre Oliva wrote: >> When VTA is disabled, LTO streams in debug stmts as gimple nops.  This >> is inadequate, for gimple nops will get in the way of removal of blocks >> and perhaps other situations in which debug stmts are properly >> disregarded.  Their presence is enough to bring about codegen >> differences, causing -fcompare-debug failures when an object file >> compiled with -g -flto is to be link-time compiled without -g, as is the >> case when -fcompare-debug is given. >> >> This patch arranges for us to drop the debug stmts entirely, but to do >> so only after applying fixups.  We could drop them a bit earlier, while >> filling in the stmts array, but then we'd have to worry about NULL stmt >> entries in the array (should debug stmts have fixups) and the array >> would probably be slower, for we'd have to test MAY_HAVE_DEBUG_STMTS >> multiple times. >> >> Is this ok, if it passes regstrap on x86_64-linux-gnu? > Ok if you make input_bb return a flag whether a debug stmt was > streamed in, aggregate that and make the loop over all stmts > conditional on that to avoid walking over all stmts in a function > one more time. How about piggibacking on another existing loop over all stmts, instead? I tried this with an -flto -fcompare-debug bootstrap and that worked fine on i686-pc-linux-gnu. On other platforms, there were -fcompare-debug failures, but no crashes, so removing the stmts at that point is fine, we just have to keep them long enough for the uids to be computed as expected. Leave the corresponding entries in the stmts array as NULL is fine. Ok to install? for gcc/ChangeLog from Alexandre Oliva PR debug/44248 * lto-streamer-in.c (input_bb): Leave debug stmts alone. (input_function): Drop them here, if VTA is disabled. Index: gcc/lto-streamer-in.c =================================================================== --- gcc/lto-streamer-in.c.orig 2010-06-16 17:17:46.000000000 -0300 +++ gcc/lto-streamer-in.c 2010-06-16 17:21:33.000000000 -0300 @@ -1204,13 +1204,6 @@ input_bb (struct lto_input_block *ib, en { gimple stmt = input_gimple_stmt (ib, data_in, fn, tag); - /* Change debug stmts to nops on-the-fly if we do not have VTA enabled. - This allows us to build for example static libs with debugging - enabled and do the final link without. */ - if (!MAY_HAVE_DEBUG_STMTS - && is_gimple_debug (stmt)) - stmt = gimple_build_nop (); - find_referenced_vars_in (stmt); gsi_insert_after (&bsi, stmt, GSI_NEW_STMT); @@ -1370,11 +1363,21 @@ input_function (tree fn_decl, struct dat stmts = (gimple *) xcalloc (gimple_stmt_max_uid (fn), sizeof (gimple)); FOR_ALL_BB (bb) { - gimple_stmt_iterator bsi; - for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi)) + gimple_stmt_iterator bsi = gsi_start_bb (bb); + while (!gsi_end_p (bsi)) { gimple stmt = gsi_stmt (bsi); - stmts[gimple_uid (stmt)] = stmt; + if (!MAY_HAVE_DEBUG_STMTS && is_gimple_debug (stmt)) + { + gimple_stmt_iterator gsi = bsi; + gsi_next (&bsi); + gsi_remove (&gsi, true); + } + else + { + gsi_next (&bsi); + stmts[gimple_uid (stmt)] = stmt; + } } }