From patchwork Thu Feb 19 17:31:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 441701 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2C5261400F1 for ; Fri, 20 Feb 2015 04:31:27 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=W8UxmwU9ZbFWIerSu hJFxjPHyc840RlR1ZBLPCjWRiIZJhcYX6HDALIpZqG38OT/jJb1JE7kkFr4RoBvm H1WA+moxvDUwkwqtZSBabxH4KGq7fh6b/3yVl51B3vQcjlgXrr9cXflu/njffScc O1nsME9am7wXc6CtR4MV0aVQEw= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=JyKAxayVsflPd2Kwpvfy6CI lxOQ=; b=iVqMR1jcUlRF+7g6VoImUWcZM2ADcdcyuV8dVJEcbwrRjxHbvC4F24W X12C2zt/DBpZJRW3VYoSS2axoOtgH2VeUjvaA/1xWC7ysDSgzZQprp+UT+yRXoXc QjmhZZOvql9mEs/BwY1G2F37uvQ2FRr7I13BznsDlrN9k7Cz266M= Received: (qmail 9415 invoked by alias); 19 Feb 2015 17:31:19 -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 9404 invoked by uid 89); 19 Feb 2015 17:31:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 19 Feb 2015 17:31:17 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1JHVGRI001669 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 19 Feb 2015 12:31:16 -0500 Received: from reynosa.quesejoda.com (vpn-61-7.rdu2.redhat.com [10.10.61.7]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1JHVE9Q019448; Thu, 19 Feb 2015 12:31:15 -0500 Message-ID: <54E61DE2.5010401@redhat.com> Date: Thu, 19 Feb 2015 09:31:14 -0800 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: jason merrill CC: Jakub Jelinek , gcc-patches , Jan Kratochvil Subject: [patch] PR debug/58123: Set correct location for TRY blocks References: <54E61BE5.9090209@redhat.com> In-Reply-To: <54E61BE5.9090209@redhat.com> X-Forwarded-Message-Id: <54E61BE5.9090209@redhat.com> [Ughh...I'm apparently incapable of CCing gcc-patches on the first try. My apologies again.] Please see the long explanation in the PR: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58123 But the short explanation for this patch is that, at the very least, we should fix the location of the GIMPLE_TRY_FINALLY. Currently we're preferring the input_location, instead of the location of the TRY_FINALLY_EXPR. An incorrect GIMPLE_TRY_FINALLY location causes the location of location-less FINALLY statements to also have an incorrect location, causing an inconsistent debugging experience. As explained in the PR, I would ideally like to get rid of the kludge where we set the location of location-less FINALLY statements to be that of the TRY statement, but that may be by design, and/or beyond the scope of this fix. Tested on x86-64 Linux. OK for mainline? commit 119b6f5c628831706ac8fa26a906d80cf996bbe3 Author: Aldy Hernandez Date: Wed Feb 18 13:31:41 2015 -0800 PR debug/58123 * gimplify.c (gimplify_expr): Prefer location of TRY_FINALLY_EXPR over input_location. testsuite/ * g++.dg/debug/dwarf2/deallocator.C: Adjust for correct try location. * g++.dg/gcov/gcov-2.C: Likewise. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 1353ada..d822913 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -8244,10 +8244,10 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, TREE_CODE (*expr_p) == TRY_FINALLY_EXPR ? GIMPLE_TRY_FINALLY : GIMPLE_TRY_CATCH); - if (LOCATION_LOCUS (saved_location) != UNKNOWN_LOCATION) - gimple_set_location (try_, saved_location); - else + if (EXPR_HAS_LOCATION (save_expr)) gimple_set_location (try_, EXPR_LOCATION (save_expr)); + else if (LOCATION_LOCUS (saved_location) != UNKNOWN_LOCATION) + gimple_set_location (try_, saved_location); if (TREE_CODE (*expr_p) == TRY_CATCH_EXPR) gimple_try_set_catch_is_cleanup (try_, TRY_CATCH_IS_CLEANUP (*expr_p)); diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C b/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C index 4057393..0fcd08e 100644 --- a/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C +++ b/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C @@ -41,6 +41,6 @@ void foo(int i) return; } // { dg-final { scan-assembler "deallocator.C:29" } } -// { dg-final { scan-assembler "deallocator.C:31" } } -// { dg-final { scan-assembler "deallocator.C:38" } } -// { dg-final { scan-assembler "deallocator.C:41" } } +// { dg-final { scan-assembler "deallocator.C:24" } } +// { dg-final { scan-assembler "deallocator.C:34" } } +// { dg-final { scan-assembler "deallocator.C:21" } } diff --git a/gcc/testsuite/g++.dg/gcov/gcov-2.C b/gcc/testsuite/g++.dg/gcov/gcov-2.C index 66d8af3..6d002f5 100644 --- a/gcc/testsuite/g++.dg/gcov/gcov-2.C +++ b/gcc/testsuite/g++.dg/gcov/gcov-2.C @@ -20,7 +20,7 @@ private: void foo() { - C c; /* count(1) */ + C c; /* count(2) */ c.seti (1); /* count(1) */ } diff --git a/gcc/testsuite/g++.dg/pr58123.C b/gcc/testsuite/g++.dg/pr58123.C new file mode 100644 index 0000000..7fe1a27 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr58123.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-options "-fdump-tree-gimple-lineno" } + +// Test that the TRY block's location is the definition of "C a". + +class C { +public: + C() {} + ~C() {} + int m() { return 0; } +}; +int main() { + C a; + return a.m(); +} + +// { dg-final { scan-tree-dump-times "pr58123.C:13\.6\] try" 1 "gimple" } } +// { dg-final { cleanup-tree-dump "gimple" } }