Commit 6f795a92 by David Malcolm Committed by David Malcolm

Formatted printing for dump_* in the middle-end

This patch converts dump_print and dump_printf_loc from using
printf (and thus ATTRIBUTE_PRINTF) to using a new pretty-printer
based on pp_format, which supports formatting middle-end types.

In particular, the following codes are implemented (in addition
to the standard pretty_printer ones):

   %E: gimple *:
       Equivalent to: dump_gimple_expr (MSG_*, TDF_SLIM, stmt, 0)
   %G: gimple *:
       Equivalent to: dump_gimple_stmt (MSG_*, TDF_SLIM, stmt, 0)
   %T: tree:
       Equivalent to: dump_generic_expr (MSG_*, arg, TDF_SLIM).

Hence it becomes possible to convert e.g.:

  if (dump_enabled_p ())
    {
      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                       "not vectorized: different sized vector "
                       "types in statement, ");
      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, vectype);
      dump_printf (MSG_MISSED_OPTIMIZATION, " and ");
      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, nunits_vectype);
      dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
    }

into a one-liner:

  if (dump_enabled_p ())
    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
                     "not vectorized: different sized vector "
                     "types in statement, %T and %T\n",
                     vectype, nunits_vectype);

Unlike regular pretty-printers, this one captures optinfo_item
instances for the formatted chunks as appropriate, so that when
written out to a JSON optimization record, the relevant parts of
the message are labelled by type, and by source location (so that
e.g. %G is entirely equivalent to using dump_gimple_stmt).

dump_printf and dump_printf_loc become marked with
ATTRIBUTE_GCC_DUMP_PRINTF, which the patch also implements.

gcc/c-family/ChangeLog:
	* c-format.c (enum format_type): Add gcc_dump_printf_format_type.
	(gcc_dump_printf_length_specs): New.
	(gcc_dump_printf_flag_pairs): New.
	(gcc_dump_printf_flag_specs): New.
	(gcc_dump_printf_char_table): New.
	(format_types_orig): Add entry for "gcc_dump_printf".
	(init_dynamic_diag_info): Set up length_char_specs and
	conversion_specs for gcc_dump_printf_format_type.
	(handle_format_attribute): Handle gcc_dump_printf_format_type.

gcc/ChangeLog:
	* dump-context.h: Include "dumpfile.h".
	(dump_context::dump_printf_va): Convert final param from va_list
	to va_list *.  Convert from ATTRIBUTE_PRINTF to
	ATTRIBUTE_GCC_DUMP_PRINTF.
	(dump_context::dump_printf_loc_va): Likewise.
	* dumpfile.c: Include "stringpool.h".
	(make_item_for_dump_printf_va): Delete.
	(make_item_for_dump_printf): Delete.
	(class dump_pretty_printer): New class.
	(dump_pretty_printer::dump_pretty_printer): New ctor.
	(dump_pretty_printer::emit_items): New member function.
	(dump_pretty_printer::emit_any_pending_textual_chunks): New member
	function.
	(dump_pretty_printer::emit_item): New member function.
	(dump_pretty_printer::stash_item): New member function.
	(dump_pretty_printer::format_decoder_cb): New member function.
	(dump_pretty_printer::decode_format): New member function.
	(dump_context::dump_printf_va): Reimplement in terms of
	dump_pretty_printer.
	(dump_context::dump_printf_loc_va): Convert final param from va_list
	to va_list *.
	(dump_context::begin_scope): Reimplement call to
	make_item_for_dump_printf.
	(dump_printf): Update for change to dump_printf_va.
	(dump_printf_loc): Likewise.
	(selftest::test_capture_of_dump_calls): Convert "stmt" from
	greturn * to gimple *.  Add a test_decl.  Add tests of dump_printf
	with %T, %E, and %G.
	* dumpfile.h (ATTRIBUTE_GCC_DUMP_PRINTF): New macro.
	(dump_printf): Replace ATTRIBUTE_PRINTF_2 with
	ATTRIBUTE_GCC_DUMP_PRINTF (2, 3).
	(dump_printf_loc): Replace ATTRIBUTE_PRINTF_3 with
	ATTRIBUTE_GCC_DUMP_PRINTF (3, 0).
	* tree-vect-data-refs.c (vect_lanes_optab_supported_p): Convert
	use of HOST_WIDE_INT_PRINT_DEC on unsigned HOST_WIDE_INT "count"
	within a dump_printf_loc call to "%wu".
	(vector_alignment_reachable_p): Merge two dump_printf[_loc] calls,
	converting a use of HOST_WIDE_INT_PRINT_DEC to "%wd".  Add a
	missing space after "=".
	* tree-vect-loop.c (vect_analyze_loop_2) Within a dump_printf
	call, convert use of HOST_WIDE_INT_PRINT_DEC to "%wd".
	* tree-vect-slp.c (vect_slp_bb): Within a dump_printf_loc call,
	convert use of HOST_WIDE_INT_PRINT_UNSIGNED to "%wu".
	* tree-vectorizer.c (try_vectorize_loop_1): Likewise.  Remove
	duplicate "vectorized" from message.

