From patchwork Fri Oct 3 18:39:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWFudWVsIEzDs3Blei1JYsOhw7Fleg==?= X-Patchwork-Id: 396417 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 83A191400E0 for ; Sat, 4 Oct 2014 04:40:14 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=lr2GoVkWdsXSMDeTMB7ROJE0Lyn7ovb8NJMkcT4RwEmD3/ l0xop9Q4vAN5Gw595WyVlEPlxN5lJrjBrgFsNSzBwOPSbB2c2hROKHYUcKhZAslh 194zi1QiW6VHcVkaGh5pTwEnI2wsNcYrJ4cNYnjRseaC3DAoVIOZ4Ez9YbrYM= 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 :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=gEEemzZThYZXLBOLev7Nrf7Wfpc=; b=WNExOXktueSXp3+4Rr+U DyXoLLc6jXMQddQGYc1BXEWhD2FL2L27/QC/zGnSoDXYBg04MdEcnj/oy/Tb5MZ1 fOjVH5T49i/g7pH0KehhEPa/HYQnpu+f2WHji0K3ax5uFfkUtV4sASKqPj1g2bjP iCuNCd/Wxueaq9kYKeQpw3o= Received: (qmail 7338 invoked by alias); 3 Oct 2014 18:40:07 -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 7322 invoked by uid 89); 3 Oct 2014 18:40:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f179.google.com Received: from mail-wi0-f179.google.com (HELO mail-wi0-f179.google.com) (209.85.212.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 03 Oct 2014 18:40:05 +0000 Received: by mail-wi0-f179.google.com with SMTP id d1so3024179wiv.0 for ; Fri, 03 Oct 2014 11:40:02 -0700 (PDT) X-Received: by 10.181.23.194 with SMTP id ic2mr253679wid.27.1412361602461; Fri, 03 Oct 2014 11:40:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.217.80.73 with HTTP; Fri, 3 Oct 2014 11:39:42 -0700 (PDT) From: =?ISO-8859-1?Q?Manuel_L=F3pez=2DIb=E1=F1ez?= Date: Fri, 3 Oct 2014 20:39:42 +0200 Message-ID: Subject: [PATCH] middle-end: use dump_location instead of copy-pasted code To: Gcc Patch List There are some inconsistencies in the middle-end about how to dump a location. The following patch makes all places (that I found) use dump_location, and makes that function print also the column number. While searching for possible callers, I noticed two cases where we use expanded_location for no good reason. Bootstrapped and regression tested on x86_64-linux-gnu. OK? gcc/ChangeLog: 2014-10-03 Manuel López-Ibáñez * tree-pretty-print.c (dump_location): Make it extern. Dump also the column. * tree-pretty-print.h (dump_location): Declare. * gimple-pretty-print.c (dump_gimple_phi): Use dump_location. (pp_gimple_stmt_1): Likewise. (dump_implicit_edges): Likewise. * gimplify.c (gimplify_call_expr): Use LOCATION_FILE and LOCATION_LINE. gcc/testsuite/ChangeLog: 2014-10-03 Manuel López-Ibáñez * gcc.dg/tm/debug-1.c: Update regex. * c-c++-common/raw-string-18.c: Update regex. * c-c++-common/raw-string-19.c: Update regex. Index: gcc/tree-pretty-print.c =================================================================== --- gcc/tree-pretty-print.c (revision 215841) +++ gcc/tree-pretty-print.c (working copy) @@ -675,22 +675,24 @@ dump_omp_clauses (pretty_printer *buffer } /* Dump location LOC to BUFFER. */ -static void +void dump_location (pretty_printer *buffer, location_t loc) { expanded_location xloc = expand_location (loc); pp_left_bracket (buffer); if (xloc.file) { pp_string (buffer, xloc.file); - pp_string (buffer, " : "); + pp_string (buffer, ":"); } pp_decimal_int (buffer, xloc.line); + pp_colon (buffer); + pp_decimal_int (buffer, xloc.column); pp_string (buffer, "] "); } /* Dump lexical block BLOCK. BUFFER, SPC and FLAGS are as in Index: gcc/tree-pretty-print.h =================================================================== --- gcc/tree-pretty-print.h (revision 215841) +++ gcc/tree-pretty-print.h (working copy) @@ -48,7 +48,8 @@ extern const char *op_symbol_code (enum extern void print_call_name (pretty_printer *, tree, int); extern void percent_K_format (text_info *); extern void pp_tree_identifier (pretty_printer *, tree); extern void dump_function_header (FILE *, tree, int); extern void pp_double_int (pretty_printer *pp, double_int d, bool uns); +extern void dump_location (pretty_printer *buffer, location_t loc); #endif /* ! GCC_TREE_PRETTY_PRINT_H */ Index: gcc/testsuite/gcc.dg/tm/debug-1.c =================================================================== --- gcc/testsuite/gcc.dg/tm/debug-1.c (revision 215841) +++ gcc/testsuite/gcc.dg/tm/debug-1.c (working copy) @@ -17,10 +17,10 @@ int main() { testing(); } return 0; } -/* { dg-final { scan-tree-dump-times ": 13:.*b = 9898" 1 "tmmark" } } */ -/* { dg-final { scan-tree-dump-times ": 14:.*_ITM_beginTransaction" 1 "tmmark" } } */ -/* { dg-final { scan-tree-dump-times ": 15:.*ITM_WU. \\(&z" 1 "tmmark" } } */ -/* { dg-final { scan-tree-dump-times ": 16:.*ITM_WU. \\(&a" 1 "tmmark" } } */ +/* { dg-final { scan-tree-dump-times ":13:.*b = 9898" 1 "tmmark" } } */ +/* { dg-final { scan-tree-dump-times ":14:.*_ITM_beginTransaction" 1 "tmmark" } } */ +/* { dg-final { scan-tree-dump-times ":15:.*ITM_WU. \\(&z" 1 "tmmark" } } */ +/* { dg-final { scan-tree-dump-times ":16:.*ITM_WU. \\(&a" 1 "tmmark" } } */ /* { dg-final { cleanup-tree-dump "tmmark" } } */ Index: gcc/testsuite/c-c++-common/raw-string-18.c =================================================================== --- gcc/testsuite/c-c++-common/raw-string-18.c (revision 215841) +++ gcc/testsuite/c-c++-common/raw-string-18.c (working copy) @@ -15,7 +15,7 @@ main () extern void foo (); foo (); return 0; } /* Verify call to foo is on line 15. */ -/* { dg-final { scan-tree-dump ": 15\[]:]\[^\n\r]*foo" "optimized" } } */ +/* { dg-final { scan-tree-dump "c:15:\[^\n\r\]*foo" "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */ Index: gcc/testsuite/c-c++-common/raw-string-19.c =================================================================== --- gcc/testsuite/c-c++-common/raw-string-19.c (revision 215841) +++ gcc/testsuite/c-c++-common/raw-string-19.c (working copy) @@ -15,8 +15,8 @@ main () extern void foo (); foo (); return 0; } /* Verify call to foo is on line 15. */ -/* { dg-final { scan-tree-dump ": 15\[]:]\[^\n\r]*foo" "optimized" } } */ +/* { dg-final { scan-tree-dump "c:15:\[^\n\r\]*foo" "optimized" } } */ /* { dg-final { cleanup-tree-dump "optimized" } } */ /* { dg-final { cleanup-saved-temps } } */ Index: gcc/gimple-pretty-print.c =================================================================== --- gcc/gimple-pretty-print.c (revision 215841) +++ gcc/gimple-pretty-print.c (working copy) @@ -1832,25 +1832,11 @@ dump_gimple_phi (pretty_printer *buffer, pp_string (buffer, " = PHI <"); } for (i = 0; i < gimple_phi_num_args (phi); i++) { if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i)) - { - expanded_location xloc; - - xloc = expand_location (gimple_phi_arg_location (phi, i)); - pp_left_bracket (buffer); - if (xloc.file) - { - pp_string (buffer, xloc.file); - pp_string (buffer, " : "); - } - pp_decimal_int (buffer, xloc.line); - pp_colon (buffer); - pp_decimal_int (buffer, xloc.column); - pp_string (buffer, "] "); - } + dump_location (buffer, gimple_phi_arg_location (phi, i)); dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags, false); pp_left_paren (buffer); pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index); pp_right_paren (buffer); @@ -2074,23 +2060,11 @@ pp_gimple_stmt_1 (pretty_printer *buffer if (flags & TDF_STMTADDR) pp_printf (buffer, "<&%p> ", (void *) gs); if ((flags & TDF_LINENO) && gimple_has_location (gs)) - { - expanded_location xloc = expand_location (gimple_location (gs)); - pp_left_bracket (buffer); - if (xloc.file) - { - pp_string (buffer, xloc.file); - pp_string (buffer, " : "); - } - pp_decimal_int (buffer, xloc.line); - pp_colon (buffer); - pp_decimal_int (buffer, xloc.column); - pp_string (buffer, "] "); - } + dump_location (buffer, gimple_location (gs)); if (flags & TDF_EH) { int lp_nr = lookup_stmt_eh_lp (gs); if (lp_nr > 0) @@ -2402,26 +2376,12 @@ dump_implicit_edges (pretty_printer *buf if (e && e->dest != bb->next_bb) { INDENT (indent); if ((flags & TDF_LINENO) - && e->goto_locus != UNKNOWN_LOCATION - ) - { - expanded_location goto_xloc; - goto_xloc = expand_location (e->goto_locus); - pp_left_bracket (buffer); - if (goto_xloc.file) - { - pp_string (buffer, goto_xloc.file); - pp_string (buffer, " : "); - } - pp_decimal_int (buffer, goto_xloc.line); - pp_string (buffer, " : "); - pp_decimal_int (buffer, goto_xloc.column); - pp_string (buffer, "] "); - } + && e->goto_locus != UNKNOWN_LOCATION) + dump_location (buffer, e->goto_locus); pp_cfg_jump (buffer, e->dest); pp_newline (buffer); } } Index: gcc/gimplify.c =================================================================== --- gcc/gimplify.c (revision 215841) +++ gcc/gimplify.c (working copy) @@ -2315,18 +2315,18 @@ gimplify_call_expr (tree *expr_p, gimple } break; } case BUILT_IN_LINE: { - expanded_location loc = expand_location (EXPR_LOCATION (*expr_p)); - *expr_p = build_int_cst (TREE_TYPE (*expr_p), loc.line); + *expr_p = build_int_cst (TREE_TYPE (*expr_p), + LOCATION_LINE (EXPR_LOCATION (*expr_p))); return GS_OK; } case BUILT_IN_FILE: { - expanded_location loc = expand_location (EXPR_LOCATION (*expr_p)); - *expr_p = build_string_literal (strlen (loc.file) + 1, loc.file); + const char *locfile = LOCATION_FILE (EXPR_LOCATION (*expr_p)); + *expr_p = build_string_literal (strlen (locfile) + 1, locfile); return GS_OK; } case BUILT_IN_FUNCTION: { const char *function;