From patchwork Thu Sep 11 08:34:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 388137 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 32E3914011D for ; Thu, 11 Sep 2014 18:38:25 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=jt6w4p0zF7JF+cn0R1zQj7MqaxmYhKsCDDQiJD+1kvjBbWlDxPgQ1 seTTJmYE+0KGA50I0Za7gbR75JlYB6BATkK4fKXSUebXd4F8M/HB8KhjGASq5iRM RehbFDPO+WEcboY3SMWYOSxFiajKOiLKaW6smO+smZhUSUO33Z4Qc8= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=E4SWkYOdllroyB4OPUM1hObMnW0=; b=BEQbfXjfg2nqMTYExEyY iA+RWNQTfZzZhgH2dkvcacK+gKzdvWCNFvTMxf4jFgsrUiC5EVgY1/4+LWc9TgKJ 9CVQoYi59U10gxXrnaMJHFB9XfehxdGSqbMhfxtOh3JCM3F7zA4UPowAFSGxQL/U AZ6Jp2XDyby4gEv/fxHZF/0= Received: (qmail 8716 invoked by alias); 11 Sep 2014 08:38:19 -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 8703 invoked by uid 89); 11 Sep 2014 08:38:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, UNSUBSCRIBE_BODY autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 11 Sep 2014 08:38:17 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 71D46AAF1 for ; Thu, 11 Sep 2014 08:38:14 +0000 (UTC) Date: Thu, 11 Sep 2014 10:34:42 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH][match-and-simplify] Dump what patterns get applied Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 The following adds dumping what patterns get applied with -details. This is useful for tracking down which patterns cause a miscompile. Applied. Richard. 2014-09-11 Richard Biener * genmatch.c (output_line_directive): Add variant for dump files. (dt_simplify::gen): Write to dump file with TDF_DETAILS what patterns get applied. * gimple-match-head: Include dumpfile.h. * generic-match-head: Likewise. Index: gcc/genmatch.c =================================================================== --- gcc/genmatch.c (revision 215124) +++ gcc/genmatch.c (working copy) @@ -64,16 +64,28 @@ fatal_at (const cpp_token *tk, const cha } static void -output_line_directive (FILE *f, source_location location) +output_line_directive (FILE *f, source_location location, + bool dumpfile = false) { const line_map *map; linemap_resolve_location (line_table, location, LRK_SPELLING_LOCATION, &map); expanded_location loc = linemap_expand_location (line_table, map, location); - /* Other gen programs really output line directives here, at least for - development it's right now more convenient to have line information - from the generated file. Still keep the directives as comment for now - to easily back-point to the meta-description. */ - fprintf (f, "/* #line %d \"%s\" */\n", loc.line, loc.file); + if (dumpfile) + { + /* When writing to a dumpfile only dump the filename. */ + const char *file = strrchr (loc.file, DIR_SEPARATOR); + if (!file) + file = loc.file; + else + ++file; + fprintf (f, "%s:%d", file, loc.line); + } + else + /* Other gen programs really output line directives here, at least for + development it's right now more convenient to have line information + from the generated file. Still keep the directives as comment for now + to easily back-point to the meta-description. */ + fprintf (f, "/* #line %d \"%s\" */\n", loc.line, loc.file); } @@ -1710,9 +1722,8 @@ dt_operand::gen_generic_kids (FILE *f) void dt_simplify::gen (FILE *f, bool gimple) { - output_line_directive (f, s->result_location); - fprintf (f, "{\n"); + output_line_directive (f, s->result_location); fprintf (f, "tree captures[%u] ATTRIBUTE_UNUSED = {};\n", dt_simplify::capture_max); for (unsigned i = 0; i < dt_simplify::capture_max; ++i) @@ -1729,15 +1740,16 @@ dt_simplify::gen (FILE *f, bool gimple) for (int i = s->ifexpr_vec.length () - 1; i >= 0; --i) { if_or_with &w = s->ifexpr_vec[i]; - output_line_directive (f, w.location); if (w.is_with) { fprintf (f, "{\n"); + output_line_directive (f, w.location); w.cexpr->gen_transform (f, NULL, true, 1, "type"); n_braces++; } else { + output_line_directive (f, w.location); fprintf (f, "if ("); if (i == 0 || s->ifexpr_vec[i-1].is_with) w.cexpr->gen_transform (f, NULL, true, 1, "type"); @@ -1768,6 +1780,11 @@ dt_simplify::gen (FILE *f, bool gimple) n_braces++; } + fprintf (f, "if (dump_file && (dump_flags & TDF_DETAILS)) " + "fprintf (dump_file, \"Applying pattern "); + output_line_directive (f, s->result_location, true); + fprintf (f, ", %%s:%%d\\n\", __FILE__, __LINE__);\n"); + if (gimple) { if (s->result->type == operand::OP_EXPR) Index: gcc/gimple-match-head.c =================================================================== --- gcc/gimple-match-head.c (revision 215009) +++ gcc/gimple-match-head.c (working copy) @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. #include "expr.h" #include "tree-dfa.h" #include "builtins.h" +#include "dumpfile.h" #include "gimple-match.h" #define integral_op_p(node) INTEGRAL_TYPE_P(TREE_TYPE(node)) Index: gcc/generic-match-head.c =================================================================== --- gcc/generic-match-head.c (revision 215009) +++ gcc/generic-match-head.c (working copy) @@ -38,6 +38,7 @@ along with GCC; see the file COPYING3. #include "expr.h" #include "tree-dfa.h" #include "builtins.h" +#include "dumpfile.h" #define INTEGER_CST_P(node) (TREE_CODE(node) == INTEGER_CST) #define integral_op_p(node) INTEGRAL_TYPE_P(TREE_TYPE(node))