gcc/testsuite/ChangeLog:
	* gcc.dg/format/gcc_diag-1.c: Fix typo.  Add test coverage for
	gcc_dump_printf.
	* gcc.dg/format/gcc_diag-10.c: Add gimple typedef.  Add test
	coverage for gcc_dump_printf.

From-SVN: r263626
parent 478490f6
2018-08-17 David Malcolm <dmalcolm@redhat.com>
* dump-context.h: Include "dumpfile.h".
(dump_context::dump_printf_va): Convert final param from va_list
to va_list *. Convert from ATTRIBUTE_PRINTF to
ATTRIBUTE_GCC_DUMP_PRINTF.
(dump_context::dump_printf_loc_va): Likewise.
* dumpfile.c: Include "stringpool.h".
(make_item_for_dump_printf_va): Delete.
(make_item_for_dump_printf): Delete.
(class dump_pretty_printer): New class.
(dump_pretty_printer::dump_pretty_printer): New ctor.
(dump_pretty_printer::emit_items): New member function.
(dump_pretty_printer::emit_any_pending_textual_chunks): New member
function.
(dump_pretty_printer::emit_item): New member function.
(dump_pretty_printer::stash_item): New member function.
(dump_pretty_printer::format_decoder_cb): New member function.
(dump_pretty_printer::decode_format): New member function.
(dump_context::dump_printf_va): Reimplement in terms of
dump_pretty_printer.
(dump_context::dump_printf_loc_va): Convert final param from va_list
to va_list *.
(dump_context::begin_scope): Reimplement call to
make_item_for_dump_printf.
(dump_printf): Update for change to dump_printf_va.
(dump_printf_loc): Likewise.
(selftest::test_capture_of_dump_calls): Convert "stmt" from
greturn * to gimple *. Add a test_decl. Add tests of dump_printf
with %T, %E, and %G.
* dumpfile.h (ATTRIBUTE_GCC_DUMP_PRINTF): New macro.
(dump_printf): Replace ATTRIBUTE_PRINTF_2 with
ATTRIBUTE_GCC_DUMP_PRINTF (2, 3).
(dump_printf_loc): Replace ATTRIBUTE_PRINTF_3 with
ATTRIBUTE_GCC_DUMP_PRINTF (3, 0).
* tree-vect-data-refs.c (vect_lanes_optab_supported_p): Convert
use of HOST_WIDE_INT_PRINT_DEC on unsigned HOST_WIDE_INT "count"
within a dump_printf_loc call to "%wu".
(vector_alignment_reachable_p): Merge two dump_printf[_loc] calls,
converting a use of HOST_WIDE_INT_PRINT_DEC to "%wd". Add a
missing space after "=".
* tree-vect-loop.c (vect_analyze_loop_2) Within a dump_printf
call, convert use of HOST_WIDE_INT_PRINT_DEC to "%wd".
* tree-vect-slp.c (vect_slp_bb): Within a dump_printf_loc call,
convert use of HOST_WIDE_INT_PRINT_UNSIGNED to "%wu".
* tree-vectorizer.c (try_vectorize_loop_1): Likewise. Remove
duplicate "vectorized" from message.
2018-08-17 Szabolcs Nagy <szabolcs.nagy@arm.com> 2018-08-17 Szabolcs Nagy <szabolcs.nagy@arm.com>
* config/arm/arm-builtins.c (arm_init_simd_builtin_types): Clear * config/arm/arm-builtins.c (arm_init_simd_builtin_types): Clear
......
2018-08-17 David Malcolm <dmalcolm@redhat.com>
* c-format.c (enum format_type): Add gcc_dump_printf_format_type.
(gcc_dump_printf_length_specs): New.
(gcc_dump_printf_flag_pairs): New.
(gcc_dump_printf_flag_specs): New.
(gcc_dump_printf_char_table): New.
(format_types_orig): Add entry for "gcc_dump_printf".
(init_dynamic_diag_info): Set up length_char_specs and
conversion_specs for gcc_dump_printf_format_type.
(handle_format_attribute): Handle gcc_dump_printf_format_type.
2018-08-17 Nathan Sidwell <nathan@acm.org> 2018-08-17 Nathan Sidwell <nathan@acm.org>
* c-ada-spec.c (macro_length, dump_ada_macros): Constify. * c-ada-spec.c (macro_length, dump_ada_macros): Constify.
......
...@@ -46,6 +46,7 @@ enum format_type { printf_format_type, asm_fprintf_format_type, ...@@ -46,6 +46,7 @@ enum format_type { printf_format_type, asm_fprintf_format_type,
gcc_diag_format_type, gcc_tdiag_format_type, gcc_diag_format_type, gcc_tdiag_format_type,
gcc_cdiag_format_type, gcc_cdiag_format_type,
gcc_cxxdiag_format_type, gcc_gfc_format_type, gcc_cxxdiag_format_type, gcc_gfc_format_type,
gcc_dump_printf_format_type,
gcc_objc_string_format_type, gcc_objc_string_format_type,
format_type_error = -1}; format_type_error = -1};
...@@ -463,6 +464,7 @@ static const format_length_info gcc_diag_length_specs[] = ...@@ -463,6 +464,7 @@ static const format_length_info gcc_diag_length_specs[] =
#define gcc_tdiag_length_specs gcc_diag_length_specs #define gcc_tdiag_length_specs gcc_diag_length_specs
#define gcc_cdiag_length_specs gcc_diag_length_specs #define gcc_cdiag_length_specs gcc_diag_length_specs
#define gcc_cxxdiag_length_specs gcc_diag_length_specs #define gcc_cxxdiag_length_specs gcc_diag_length_specs
#define gcc_dump_printf_length_specs gcc_diag_length_specs
/* This differs from printf_length_specs only in that "Z" is not accepted. */ /* This differs from printf_length_specs only in that "Z" is not accepted. */
static const format_length_info scanf_length_specs[] = static const format_length_info scanf_length_specs[] =
...@@ -552,6 +554,7 @@ static const format_flag_pair gcc_diag_flag_pairs[] = ...@@ -552,6 +554,7 @@ static const format_flag_pair gcc_diag_flag_pairs[] =
#define gcc_cdiag_flag_pairs gcc_diag_flag_pairs #define gcc_cdiag_flag_pairs gcc_diag_flag_pairs
#define gcc_cxxdiag_flag_pairs gcc_diag_flag_pairs #define gcc_cxxdiag_flag_pairs gcc_diag_flag_pairs
#define gcc_gfc_flag_pairs gcc_diag_flag_pairs #define gcc_gfc_flag_pairs gcc_diag_flag_pairs
#define gcc_dump_printf_flag_pairs gcc_diag_flag_pairs
static const format_flag_spec gcc_diag_flag_specs[] = static const format_flag_spec gcc_diag_flag_specs[] =
{ {
...@@ -567,6 +570,7 @@ static const format_flag_spec gcc_diag_flag_specs[] = ...@@ -567,6 +570,7 @@ static const format_flag_spec gcc_diag_flag_specs[] =
#define gcc_cdiag_flag_specs gcc_diag_flag_specs #define gcc_cdiag_flag_specs gcc_diag_flag_specs
#define gcc_cxxdiag_flag_specs gcc_diag_flag_specs #define gcc_cxxdiag_flag_specs gcc_diag_flag_specs
#define gcc_gfc_flag_specs gcc_diag_flag_specs #define gcc_gfc_flag_specs gcc_diag_flag_specs
#define gcc_dump_printf_flag_specs gcc_diag_flag_specs
static const format_flag_spec scanf_flag_specs[] = static const format_flag_spec scanf_flag_specs[] =
{ {
...@@ -788,6 +792,22 @@ static const format_char_info gcc_gfc_char_table[] = ...@@ -788,6 +792,22 @@ static const format_char_info gcc_gfc_char_table[] =
{ NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL } { NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
}; };
static const format_char_info gcc_dump_printf_char_table[] =
{
/* The conversion specifiers implemented within pp_format. */
PP_FORMAT_CHAR_TABLE,
/* Custom conversion specifiers implemented by dump_pretty_printer. */
/* E and G require a "gimple *" argument at runtime. */
{ "EG", 1, STD_C89, { T89_G, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL },
/* T requires a "tree" at runtime. */
{ "T", 1, STD_C89, { T89_T, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN, BADLEN }, "", "\"", NULL },
{ NULL, 0, STD_C89, NOLENGTHS, NULL, NULL, NULL }
};
static const format_char_info scan_char_table[] = static const format_char_info scan_char_table[] =
{ {
/* C89 conversion specifiers. */ /* C89 conversion specifiers. */
...@@ -887,6 +907,13 @@ static const format_kind_info format_types_orig[] = ...@@ -887,6 +907,13 @@ static const format_kind_info format_types_orig[] =
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
NULL, NULL NULL, NULL
}, },
{ "gcc_dump_printf", gcc_dump_printf_length_specs,
gcc_dump_printf_char_table, "q+#", NULL,
gcc_dump_printf_flag_specs, gcc_dump_printf_flag_pairs,
FMT_FLAG_ARG_CONVERT,
0, 0, 'p', 0, 'L', 0,
NULL, &integer_type_node
},
{ "NSString", NULL, NULL, NULL, NULL, { "NSString", NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
FMT_FLAG_ARG_CONVERT|FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL, 0, 0, 0, 0, 0, 0, FMT_FLAG_ARG_CONVERT|FMT_FLAG_PARSE_ARG_CONVERT_EXTERNAL, 0, 0, 0, 0, 0, 0,
...@@ -3971,6 +3998,7 @@ init_dynamic_diag_info (void) ...@@ -3971,6 +3998,7 @@ init_dynamic_diag_info (void)
dynamic_format_types[gcc_tdiag_format_type].length_char_specs = dynamic_format_types[gcc_tdiag_format_type].length_char_specs =
dynamic_format_types[gcc_cdiag_format_type].length_char_specs = dynamic_format_types[gcc_cdiag_format_type].length_char_specs =
dynamic_format_types[gcc_cxxdiag_format_type].length_char_specs = dynamic_format_types[gcc_cxxdiag_format_type].length_char_specs =
dynamic_format_types[gcc_dump_printf_format_type].length_char_specs =
diag_ls = (format_length_info *) diag_ls = (format_length_info *)
xmemdup (gcc_diag_length_specs, xmemdup (gcc_diag_length_specs,
sizeof (gcc_diag_length_specs), sizeof (gcc_diag_length_specs),
...@@ -3997,6 +4025,8 @@ init_dynamic_diag_info (void) ...@@ -3997,6 +4025,8 @@ init_dynamic_diag_info (void)
gcc_cdiag_char_table; gcc_cdiag_char_table;
dynamic_format_types[gcc_cxxdiag_format_type].conversion_specs = dynamic_format_types[gcc_cxxdiag_format_type].conversion_specs =
gcc_cxxdiag_char_table; gcc_cxxdiag_char_table;
dynamic_format_types[gcc_dump_printf_format_type].conversion_specs =
gcc_dump_printf_char_table;
} }
#ifdef TARGET_FORMAT_TYPES #ifdef TARGET_FORMAT_TYPES
...@@ -4151,7 +4181,8 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args, ...@@ -4151,7 +4181,8 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args,
|| info.format_type == gcc_diag_format_type || info.format_type == gcc_diag_format_type
|| info.format_type == gcc_tdiag_format_type || info.format_type == gcc_tdiag_format_type
|| info.format_type == gcc_cdiag_format_type || info.format_type == gcc_cdiag_format_type
|| info.format_type == gcc_cxxdiag_format_type) || info.format_type == gcc_cxxdiag_format_type
|| info.format_type == gcc_dump_printf_format_type)
{ {
/* Our first time through, we have to make sure that our /* Our first time through, we have to make sure that our
format_type data is allocated dynamically and is modifiable. */ format_type data is allocated dynamically and is modifiable. */
...@@ -4173,7 +4204,8 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args, ...@@ -4173,7 +4204,8 @@ handle_format_attribute (tree *node, tree ARG_UNUSED (name), tree args,
else if (info.format_type == gcc_diag_format_type else if (info.format_type == gcc_diag_format_type
|| info.format_type == gcc_tdiag_format_type || info.format_type == gcc_tdiag_format_type
|| info.format_type == gcc_cdiag_format_type || info.format_type == gcc_cdiag_format_type
|| info.format_type == gcc_cxxdiag_format_type) || info.format_type == gcc_cxxdiag_format_type
|| info.format_type == gcc_dump_printf_format_type)
init_dynamic_diag_info (); init_dynamic_diag_info ();
else else
gcc_unreachable (); gcc_unreachable ();
......
...@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_DUMP_CONTEXT_H #ifndef GCC_DUMP_CONTEXT_H
#define GCC_DUMP_CONTEXT_H 1 #define GCC_DUMP_CONTEXT_H 1
#include "dumpfile.h"
#include "pretty-print.h" #include "pretty-print.h"
/* A class for handling the various dump_* calls. /* A class for handling the various dump_* calls.
...@@ -73,11 +74,11 @@ class dump_context ...@@ -73,11 +74,11 @@ class dump_context
tree t); tree t);
void dump_printf_va (dump_flags_t dump_kind, const char *format, void dump_printf_va (dump_flags_t dump_kind, const char *format,
va_list ap) ATTRIBUTE_PRINTF (3, 0); va_list *ap) ATTRIBUTE_GCC_DUMP_PRINTF (3, 0);
void dump_printf_loc_va (dump_flags_t dump_kind, const dump_location_t &loc, void dump_printf_loc_va (dump_flags_t dump_kind, const dump_location_t &loc,
const char *format, va_list ap) const char *format, va_list *ap)
ATTRIBUTE_PRINTF (4, 0); ATTRIBUTE_GCC_DUMP_PRINTF (4, 0);
template<unsigned int N, typename C> template<unsigned int N, typename C>
void dump_dec (dump_flags_t dump_kind, const poly_int<N, C> &value); void dump_dec (dump_flags_t dump_kind, const poly_int<N, C> &value);
......
...@@ -23,6 +23,19 @@ along with GCC; see the file COPYING3. If not see ...@@ -23,6 +23,19 @@ along with GCC; see the file COPYING3. If not see
#include "profile-count.h" #include "profile-count.h"
/* An attribute for annotating formatting printing functions that use
the dumpfile/optinfo formatting codes. These are the pretty_printer
format codes (see pretty-print.c), with additional codes for middle-end
specific entities (see dumpfile.c). */
#if GCC_VERSION >= 3005
#define ATTRIBUTE_GCC_DUMP_PRINTF(m, n) \
__attribute__ ((__format__ (__gcc_dump_printf__, m ,n))) \
ATTRIBUTE_NONNULL(m)
#else
#define ATTRIBUTE_GCC_DUMP_PRINTF(m, n) ATTRIBUTE_NONNULL(m)
#endif
/* Different tree dump places. When you add new tree dump places, /* Different tree dump places. When you add new tree dump places,
extend the DUMP_FILES array in dumpfile.c. */ extend the DUMP_FILES array in dumpfile.c. */
enum tree_dump_index enum tree_dump_index
...@@ -476,9 +489,12 @@ dump_enabled_p (void) ...@@ -476,9 +489,12 @@ dump_enabled_p (void)
to minimize the work done for the common case where dumps to minimize the work done for the common case where dumps
are disabled. */ are disabled. */
extern void dump_printf (dump_flags_t, const char *, ...) ATTRIBUTE_PRINTF_2; extern void dump_printf (dump_flags_t, const char *, ...)
ATTRIBUTE_GCC_DUMP_PRINTF (2, 3);
extern void dump_printf_loc (dump_flags_t, const dump_location_t &, extern void dump_printf_loc (dump_flags_t, const dump_location_t &,
const char *, ...) ATTRIBUTE_PRINTF_3; const char *, ...)
ATTRIBUTE_GCC_DUMP_PRINTF (3, 0);
extern void dump_function (int phase, tree fn); extern void dump_function (int phase, tree fn);
extern void dump_basic_block (dump_flags_t, basic_block, int); extern void dump_basic_block (dump_flags_t, basic_block, int);
extern void dump_generic_expr_loc (dump_flags_t, const dump_location_t &, extern void dump_generic_expr_loc (dump_flags_t, const dump_location_t &,
......
2018-08-17 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/format/gcc_diag-1.c: Fix typo. Add test coverage for
gcc_dump_printf.
* gcc.dg/format/gcc_diag-10.c: Add gimple typedef. Add test
coverage for gcc_dump_printf.
2018-08-17 Martin Liska <mliska@suse.cz> 2018-08-17 Martin Liska <mliska@suse.cz>
* g++.dg/opt/mpx.C: Fix scanned pattern. * g++.dg/opt/mpx.C: Fix scanned pattern.
......
/* Test for GCC diagnositc formats. */ /* Test for GCC diagnostic formats. */
/* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> */ /* Origin: Kaveh Ghazi <ghazi@caip.rutgers.edu> */
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-Wformat" } */ /* { dg-options "-Wformat" } */
...@@ -24,6 +24,7 @@ extern int diag (const char *, ...) ATTRIBUTE_DIAG(__gcc_diag__); ...@@ -24,6 +24,7 @@ extern int diag (const char *, ...) ATTRIBUTE_DIAG(__gcc_diag__);
extern int tdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_tdiag__); extern int tdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_tdiag__);
extern int cdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_cdiag__); extern int cdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_cdiag__);
extern int cxxdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_cxxdiag__); extern int cxxdiag (const char *, ...) ATTRIBUTE_DIAG(__gcc_cxxdiag__);
extern int dump (const char *, ...) ATTRIBUTE_DIAG(__gcc_dump_printf__);
void void
foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p, foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
...@@ -39,36 +40,44 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p, ...@@ -39,36 +40,44 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
tdiag ("%%"); tdiag ("%%");
cdiag ("%%"); cdiag ("%%");
cxxdiag ("%%"); cxxdiag ("%%");
dump ("%%");
diag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p); diag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
tdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p); tdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
cdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p); cdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
cxxdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p); cxxdiag ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
dump ("%d%i%o%u%x%c%s%p%%", i, i, u, u, u, i, s, p);
diag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p); diag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
tdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p); tdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
cdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p); cdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
cxxdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p); cxxdiag ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
dump ("%qd%qi%qo%qu%qx%qc%qs%qp%<%%%'%>", i, i, u, u, u, i, s, p);
diag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul); diag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
tdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul); tdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
cdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul); cdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
cxxdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul); cxxdiag ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
dump ("%ld%li%lo%lu%lx", l, l, ul, ul, ul);
diag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull); diag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
tdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull); tdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
cdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull); cdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
cxxdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull); cxxdiag ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
dump ("%lld%lli%llo%llu%llx", ll, ll, ull, ull, ull);
diag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); diag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
tdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); tdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
cdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); cdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
cxxdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull); cxxdiag ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
dump ("%wd%wi%wo%wu%wx", ll, ll, ull, ull, ull);
diag ("%.*s", i, s); diag ("%.*s", i, s);
tdiag ("%.*s", i, s); tdiag ("%.*s", i, s);
cdiag ("%.*s", i, s); cdiag ("%.*s", i, s);
cxxdiag ("%.*s", i, s); cxxdiag ("%.*s", i, s);
dump ("%.*s", i, s);
/* Extensions provided in the diagnostic framework. */ /* Extensions provided in the diagnostic framework. */
diag ("%m"); diag ("%m");
tdiag ("%m"); tdiag ("%m");
cdiag ("%m"); cdiag ("%m");
cxxdiag ("%m"); cxxdiag ("%m");
dump ("%m");
/* Quote directives to avoid "warning: conversion used unquoted." */ /* Quote directives to avoid "warning: conversion used unquoted." */
tdiag ("%<%D%F%T%V%>", t1, t1, t1, t1); tdiag ("%<%D%F%T%V%>", t1, t1, t1, t1);
...@@ -94,20 +103,24 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p, ...@@ -94,20 +103,24 @@ foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
tdiag ("%Z", v, v_len); tdiag ("%Z", v, v_len);
cdiag ("%Z", v, v_len); cdiag ("%Z", v, v_len);
cxxdiag ("%Z", v, v_len); cxxdiag ("%Z", v, v_len);
dump ("%Z", v, v_len);
/* Bad stuff with extensions. */ /* Bad stuff with extensions. */
diag ("%m", i); /* { dg-warning "format" "extra arg" } */ diag ("%m", i); /* { dg-warning "format" "extra arg" } */
tdiag ("%m", i); /* { dg-warning "format" "extra arg" } */ tdiag ("%m", i); /* { dg-warning "format" "extra arg" } */
cdiag ("%m", i); /* { dg-warning "format" "extra arg" } */ cdiag ("%m", i); /* { dg-warning "format" "extra arg" } */
cxxdiag ("%m", i); /* { dg-warning "format" "extra arg" } */ cxxdiag ("%m", i); /* { dg-warning "format" "extra arg" } */
dump ("%m", i); /* { dg-warning "format" "extra arg" } */
diag ("%#m"); /* { dg-warning "format" "bogus modifier" } */ diag ("%#m"); /* { dg-warning "format" "bogus modifier" } */
tdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */ tdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */
cdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */ cdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */
cxxdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */ cxxdiag ("%#m"); /* { dg-warning "format" "bogus modifier" } */
dump ("%#m"); /* { dg-warning "format" "bogus modifier" } */
diag ("%+m"); /* { dg-warning "format" "bogus modifier" } */ diag ("%+m"); /* { dg-warning "format" "bogus modifier" } */
tdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */ tdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */
cdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */ cdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */
cxxdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */ cxxdiag ("%+m"); /* { dg-warning "format" "bogus modifier" } */
dump ("%+m"); /* { dg-warning "format" "bogus modifier" } */
diag ("%D", t1); /* { dg-warning "format" "bogus tree" } */ diag ("%D", t1); /* { dg-warning "format" "bogus tree" } */
tdiag ("%A", t1); /* { dg-warning "format" "bogus tree" } */ tdiag ("%A", t1); /* { dg-warning "format" "bogus tree" } */
tdiag ("%E", t1); tdiag ("%E", t1);
......
...@@ -19,12 +19,16 @@ typedef union tree_node *tree; ...@@ -19,12 +19,16 @@ typedef union tree_node *tree;
the C test to find the symbol. */ the C test to find the symbol. */
typedef struct gimple gimple; typedef struct gimple gimple;
/* Likewise for gimple. */
typedef struct gimple gimple;
#define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2))) #define FORMAT(kind) __attribute__ ((format (__gcc_## kind ##__, 1, 2)))
void diag (const char*, ...) FORMAT (diag); void diag (const char*, ...) FORMAT (diag);
void cdiag (const char*, ...) FORMAT (cdiag); void cdiag (const char*, ...) FORMAT (cdiag);
void tdiag (const char*, ...) FORMAT (tdiag); void tdiag (const char*, ...) FORMAT (tdiag);
void cxxdiag (const char*, ...) FORMAT (cxxdiag); void cxxdiag (const char*, ...) FORMAT (cxxdiag);
void dump (const char*, ...) FORMAT (dump_printf);
void test_diag (tree t, gimple *gc) void test_diag (tree t, gimple *gc)
{ {
...@@ -157,3 +161,25 @@ void test_cxxdiag (tree t, gimple *gc) ...@@ -157,3 +161,25 @@ void test_cxxdiag (tree t, gimple *gc)
cxxdiag ("%<%V%>", t); cxxdiag ("%<%V%>", t);
cxxdiag ("%<%X%>", t); cxxdiag ("%<%X%>", t);
} }
void test_dump (tree t, gimple *stmt)
{
dump ("%<"); /* { dg-warning "unterminated quoting directive" } */
dump ("%>"); /* { dg-warning "unmatched quoting directive " } */
dump ("%<foo%<bar%>%>"); /* { dg-warning "nested quoting directive" } */
dump ("%R"); /* { dg-warning "unmatched color reset directive" } */
dump ("%r", ""); /* { dg-warning "unterminated color directive" } */
dump ("%r%r", "", ""); /* { dg-warning "unterminated color directive" } */
dump ("%r%R", "");
dump ("%r%r%R", "", "");
dump ("%r%R%r%R", "", "");
dump ("%<%R%>"); /* { dg-warning "unmatched color reset directive" } */
dump ("%<%r%>", ""); /* { dg-warning "unterminated color directive" } */
dump ("%<%r%R%>", "");
dump ("%E", stmt);
dump ("%T", t);
dump ("%G", stmt);
}
...@@ -74,8 +74,7 @@ vect_lanes_optab_supported_p (const char *name, convert_optab optab, ...@@ -74,8 +74,7 @@ vect_lanes_optab_supported_p (const char *name, convert_optab optab,
{ {
if (dump_enabled_p ()) if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
"no array mode for %s[" "no array mode for %s[%wu]\n",
HOST_WIDE_INT_PRINT_DEC "]\n",
GET_MODE_NAME (mode), count); GET_MODE_NAME (mode), count);
return false; return false;
} }
...@@ -1249,9 +1248,8 @@ vector_alignment_reachable_p (dr_vec_info *dr_info) ...@@ -1249,9 +1248,8 @@ vector_alignment_reachable_p (dr_vec_info *dr_info)
if (dump_enabled_p ()) if (dump_enabled_p ())
{ {
dump_printf_loc (MSG_NOTE, vect_location, dump_printf_loc (MSG_NOTE, vect_location,
"data size =" HOST_WIDE_INT_PRINT_DEC, elmsize); "data size = %wd. misalignment = %d.\n", elmsize,
dump_printf (MSG_NOTE, DR_MISALIGNMENT (dr_info));
". misalignment = %d.\n", DR_MISALIGNMENT (dr_info));
} }
if (DR_MISALIGNMENT (dr_info) % elmsize) if (DR_MISALIGNMENT (dr_info) % elmsize)
{ {
......
...@@ -1958,7 +1958,7 @@ start_over: ...@@ -1958,7 +1958,7 @@ start_over:
dump_printf_loc (MSG_NOTE, vect_location, dump_printf_loc (MSG_NOTE, vect_location,
"vectorization_factor = "); "vectorization_factor = ");
dump_dec (MSG_NOTE, vectorization_factor); dump_dec (MSG_NOTE, vectorization_factor);
dump_printf (MSG_NOTE, ", niters = " HOST_WIDE_INT_PRINT_DEC "\n", dump_printf (MSG_NOTE, ", niters = %wd\n",
LOOP_VINFO_INT_NITERS (loop_vinfo)); LOOP_VINFO_INT_NITERS (loop_vinfo));
} }
......
...@@ -2984,8 +2984,7 @@ vect_slp_bb (basic_block bb) ...@@ -2984,8 +2984,7 @@ vect_slp_bb (basic_block bb)
unsigned HOST_WIDE_INT bytes; unsigned HOST_WIDE_INT bytes;
if (current_vector_size.is_constant (&bytes)) if (current_vector_size.is_constant (&bytes))
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
"basic block part vectorized using " "basic block part vectorized using %wu byte "
HOST_WIDE_INT_PRINT_UNSIGNED " byte "
"vectors\n", bytes); "vectors\n", bytes);
else else
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
......
...@@ -935,9 +935,7 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab, ...@@ -935,9 +935,7 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
unsigned HOST_WIDE_INT bytes; unsigned HOST_WIDE_INT bytes;
if (current_vector_size.is_constant (&bytes)) if (current_vector_size.is_constant (&bytes))
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
"loop vectorized vectorized using " "loop vectorized using %wu byte vectors\n", bytes);
HOST_WIDE_INT_PRINT_UNSIGNED " byte "
"vectors\n", bytes);
else else
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
"loop vectorized using variable length vectors\n"); "loop vectorized using variable length vectors\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment