From patchwork Tue Aug 20 05:21:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teresa Johnson X-Patchwork-Id: 268360 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 85D6F2C0137 for ; Tue, 20 Aug 2013 15:22:02 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=X7hVUAM/tBFta+WJqa Hupqeu6e4gXtRZNvFKxQvdB57h5uxo5WoUw2zEVw7YxqlNYXsJeca9Mes7Eu6mn6 70n30w0V7Xe5fuTlQgwd5yRI97MiNxMLYn/ViudMKRjDK4dDGj6XY6L6kLw1lf7h nqPrQkZa7oS4nErrrPkdcDtC8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=jhKska7KFj2hMgM8zkz8ggjD hDI=; b=iqYq/S4SWXkY61yGGyEzCGXo/1yToqSd8OFzX1St/nJ0hxV4KA+dRGJI zVJmSgMrYlKklm8pwwjwJjuH39HdGBauB2No+AJAaO6wPS5f/wh+CK2U3DY67zaU Xl8Ij/DaBhbk7Caz5sHEIy6+DgVjhpdd3YHKPPZdMM2dYsklptY= Received: (qmail 16457 invoked by alias); 20 Aug 2013 05:21:54 -0000 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 Received: (qmail 16435 invoked by uid 89); 20 Aug 2013 05:21:53 -0000 X-Spam-SWARE-Status: No, score=-5.4 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 Received: from mail-qe0-f51.google.com (HELO mail-qe0-f51.google.com) (209.85.128.51) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 20 Aug 2013 05:21:52 +0000 Received: by mail-qe0-f51.google.com with SMTP id cy11so1605844qeb.24 for ; Mon, 19 Aug 2013 22:21:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=w+/N5/BkkCigR+gjm6J0JT1viIhZN8ZXgMEtDbSA/iM=; b=InJ82VB3b7k1rauzMpf/ylukCMZwSrA7b4wTSZVPiFQxgldHZVS6nuzPMSqKm1bYDx VCOiGPEf4zvMckYqihpz+l+OT0Rk6PWQQwKEhCCLD8aSpkl5iRVU1Dj3NWo35HesQs65 j8aZbpmDjV7UVRn5rZEfY7Tz8cKiGwTnWAZOXVWEHthdWEmENOu5jkwJkk/jINtpul2x Ze5gODtQJ+pHk4zoMycsvqaBtQs3FNlC5S+K0tki18EWEZB5p8ljvRptODeJxkzXccN8 1/sDt7nV6Pbgs10jghho2+tPDq4K7mv1Omjr8S1x3VFExAdV+P/EjbV1ILW8w0Z6SWNo Z45A== X-Gm-Message-State: ALoCoQm+g3Ux20L7Z3iBaUlnBqzvZ4u+8FJtBZNxKmpV9sEJRrMb+kX7e/B8io8Jr1VDLulqXV9KFDi6Li+F8Th/5fLsU92CrzO6WgbhfPw/57A1X2C9166Up7WQd3Sz+6aXthPFPvRmvJKgAXFNNRkqhNf8xlOHNw7vCQJctGxD+WcL3yZpUf4co/VhjSrmusr95MjE4z1BXhTGIdwMJAV2RC1ZyLBeNw== MIME-Version: 1.0 X-Received: by 10.224.66.201 with SMTP id o9mr1727258qai.36.1376976109244; Mon, 19 Aug 2013 22:21:49 -0700 (PDT) Received: by 10.49.40.161 with HTTP; Mon, 19 Aug 2013 22:21:49 -0700 (PDT) In-Reply-To: References: <521267AB.6080207@redhat.com> Date: Mon, 19 Aug 2013 22:21:49 -0700 Message-ID: Subject: Re: [PATCH] Fix PR57451 (Incorrect debug ranges emitted for -freorder-blocks-and-partition -g) From: Teresa Johnson To: Jeff Law Cc: "gcc-patches@gcc.gnu.org" , Cary Coutant , Christophe Lyon On Mon, Aug 19, 2013 at 5:01 PM, Teresa Johnson wrote: > On Mon, Aug 19, 2013 at 11:44 AM, Jeff Law wrote: >> On 08/19/2013 12:34 PM, Teresa Johnson wrote: >>> >>> Ping. >>> Thanks, >>> Teresa >>> >>> On Sun, Aug 11, 2013 at 9:35 PM, Teresa Johnson >>> wrote: >>>> >>>> This patch fixes PR rtl-optimizations/57451 by preventing scopes and >>>> therefore lexical blocks from crossing split section boundaries. >>>> This will prevent debug info generation from using DW_AT_low_pc/high_pc >>>> pairs across the section boundary. >>>> >>>> Bootstrapped and tested on x86_64-unknown-linux-gnu. With this patch, >>>> a profilebootstrap with -freorder-blocks-and-partition force-enabled >>>> also passes. Ok for trunk? >>>> >>>> Thanks, >>>> Teresa >>>> >>>> 2013-08-11 Teresa Johnson >>>> >>>> PR rtl-optimizations/57451 >>>> * final.c (reemit_insn_block_notes): Prevent lexical blocks >>>> from crossing split section boundaries. >> >> This is fine. Is there any way you can turn the steps mentioned in 57451 >> into a dejagnu testcase? Clearly it would only work in a native >> configuration due to the need to run the instrumented program. > > Since this was a compile-time failure (link-time actually), I could > just take the existing test case mentioned there and turn it into a > "-g -freorder-blocks-and-partition" test (probably by cloning as a new > test case the g++.dg/tree-prof testsuite directory). Does that seem > reasonable? Here is the new patch with that test added. Passes bootstrap and regression tests on x86_64-unknown-linux-gnu. Ok for trunk? Thanks, Teresa 2013-08-19 Teresa Johnson PR rtl-optimizations/57451 * final.c (reemit_insn_block_notes): Prevent lexical blocks from crossing split section boundaries. * testsuite/g++.dg/tree-prof/pr57451.C: New test. > > Thanks, > Teresa > >> >> jeff >> > > > > -- > Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413 Index: final.c =================================================================== --- final.c (revision 201644) +++ final.c (working copy) @@ -1650,12 +1650,26 @@ reemit_insn_block_notes (void) rtx insn, note; insn = get_insns (); - if (!active_insn_p (insn)) - insn = next_active_insn (insn); - for (; insn; insn = next_active_insn (insn)) + for (; insn; insn = next_insn (insn)) { tree this_block; + /* Prevent lexical blocks from straddling section boundaries. */ + if (NOTE_P (insn) && NOTE_KIND (insn) == NOTE_INSN_SWITCH_TEXT_SECTIONS) + { + for (tree s = cur_block; s != DECL_INITIAL (cfun->decl); + s = BLOCK_SUPERCONTEXT (s)) + { + rtx note = emit_note_before (NOTE_INSN_BLOCK_END, insn); + NOTE_BLOCK (note) = s; + note = emit_note_after (NOTE_INSN_BLOCK_BEG, insn); + NOTE_BLOCK (note) = s; + } + } + + if (!active_insn_p (insn)) + continue; + /* Avoid putting scope notes between jump table and its label. */ if (JUMP_TABLE_DATA_P (insn)) continue; Index: testsuite/g++.dg/tree-prof/pr57451.C =================================================================== --- testsuite/g++.dg/tree-prof/pr57451.C (revision 0) +++ testsuite/g++.dg/tree-prof/pr57451.C (revision 0) @@ -0,0 +1,27 @@ +// { dg-do run } +// { dg-require-effective-target freorder } +// { dg-options "-O2 -freorder-blocks-and-partition -g" } + +extern "C" void abort (void); +struct MyException {}; +struct Data { + int nr; + Data() : nr(66) {} +}; +Data __attribute__((noinline,noclone)) getData(int i) +{ + if (i) throw MyException(); + Data data; + data.nr = i; + return data; +} +int main(int, char **) +{ + Data data; + try { + data = getData(1); + } catch (MyException& e) { + if (data.nr != 66) + abort (); + } +}