From patchwork Mon Oct 8 00:38:46 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 189876 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 A5A832C026A for ; Mon, 8 Oct 2012 11:38:56 +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=1350261538; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received: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=PD/Q4kc h0TCqqttHScHLsQNpB2o=; b=yKjBbRLp2NJGXaNoP9GGFTReVCnpyySh2ui3Kbl TYIS7yVLOIsVlF7VmedK4y59Kdxh/DorM/A++j+Akv4klYvkAJQ/od5uH31v9bG8 yhpgsBPQbd6gStD8jJRZbhnQ+ag4ErSFHtL3c8XNCXjBNi8Mnso0xwlghftEl6Pb ROq0= 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: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=inGnCrLLorQgS4G4JhYq5+y+rU9JSkfwPfwxRAZzVo9YVOCOp/A56J7VZwrZ79 goFQl0Dw+uVPvqaL+tHE+JMXsWs/GyD5JYX7p5RWS+4g0goJ5OF8HROkvMTnRnno QqS8vmxacRZpdkNM88s0iO+0a83WYNcfeTu+YUNB1ZwMI=; Received: (qmail 30272 invoked by alias); 8 Oct 2012 00:38:53 -0000 Received: (qmail 30260 invoked by uid 22791); 8 Oct 2012 00:38:52 -0000 X-SWARE-Spam-Status: No, hits=-6.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, 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; Mon, 08 Oct 2012 00:38:47 +0000 Received: by mail-pb0-f47.google.com with SMTP id ro12so3670061pbb.20 for ; Sun, 07 Oct 2012 17:38:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :x-system-of-record:x-gm-message-state; bh=4y9hvtQtbOvTAIsDJ+16zUxTlIFKwB8786w+EOPBvZg=; b=oJVod0HMxesEKCYa1c9mCenxJxph4kZdhx+YgjbwyxaGc7lLZ+H7Bhtm1T4f6FkuZs FbH6VSdUJuidVF/6yEEKudq88k+l+7Uyax2sO19IsKhE0qaD9QKvB+RMZvTgg75URKyx R7kP24YEoPi5rG4aSyYC/B2dlpWk8ADHhap7ayhC7VWcfqURR1VIcZPvX5qotKK1tfng lD9PKNI7AuAeQdx2VQVsFFg0JxosX3VBPkKn1YvrwmEkmY/dNX+gc3Blww/Uo1dtjbTI 99jAs7UF+ftDv+9Ck7fgqtj6aNfVDeovma69PnJ83PTZQVxkgrCYG2kBPWb8wHstWcCu 58Ng== MIME-Version: 1.0 Received: by 10.68.224.69 with SMTP id ra5mr48557724pbc.114.1349656726481; Sun, 07 Oct 2012 17:38:46 -0700 (PDT) Received: by 10.68.49.232 with HTTP; Sun, 7 Oct 2012 17:38:46 -0700 (PDT) Date: Sun, 7 Oct 2012 17:38:46 -0700 Message-ID: Subject: [PATCH] Assigning correct source location for deallocator From: Dehao Chen To: GCC Patches Cc: Richard Guenther X-System-Of-Record: true X-Gm-Message-State: ALoCoQnRc22jfxfY0D0jbiCVD1qJbqEI8N8bAlzaiRkMkt4+ftf95BB7s6eohtC+5dpkx9jDS5lz33OGx6Ud/Un+Ormcg1sxMPqsrmgJQxTZmdd0dUwZ8no6kurmiPgDKfvSr+dToHrXY0y4IYeTomBGjqreu+XFsKb9rSTx8u87B01NPw1C7MzaaWf54FGmX+KdAa2zgf4S 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 Hi, R191338 did not completely fix the location for deallocator. This patch covers more cases for deallocator. Bootstrapped and passed gcc regression test on x86. Okay for trunk? Thanks, Dehao gcc/ChangeLog: 2012-10-07 Dehao Chen * tree-eh.c (lower_try_finally_onedest): Set correct location for deallocator. * gimplify.c (gimplify_expr): Set correct location for TRY stmt. gcc/cp/ChangeLog: 2012-10-07 Dehao Chen * cp-gimplify.c (cp_genericize_r): Set location for TRY expr. gcc/testsuite/ChangeLog: 2012-10-07 Dehao Chen * g++.dg/debug/dwarf2/deallocator.C: Cover more deallocator cases. 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 (input_location, + 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) { 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/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/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