From patchwork Fri Oct 26 22:53:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 194576 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 5EFF22C0092 for ; Sat, 27 Oct 2012 09:53:27 +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=1351896808; 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=8ux8XT/67J+VGrzR2aTfNN7SKiU=; b=ai5ISWJ51JEo1tPQVE3UdVoIXM0erAatLPwyeV3tIAa9FWJ3a7HWpm1Hz0iD4c zodFv8bj/YA74j2TjG1Q5On5TIXTEE44GtVlfowlPtt4WoA9IbuHlWpw+S5MXHKX MDCsRJztBwLo7wgG9j/uAlRcVc4Di19RWZsNyonhazqis= 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=Vn0xc66XKkebBymqSB9DGsiGZFWFU3LTRs2o8JCmztC4PXdAkwdaLNU/73rgez QytSPLzA+n03VvQWYMFUY7ulK0uGDx6eIDbe7sBg9ewrOoX56mMHdj24GbzVkbCQ Lzd3tOz/KIgZkxCu2q/Fr0L4p2OD4ZhE7TCO3aZruKR/0=; Received: (qmail 2838 invoked by alias); 26 Oct 2012 22:53:12 -0000 Received: (qmail 2817 invoked by uid 22791); 26 Oct 2012 22:53:08 -0000 X-SWARE-Spam-Status: No, hits=-6.1 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-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Oct 2012 22:53:02 +0000 Received: by mail-pa0-f47.google.com with SMTP id fa11so2130270pad.20 for ; Fri, 26 Oct 2012 15:53:01 -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=nT58himvVnuVm6FZKe+HQLKnC4hcIf4ZO6Pzkkbl8iE=; b=OXmlr3IsePMW8qhLDN64X4IUgWOMvk7ZD/xSO6eg/ThDUNM+YeTB2k+t/xds9RRPky gAcM7dGyn3xttPSZlMsXhR1/je10hr/PAqVmDuEfCiJ7xGMzEUMXIuo5Koq6hB+89eEg PNADACU2MZdff54fFPUIJHCFhvitXvD9YvQhVBsl35p1h4TNkcdAQZhsH624vDxE/+mU Em5Y3VzNux+Js7vnXPBNYxYY44gxObDmy3WH60aI+Uurb/y/Axm9ioXDANK2mw5IGkhU jiB0fehBK/T8RVY2+LHmIZJ1sZ0JU4kv57yDjtyb3hUAXf5gyC6YrDsdpJsELtLJnp4X 2hYQ== MIME-Version: 1.0 Received: by 10.68.83.68 with SMTP id o4mr74708412pby.25.1351291981379; Fri, 26 Oct 2012 15:53:01 -0700 (PDT) Received: by 10.68.49.232 with HTTP; Fri, 26 Oct 2012 15:53:01 -0700 (PDT) In-Reply-To: References: <1945668.Pu87KJAiWx@polaris> Date: Fri, 26 Oct 2012 15:53:01 -0700 Message-ID: Subject: Re: [PATCH] Fix debug info for expr and jump stmt From: Dehao Chen To: Michael Matz Cc: Eric Botcazou , GCC Patches , Richard Guenther , Jason Merrill X-System-Of-Record: true X-Gm-Message-State: ALoCoQm3Sk3Xx0V1ENjSH7LvYMY17R9TVPhSSUPvsXDIdkMMeKkNx5zj6NorPIgH9EVco6ub3tC5WH3+nDvB9rU5UggDy5mSi0HbI7LHEr2tRAtPV6F7jSfDQqZBRnxEa9U3zwdbLLZJ1RyIWjluBK3J5e/gi928QXwG1vJ/NtVSLE5rpAQ3xX3VWIcOqt9CQfhyFBf+Q7Xk 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, I've updated the patch: 1. abandon the changes in cfgexpand.c 2. set the block for trees when lowering gimple stmt. 3. add a unittest. However, this patch will trigger two lto bug when asserting LTO_NO_PREVAIL for TREE_CHAIN. After debugging for a while, I found that the problem was also there even without the patch. This patch just reveal the problem by moving a decl into cache so that it will be checked. As I'm not familiar with LTO, not quite sure what the root problem is. Can anyone help take a look? Thanks, Dehao gcc/ChangeLog: 2012-10-25 Dehao Chen * tree-eh.c (do_return_redirection): Set location for jump statement. (do_goto_redirection): Likewise. (frob_into_branch_around): Likewise. (lower_try_finally_nofallthru): Likewise. (lower_try_finally_copy): Likewise. (lower_try_finally_switch): Likewise. * gimple-low.c (tree_set_block_r): New callback function. (lower_stmt): Set block for tested expr. gcc/testsuite/ChangeLog: 2012-10-25 Dehao Chen * g++.dg/debug/dwarf2/block.C: New testcase. Index: gcc/tree-eh.c =================================================================== --- gcc/tree-eh.c (revision 192809) +++ gcc/tree-eh.c (working copy) @@ -739,6 +739,7 @@ do_return_redirection (struct goto_queue_node *q, gimple_seq_add_seq (&q->repl_stmt, mod); x = gimple_build_goto (finlab); + gimple_set_location (x, q->location); gimple_seq_add_stmt (&q->repl_stmt, x); } @@ -758,6 +759,7 @@ do_goto_redirection (struct goto_queue_node *q, tr gimple_seq_add_seq (&q->repl_stmt, mod); x = gimple_build_goto (finlab); + gimple_set_location (x, q->location); gimple_seq_add_stmt (&q->repl_stmt, x); } @@ -857,6 +859,7 @@ frob_into_branch_around (gimple tp, eh_region regi if (!over) over = create_artificial_label (loc); x = gimple_build_goto (over); + gimple_set_location (x, loc); gimple_seq_add_stmt (&cleanup, x); } gimple_seq_add_seq (&eh_seq, cleanup); @@ -1085,6 +1088,7 @@ lower_try_finally_nofallthru (struct leh_state *st emit_post_landing_pad (&eh_seq, tf->region); x = gimple_build_goto (lab); + gimple_set_location (x, gimple_location (tf->try_finally_expr)); gimple_seq_add_stmt (&eh_seq, x); } } @@ -1223,6 +1227,7 @@ lower_try_finally_copy (struct leh_state *state, s tmp = lower_try_finally_fallthru_label (tf); x = gimple_build_goto (tmp); + gimple_set_location (x, tf_loc); gimple_seq_add_stmt (&new_stmt, x); } @@ -1395,6 +1400,7 @@ lower_try_finally_switch (struct leh_state *state, tmp = lower_try_finally_fallthru_label (tf); x = gimple_build_goto (tmp); + gimple_set_location (x, tf_loc); gimple_seq_add_stmt (&switch_body, x); } @@ -1423,6 +1429,7 @@ lower_try_finally_switch (struct leh_state *state, gimple_seq_add_stmt (&eh_seq, x); x = gimple_build_goto (finally_label); + gimple_set_location (x, tf_loc); gimple_seq_add_stmt (&eh_seq, x); tmp = build_int_cst (integer_type_node, eh_index); Index: gcc/gimple-low.c =================================================================== --- gcc/gimple-low.c (revision 192809) +++ gcc/gimple-low.c (working copy) @@ -331,7 +331,18 @@ lower_omp_directive (gimple_stmt_iterator *gsi, st gsi_next (gsi); } +/* Call back function to set the block for expr. */ +static tree +tree_set_block_r (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED, + void *data) +{ + tree block = (tree) data; + if (CAN_HAVE_LOCATION_P (*tp)) + TREE_SET_BLOCK (*tp, block); + return NULL_TREE; +} + /* Lower statement GSI. DATA is passed through the recursion. We try to track the fallthruness of statements and get rid of unreachable return statements in order to prevent the EH lowering pass from adding useless @@ -343,8 +354,11 @@ static void lower_stmt (gimple_stmt_iterator *gsi, struct lower_data *data) { gimple stmt = gsi_stmt (*gsi); + unsigned i; gimple_set_block (stmt, data->block); + for (i = 0; i < gimple_num_ops (stmt); i++) + walk_tree (gimple_op_ptr (stmt, i), tree_set_block_r, data->block, NULL); switch (gimple_code (stmt)) { Index: gcc/testsuite/g++.dg/debug/dwarf2/block.C =================================================================== --- gcc/testsuite/g++.dg/debug/dwarf2/block.C (revision 0) +++ gcc/testsuite/g++.dg/debug/dwarf2/block.C (revision 0) @@ -0,0 +1,29 @@ +// Compiler should not generate too many lexical blocks for this function. +// { dg-do compile { target { i?86-*-* x86_64-*-* } } } +// { dg-options "-O0 -fno-exceptions -g -dA" } + +union UElement { + void* pointer; + int integer; +}; +struct UColToken { + unsigned source; + unsigned char **rulesToParseHdl; +}; + +int uhash_hashTokens(const union UElement k) +{ + int hash = 0; + struct UColToken *key = (struct UColToken *)k.pointer; + if (key != 0) { + int len = (key->source & 0xFF000000)>>24; + int inc = ((len - 32) / 32) + 1; + const unsigned char *p = (key->source & 0x00FFFFFF) + + *(key->rulesToParseHdl); + const unsigned char *limit = p + len; + hash = *p + *limit; + } + return hash; +} + +// { dg-final { scan-assembler-not "LBB10" } }