From patchwork Tue Oct 9 20:16:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 190425 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 AEA8B2C00A5 for ; Wed, 10 Oct 2012 07:17:06 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1350418626; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:In-Reply-To:References:Date: Message-ID:Subject:From:To:Cc:Content-Type:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=akltrCeInBBiYavfQNJxmSDqQjQ=; b=uc1vS60RmT9hw8kHbZQHce8l/w6YmDFlAo2rS++wDO8YF+7u1iINaHaUkekq9C X1aa4i8DdhN3p1IqLs0utjFNy3hsmncglVMD53Z17/D/9ID/SlOAF3uloSFXSbC0 vNaiwGWb6ZTfsAFT0DaBoMRAzt4BOe1MdQXGEOYxPQubs= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-Google-DKIM-Signature:MIME-Version:Received:Received:In-Reply-To:References:Date:Message-ID:Subject:From:To:Cc:Content-Type:X-System-Of-Record:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=A3t89UZoe+yxGNyk9wlSTMs+96rO/zp5LqtSnbf32lx9AXkNM47p3tXboKhXtL BXMSM0/ofq3vheLc4aX6P1ZrqK40ENBQQ0wwWjZMl3WQF6Sp8zPtP+l9M8mQkWP0 TYCNxcJ/BW1r6fV87eNyuhdXpRl6XJN45FOyAIKvV0HG4=; Received: (qmail 8554 invoked by alias); 9 Oct 2012 20:17:00 -0000 Received: (qmail 8544 invoked by uid 22791); 9 Oct 2012 20:16:59 -0000 X-SWARE-Spam-Status: No, hits=-6.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, TW_TM X-Spam-Check-By: sourceware.org Received: from mail-pb0-f47.google.com (HELO mail-pb0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 09 Oct 2012 20:16:55 +0000 Received: by mail-pb0-f47.google.com with SMTP id ro12so5816805pbb.20 for ; Tue, 09 Oct 2012 13:16:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-system-of-record:x-gm-message-state; bh=JNxcVk5qaFolKBMECsBu3VwUZVD5hTzfBiz5dLTa6GM=; b=MeRy22DCwp4AITDAadF9lOQPxnn2BOOT52JSQ3qfWjSXS8thKfLiyeeKFbKRBU6D3/ 66dvsMKV3J5AMJvYvzQCpXl086JCTOt2fJjPb+DobkVundurBYKDhBNhzS8usC1kBe6r TOXkosMc2OACK157Q5Ky3IEMGXJOKBhhouWw+m+u/+8UvR3zp25JQDWN3Re1+cxgV5UC 0QtoXWAqXWRc9ikjzwdJHMP/JqooD/O47YlPkhgKj0GJRU8YTU4fBe7/Cn+YLooN+6+M 30g0vxoQ9OytCE13/BAtqAYowsNJw4ANgaUJLwRAw5EohdBgfrsQBYmg/eKt9yQGpHQr HrEA== MIME-Version: 1.0 Received: by 10.68.241.133 with SMTP id wi5mr60914714pbc.48.1349813815063; Tue, 09 Oct 2012 13:16:55 -0700 (PDT) Received: by 10.68.49.232 with HTTP; Tue, 9 Oct 2012 13:16:54 -0700 (PDT) In-Reply-To: <50747C85.6070505@redhat.com> References: <50747C85.6070505@redhat.com> Date: Tue, 9 Oct 2012 13:16:54 -0700 Message-ID: Subject: Re: [PATCH] Assigning correct source location for deallocator From: Dehao Chen To: Jason Merrill Cc: GCC Patches , Richard Guenther X-System-Of-Record: true X-Gm-Message-State: ALoCoQmjo192KYr8zudpOnOHmE8PZpgcTG3ayky68xMkb1b93slLLOG1qJrcPqqxu3nENt4ZUxFeOC06QcM0DIZd/XsP1+giP97goEPOVk8AMKBw0w3ogIlAsc1MtcKgvyWGMmwBX/2/x9sD1UIwLjxWgtrqO/+MxYDblpsvsr/otKtBTgXmCvYOBPokz8ozmcrXy4dlkU+6 X-IsSubscribed: yes 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 Yes, you are right. I've changed to use EXPR_LOCATION (stmt) for the location. New patch attached, testing is on-going. Thanks, Dehao On Tue, Oct 9, 2012 at 12:35 PM, Jason Merrill wrote: > On 10/07/2012 08:38 PM, Dehao Chen wrote: >> >> + *stmt_p = build2_loc (input_location, > > > I think input_location in cp_genericize_r will always be the closing brace > of the function, which might be right for a variable in the outermost block > of the function, but not for variables in inner scopes. > > Jason > Index: gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C =================================================================== --- gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C (revision 192168) +++ gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C (working copy) @@ -18,6 +18,7 @@ int bar(); void foo(int i) { + t test_outside; for (int j = 0; j < 10; j++) { t test; @@ -28,6 +29,18 @@ void foo(int i) return; } } + if (i) + { + t test; + if (i == 10) + { + test.bar(); + } + } + test_outside.foo(); return; } -// { dg-final { scan-assembler "deallocator.C:28" } } +// { 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" } } Index: gcc/gimplify.c =================================================================== --- gcc/gimplify.c (revision 192168) +++ gcc/gimplify.c (working copy) @@ -7475,6 +7475,10 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gi 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 + gimple_set_location (try_, EXPR_LOCATION (save_expr)); if (TREE_CODE (*expr_p) == TRY_CATCH_EXPR) gimple_try_set_catch_is_cleanup (try_, TRY_CATCH_IS_CLEANUP (*expr_p)); Index: gcc/tree-eh.c =================================================================== --- gcc/tree-eh.c (revision 192168) +++ gcc/tree-eh.c (working copy) @@ -1100,6 +1100,7 @@ lower_try_finally_onedest (struct leh_state *state struct goto_queue_node *q, *qe; gimple x; gimple_seq finally; + gimple_stmt_iterator gsi; tree finally_label; location_t loc = gimple_location (tf->try_finally_expr); @@ -1120,6 +1121,17 @@ lower_try_finally_onedest (struct leh_state *state lower_eh_constructs_1 (state, &finally); + for (gsi = gsi_start (finally); !gsi_end_p (gsi); gsi_next (&gsi)) + { + gimple stmt = gsi_stmt (gsi); + if (LOCATION_LOCUS (gimple_location (stmt)) == UNKNOWN_LOCATION) + { + tree block = gimple_block (stmt); + gimple_set_location (stmt, gimple_location (tf->try_finally_expr)); + gimple_set_block (stmt, block); + } + } + if (tf->may_throw) { /* Only reachable via the exception edge. Add the given label to Index: gcc/cp/cp-gimplify.c =================================================================== --- gcc/cp/cp-gimplify.c (revision 192168) +++ gcc/cp/cp-gimplify.c (working copy) @@ -948,11 +948,12 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, to lower this construct before scanning it, so we need to lower these before doing anything else. */ else if (TREE_CODE (stmt) == CLEANUP_STMT) - *stmt_p = build2 (CLEANUP_EH_ONLY (stmt) ? TRY_CATCH_EXPR - : TRY_FINALLY_EXPR, - void_type_node, - CLEANUP_BODY (stmt), - CLEANUP_EXPR (stmt)); + *stmt_p = build2_loc (EXPR_LOCATION (stmt), + CLEANUP_EH_ONLY (stmt) ? TRY_CATCH_EXPR + : TRY_FINALLY_EXPR, + void_type_node, + CLEANUP_BODY (stmt), + CLEANUP_EXPR (stmt)); else if (TREE_CODE (stmt) == IF_STMT) {