From patchwork Tue Oct 30 23:00:03 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dehao Chen X-Patchwork-Id: 195647 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 F0F482C0085 for ; Wed, 31 Oct 2012 10:00:32 +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=1352242833; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=lQPdbHI orB9IvF876RGxPCx/oNg=; b=shrpW6T2YvKy/p4UNbDApeN9wAa+6fNDvYWzDKQ htQzMUg8pvDKaFiScREUcsVg0OqKCnKendETLnMsoHVYtnPmqNkltHwuQVIKEaLa 0eC2NnAPPBCztl++NzSKg8/P0/0cTbKSrWckVr9ObmyHMf23gENCmIJhsESJwlDd rENM= 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: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=maDZoaggLpnbBk+QDnOiNQVXSiGRL8Lz7taK/vwfWUrMCUdk0iMijffNAeZBJJ CaDyUv695NYxpzWUH7SAFucEV8v33nL3ecak7bXILiXZqXP2mRHc/AMHiEJC/hS+ Swt5pufHYRBrYMVP4fzsQd69laJb87nYdA1oXbStX4BwI=; Received: (qmail 13474 invoked by alias); 30 Oct 2012 23:00:17 -0000 Received: (qmail 13452 invoked by uid 22791); 30 Oct 2012 23:00:15 -0000 X-SWARE-Spam-Status: No, hits=-5.4 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-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 30 Oct 2012 23:00:04 +0000 Received: by mail-pa0-f47.google.com with SMTP id fa11so497828pad.20 for ; Tue, 30 Oct 2012 16:00:04 -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:content-type :x-system-of-record:x-gm-message-state; bh=F2XfHM0NoHynlJ4KYg822i3oxdqcuFpE5/lTHewM7JM=; b=BeMEuAHLj/yi/49DCVNFcMPovGP2wjcBOSTBcAP1t3BcPqpCxhSDz+BtwVysA38Z6u 8SvhBHoItg1vq4qEkWzfICMQCfm14cMhU+DXLlwLEbQKU5Fwagc/1C1zMLnNuB0I2IQw wB57Mv2JKi/Z1I5rvYj3Xdpu2tNyg6J6f2ubN7LrAEAqAascxGW4Oe3KtQQQytAgWx/6 84zE2hEowxzfSURbUPmHZJgdBkLF53FmZNXgQUWaDLLL72MzJwvLmtgfdyMkDQhteAbT UkCAE9/iIGBBC6RWxiN1FYtwCdO9EWtKb1sLf8OK3ueVd7ltYew2HuGKSYm3DwPR+iOi KotQ== MIME-Version: 1.0 Received: by 10.68.200.193 with SMTP id ju1mr49106230pbc.53.1351638003974; Tue, 30 Oct 2012 16:00:03 -0700 (PDT) Received: by 10.68.49.232 with HTTP; Tue, 30 Oct 2012 16:00:03 -0700 (PDT) Date: Tue, 30 Oct 2012 16:00:03 -0700 Message-ID: Subject: [PATCH] Update source location for PRE inserted stmt From: Dehao Chen To: GCC Patches X-System-Of-Record: true X-Gm-Message-State: ALoCoQm6vGvoW2nGMGtdP2wnzv6x4VaKfMQ4LxLVMWjRSjCQGvQq9307v7Kk+5LSY/qW2rDDhBr8KZDammtne7P0kSG23Ecn9igDcxrQdoBBrMP04MILnvR4LmpnvmpjzjtNa56KmnRVbjajFiyY8Z7YzbqeCAPwHBiH8luQa4atLSFB8hJ5dudoD64bjBqiC9ceQd4uRabD 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, This patch aims to improve debugging of optimized code. It ensures that PRE inserted statements have the same source location as the statement at the insertion point, instead of UNKNOWN_LOCATION. Bootstrapped on x86_64, and passed gcc regression tests and gdb regression tests. Is it okay for trunk? Thanks, Dehao gcc/ChangeLog: 2012-10-30 Dehao Chen * tree-ssa-pre.c (insert_into_pred_update_location): New Function. (insert_into_preds_of_block): Update source location for inserted stmts. gcc/testsuite/ChangeLog: 2012-10-30 Dehao Chen * gcc.dg/debug/dwarf2/pre.c: New testcase. Index: testsuite/g++.dg/debug/dwarf2/block.C =================================================================== --- testsuite/g++.dg/debug/dwarf2/block.C (revision 0) +++ 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" } } Index: tree-eh.c =================================================================== --- tree-eh.c (revision 192809) +++ 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: expr.c =================================================================== --- expr.c (revision 192809) +++ expr.c (working copy) @@ -5030,7 +5030,7 @@ store_expr (tree exp, rtx target, int call_param_p { rtx temp; rtx alt_rtl = NULL_RTX; - location_t loc = EXPR_LOCATION (exp); + location_t loc = curr_insn_location (); if (VOID_TYPE_P (TREE_TYPE (exp))) { @@ -7869,31 +7869,7 @@ expand_expr_real (tree exp, rtx target, enum machi return ret ? ret : const0_rtx; } - /* If this is an expression of some kind and it has an associated line - number, then emit the line number before expanding the expression. - - We need to save and restore the file and line information so that - errors discovered during expansion are emitted with the right - information. It would be better of the diagnostic routines - used the file/line information embedded in the tree nodes rather - than globals. */ - if (cfun && EXPR_HAS_LOCATION (exp)) - { - location_t saved_location = input_location; - location_t saved_curr_loc = curr_insn_location (); - input_location = EXPR_LOCATION (exp); - set_curr_insn_location (input_location); - - ret = expand_expr_real_1 (exp, target, tmode, modifier, alt_rtl); - - input_location = saved_location; - set_curr_insn_location (saved_curr_loc); - } - else - { - ret = expand_expr_real_1 (exp, target, tmode, modifier, alt_rtl); - } - + ret = expand_expr_real_1 (exp, target, tmode, modifier, alt_rtl); return ret; } @@ -9250,8 +9226,15 @@ expand_expr_real_1 (tree exp, rtx target, enum mac g = SSA_NAME_DEF_STMT (exp); if (g) { - rtx r = expand_expr_real (gimple_assign_rhs_to_tree (g), target, - tmode, modifier, NULL); + rtx r; + location_t saved_loc = input_location; + + input_location = gimple_location (g); + set_curr_insn_location (input_location); + r = expand_expr_real (gimple_assign_rhs_to_tree (g), target, + tmode, modifier, NULL); + input_location = saved_loc; + set_curr_insn_location (saved_loc); if (REG_P (r) && !REG_EXPR (r)) set_reg_attrs_for_decl_rtl (SSA_NAME_VAR (exp), r); return r; @@ -9481,7 +9464,7 @@ expand_expr_real_1 (tree exp, rtx target, enum mac with non-BLKmode values. */ gcc_assert (GET_MODE (ret) != BLKmode); - val = build_decl (EXPR_LOCATION (exp), + val = build_decl (curr_insn_location (), VAR_DECL, NULL, TREE_TYPE (exp)); DECL_ARTIFICIAL (val) = 1; DECL_IGNORED_P (val) = 1;