This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH][match-and-simplify] Dump what patterns get applied
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 11 Sep 2014 10:34:42 +0200 (CEST)
- Subject: [PATCH][match-and-simplify] Dump what patterns get applied
- Authentication-results: sourceware.org; auth=none
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 <rguenther@suse.de>
* 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))