diff options
author | David Malcolm <dmalcolm@redhat.com> | 2018-09-28 17:40:04 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2018-09-28 17:40:04 +0000 |
commit | ed2d9d3720adef3a260b8a55e17e744352a901fc (patch) | |
tree | 53b1bfbea366b01dd4b7d2ab8e3c405d9b2c7509 /gcc/dumpfile.c | |
parent | 5718d9d95fd9457c9f6cf49526ef52f974d9419c (diff) | |
download | gcc-ed2d9d3720adef3a260b8a55e17e744352a901fc.zip gcc-ed2d9d3720adef3a260b8a55e17e744352a901fc.tar.gz gcc-ed2d9d3720adef3a260b8a55e17e744352a901fc.tar.bz2 |
dumpfile.c: use prefixes other than 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
As noted at Cauldron, dumpfile.c currently emits "note: " for all kinds
of dump message, so that (after filtering) there's no distinction between
MSG_OPTIMIZED_LOCATIONS vs MSG_NOTE vs MSG_MISSED_OPTIMIZATION in the
textual output.
This patch changes dumpfile.c so that the "note: " varies to show
which MSG_* was used, with the string prefix matching that used for
filtering in -fopt-info, hence e.g.
directive_unroll_3.f90:24:0: optimized: loop unrolled 7 times
and:
pr19210-1.c:24:3: missed: missed loop optimization: niters analysis ends up with assumptions.
The patch adds "dg-optimized" and "dg-missed" directives for use
in the testsuite for matching these (with -fopt-info on stderr; they
don't help for dumpfile output).
The patch also converts the various problem-reporting dump messages
in coverage.c:get_coverage_counts to use MSG_MISSED_OPTIMIZATION
rather than MSG_OPTIMIZED_LOCATIONS, as the docs call out "optimized"
as
"information when an optimization is successfully applied",
whereas "missed" is for
"information about missed optimizations",
and problems with profile data seem to me to fall much more into the
latter category than the former. Doing so requires converting a few
tests from using "-fopt-info" (which is implicitly
"-fopt-info-optimized-optall") to getting the "missed" optimizations.
Changing them to "-fopt-info-missed" added lots of noise from the
vectorizer, so I changed these tests to use "-fopt-info-missed-ipa".
gcc/ChangeLog:
* coverage.c (get_coverage_counts): Convert problem-reporting dump
messages from MSG_OPTIMIZED_LOCATIONS to MSG_MISSED_OPTIMIZATION.
* dumpfile.c (kind_as_string): New function.
(dump_loc): Rather than a hardcoded prefix of "note: ", use
kind_as_string to vary the prefix based on dump_kind.
(selftest::test_capture_of_dump_calls): Update for above.
gcc/testsuite/ChangeLog:
* c-c++-common/unroll-1.c: Update expected output from "note" to
"optimized".
* c-c++-common/unroll-2.c: Likewise.
* c-c++-common/unroll-3.c: Likewise.
* g++.dg/tree-ssa/dom-invalid.C: Update expected output from
dg-message to dg-missed. Convert param from -fopt-info to
-fopt-info-missed-ipa.
* g++.dg/tree-ssa/pr81408.C: Update expected output from
dg-message to dg-missed.
* g++.dg/vect/slp-pr56812.cc: Update expected output from
dg-message to dg-optimized.
* gcc.dg/pr26570.c: Update expected output from dg-message to
dg-missed. Convert param from -fopt-info to
-fopt-info-missed-ipa.
* gcc.dg/pr32773.c: Likewise.
* gcc.dg/tree-ssa/pr19210-1.c: Update expected output from
dg-message to dg-missed.
* gcc.dg/unroll-2.c: Update expected output from dg-message to
dg-optimized.
* gcc.dg/vect/nodump-vect-opt-info-1.c: Likewise. Convert param
from -fopt-info to -fopt-info-vec.
* gfortran.dg/directive_unroll_1.f90: Update expected output from
"note" to "optimized".
* gfortran.dg/directive_unroll_2.f90: Likewise.
* gfortran.dg/directive_unroll_3.f90: Likewise.
* gnat.dg/unroll4.adb: Likewise.
* lib/gcc-dg.exp (dg-optimized): New procedure.
(dg-missed): New procedure.
From-SVN: r264697
Diffstat (limited to 'gcc/dumpfile.c')
-rw-r--r-- | gcc/dumpfile.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c index b4faeaa..d430ea3 100644 --- a/gcc/dumpfile.c +++ b/gcc/dumpfile.c @@ -437,6 +437,27 @@ dump_user_location_t::from_function_decl (tree fndecl) DECL_SOURCE_LOCATION (fndecl)); } +/* Extract the MSG_* component from DUMP_KIND and return a string for use + as a prefix to dump messages. + These match the strings in optinfo_verbosity_options and thus the + "OPTIONS" within "-fopt-info-OPTIONS". */ + +static const char * +kind_as_string (dump_flags_t dump_kind) +{ + switch (dump_kind & MSG_ALL) + { + default: + gcc_unreachable (); + case MSG_OPTIMIZED_LOCATIONS: + return "optimized"; + case MSG_MISSED_OPTIMIZATION: + return "missed"; + case MSG_NOTE: + return "note"; + } +} + /* Print source location on DFILE if enabled. */ static void @@ -445,13 +466,14 @@ dump_loc (dump_flags_t dump_kind, FILE *dfile, source_location loc) if (dump_kind) { if (LOCATION_LOCUS (loc) > BUILTINS_LOCATION) - fprintf (dfile, "%s:%d:%d: note: ", LOCATION_FILE (loc), + fprintf (dfile, "%s:%d:%d: ", LOCATION_FILE (loc), LOCATION_LINE (loc), LOCATION_COLUMN (loc)); else if (current_function_decl) - fprintf (dfile, "%s:%d:%d: note: ", + fprintf (dfile, "%s:%d:%d: ", DECL_SOURCE_FILE (current_function_decl), DECL_SOURCE_LINE (current_function_decl), DECL_SOURCE_COLUMN (current_function_decl)); + fprintf (dfile, "%s: ", kind_as_string (dump_kind)); /* Indentation based on scope depth. */ fprintf (dfile, "%*s", get_dump_scope_depth (), ""); } @@ -465,13 +487,14 @@ dump_loc (dump_flags_t dump_kind, pretty_printer *pp, source_location loc) if (dump_kind) { if (LOCATION_LOCUS (loc) > BUILTINS_LOCATION) - pp_printf (pp, "%s:%d:%d: note: ", LOCATION_FILE (loc), + pp_printf (pp, "%s:%d:%d: ", LOCATION_FILE (loc), LOCATION_LINE (loc), LOCATION_COLUMN (loc)); else if (current_function_decl) - pp_printf (pp, "%s:%d:%d: note: ", + pp_printf (pp, "%s:%d:%d: ", DECL_SOURCE_FILE (current_function_decl), DECL_SOURCE_LINE (current_function_decl), DECL_SOURCE_COLUMN (current_function_decl)); + pp_printf (pp, "%s: ", kind_as_string (dump_kind)); /* Indentation based on scope depth. */ for (unsigned i = 0; i < get_dump_scope_depth (); i++) pp_character (pp, ' '); @@ -2325,7 +2348,7 @@ test_capture_of_dump_calls (const line_table_case &case_) } dump_printf_loc (MSG_NOTE, stmt, "msg 7\n"); - ASSERT_DUMPED_TEXT_EQ (tmp, "test.txt:5:10: note: msg 4\n"); + ASSERT_DUMPED_TEXT_EQ (tmp, "test.txt:5:10: optimized: msg 4\n"); } } |