public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
@ 2018-09-25 21:55 David Malcolm
  2018-09-28  9:44 ` Richard Biener
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: David Malcolm @ 2018-09-25 21:55 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Malcolm

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".

Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.

OK for trunk?

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.
---
 gcc/coverage.c                                     | 10 +++----
 gcc/dumpfile.c                                     | 33 ++++++++++++++++++----
 gcc/testsuite/c-c++-common/unroll-1.c              |  8 +++---
 gcc/testsuite/c-c++-common/unroll-2.c              |  8 +++---
 gcc/testsuite/c-c++-common/unroll-3.c              | 12 ++++----
 gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C        |  4 +--
 gcc/testsuite/g++.dg/tree-ssa/pr81408.C            |  2 +-
 gcc/testsuite/g++.dg/vect/slp-pr56812.cc           |  2 +-
 gcc/testsuite/gcc.dg/pr26570.c                     |  4 +--
 gcc/testsuite/gcc.dg/pr32773.c                     |  6 ++--
 gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c          |  8 +++---
 gcc/testsuite/gcc.dg/unroll-2.c                    |  4 +--
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c |  6 ++--
 gcc/testsuite/gfortran.dg/directive_unroll_1.f90   |  6 ++--
 gcc/testsuite/gfortran.dg/directive_unroll_2.f90   |  6 ++--
 gcc/testsuite/gfortran.dg/directive_unroll_3.f90   |  8 +++---
 gcc/testsuite/gnat.dg/unroll4.adb                  |  2 +-
 gcc/testsuite/lib/gcc-dg.exp                       | 20 +++++++++++++
 18 files changed, 96 insertions(+), 53 deletions(-)

diff --git a/gcc/coverage.c b/gcc/coverage.c
index 8f12778..2475495 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -308,7 +308,7 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
 	{
 	  dump_user_location_t loc
 	    = dump_user_location_t::from_location_t (input_location);
-	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
 			   (flag_guess_branch_prob
 			    ? "file %s not found, execution counts estimated\n"
 			    : "file %s not found, execution counts assumed to "
@@ -347,7 +347,7 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
 	{
 	  dump_user_location_t loc
 	    = dump_user_location_t::from_location_t (input_location);
-          dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
                            "use -Wno-error=coverage-mismatch to tolerate "
                            "the mismatch but performance may drop if the "
                            "function is hot\n");
@@ -355,14 +355,14 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
 	  if (!seen_error ()
 	      && !warned++)
 	    {
-	      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
                                "coverage mismatch ignored\n");
-	      dump_printf (MSG_OPTIMIZED_LOCATIONS,
+	      dump_printf (MSG_MISSED_OPTIMIZATION,
                            flag_guess_branch_prob
                            ? G_("execution counts estimated\n")
                            : G_("execution counts assumed to be zero\n"));
 	      if (!flag_guess_branch_prob)
-		dump_printf (MSG_OPTIMIZED_LOCATIONS,
+		dump_printf (MSG_MISSED_OPTIMIZATION,
                              "this can result in poorly optimized code\n");
 	    }
 	}
diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
index 5655e46..db260a5 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");
   }
 }
 
diff --git a/gcc/testsuite/c-c++-common/unroll-1.c b/gcc/testsuite/c-c++-common/unroll-1.c
index 105a82c..fe7f4f3 100644
--- a/gcc/testsuite/c-c++-common/unroll-1.c
+++ b/gcc/testsuite/c-c++-common/unroll-1.c
@@ -20,22 +20,22 @@ void test (void)
   #pragma GCC unroll 8
   for (unsigned long i = 1; i <= 15; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "21:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "21:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
 
   #pragma GCC unroll 8
   for (unsigned long i = 1; i <= j; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "26:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "26:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
 
   #pragma GCC unroll 7
   for (unsigned long i = 1; i <= j; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "31:.*: note: loop unrolled 3 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "31:.*: optimized: loop unrolled 3 times" "loop2_unroll" } } */
 
   unsigned long i = 0;
   #pragma GCC unroll 3
   do {
     bar(i);
   } while (++i < 9);
-  /* { dg-final { scan-rtl-dump "3\[79\]:.*: note: loop unrolled 2 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "3\[79\]:.*: optimized: loop unrolled 2 times" "loop2_unroll" } } */
 }
diff --git a/gcc/testsuite/c-c++-common/unroll-2.c b/gcc/testsuite/c-c++-common/unroll-2.c
index a67a1d7..0bb4bbb 100644
--- a/gcc/testsuite/c-c++-common/unroll-2.c
+++ b/gcc/testsuite/c-c++-common/unroll-2.c
@@ -20,22 +20,22 @@ void test (void)
   #pragma GCC unroll 8
   for (unsigned long i = 1; i <= 15; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "21:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "21:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
 
   #pragma GCC unroll 8
   for (unsigned long i = 1; i <= j; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "26:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "26:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
 
   #pragma GCC unroll 7
   for (unsigned long i = 1; i <= j; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "31:.*: note: loop unrolled 3 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "31:.*: optimized: loop unrolled 3 times" "loop2_unroll" } } */
 
   unsigned long i = 0;
   #pragma GCC unroll 3
   do {
     bar(i);
   } while (++i < 9);
-  /* { dg-final { scan-rtl-dump "3\[79\]:.*: note: loop unrolled 2 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "3\[79\]:.*: optimized: loop unrolled 2 times" "loop2_unroll" } } */
 }
diff --git a/gcc/testsuite/c-c++-common/unroll-3.c b/gcc/testsuite/c-c++-common/unroll-3.c
index 6cefa75..541accb 100644
--- a/gcc/testsuite/c-c++-common/unroll-3.c
+++ b/gcc/testsuite/c-c++-common/unroll-3.c
@@ -10,32 +10,32 @@ void test (void)
   #pragma GCC unroll 8
   for (unsigned long i = 1; i <= 8; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump-not "11:.*: note: loop unrolled" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump-not "11:.*: optimized: loop unrolled" "loop2_unroll" } } */
 
   #pragma GCC unroll 8
   for (unsigned long i = 1; i <= 7; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump-not "16:.*: note: loop unrolled" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump-not "16:.*: optimized: loop unrolled" "loop2_unroll" } } */
 
   #pragma GCC unroll 8
   for (unsigned long i = 1; i <= 15; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "21:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "21:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
 
   #pragma GCC unroll 8
   for (unsigned long i = 1; i <= j; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "26:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "26:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
 
   #pragma GCC unroll 7
   for (unsigned long i = 1; i <= j; ++i)
     bar(i);
-  /* { dg-final { scan-rtl-dump "31:.*: note: loop unrolled 3 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "31:.*: optimized: loop unrolled 3 times" "loop2_unroll" } } */
 
   unsigned long i = 0;
   #pragma GCC unroll 3
   do {
     bar(i);
   } while (++i < 9);
-  /* { dg-final { scan-rtl-dump "3\[79\]:.*: note: loop unrolled 2 times" "loop2_unroll" } } */
+  /* { dg-final { scan-rtl-dump "3\[79\]:.*: optimized: loop unrolled 2 times" "loop2_unroll" } } */
 }
diff --git a/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C b/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
index 41343ee..056d6ed 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
@@ -1,7 +1,7 @@
 // PR tree-optimization/39557
 // invalid post-dom info leads to infinite loop
 // { dg-do run }
-// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fopt-info -fno-rtti" }
+// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fopt-info-missed-ipa -fno-rtti" }
 
 struct C
 {
@@ -49,4 +49,4 @@ main ()
 {
  E e;
  e.bar ();
-} // { dg-message  "note: file" }
+} // { dg-missed "file .* not found" }
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
index 89d6e55..39e32fd 100644
--- a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
@@ -86,7 +86,7 @@ a::H t;
 void
 ShowHelpListCommands ()
 {
-  for (auto c : t) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
+  for (auto c : t) /* { dg-missed "missed loop optimization: niters analysis .*" } */
     a::ax << c.ay << a::av;
 }
 
diff --git a/gcc/testsuite/g++.dg/vect/slp-pr56812.cc b/gcc/testsuite/g++.dg/vect/slp-pr56812.cc
index 08b0981..3e7a495 100644
--- a/gcc/testsuite/g++.dg/vect/slp-pr56812.cc
+++ b/gcc/testsuite/g++.dg/vect/slp-pr56812.cc
@@ -14,6 +14,6 @@ public:
 void mydata::Set (float x)
 {
   /* We want to vectorize this either as loop or basic-block.  */
-  for (int i=0; i<upper(); i++) /* { dg-message "note: \[^\n\]* vectorized" } */
+  for (int i=0; i<upper(); i++) /* { dg-optimized "\[^\n\]* vectorized" } */
     data[i] = x;
 }
diff --git a/gcc/testsuite/gcc.dg/pr26570.c b/gcc/testsuite/gcc.dg/pr26570.c
index 8ce8a44..e267055 100644
--- a/gcc/testsuite/gcc.dg/pr26570.c
+++ b/gcc/testsuite/gcc.dg/pr26570.c
@@ -1,8 +1,8 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fprofile-generate -fprofile-use -fopt-info" } */
+/* { dg-options "-O2 -fprofile-generate -fprofile-use -fopt-info-missed-ipa" } */
 /* { dg-require-profiling "-fprofile-generate" } */
 
 unsigned test (unsigned a, unsigned b)
 {
   return a / b;
-} /* { dg-message "note: \[^\n\]*execution counts estimated" } */
+} /* { dg-missed "\[^\n\]*execution counts estimated" } */
diff --git a/gcc/testsuite/gcc.dg/pr32773.c b/gcc/testsuite/gcc.dg/pr32773.c
index 19a9019..edfcb3a 100644
--- a/gcc/testsuite/gcc.dg/pr32773.c
+++ b/gcc/testsuite/gcc.dg/pr32773.c
@@ -1,9 +1,9 @@
 /* { dg-do compile } */
-/* { dg-options "-O -fprofile-use -fopt-info" } */
-/* { dg-options "-O -m4 -fprofile-use -fopt-info" { target sh-*-* } } */
+/* { dg-options "-O -fprofile-use -fopt-info-missed-ipa" } */
+/* { dg-options "-O -m4 -fprofile-use -fopt-info-missed-ipa" { target sh-*-* } } */
 
 void foo (int *p)
 {
   if (p)
     *p = 0;
-} /* { dg-message "note: \[^\n\]*execution counts estimated" } */
+} /* { dg-missed "\[^\n\]*execution counts estimated" } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
index 9162d15..50d86a0 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
@@ -6,10 +6,10 @@ void
 f (unsigned n)
 {
   unsigned k;
-  for(k = 0;k <= n;k++) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
+  for(k = 0;k <= n;k++) /* { dg-missed "missed loop optimization: niters analysis .*" } */
     g();
 
-  for(k = 0;k <= n;k += 4) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
+  for(k = 0;k <= n;k += 4) /* { dg-missed "missed loop optimization: niters analysis .*" } */
     g();
 
   /* We used to get warning for this loop.  However, since then # of iterations
@@ -21,9 +21,9 @@ f (unsigned n)
     g();
 
   /* So we need the following loop, instead.  */
-  for(k = 4;k <= n;k += 5) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
+  for(k = 4;k <= n;k += 5) /* { dg-missed "missed loop optimization: niters analysis .*" } */
     g();
   
-  for(k = 15;k >= n;k--) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
+  for(k = 15;k >= n;k--) /* { dg-missed "missed loop optimization: niters analysis .*" } */
     g();
 }
diff --git a/gcc/testsuite/gcc.dg/unroll-2.c b/gcc/testsuite/gcc.dg/unroll-2.c
index 46126c3..8baceaa 100644
--- a/gcc/testsuite/gcc.dg/unroll-2.c
+++ b/gcc/testsuite/gcc.dg/unroll-2.c
@@ -15,7 +15,7 @@ int foo(void)
 {
   int i;
   bar();
-  for (i = 0; i < 2; i++) /* { dg-message "note: loop with 2 iterations completely unrolled" } */
+  for (i = 0; i < 2; i++) /* { dg-optimized "loop with 2 iterations completely unrolled" } */
   {
      a[i]= b[i] + 1;
   }
@@ -25,7 +25,7 @@ int foo(void)
 int foo2(void)
 {
   int i;
-  for (i = 0; i < 2; i++) /* { dg-message "note: loop with 2 iterations completely unrolled" } */
+  for (i = 0; i < 2; i++) /* { dg-optimized "loop with 2 iterations completely unrolled" } */
   {
      a[i]= b[i] + 1;
   }
diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
index 0b14b8e..258e378 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
@@ -1,11 +1,11 @@
 /* { dg-do compile { target vect_int } } */
-/* { dg-additional-options "-std=c99 -fopt-info -O3" } */
+/* { dg-additional-options "-std=c99 -fopt-info-vec -O3" } */
 
 void
 vadd (int *dst, int *op1, int *op2, int count)
 {
-/* { dg-message "loop vectorized" "" { target *-*-* } .+2 } */
-/* { dg-message "loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
+/* { dg-optimized "loop vectorized" "" { target *-*-* } .+2 } */
+/* { dg-optimized "loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
   for (int i = 0; i < count; ++i)
     dst[i] = op1[i] + op2[i];
 }
diff --git a/gcc/testsuite/gfortran.dg/directive_unroll_1.f90 b/gcc/testsuite/gfortran.dg/directive_unroll_1.f90
index 85b3671..d758ad7 100644
--- a/gcc/testsuite/gfortran.dg/directive_unroll_1.f90
+++ b/gcc/testsuite/gfortran.dg/directive_unroll_1.f90
@@ -24,7 +24,7 @@ subroutine test2(a, n)
   DO i=1, n, 1
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "24:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "24:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test2
 
 subroutine test3(a, n)
@@ -36,7 +36,7 @@ subroutine test3(a, n)
   DO i=n, 1, -1
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "36:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "36:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test3
 
 subroutine test4(a, n)
@@ -48,5 +48,5 @@ subroutine test4(a, n)
   DO i=1, n, 2
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "48:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "48:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test4
diff --git a/gcc/testsuite/gfortran.dg/directive_unroll_2.f90 b/gcc/testsuite/gfortran.dg/directive_unroll_2.f90
index 6dff8fa..c726227 100644
--- a/gcc/testsuite/gfortran.dg/directive_unroll_2.f90
+++ b/gcc/testsuite/gfortran.dg/directive_unroll_2.f90
@@ -24,7 +24,7 @@ subroutine test2(a, n)
   DO i=1, n, 1
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "24:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "24:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test2
 
 subroutine test3(a, n)
@@ -36,7 +36,7 @@ subroutine test3(a, n)
   DO i=n, 1, -1
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "36:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "36:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test3
 
 subroutine test4(a, n)
@@ -48,5 +48,5 @@ subroutine test4(a, n)
   DO i=1, n, 2
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "48:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "48:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test4
diff --git a/gcc/testsuite/gfortran.dg/directive_unroll_3.f90 b/gcc/testsuite/gfortran.dg/directive_unroll_3.f90
index 4e3ec09..59a8e02 100644
--- a/gcc/testsuite/gfortran.dg/directive_unroll_3.f90
+++ b/gcc/testsuite/gfortran.dg/directive_unroll_3.f90
@@ -12,7 +12,7 @@ subroutine test1(a)
   DO i=1, 8, 1
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump-not "12:.: note: loop unrolled" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump-not "12:.: optimized: loop unrolled" "loop2_unroll" } }
 end subroutine test1
 
 subroutine test2(a, n)
@@ -24,7 +24,7 @@ subroutine test2(a, n)
   DO i=1, n, 1
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "24:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "24:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test2
 
 subroutine test3(a, n)
@@ -36,7 +36,7 @@ subroutine test3(a, n)
   DO i=n, 1, -1
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "36:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "36:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test3
 
 subroutine test4(a, n)
@@ -48,5 +48,5 @@ subroutine test4(a, n)
   DO i=1, n, 2
     call dummy(a(i))
   ENDDO
-! { dg-final { scan-rtl-dump "48:.: note: loop unrolled 7 times" "loop2_unroll" } }
+! { dg-final { scan-rtl-dump "48:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
 end subroutine test4
diff --git a/gcc/testsuite/gnat.dg/unroll4.adb b/gcc/testsuite/gnat.dg/unroll4.adb
index d9b763a..0cea4e8 100644
--- a/gcc/testsuite/gnat.dg/unroll4.adb
+++ b/gcc/testsuite/gnat.dg/unroll4.adb
@@ -23,4 +23,4 @@ package body Unroll4 is
 
 end Unroll4;
 
--- { dg-final { scan-rtl-dump-times "note: loop unrolled 7 times" 2 "loop2_unroll" } }
+-- { dg-final { scan-rtl-dump-times "optimized: loop unrolled 7 times" 2 "loop2_unroll" } }
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 24d0b00..c33a50c 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1194,6 +1194,26 @@ proc dg-locus { args } {
     verbose "process-message:\n${dg-messages}" 2
 }
 
+# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
+# a successful optimization.
+
+proc dg-optimized { args } {
+    # Make this variable available here and to the saved proc.
+    upvar dg-messages dg-messages
+
+    process-message saved-dg-error "optimized: " "$args"
+}
+
+# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
+# a missed optimization.
+
+proc dg-missed { args } {
+    # Make this variable available here and to the saved proc.
+    upvar dg-messages dg-messages
+
+    process-message saved-dg-error "missed: " "$args"
+}
+
 # Check the existence of a gdb in the path, and return true if there
 # is one.
 #
-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2018-09-25 21:55 [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION} David Malcolm
@ 2018-09-28  9:44 ` Richard Biener
  2018-09-29 23:06 ` Andreas Schwab
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 17+ messages in thread
From: Richard Biener @ 2018-09-28  9:44 UTC (permalink / raw)
  To: David Malcolm; +Cc: GCC Patches

On Tue, Sep 25, 2018 at 9:12 PM David Malcolm <dmalcolm@redhat.com> wrote:
>
> 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".
>
> Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
>
> OK for trunk?

OK.

Richard.

> 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.
> ---
>  gcc/coverage.c                                     | 10 +++----
>  gcc/dumpfile.c                                     | 33 ++++++++++++++++++----
>  gcc/testsuite/c-c++-common/unroll-1.c              |  8 +++---
>  gcc/testsuite/c-c++-common/unroll-2.c              |  8 +++---
>  gcc/testsuite/c-c++-common/unroll-3.c              | 12 ++++----
>  gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C        |  4 +--
>  gcc/testsuite/g++.dg/tree-ssa/pr81408.C            |  2 +-
>  gcc/testsuite/g++.dg/vect/slp-pr56812.cc           |  2 +-
>  gcc/testsuite/gcc.dg/pr26570.c                     |  4 +--
>  gcc/testsuite/gcc.dg/pr32773.c                     |  6 ++--
>  gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c          |  8 +++---
>  gcc/testsuite/gcc.dg/unroll-2.c                    |  4 +--
>  gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c |  6 ++--
>  gcc/testsuite/gfortran.dg/directive_unroll_1.f90   |  6 ++--
>  gcc/testsuite/gfortran.dg/directive_unroll_2.f90   |  6 ++--
>  gcc/testsuite/gfortran.dg/directive_unroll_3.f90   |  8 +++---
>  gcc/testsuite/gnat.dg/unroll4.adb                  |  2 +-
>  gcc/testsuite/lib/gcc-dg.exp                       | 20 +++++++++++++
>  18 files changed, 96 insertions(+), 53 deletions(-)
>
> diff --git a/gcc/coverage.c b/gcc/coverage.c
> index 8f12778..2475495 100644
> --- a/gcc/coverage.c
> +++ b/gcc/coverage.c
> @@ -308,7 +308,7 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
>         {
>           dump_user_location_t loc
>             = dump_user_location_t::from_location_t (input_location);
> -         dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
> +         dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
>                            (flag_guess_branch_prob
>                             ? "file %s not found, execution counts estimated\n"
>                             : "file %s not found, execution counts assumed to "
> @@ -347,7 +347,7 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
>         {
>           dump_user_location_t loc
>             = dump_user_location_t::from_location_t (input_location);
> -          dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
> +          dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
>                             "use -Wno-error=coverage-mismatch to tolerate "
>                             "the mismatch but performance may drop if the "
>                             "function is hot\n");
> @@ -355,14 +355,14 @@ get_coverage_counts (unsigned counter, unsigned cfg_checksum,
>           if (!seen_error ()
>               && !warned++)
>             {
> -             dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
> +             dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
>                                 "coverage mismatch ignored\n");
> -             dump_printf (MSG_OPTIMIZED_LOCATIONS,
> +             dump_printf (MSG_MISSED_OPTIMIZATION,
>                             flag_guess_branch_prob
>                             ? G_("execution counts estimated\n")
>                             : G_("execution counts assumed to be zero\n"));
>               if (!flag_guess_branch_prob)
> -               dump_printf (MSG_OPTIMIZED_LOCATIONS,
> +               dump_printf (MSG_MISSED_OPTIMIZATION,
>                               "this can result in poorly optimized code\n");
>             }
>         }
> diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c
> index 5655e46..db260a5 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");
>    }
>  }
>
> diff --git a/gcc/testsuite/c-c++-common/unroll-1.c b/gcc/testsuite/c-c++-common/unroll-1.c
> index 105a82c..fe7f4f3 100644
> --- a/gcc/testsuite/c-c++-common/unroll-1.c
> +++ b/gcc/testsuite/c-c++-common/unroll-1.c
> @@ -20,22 +20,22 @@ void test (void)
>    #pragma GCC unroll 8
>    for (unsigned long i = 1; i <= 15; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "21:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "21:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
>
>    #pragma GCC unroll 8
>    for (unsigned long i = 1; i <= j; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "26:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "26:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
>
>    #pragma GCC unroll 7
>    for (unsigned long i = 1; i <= j; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "31:.*: note: loop unrolled 3 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "31:.*: optimized: loop unrolled 3 times" "loop2_unroll" } } */
>
>    unsigned long i = 0;
>    #pragma GCC unroll 3
>    do {
>      bar(i);
>    } while (++i < 9);
> -  /* { dg-final { scan-rtl-dump "3\[79\]:.*: note: loop unrolled 2 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "3\[79\]:.*: optimized: loop unrolled 2 times" "loop2_unroll" } } */
>  }
> diff --git a/gcc/testsuite/c-c++-common/unroll-2.c b/gcc/testsuite/c-c++-common/unroll-2.c
> index a67a1d7..0bb4bbb 100644
> --- a/gcc/testsuite/c-c++-common/unroll-2.c
> +++ b/gcc/testsuite/c-c++-common/unroll-2.c
> @@ -20,22 +20,22 @@ void test (void)
>    #pragma GCC unroll 8
>    for (unsigned long i = 1; i <= 15; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "21:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "21:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
>
>    #pragma GCC unroll 8
>    for (unsigned long i = 1; i <= j; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "26:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "26:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
>
>    #pragma GCC unroll 7
>    for (unsigned long i = 1; i <= j; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "31:.*: note: loop unrolled 3 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "31:.*: optimized: loop unrolled 3 times" "loop2_unroll" } } */
>
>    unsigned long i = 0;
>    #pragma GCC unroll 3
>    do {
>      bar(i);
>    } while (++i < 9);
> -  /* { dg-final { scan-rtl-dump "3\[79\]:.*: note: loop unrolled 2 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "3\[79\]:.*: optimized: loop unrolled 2 times" "loop2_unroll" } } */
>  }
> diff --git a/gcc/testsuite/c-c++-common/unroll-3.c b/gcc/testsuite/c-c++-common/unroll-3.c
> index 6cefa75..541accb 100644
> --- a/gcc/testsuite/c-c++-common/unroll-3.c
> +++ b/gcc/testsuite/c-c++-common/unroll-3.c
> @@ -10,32 +10,32 @@ void test (void)
>    #pragma GCC unroll 8
>    for (unsigned long i = 1; i <= 8; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump-not "11:.*: note: loop unrolled" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump-not "11:.*: optimized: loop unrolled" "loop2_unroll" } } */
>
>    #pragma GCC unroll 8
>    for (unsigned long i = 1; i <= 7; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump-not "16:.*: note: loop unrolled" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump-not "16:.*: optimized: loop unrolled" "loop2_unroll" } } */
>
>    #pragma GCC unroll 8
>    for (unsigned long i = 1; i <= 15; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "21:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "21:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
>
>    #pragma GCC unroll 8
>    for (unsigned long i = 1; i <= j; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "26:.*: note: loop unrolled 7 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "26:.*: optimized: loop unrolled 7 times" "loop2_unroll" } } */
>
>    #pragma GCC unroll 7
>    for (unsigned long i = 1; i <= j; ++i)
>      bar(i);
> -  /* { dg-final { scan-rtl-dump "31:.*: note: loop unrolled 3 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "31:.*: optimized: loop unrolled 3 times" "loop2_unroll" } } */
>
>    unsigned long i = 0;
>    #pragma GCC unroll 3
>    do {
>      bar(i);
>    } while (++i < 9);
> -  /* { dg-final { scan-rtl-dump "3\[79\]:.*: note: loop unrolled 2 times" "loop2_unroll" } } */
> +  /* { dg-final { scan-rtl-dump "3\[79\]:.*: optimized: loop unrolled 2 times" "loop2_unroll" } } */
>  }
> diff --git a/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C b/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
> index 41343ee..056d6ed 100644
> --- a/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
> +++ b/gcc/testsuite/g++.dg/tree-ssa/dom-invalid.C
> @@ -1,7 +1,7 @@
>  // PR tree-optimization/39557
>  // invalid post-dom info leads to infinite loop
>  // { dg-do run }
> -// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fopt-info -fno-rtti" }
> +// { dg-options "-Wall -fno-exceptions -O2 -fprofile-use -fopt-info-missed-ipa -fno-rtti" }
>
>  struct C
>  {
> @@ -49,4 +49,4 @@ main ()
>  {
>   E e;
>   e.bar ();
> -} // { dg-message  "note: file" }
> +} // { dg-missed "file .* not found" }
> diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
> index 89d6e55..39e32fd 100644
> --- a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
> +++ b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C
> @@ -86,7 +86,7 @@ a::H t;
>  void
>  ShowHelpListCommands ()
>  {
> -  for (auto c : t) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
> +  for (auto c : t) /* { dg-missed "missed loop optimization: niters analysis .*" } */
>      a::ax << c.ay << a::av;
>  }
>
> diff --git a/gcc/testsuite/g++.dg/vect/slp-pr56812.cc b/gcc/testsuite/g++.dg/vect/slp-pr56812.cc
> index 08b0981..3e7a495 100644
> --- a/gcc/testsuite/g++.dg/vect/slp-pr56812.cc
> +++ b/gcc/testsuite/g++.dg/vect/slp-pr56812.cc
> @@ -14,6 +14,6 @@ public:
>  void mydata::Set (float x)
>  {
>    /* We want to vectorize this either as loop or basic-block.  */
> -  for (int i=0; i<upper(); i++) /* { dg-message "note: \[^\n\]* vectorized" } */
> +  for (int i=0; i<upper(); i++) /* { dg-optimized "\[^\n\]* vectorized" } */
>      data[i] = x;
>  }
> diff --git a/gcc/testsuite/gcc.dg/pr26570.c b/gcc/testsuite/gcc.dg/pr26570.c
> index 8ce8a44..e267055 100644
> --- a/gcc/testsuite/gcc.dg/pr26570.c
> +++ b/gcc/testsuite/gcc.dg/pr26570.c
> @@ -1,8 +1,8 @@
>  /* { dg-do compile } */
> -/* { dg-options "-O2 -fprofile-generate -fprofile-use -fopt-info" } */
> +/* { dg-options "-O2 -fprofile-generate -fprofile-use -fopt-info-missed-ipa" } */
>  /* { dg-require-profiling "-fprofile-generate" } */
>
>  unsigned test (unsigned a, unsigned b)
>  {
>    return a / b;
> -} /* { dg-message "note: \[^\n\]*execution counts estimated" } */
> +} /* { dg-missed "\[^\n\]*execution counts estimated" } */
> diff --git a/gcc/testsuite/gcc.dg/pr32773.c b/gcc/testsuite/gcc.dg/pr32773.c
> index 19a9019..edfcb3a 100644
> --- a/gcc/testsuite/gcc.dg/pr32773.c
> +++ b/gcc/testsuite/gcc.dg/pr32773.c
> @@ -1,9 +1,9 @@
>  /* { dg-do compile } */
> -/* { dg-options "-O -fprofile-use -fopt-info" } */
> -/* { dg-options "-O -m4 -fprofile-use -fopt-info" { target sh-*-* } } */
> +/* { dg-options "-O -fprofile-use -fopt-info-missed-ipa" } */
> +/* { dg-options "-O -m4 -fprofile-use -fopt-info-missed-ipa" { target sh-*-* } } */
>
>  void foo (int *p)
>  {
>    if (p)
>      *p = 0;
> -} /* { dg-message "note: \[^\n\]*execution counts estimated" } */
> +} /* { dg-missed "\[^\n\]*execution counts estimated" } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
> index 9162d15..50d86a0 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c
> @@ -6,10 +6,10 @@ void
>  f (unsigned n)
>  {
>    unsigned k;
> -  for(k = 0;k <= n;k++) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
> +  for(k = 0;k <= n;k++) /* { dg-missed "missed loop optimization: niters analysis .*" } */
>      g();
>
> -  for(k = 0;k <= n;k += 4) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
> +  for(k = 0;k <= n;k += 4) /* { dg-missed "missed loop optimization: niters analysis .*" } */
>      g();
>
>    /* We used to get warning for this loop.  However, since then # of iterations
> @@ -21,9 +21,9 @@ f (unsigned n)
>      g();
>
>    /* So we need the following loop, instead.  */
> -  for(k = 4;k <= n;k += 5) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
> +  for(k = 4;k <= n;k += 5) /* { dg-missed "missed loop optimization: niters analysis .*" } */
>      g();
>
> -  for(k = 15;k >= n;k--) /* { dg-message "note: missed loop optimization: niters analysis .*" } */
> +  for(k = 15;k >= n;k--) /* { dg-missed "missed loop optimization: niters analysis .*" } */
>      g();
>  }
> diff --git a/gcc/testsuite/gcc.dg/unroll-2.c b/gcc/testsuite/gcc.dg/unroll-2.c
> index 46126c3..8baceaa 100644
> --- a/gcc/testsuite/gcc.dg/unroll-2.c
> +++ b/gcc/testsuite/gcc.dg/unroll-2.c
> @@ -15,7 +15,7 @@ int foo(void)
>  {
>    int i;
>    bar();
> -  for (i = 0; i < 2; i++) /* { dg-message "note: loop with 2 iterations completely unrolled" } */
> +  for (i = 0; i < 2; i++) /* { dg-optimized "loop with 2 iterations completely unrolled" } */
>    {
>       a[i]= b[i] + 1;
>    }
> @@ -25,7 +25,7 @@ int foo(void)
>  int foo2(void)
>  {
>    int i;
> -  for (i = 0; i < 2; i++) /* { dg-message "note: loop with 2 iterations completely unrolled" } */
> +  for (i = 0; i < 2; i++) /* { dg-optimized "loop with 2 iterations completely unrolled" } */
>    {
>       a[i]= b[i] + 1;
>    }
> diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
> index 0b14b8e..258e378 100644
> --- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
> +++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
> @@ -1,11 +1,11 @@
>  /* { dg-do compile { target vect_int } } */
> -/* { dg-additional-options "-std=c99 -fopt-info -O3" } */
> +/* { dg-additional-options "-std=c99 -fopt-info-vec -O3" } */
>
>  void
>  vadd (int *dst, int *op1, int *op2, int count)
>  {
> -/* { dg-message "loop vectorized" "" { target *-*-* } .+2 } */
> -/* { dg-message "loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
> +/* { dg-optimized "loop vectorized" "" { target *-*-* } .+2 } */
> +/* { dg-optimized "loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
>    for (int i = 0; i < count; ++i)
>      dst[i] = op1[i] + op2[i];
>  }
> diff --git a/gcc/testsuite/gfortran.dg/directive_unroll_1.f90 b/gcc/testsuite/gfortran.dg/directive_unroll_1.f90
> index 85b3671..d758ad7 100644
> --- a/gcc/testsuite/gfortran.dg/directive_unroll_1.f90
> +++ b/gcc/testsuite/gfortran.dg/directive_unroll_1.f90
> @@ -24,7 +24,7 @@ subroutine test2(a, n)
>    DO i=1, n, 1
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "24:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "24:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test2
>
>  subroutine test3(a, n)
> @@ -36,7 +36,7 @@ subroutine test3(a, n)
>    DO i=n, 1, -1
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "36:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "36:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test3
>
>  subroutine test4(a, n)
> @@ -48,5 +48,5 @@ subroutine test4(a, n)
>    DO i=1, n, 2
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "48:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "48:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test4
> diff --git a/gcc/testsuite/gfortran.dg/directive_unroll_2.f90 b/gcc/testsuite/gfortran.dg/directive_unroll_2.f90
> index 6dff8fa..c726227 100644
> --- a/gcc/testsuite/gfortran.dg/directive_unroll_2.f90
> +++ b/gcc/testsuite/gfortran.dg/directive_unroll_2.f90
> @@ -24,7 +24,7 @@ subroutine test2(a, n)
>    DO i=1, n, 1
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "24:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "24:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test2
>
>  subroutine test3(a, n)
> @@ -36,7 +36,7 @@ subroutine test3(a, n)
>    DO i=n, 1, -1
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "36:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "36:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test3
>
>  subroutine test4(a, n)
> @@ -48,5 +48,5 @@ subroutine test4(a, n)
>    DO i=1, n, 2
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "48:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "48:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test4
> diff --git a/gcc/testsuite/gfortran.dg/directive_unroll_3.f90 b/gcc/testsuite/gfortran.dg/directive_unroll_3.f90
> index 4e3ec09..59a8e02 100644
> --- a/gcc/testsuite/gfortran.dg/directive_unroll_3.f90
> +++ b/gcc/testsuite/gfortran.dg/directive_unroll_3.f90
> @@ -12,7 +12,7 @@ subroutine test1(a)
>    DO i=1, 8, 1
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump-not "12:.: note: loop unrolled" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump-not "12:.: optimized: loop unrolled" "loop2_unroll" } }
>  end subroutine test1
>
>  subroutine test2(a, n)
> @@ -24,7 +24,7 @@ subroutine test2(a, n)
>    DO i=1, n, 1
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "24:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "24:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test2
>
>  subroutine test3(a, n)
> @@ -36,7 +36,7 @@ subroutine test3(a, n)
>    DO i=n, 1, -1
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "36:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "36:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test3
>
>  subroutine test4(a, n)
> @@ -48,5 +48,5 @@ subroutine test4(a, n)
>    DO i=1, n, 2
>      call dummy(a(i))
>    ENDDO
> -! { dg-final { scan-rtl-dump "48:.: note: loop unrolled 7 times" "loop2_unroll" } }
> +! { dg-final { scan-rtl-dump "48:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
>  end subroutine test4
> diff --git a/gcc/testsuite/gnat.dg/unroll4.adb b/gcc/testsuite/gnat.dg/unroll4.adb
> index d9b763a..0cea4e8 100644
> --- a/gcc/testsuite/gnat.dg/unroll4.adb
> +++ b/gcc/testsuite/gnat.dg/unroll4.adb
> @@ -23,4 +23,4 @@ package body Unroll4 is
>
>  end Unroll4;
>
> --- { dg-final { scan-rtl-dump-times "note: loop unrolled 7 times" 2 "loop2_unroll" } }
> +-- { dg-final { scan-rtl-dump-times "optimized: loop unrolled 7 times" 2 "loop2_unroll" } }
> diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
> index 24d0b00..c33a50c 100644
> --- a/gcc/testsuite/lib/gcc-dg.exp
> +++ b/gcc/testsuite/lib/gcc-dg.exp
> @@ -1194,6 +1194,26 @@ proc dg-locus { args } {
>      verbose "process-message:\n${dg-messages}" 2
>  }
>
> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
> +# a successful optimization.
> +
> +proc dg-optimized { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    process-message saved-dg-error "optimized: " "$args"
> +}
> +
> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
> +# a missed optimization.
> +
> +proc dg-missed { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    process-message saved-dg-error "missed: " "$args"
> +}
> +
>  # Check the existence of a gdb in the path, and return true if there
>  # is one.
>  #
> --
> 1.8.5.3
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2018-09-25 21:55 [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION} David Malcolm
  2018-09-28  9:44 ` Richard Biener
@ 2018-09-29 23:06 ` Andreas Schwab
  2018-10-01 14:20   ` David Malcolm
  2020-11-06  8:38 ` Thomas Schwinge
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2018-09-29 23:06 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

That produces extra output that breaks a few tests.

g++.dg/vect/pr33426-ivdep-2.cc  -std=c++11 (test for excess errors)
g++.dg/vect/pr33426-ivdep-2.cc  -std=c++14 (test for excess errors)
g++.dg/vect/pr33426-ivdep-2.cc  -std=c++98 (test for excess errors)
g++.dg/vect/pr33426-ivdep-3.cc   (test for excess errors)
g++.dg/vect/pr33426-ivdep-4.cc   (test for excess errors)
g++.dg/vect/pr33426-ivdep.cc  -std=c++11 (test for excess errors)
g++.dg/vect/pr33426-ivdep.cc  -std=c++14 (test for excess errors)
g++.dg/vect/pr33426-ivdep.cc  -std=c++98 (test for excess errors)
gcc.dg/vect/nodump-vect-opt-info-1.c (test for excess errors)
gcc.dg/vect/vect-ivdep-1.c (test for excess errors)
gcc.dg/vect/vect-ivdep-1.c -flto -ffat-lto-objects (test for excess errors)
gcc.dg/vect/vect-ivdep-2.c (test for excess errors)
gcc.dg/vect/vect-ivdep-2.c -flto -ffat-lto-objects (test for excess errors)

FAIL: gcc.dg/vect/vect-ivdep-1.c (test for excess errors)
Excess errors:
/usr/local/gcc/gcc-20180929/gcc/testsuite/gcc.dg/vect/vect-ivdep-1.c:11:3: optimized:  loop versioned for vectorization to enhance alignment

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2018-09-29 23:06 ` Andreas Schwab
@ 2018-10-01 14:20   ` David Malcolm
  2018-10-01 14:29     ` Andreas Schwab
  0 siblings, 1 reply; 17+ messages in thread
From: David Malcolm @ 2018-10-01 14:20 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: gcc-patches

On Sun, 2018-09-30 at 00:12 +0200, Andreas Schwab wrote:
> That produces extra output that breaks a few tests.
> 
> g++.dg/vect/pr33426-ivdep-2.cc  -std=c++11 (test for excess errors)
> g++.dg/vect/pr33426-ivdep-2.cc  -std=c++14 (test for excess errors)
> g++.dg/vect/pr33426-ivdep-2.cc  -std=c++98 (test for excess errors)
> g++.dg/vect/pr33426-ivdep-3.cc   (test for excess errors)
> g++.dg/vect/pr33426-ivdep-4.cc   (test for excess errors)
> g++.dg/vect/pr33426-ivdep.cc  -std=c++11 (test for excess errors)
> g++.dg/vect/pr33426-ivdep.cc  -std=c++14 (test for excess errors)
> g++.dg/vect/pr33426-ivdep.cc  -std=c++98 (test for excess errors)
> gcc.dg/vect/nodump-vect-opt-info-1.c (test for excess errors)
> gcc.dg/vect/vect-ivdep-1.c (test for excess errors)
> gcc.dg/vect/vect-ivdep-1.c -flto -ffat-lto-objects (test for excess
> errors)
> gcc.dg/vect/vect-ivdep-2.c (test for excess errors)
> gcc.dg/vect/vect-ivdep-2.c -flto -ffat-lto-objects (test for excess
> errors)
> 
> FAIL: gcc.dg/vect/vect-ivdep-1.c (test for excess errors)
> Excess errors:
> /usr/local/gcc/gcc-20180929/gcc/testsuite/gcc.dg/vect/vect-ivdep-
> 1.c:11:3: optimized:  loop versioned for vectorization to enhance
> alignment

Thanks for the report; sorry about the breakage.

What target is this for?  I'm not seeing these issues on x86_64-pc-
linux-gnu.

I think that what's happening is that my patch changed various existing
dump messages from -fopt-info from being "note: " to being "optimized:
" or "missed: ".

gcc/testsuite/lib/prune.exp has:

    # Ignore informational notes.
    regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text

which strips out all notes after dg-message directives have been
checked.  Presumably these pre-existing "note: " dump messages were
being ignored, and are no longer matching that pattern.

I can see two approaches to fixing this:

(a) extend those lines in prune.exp to also ignore "optimized: " and
"missed: "

(b) figure out the criteria for when these messages appear, and add new
 dg-optimized and dg-missed directives to the tests in questions, with
suitable filters.

Is there a link to the .log files somewhere so I can see the precise
messages in question?  (e.g. are they all "loop versioned for
vectorization to enhance alignment"?).

Thanks, and sorry again about the breakage.
Dave

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2018-10-01 14:20   ` David Malcolm
@ 2018-10-01 14:29     ` Andreas Schwab
  2018-10-04 11:34       ` Rainer Orth
  0 siblings, 1 reply; 17+ messages in thread
From: Andreas Schwab @ 2018-10-01 14:29 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches

On Okt 01 2018, David Malcolm <dmalcolm@redhat.com> wrote:

> Is there a link to the .log files somewhere so I can see the precise
> messages in question?  (e.g. are they all "loop versioned for
> vectorization to enhance alignment"?).

Yes, they are all the same message.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2018-10-01 14:29     ` Andreas Schwab
@ 2018-10-04 11:34       ` Rainer Orth
  2018-12-05 13:57         ` Rainer Orth
  0 siblings, 1 reply; 17+ messages in thread
From: Rainer Orth @ 2018-10-04 11:34 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: David Malcolm, gcc-patches

Hi Andreas,

> On Okt 01 2018, David Malcolm <dmalcolm@redhat.com> wrote:
>
>> Is there a link to the .log files somewhere so I can see the precise
>> messages in question?  (e.g. are they all "loop versioned for
>> vectorization to enhance alignment"?).
>
> Yes, they are all the same message.

just for the record: I'm seeing exactly the same on Solaris/SPARC (32
and 64-bit).

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2018-10-04 11:34       ` Rainer Orth
@ 2018-12-05 13:57         ` Rainer Orth
  0 siblings, 0 replies; 17+ messages in thread
From: Rainer Orth @ 2018-12-05 13:57 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: David Malcolm, gcc-patches

Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> Hi Andreas,
>
>> On Okt 01 2018, David Malcolm <dmalcolm@redhat.com> wrote:
>>
>>> Is there a link to the .log files somewhere so I can see the precise
>>> messages in question?  (e.g. are they all "loop versioned for
>>> vectorization to enhance alignment"?).
>>
>> Yes, they are all the same message.
>
> just for the record: I'm seeing exactly the same on Solaris/SPARC (32
> and 64-bit).

I've now filed PR testsuite/88369 for this issue.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2018-09-25 21:55 [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION} David Malcolm
  2018-09-28  9:44 ` Richard Biener
  2018-09-29 23:06 ` Andreas Schwab
@ 2020-11-06  8:38 ` Thomas Schwinge
  2020-11-13 22:06   ` Jeff Law
  2020-11-06  8:50 ` Thomas Schwinge
  2020-11-06  9:26 ` Add 'dg-note' next to 'dg-optimized', 'dg-missed' (was: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}) Thomas Schwinge
  4 siblings, 1 reply; 17+ messages in thread
From: Thomas Schwinge @ 2020-11-06  8:38 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2419 bytes --]

Hi!

On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
> 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).

Thanks, this is very useful.


I just ran into a problem regarding these two:

> --- a/gcc/testsuite/lib/gcc-dg.exp
> +++ b/gcc/testsuite/lib/gcc-dg.exp

> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
> +# a successful optimization.
> +
> +proc dg-optimized { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    process-message saved-dg-error "optimized: " "$args"
> +}
> +
> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
> +# a missed optimization.
> +
> +proc dg-missed { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    process-message saved-dg-error "missed: " "$args"
> +}

If, in addition to the usual line location checking, you'd like to do
column location checking ("[column]: " prefix before the actual
diagnostic), and the actual diagnostic doesn't begin with whitespace,
then this currently fails.  To address this, OK to push the attached
patch "[testsuite] Enable column location checking for 'dg-optimized',
'dg-missed'" -- with or without the demonstrator
'gcc.dg/vect/nodump-vect-opt-info-1.c',
'gcc.dg/vect/nodump-vect-opt-info-2.c' changes, your call?  (I still have
to run this through regression testing.)


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-testsuite-Enable-column-location-checking-for-dg-opt.patch --]
[-- Type: text/x-diff, Size: 3501 bytes --]

From f3046b8bea6a2a6489dd10d72cb038b92aa4fc38 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 6 Nov 2020 09:18:06 +0100
Subject: [PATCH] [testsuite] Enable column location checking for
 'dg-optimized', 'dg-missed'

'process-message' would like the 'msgprefix' argument without trailing space.

This is a bug-fix for commit ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.

	gcc/testsuite/
	* lib/gcc-dg.exp (dg-optimized, dg-missed): Fix 'process-message'
	call.
	* gcc.dg/vect/nodump-vect-opt-info-1.c: Demonstrate.
	* gcc.dg/vect/nodump-vect-opt-info-2.c: Likewise.
---
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c | 4 ++--
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c | 4 ++--
 gcc/testsuite/lib/gcc-dg.exp                       | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
index 3bfe498ef0a2..6834b9a9d0b9 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
@@ -5,8 +5,8 @@ void
 vadd (int *dst, int *op1, int *op2, int count)
 {
 /* { dg-prune-output " version\[^\n\r]* alignment" } */
-/* { dg-optimized "loop vectorized" "" { target *-*-* } .+2 } */
-/* { dg-optimized "loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
+/* { dg-optimized "21: loop vectorized" "" { target *-*-* } .+2 } */
+/* { dg-optimized "21: loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
   for (int i = 0; i < count; ++i)
     dst[i] = op1[i] + op2[i];
 }
diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
index 94c55a92bb4f..23a3b39fbb32 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
@@ -6,7 +6,7 @@ extern void accumulate (int x, int *a);
 int test_missing_function_defn (int *arr, int n) /* { dg-message "vectorized 0 loops in function" } */
 {
   int sum = 0;
-  for (int i = 0; i < n; ++i) /* { dg-missed "couldn't vectorize loop" } */
-    accumulate (arr[i], &sum); /* { dg-missed "statement clobbers memory: accumulate \\(.*\\);" } */
+  for (int i = 0; i < n; ++i) /* { dg-missed "21: couldn't vectorize loop" } */
+    accumulate (arr[i], &sum); /* { dg-missed "5: statement clobbers memory: accumulate \\(.*\\);" } */
   return sum;
 }
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index e8ad3052657e..0e1aafec82f4 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1232,7 +1232,7 @@ proc dg-optimized { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "optimized: " "$args"
+    process-message saved-dg-error "optimized:" "$args"
 }
 
 # Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
@@ -1242,7 +1242,7 @@ proc dg-missed { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "missed: " "$args"
+    process-message saved-dg-error "missed:" "$args"
 }
 
 # Check the existence of a gdb in the path, and return true if there
-- 
2.17.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2018-09-25 21:55 [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION} David Malcolm
                   ` (2 preceding siblings ...)
  2020-11-06  8:38 ` Thomas Schwinge
@ 2020-11-06  8:50 ` Thomas Schwinge
  2020-11-13 22:06   ` Jeff Law
  2020-11-06  9:26 ` Add 'dg-note' next to 'dg-optimized', 'dg-missed' (was: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}) Thomas Schwinge
  4 siblings, 1 reply; 17+ messages in thread
From: Thomas Schwinge @ 2020-11-06  8:50 UTC (permalink / raw)
  To: David Malcolm, gcc-patches

Hi!

On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
> The patch adds "dg-optimized" and "dg-missed" directives

Another small thing I just noticed:

> --- a/gcc/testsuite/lib/gcc-dg.exp
> +++ b/gcc/testsuite/lib/gcc-dg.exp

> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
> +# a successful optimization.
> +
> +proc dg-optimized { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    process-message saved-dg-error "optimized: " "$args"
> +}
> +
> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
> +# a missed optimization.
> +
> +proc dg-missed { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    process-message saved-dg-error "missed: " "$args"
> +}

These currently print "(test for *errors*, line [...])".  However, these
diagnostics are not actually error diagnostics (fatal, meaning: causes
compilation to fail) but rather warning diagnostics (non-fatal, doesn't
cause compilation to fail).  Thus, same as 'dg-message', these should use
'saved-dg-warning' instead of 'saved-dg-error', which will print: "(test
for *warnings*, line [...])".  OK to change that after regression
testing?


Grüße
 Thomas
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Add 'dg-note' next to 'dg-optimized', 'dg-missed' (was: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION})
  2018-09-25 21:55 [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION} David Malcolm
                   ` (3 preceding siblings ...)
  2020-11-06  8:50 ` Thomas Schwinge
@ 2020-11-06  9:26 ` Thomas Schwinge
  2020-11-24  9:53   ` Thomas Schwinge
  4 siblings, 1 reply; 17+ messages in thread
From: Thomas Schwinge @ 2020-11-06  9:26 UTC (permalink / raw)
  To: David Malcolm, gcc-patches, Rainer Orth, Mike Stump

[-- Attachment #1: Type: text/plain, Size: 2900 bytes --]

Hi, again!

On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
> 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.

(However, 'MSG_NOTE'/'note: ' also still remains used for "general
optimization info".)

> The patch adds "dg-optimized" and "dg-missed" directives

> --- a/gcc/testsuite/lib/gcc-dg.exp
> +++ b/gcc/testsuite/lib/gcc-dg.exp

> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
> +# a successful optimization.
> +
> +proc dg-optimized { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    process-message saved-dg-error "optimized: " "$args"
> +}
> +
> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
> +# a missed optimization.
> +
> +proc dg-missed { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    process-message saved-dg-error "missed: " "$args"
> +}
> +

Next to these, I'm proposing to add 'dg-note', see attached "[WIP] Add
'dg-note' next to 'dg-optimized'", which may be used instead of generic
'dg-message' (which in current uses in testcases often doesn't scan for
the 'note: ' prefix, by the way).

The proposed 'dg-note' has the additional property that "if dg-note is
used once, [notes] must *all* be handled explicitly".  The rationale is
that either you're not interested in notes at all (default behavior of
pruning all notes), but often, when you're interested in one note, you're
in fact interested in all notes, and especially interested if
*additional* notes appear over time, as GCC evolves.  It seemed somewhat
useful, but I'm not insisting on coupling the disabling of notes pruning
on 'dg-note' usage, so if anyone feels strongly about that, please speak
up.

TODO document (also 'dg-optimized', 'dg-missed')

TODO 'gcc/testsuite/lib/lto.exp' change necessary/desirable?

The latter got added in commit 824721f0905478ebc39e6a295cc8e95c22fa9d17
"lto, testsuite: Fix ICE in -Wodr (PR lto/83121)".  David, do you happen
to have an opinion on that one?


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-WIP-Add-dg-note-next-to-dg-optimized-dg-missed.patch --]
[-- Type: text/x-diff, Size: 3982 bytes --]

From bb293fff7580025a3b78fc1619d8bf0d8f8b8a1a Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 6 Nov 2020 09:01:26 +0100
Subject: [PATCH] [WIP] Add 'dg-note' next to 'dg-optimized', 'dg-missed'

TODO document (also 'dg-optimized', 'dg-missed')

TODO 'gcc/testsuite/lib/lto.exp' change necessary/desirable?
---
 .../gcc.dg/vect/nodump-vect-opt-info-2.c      |  4 ++-
 gcc/testsuite/lib/gcc-dg.exp                  | 26 +++++++++++++++++++
 gcc/testsuite/lib/lto.exp                     |  7 +++--
 gcc/testsuite/lib/prune.exp                   |  7 +++--
 4 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
index 23a3b39fbb32..bcdf7f076715 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
@@ -3,7 +3,9 @@
 
 extern void accumulate (int x, int *a);
 
-int test_missing_function_defn (int *arr, int n) /* { dg-message "vectorized 0 loops in function" } */
+int test_missing_function_defn (int *arr, int n) /* { dg-note "5: vectorized 0 loops in function" } */
+/* { dg-prune-output "note: " } as we're not interested in matching any further
+   notes.  */
 {
   int sum = 0;
   for (int i = 0; i < n; ++i) /* { dg-missed "21: couldn't vectorize loop" } */
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 700529afbe25..c6ff07ab1376 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1012,6 +1012,8 @@ if { [info procs saved-dg-test] == [list] } {
 	    }
 	    unset save_linenr_varnames
 	}
+
+	initialize_prune_notes
     }
 
     proc dg-test { args } {
@@ -1245,6 +1247,30 @@ proc dg-missed { args } {
     process-message saved-dg-warning "missed:" "$args"
 }
 
+# Handle output from -fopt-info for MSG_NOTE:
+# a general optimization info.
+# By default, such notes are pruned, but if dg-note is used once, they must all
+# be handled explicitly.
+
+variable prune_notes
+
+proc initialize_prune_notes { } {
+    global prune_notes
+    set prune_notes 1
+}
+
+initialize_prune_notes
+
+proc dg-note { args } {
+    # Make this variable available here and to the saved proc.
+    upvar dg-messages dg-messages
+
+    global prune_notes
+    set prune_notes 0
+
+    process-message saved-dg-warning "note:" "$args"
+}
+
 # Check the existence of a gdb in the path, and return true if there
 # is one.
 #
diff --git a/gcc/testsuite/lib/lto.exp b/gcc/testsuite/lib/lto.exp
index b2fa7ec8cecb..c9ed65ffc7cb 100644
--- a/gcc/testsuite/lib/lto.exp
+++ b/gcc/testsuite/lib/lto.exp
@@ -159,8 +159,11 @@ proc lto_prune_warns { text } {
     regsub -all "(^|\n)\[ \t\]*\[\(\]file \[^\n\]* value=\[^\n\]*; file \[^\n\]* value=\[^\n\]*\[)\];" $text "" text
     regsub -all "(^|\n)\[ \t\]*\[^\n\]* definition taken" $text "" text
 
-    # Ignore informational notes.
-    regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
+    global prune_notes
+    if { $prune_notes } {
+	# Ignore informational notes.
+	regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
+    }
 
     verbose "lto_prune_warns: exit: $text" 2
 
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index 190367c44e0f..ed7dec16fa1f 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -50,8 +50,11 @@ proc prune_gcc_output { text } {
     regsub -all "(^|\n)\[0-9\]\[0-9\]* errors\." $text "" text
     regsub -all "(^|\n)(In file included|\[ \]+from)\[^\n\]*" $text "" text
 
-    # Ignore informational notes.
-    regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
+    global prune_notes
+    if { $prune_notes } {
+	# Ignore informational notes.
+	regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
+    }
 
     # Ignore harmless -fpic warnings.
     regsub -all "(^|\n)\[^\n\]*: warning: -f(pic|PIC) ignored for target\[^\n\]*" $text "" text
-- 
2.17.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2020-11-06  8:38 ` Thomas Schwinge
@ 2020-11-13 22:06   ` Jeff Law
  2020-11-24  9:46     ` Thomas Schwinge
  0 siblings, 1 reply; 17+ messages in thread
From: Jeff Law @ 2020-11-13 22:06 UTC (permalink / raw)
  To: Thomas Schwinge, David Malcolm, gcc-patches


On 11/6/20 1:38 AM, Thomas Schwinge wrote:
> Hi!
>
> On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
>> 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).
> Thanks, this is very useful.
>
>
> I just ran into a problem regarding these two:
>
>> --- a/gcc/testsuite/lib/gcc-dg.exp
>> +++ b/gcc/testsuite/lib/gcc-dg.exp
>> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
>> +# a successful optimization.
>> +
>> +proc dg-optimized { args } {
>> +    # Make this variable available here and to the saved proc.
>> +    upvar dg-messages dg-messages
>> +
>> +    process-message saved-dg-error "optimized: " "$args"
>> +}
>> +
>> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
>> +# a missed optimization.
>> +
>> +proc dg-missed { args } {
>> +    # Make this variable available here and to the saved proc.
>> +    upvar dg-messages dg-messages
>> +
>> +    process-message saved-dg-error "missed: " "$args"
>> +}
> If, in addition to the usual line location checking, you'd like to do
> column location checking ("[column]: " prefix before the actual
> diagnostic), and the actual diagnostic doesn't begin with whitespace,
> then this currently fails.  To address this, OK to push the attached
> patch "[testsuite] Enable column location checking for 'dg-optimized',
> 'dg-missed'" -- with or without the demonstrator
> 'gcc.dg/vect/nodump-vect-opt-info-1.c',
> 'gcc.dg/vect/nodump-vect-opt-info-2.c' changes, your call?  (I still have
> to run this through regression testing.)
>
>
> Grüße
>  Thomas
>
>
> -----------------
> Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
> Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter
>
> 0001-testsuite-Enable-column-location-checking-for-dg-opt.patch
>
> From f3046b8bea6a2a6489dd10d72cb038b92aa4fc38 Mon Sep 17 00:00:00 2001
> From: Thomas Schwinge <thomas@codesourcery.com>
> Date: Fri, 6 Nov 2020 09:18:06 +0100
> Subject: [PATCH] [testsuite] Enable column location checking for
>  'dg-optimized', 'dg-missed'
>
> 'process-message' would like the 'msgprefix' argument without trailing space.
>
> This is a bug-fix for commit ed2d9d3720adef3a260b8a55e17e744352a901fc
> "dumpfile.c: use prefixes other than 'note: ' for
> MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
> 'dg-missed'.
>
> 	gcc/testsuite/
> 	* lib/gcc-dg.exp (dg-optimized, dg-missed): Fix 'process-message'
> 	call.
> 	* gcc.dg/vect/nodump-vect-opt-info-1.c: Demonstrate.
> 	* gcc.dg/vect/nodump-vect-opt-info-2.c: Likewise.

OK

jeff



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2020-11-06  8:50 ` Thomas Schwinge
@ 2020-11-13 22:06   ` Jeff Law
  2020-11-24  9:51     ` Thomas Schwinge
  0 siblings, 1 reply; 17+ messages in thread
From: Jeff Law @ 2020-11-13 22:06 UTC (permalink / raw)
  To: Thomas Schwinge, David Malcolm, gcc-patches


On 11/6/20 1:50 AM, Thomas Schwinge wrote:
> Hi!
>
> On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
>> The patch adds "dg-optimized" and "dg-missed" directives
> Another small thing I just noticed:
>
>> --- a/gcc/testsuite/lib/gcc-dg.exp
>> +++ b/gcc/testsuite/lib/gcc-dg.exp
>> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
>> +# a successful optimization.
>> +
>> +proc dg-optimized { args } {
>> +    # Make this variable available here and to the saved proc.
>> +    upvar dg-messages dg-messages
>> +
>> +    process-message saved-dg-error "optimized: " "$args"
>> +}
>> +
>> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
>> +# a missed optimization.
>> +
>> +proc dg-missed { args } {
>> +    # Make this variable available here and to the saved proc.
>> +    upvar dg-messages dg-messages
>> +
>> +    process-message saved-dg-error "missed: " "$args"
>> +}
> These currently print "(test for *errors*, line [...])".  However, these
> diagnostics are not actually error diagnostics (fatal, meaning: causes
> compilation to fail) but rather warning diagnostics (non-fatal, doesn't
> cause compilation to fail).  Thus, same as 'dg-message', these should use
> 'saved-dg-warning' instead of 'saved-dg-error', which will print: "(test
> for *warnings*, line [...])".  OK to change that after regression
> testing?

Yes.

jeff


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2020-11-13 22:06   ` Jeff Law
@ 2020-11-24  9:46     ` Thomas Schwinge
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Schwinge @ 2020-11-24  9:46 UTC (permalink / raw)
  To: Jeff Law, David Malcolm, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 852 bytes --]

Hi!

On 2020-11-13T15:06:24-0700, Jeff Law <law@redhat.com> wrote:
> On 11/6/20 1:38 AM, Thomas Schwinge wrote:
>> Subject: [PATCH] [testsuite] Enable column location checking for
>>  'dg-optimized', 'dg-missed'

> OK

Thanks, pushed "[testsuite] Enable column location checking for
'dg-optimized', 'dg-missed'" to master branch in commit
24b553d0f73ffea2551a77c67859ad6fe44110a6, and backported to
releases/gcc-10 branch in commit
f696775c43cc38233b037bf677f72b9b9c0b2cba, and releases/gcc-9 branch in
commit c71d97549d4dca17d452b4a47e406c5f6b2a1a56, see attached.
(Functionality not present in releases/gcc-8 branch.)


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-testsuite-Enable-column-location-checking-for-dg-opt.patch --]
[-- Type: text/x-diff, Size: 3501 bytes --]

From 24b553d0f73ffea2551a77c67859ad6fe44110a6 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 6 Nov 2020 09:18:06 +0100
Subject: [PATCH] [testsuite] Enable column location checking for
 'dg-optimized', 'dg-missed'

'process-message' would like the 'msgprefix' argument without trailing space.

This is a small bug-fix for commit ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.

	gcc/testsuite/
	* lib/gcc-dg.exp (dg-optimized, dg-missed): Fix 'process-message'
	call.
	* gcc.dg/vect/nodump-vect-opt-info-1.c: Demonstrate.
	* gcc.dg/vect/nodump-vect-opt-info-2.c: Likewise.
---
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c | 4 ++--
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c | 4 ++--
 gcc/testsuite/lib/gcc-dg.exp                       | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
index 3bfe498ef0a..6834b9a9d0b 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
@@ -5,8 +5,8 @@ void
 vadd (int *dst, int *op1, int *op2, int count)
 {
 /* { dg-prune-output " version\[^\n\r]* alignment" } */
-/* { dg-optimized "loop vectorized" "" { target *-*-* } .+2 } */
-/* { dg-optimized "loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
+/* { dg-optimized "21: loop vectorized" "" { target *-*-* } .+2 } */
+/* { dg-optimized "21: loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
   for (int i = 0; i < count; ++i)
     dst[i] = op1[i] + op2[i];
 }
diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
index 94c55a92bb4..23a3b39fbb3 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
@@ -6,7 +6,7 @@ extern void accumulate (int x, int *a);
 int test_missing_function_defn (int *arr, int n) /* { dg-message "vectorized 0 loops in function" } */
 {
   int sum = 0;
-  for (int i = 0; i < n; ++i) /* { dg-missed "couldn't vectorize loop" } */
-    accumulate (arr[i], &sum); /* { dg-missed "statement clobbers memory: accumulate \\(.*\\);" } */
+  for (int i = 0; i < n; ++i) /* { dg-missed "21: couldn't vectorize loop" } */
+    accumulate (arr[i], &sum); /* { dg-missed "5: statement clobbers memory: accumulate \\(.*\\);" } */
   return sum;
 }
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index e8ad3052657..0e1aafec82f 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1232,7 +1232,7 @@ proc dg-optimized { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "optimized: " "$args"
+    process-message saved-dg-error "optimized:" "$args"
 }
 
 # Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
@@ -1242,7 +1242,7 @@ proc dg-missed { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "missed: " "$args"
+    process-message saved-dg-error "missed:" "$args"
 }
 
 # Check the existence of a gdb in the path, and return true if there
-- 
2.17.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-testsuite-Enable-column-location-checking-for-dg.g10.patch --]
[-- Type: text/x-diff, Size: 3568 bytes --]

From f696775c43cc38233b037bf677f72b9b9c0b2cba Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 6 Nov 2020 09:18:06 +0100
Subject: [PATCH] [testsuite] Enable column location checking for
 'dg-optimized', 'dg-missed'

'process-message' would like the 'msgprefix' argument without trailing space.

This is a small bug-fix for commit ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.

	gcc/testsuite/
	* lib/gcc-dg.exp (dg-optimized, dg-missed): Fix 'process-message'
	call.
	* gcc.dg/vect/nodump-vect-opt-info-1.c: Demonstrate.
	* gcc.dg/vect/nodump-vect-opt-info-2.c: Likewise.

(cherry picked from commit 24b553d0f73ffea2551a77c67859ad6fe44110a6)
---
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c | 4 ++--
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c | 4 ++--
 gcc/testsuite/lib/gcc-dg.exp                       | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
index 3bfe498ef0a..1bc35d9ec5f 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
@@ -5,8 +5,8 @@ void
 vadd (int *dst, int *op1, int *op2, int count)
 {
 /* { dg-prune-output " version\[^\n\r]* alignment" } */
-/* { dg-optimized "loop vectorized" "" { target *-*-* } .+2 } */
-/* { dg-optimized "loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
+/* { dg-optimized "3: loop vectorized" "" { target *-*-* } .+2 } */
+/* { dg-optimized "3: loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
   for (int i = 0; i < count; ++i)
     dst[i] = op1[i] + op2[i];
 }
diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
index 94c55a92bb4..c426d19eb41 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
@@ -6,7 +6,7 @@ extern void accumulate (int x, int *a);
 int test_missing_function_defn (int *arr, int n) /* { dg-message "vectorized 0 loops in function" } */
 {
   int sum = 0;
-  for (int i = 0; i < n; ++i) /* { dg-missed "couldn't vectorize loop" } */
-    accumulate (arr[i], &sum); /* { dg-missed "statement clobbers memory: accumulate \\(.*\\);" } */
+  for (int i = 0; i < n; ++i) /* { dg-missed "3: couldn't vectorize loop" } */
+    accumulate (arr[i], &sum); /* { dg-missed "5: statement clobbers memory: accumulate \\(.*\\);" } */
   return sum;
 }
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 45d97024883..cc331214a1f 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1216,7 +1216,7 @@ proc dg-optimized { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "optimized: " "$args"
+    process-message saved-dg-error "optimized:" "$args"
 }
 
 # Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
@@ -1226,7 +1226,7 @@ proc dg-missed { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "missed: " "$args"
+    process-message saved-dg-error "missed:" "$args"
 }
 
 # Check the existence of a gdb in the path, and return true if there
-- 
2.17.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-testsuite-Enable-column-location-checking-for-dg-.g9.patch --]
[-- Type: text/x-diff, Size: 3568 bytes --]

From c71d97549d4dca17d452b4a47e406c5f6b2a1a56 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 6 Nov 2020 09:18:06 +0100
Subject: [PATCH] [testsuite] Enable column location checking for
 'dg-optimized', 'dg-missed'

'process-message' would like the 'msgprefix' argument without trailing space.

This is a small bug-fix for commit ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.

	gcc/testsuite/
	* lib/gcc-dg.exp (dg-optimized, dg-missed): Fix 'process-message'
	call.
	* gcc.dg/vect/nodump-vect-opt-info-1.c: Demonstrate.
	* gcc.dg/vect/nodump-vect-opt-info-2.c: Likewise.

(cherry picked from commit 24b553d0f73ffea2551a77c67859ad6fe44110a6)
---
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c | 4 ++--
 gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c | 4 ++--
 gcc/testsuite/lib/gcc-dg.exp                       | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
index 3bfe498ef0a..1bc35d9ec5f 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-1.c
@@ -5,8 +5,8 @@ void
 vadd (int *dst, int *op1, int *op2, int count)
 {
 /* { dg-prune-output " version\[^\n\r]* alignment" } */
-/* { dg-optimized "loop vectorized" "" { target *-*-* } .+2 } */
-/* { dg-optimized "loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
+/* { dg-optimized "3: loop vectorized" "" { target *-*-* } .+2 } */
+/* { dg-optimized "3: loop versioned for vectorization because of possible aliasing" "" { target *-*-* } .+1 } */
   for (int i = 0; i < count; ++i)
     dst[i] = op1[i] + op2[i];
 }
diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
index 94c55a92bb4..c426d19eb41 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
@@ -6,7 +6,7 @@ extern void accumulate (int x, int *a);
 int test_missing_function_defn (int *arr, int n) /* { dg-message "vectorized 0 loops in function" } */
 {
   int sum = 0;
-  for (int i = 0; i < n; ++i) /* { dg-missed "couldn't vectorize loop" } */
-    accumulate (arr[i], &sum); /* { dg-missed "statement clobbers memory: accumulate \\(.*\\);" } */
+  for (int i = 0; i < n; ++i) /* { dg-missed "3: couldn't vectorize loop" } */
+    accumulate (arr[i], &sum); /* { dg-missed "5: statement clobbers memory: accumulate \\(.*\\);" } */
   return sum;
 }
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 547b6465d74..c2600f2b746 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1225,7 +1225,7 @@ proc dg-optimized { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "optimized: " "$args"
+    process-message saved-dg-error "optimized:" "$args"
 }
 
 # Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
@@ -1235,7 +1235,7 @@ proc dg-missed { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "missed: " "$args"
+    process-message saved-dg-error "missed:" "$args"
 }
 
 # Check the existence of a gdb in the path, and return true if there
-- 
2.17.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}
  2020-11-13 22:06   ` Jeff Law
@ 2020-11-24  9:51     ` Thomas Schwinge
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Schwinge @ 2020-11-24  9:51 UTC (permalink / raw)
  To: Jeff Law, David Malcolm, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

Hi!

On 2020-11-13T15:06:45-0700, Jeff Law <law@redhat.com> wrote:
> On 11/6/20 1:50 AM, Thomas Schwinge wrote:
>> On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
>>> The patch adds "dg-optimized" and "dg-missed" directives

>> These currently print "(test for *errors*, line [...])".  However, these
>> diagnostics are not actually error diagnostics (fatal, meaning: causes
>> compilation to fail) but rather warning diagnostics (non-fatal, doesn't
>> cause compilation to fail).  Thus, same as 'dg-message', these should use
>> 'saved-dg-warning' instead of 'saved-dg-error', which will print: "(test
>> for *warnings*, line [...])".  OK to change that after regression
>> testing?
>
> Yes.

Thanks, pushed "[testsuite] Emit 'warning' instead of 'error' diagnostics
for 'dg-optimized', 'dg-missed'" to master branch in commit
54f72078fc05b865601645edafbc6b21701ea546, and backported to
releases/gcc-10 branch in commit
51bec3f6aa1218aeaa8e5e8cdef28fe712ba2902, and releases/gcc-9 branch in
commit b5eabef5daa1393763f2f6df6562d0c4c8ef63ab, see attached.
(Functionality not present in releases/gcc-8 branch.)


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-testsuite-Emit-warning-instead-of-error-diagnostics-.patch --]
[-- Type: text/x-diff, Size: 1961 bytes --]

From 54f72078fc05b865601645edafbc6b21701ea546 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 6 Nov 2020 09:51:16 +0100
Subject: [PATCH] [testsuite] Emit 'warning' instead of 'error' diagnostics for
 'dg-optimized', 'dg-missed'

The diagnostics produced by 'dg-optimized', 'dg-missed' aren't error
diagnostics (fatal, meaning: causes compilation to fail) but rather warning
diagnostics (non-fatal, doesn't cause compilation to fail).  Thus, same as
'dg-message', these should use 'saved-dg-warning' instead of 'saved-dg-error',
which then prints: "(test for *warnings*, line [...]) instead of currently:
"(test for *errors*, line [...])".

This is a small bug-fix for commit ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.

	gcc/testsuite/
	* lib/gcc-dg.exp (dg-optimized, dg-missed): Use 'saved-dg-warning'
	instead of 'saved-dg-error'.
---
 gcc/testsuite/lib/gcc-dg.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 0e1aafec82f..700529afbe2 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1232,7 +1232,7 @@ proc dg-optimized { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "optimized:" "$args"
+    process-message saved-dg-warning "optimized:" "$args"
 }
 
 # Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
@@ -1242,7 +1242,7 @@ proc dg-missed { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "missed:" "$args"
+    process-message saved-dg-warning "missed:" "$args"
 }
 
 # Check the existence of a gdb in the path, and return true if there
-- 
2.17.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-testsuite-Emit-warning-instead-of-error-diagnost.g10.patch --]
[-- Type: text/x-diff, Size: 2031 bytes --]

From 51bec3f6aa1218aeaa8e5e8cdef28fe712ba2902 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 6 Nov 2020 09:51:16 +0100
Subject: [PATCH] [testsuite] Emit 'warning' instead of 'error' diagnostics for
 'dg-optimized', 'dg-missed'

The diagnostics produced by 'dg-optimized', 'dg-missed' aren't error
diagnostics (fatal, meaning: causes compilation to fail) but rather warning
diagnostics (non-fatal, doesn't cause compilation to fail).  Thus, same as
'dg-message', these should use 'saved-dg-warning' instead of 'saved-dg-error',
which then prints: "(test for *warnings*, line [...]) instead of currently:
"(test for *errors*, line [...])".

This is a small bug-fix for commit ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.

	gcc/testsuite/
	* lib/gcc-dg.exp (dg-optimized, dg-missed): Use 'saved-dg-warning'
	instead of 'saved-dg-error'.

(cherry picked from commit 54f72078fc05b865601645edafbc6b21701ea546)
---
 gcc/testsuite/lib/gcc-dg.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index cc331214a1f..58519b0421b 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1216,7 +1216,7 @@ proc dg-optimized { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "optimized:" "$args"
+    process-message saved-dg-warning "optimized:" "$args"
 }
 
 # Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
@@ -1226,7 +1226,7 @@ proc dg-missed { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "missed:" "$args"
+    process-message saved-dg-warning "missed:" "$args"
 }
 
 # Check the existence of a gdb in the path, and return true if there
-- 
2.17.1


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-testsuite-Emit-warning-instead-of-error-diagnosti.g9.patch --]
[-- Type: text/x-diff, Size: 2031 bytes --]

From b5eabef5daa1393763f2f6df6562d0c4c8ef63ab Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Fri, 6 Nov 2020 09:51:16 +0100
Subject: [PATCH] [testsuite] Emit 'warning' instead of 'error' diagnostics for
 'dg-optimized', 'dg-missed'

The diagnostics produced by 'dg-optimized', 'dg-missed' aren't error
diagnostics (fatal, meaning: causes compilation to fail) but rather warning
diagnostics (non-fatal, doesn't cause compilation to fail).  Thus, same as
'dg-message', these should use 'saved-dg-warning' instead of 'saved-dg-error',
which then prints: "(test for *warnings*, line [...]) instead of currently:
"(test for *errors*, line [...])".

This is a small bug-fix for commit ed2d9d3720adef3a260b8a55e17e744352a901fc
"dumpfile.c: use prefixes other than 'note: ' for
MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}", which added 'dg-optimized',
'dg-missed'.

	gcc/testsuite/
	* lib/gcc-dg.exp (dg-optimized, dg-missed): Use 'saved-dg-warning'
	instead of 'saved-dg-error'.

(cherry picked from commit 54f72078fc05b865601645edafbc6b21701ea546)
---
 gcc/testsuite/lib/gcc-dg.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index c2600f2b746..b756f7c80f9 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1225,7 +1225,7 @@ proc dg-optimized { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "optimized:" "$args"
+    process-message saved-dg-warning "optimized:" "$args"
 }
 
 # Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
@@ -1235,7 +1235,7 @@ proc dg-missed { args } {
     # Make this variable available here and to the saved proc.
     upvar dg-messages dg-messages
 
-    process-message saved-dg-error "missed:" "$args"
+    process-message saved-dg-warning "missed:" "$args"
 }
 
 # Check the existence of a gdb in the path, and return true if there
-- 
2.17.1


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Add 'dg-note' next to 'dg-optimized', 'dg-missed' (was: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION})
  2020-11-06  9:26 ` Add 'dg-note' next to 'dg-optimized', 'dg-missed' (was: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}) Thomas Schwinge
@ 2020-11-24  9:53   ` Thomas Schwinge
  2020-11-30 19:28     ` Jeff Law
  0 siblings, 1 reply; 17+ messages in thread
From: Thomas Schwinge @ 2020-11-24  9:53 UTC (permalink / raw)
  To: David Malcolm, gcc-patches, Rainer Orth, Mike Stump

Hi!

Ping.


Grüße
 Thomas


On 2020-11-06T10:26:46+0100, I wrote:
> Hi, again!
>
> On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
>> 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.
>
> (However, 'MSG_NOTE'/'note: ' also still remains used for "general
> optimization info".)
>
>> The patch adds "dg-optimized" and "dg-missed" directives
>
>> --- a/gcc/testsuite/lib/gcc-dg.exp
>> +++ b/gcc/testsuite/lib/gcc-dg.exp
>
>> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
>> +# a successful optimization.
>> +
>> +proc dg-optimized { args } {
>> +    # Make this variable available here and to the saved proc.
>> +    upvar dg-messages dg-messages
>> +
>> +    process-message saved-dg-error "optimized: " "$args"
>> +}
>> +
>> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
>> +# a missed optimization.
>> +
>> +proc dg-missed { args } {
>> +    # Make this variable available here and to the saved proc.
>> +    upvar dg-messages dg-messages
>> +
>> +    process-message saved-dg-error "missed: " "$args"
>> +}
>> +
>
> Next to these, I'm proposing to add 'dg-note', see attached "[WIP] Add
> 'dg-note' next to 'dg-optimized'", which may be used instead of generic
> 'dg-message' (which in current uses in testcases often doesn't scan for
> the 'note: ' prefix, by the way).
>
> The proposed 'dg-note' has the additional property that "if dg-note is
> used once, [notes] must *all* be handled explicitly".  The rationale is
> that either you're not interested in notes at all (default behavior of
> pruning all notes), but often, when you're interested in one note, you're
> in fact interested in all notes, and especially interested if
> *additional* notes appear over time, as GCC evolves.  It seemed somewhat
> useful, but I'm not insisting on coupling the disabling of notes pruning
> on 'dg-note' usage, so if anyone feels strongly about that, please speak
> up.
>
> TODO document (also 'dg-optimized', 'dg-missed')
>
> TODO 'gcc/testsuite/lib/lto.exp' change necessary/desirable?
>
> The latter got added in commit 824721f0905478ebc39e6a295cc8e95c22fa9d17
> "lto, testsuite: Fix ICE in -Wodr (PR lto/83121)".  David, do you happen
> to have an opinion on that one?
>
>
> Grüße
>  Thomas
>
>
> From bb293fff7580025a3b78fc1619d8bf0d8f8b8a1a Mon Sep 17 00:00:00 2001
> From: Thomas Schwinge <thomas@codesourcery.com>
> Date: Fri, 6 Nov 2020 09:01:26 +0100
> Subject: [PATCH] [WIP] Add 'dg-note' next to 'dg-optimized', 'dg-missed'
>
> TODO document (also 'dg-optimized', 'dg-missed')
>
> TODO 'gcc/testsuite/lib/lto.exp' change necessary/desirable?
> ---
>  .../gcc.dg/vect/nodump-vect-opt-info-2.c      |  4 ++-
>  gcc/testsuite/lib/gcc-dg.exp                  | 26 +++++++++++++++++++
>  gcc/testsuite/lib/lto.exp                     |  7 +++--
>  gcc/testsuite/lib/prune.exp                   |  7 +++--
>  4 files changed, 39 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
> index 23a3b39fbb32..bcdf7f076715 100644
> --- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
> +++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
> @@ -3,7 +3,9 @@
>
>  extern void accumulate (int x, int *a);
>
> -int test_missing_function_defn (int *arr, int n) /* { dg-message "vectorized 0 loops in function" } */
> +int test_missing_function_defn (int *arr, int n) /* { dg-note "5: vectorized 0 loops in function" } */
> +/* { dg-prune-output "note: " } as we're not interested in matching any further
> +   notes.  */
>  {
>    int sum = 0;
>    for (int i = 0; i < n; ++i) /* { dg-missed "21: couldn't vectorize loop" } */
> diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
> index 700529afbe25..c6ff07ab1376 100644
> --- a/gcc/testsuite/lib/gcc-dg.exp
> +++ b/gcc/testsuite/lib/gcc-dg.exp
> @@ -1012,6 +1012,8 @@ if { [info procs saved-dg-test] == [list] } {
>           }
>           unset save_linenr_varnames
>       }
> +
> +     initialize_prune_notes
>      }
>
>      proc dg-test { args } {
> @@ -1245,6 +1247,30 @@ proc dg-missed { args } {
>      process-message saved-dg-warning "missed:" "$args"
>  }
>
> +# Handle output from -fopt-info for MSG_NOTE:
> +# a general optimization info.
> +# By default, such notes are pruned, but if dg-note is used once, they must all
> +# be handled explicitly.
> +
> +variable prune_notes
> +
> +proc initialize_prune_notes { } {
> +    global prune_notes
> +    set prune_notes 1
> +}
> +
> +initialize_prune_notes
> +
> +proc dg-note { args } {
> +    # Make this variable available here and to the saved proc.
> +    upvar dg-messages dg-messages
> +
> +    global prune_notes
> +    set prune_notes 0
> +
> +    process-message saved-dg-warning "note:" "$args"
> +}
> +
>  # Check the existence of a gdb in the path, and return true if there
>  # is one.
>  #
> diff --git a/gcc/testsuite/lib/lto.exp b/gcc/testsuite/lib/lto.exp
> index b2fa7ec8cecb..c9ed65ffc7cb 100644
> --- a/gcc/testsuite/lib/lto.exp
> +++ b/gcc/testsuite/lib/lto.exp
> @@ -159,8 +159,11 @@ proc lto_prune_warns { text } {
>      regsub -all "(^|\n)\[ \t\]*\[\(\]file \[^\n\]* value=\[^\n\]*; file \[^\n\]* value=\[^\n\]*\[)\];" $text "" text
>      regsub -all "(^|\n)\[ \t\]*\[^\n\]* definition taken" $text "" text
>
> -    # Ignore informational notes.
> -    regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
> +    global prune_notes
> +    if { $prune_notes } {
> +     # Ignore informational notes.
> +     regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
> +    }
>
>      verbose "lto_prune_warns: exit: $text" 2
>
> diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
> index 190367c44e0f..ed7dec16fa1f 100644
> --- a/gcc/testsuite/lib/prune.exp
> +++ b/gcc/testsuite/lib/prune.exp
> @@ -50,8 +50,11 @@ proc prune_gcc_output { text } {
>      regsub -all "(^|\n)\[0-9\]\[0-9\]* errors\." $text "" text
>      regsub -all "(^|\n)(In file included|\[ \]+from)\[^\n\]*" $text "" text
>
> -    # Ignore informational notes.
> -    regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
> +    global prune_notes
> +    if { $prune_notes } {
> +     # Ignore informational notes.
> +     regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
> +    }
>
>      # Ignore harmless -fpic warnings.
>      regsub -all "(^|\n)\[^\n\]*: warning: -f(pic|PIC) ignored for target\[^\n\]*" $text "" text
> --
> 2.17.1
-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Add 'dg-note' next to 'dg-optimized', 'dg-missed' (was: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION})
  2020-11-24  9:53   ` Thomas Schwinge
@ 2020-11-30 19:28     ` Jeff Law
  2021-05-18 10:46       ` Add 'dg-note', 'dg-lto-note' (was: Add 'dg-note' next to 'dg-optimized', 'dg-missed') Thomas Schwinge
  0 siblings, 1 reply; 17+ messages in thread
From: Jeff Law @ 2020-11-30 19:28 UTC (permalink / raw)
  To: Thomas Schwinge, David Malcolm, gcc-patches, Rainer Orth, Mike Stump



On 11/24/20 2:53 AM, Thomas Schwinge wrote:
> Hi!
>
> Ping.
>
>
> Grüße
>  Thomas
>
>
> On 2020-11-06T10:26:46+0100, I wrote:
>> Hi, again!
>>
>> On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
>>> 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.
>> (However, 'MSG_NOTE'/'note: ' also still remains used for "general
>> optimization info".)
>>
>>> The patch adds "dg-optimized" and "dg-missed" directives
>>> --- a/gcc/testsuite/lib/gcc-dg.exp
>>> +++ b/gcc/testsuite/lib/gcc-dg.exp
>>> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
>>> +# a successful optimization.
>>> +
>>> +proc dg-optimized { args } {
>>> +    # Make this variable available here and to the saved proc.
>>> +    upvar dg-messages dg-messages
>>> +
>>> +    process-message saved-dg-error "optimized: " "$args"
>>> +}
>>> +
>>> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
>>> +# a missed optimization.
>>> +
>>> +proc dg-missed { args } {
>>> +    # Make this variable available here and to the saved proc.
>>> +    upvar dg-messages dg-messages
>>> +
>>> +    process-message saved-dg-error "missed: " "$args"
>>> +}
>>> +
>> Next to these, I'm proposing to add 'dg-note', see attached "[WIP] Add
>> 'dg-note' next to 'dg-optimized'", which may be used instead of generic
>> 'dg-message' (which in current uses in testcases often doesn't scan for
>> the 'note: ' prefix, by the way).
>>
>> The proposed 'dg-note' has the additional property that "if dg-note is
>> used once, [notes] must *all* be handled explicitly".  The rationale is
>> that either you're not interested in notes at all (default behavior of
>> pruning all notes), but often, when you're interested in one note, you're
>> in fact interested in all notes, and especially interested if
>> *additional* notes appear over time, as GCC evolves.  It seemed somewhat
>> useful, but I'm not insisting on coupling the disabling of notes pruning
>> on 'dg-note' usage, so if anyone feels strongly about that, please speak
>> up.
>>
>> TODO document (also 'dg-optimized', 'dg-missed')
>>
>> TODO 'gcc/testsuite/lib/lto.exp' change necessary/desirable?
>>
>> The latter got added in commit 824721f0905478ebc39e6a295cc8e95c22fa9d17
>> "lto, testsuite: Fix ICE in -Wodr (PR lto/83121)".  David, do you happen
>> to have an opinion on that one?
>>
>>
>> Grüße
>>  Thomas
>>
>>
>> From bb293fff7580025a3b78fc1619d8bf0d8f8b8a1a Mon Sep 17 00:00:00 2001
>> From: Thomas Schwinge <thomas@codesourcery.com>
>> Date: Fri, 6 Nov 2020 09:01:26 +0100
>> Subject: [PATCH] [WIP] Add 'dg-note' next to 'dg-optimized', 'dg-missed'
>>
>> TODO document (also 'dg-optimized', 'dg-missed')
>>
>> TODO 'gcc/testsuite/lib/lto.exp' change necessary/desirable?
I think this is generally fine with the proper doc updates.  I wouldn't
think we'd want/need to treat LTO differently, so I'm not so sure about
that specific hunk.


Jeff


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Add 'dg-note', 'dg-lto-note' (was: Add 'dg-note' next to 'dg-optimized', 'dg-missed')
  2020-11-30 19:28     ` Jeff Law
@ 2021-05-18 10:46       ` Thomas Schwinge
  0 siblings, 0 replies; 17+ messages in thread
From: Thomas Schwinge @ 2021-05-18 10:46 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 3899 bytes --]

Hi!

On 2020-11-30T12:28:31-0700, Jeff Law via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> On 11/24/20 2:53 AM, Thomas Schwinge wrote:
>> On 2020-11-06T10:26:46+0100, I wrote:
>>> On 2018-09-25T16:00:14-0400, David Malcolm <dmalcolm@redhat.com> wrote:
>>>> 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.
>>> (However, 'MSG_NOTE'/'note: ' also still remains used for "general
>>> optimization info".)

Well, and of course, 'note: ' prefixes have also "forever" been used for
'inform' etc. diagnostics; so my change here much more relates to
'dg-message', 'dg-warning', 'dg-error' rather than 'dg-optimized',
'dg-missed'.  ;-)

>>>> The patch adds "dg-optimized" and "dg-missed" directives
>>>> --- a/gcc/testsuite/lib/gcc-dg.exp
>>>> +++ b/gcc/testsuite/lib/gcc-dg.exp
>>>> +# Handle output from -fopt-info for MSG_OPTIMIZED_LOCATIONS:
>>>> +# a successful optimization.
>>>> +
>>>> +proc dg-optimized { args } {
>>>> +    # Make this variable available here and to the saved proc.
>>>> +    upvar dg-messages dg-messages
>>>> +
>>>> +    process-message saved-dg-error "optimized: " "$args"
>>>> +}
>>>> +
>>>> +# Handle output from -fopt-info for MSG_MISSED_OPTIMIZATION:
>>>> +# a missed optimization.
>>>> +
>>>> +proc dg-missed { args } {
>>>> +    # Make this variable available here and to the saved proc.
>>>> +    upvar dg-messages dg-messages
>>>> +
>>>> +    process-message saved-dg-error "missed: " "$args"
>>>> +}
>>>> +
>>>
>>> Next to these, I'm proposing to add 'dg-note', see attached "[WIP] Add
>>> 'dg-note' next to 'dg-optimized'", which may be used instead of generic
>>> 'dg-message' (which in current uses in testcases often doesn't scan for
>>> the 'note: ' prefix, by the way).
>>>
>>> The proposed 'dg-note' has the additional property that "if dg-note is
>>> used once, [notes] must *all* be handled explicitly".  The rationale is
>>> that either you're not interested in notes at all (default behavior of
>>> pruning all notes), but often, when you're interested in one note, you're
>>> in fact interested in all notes, and especially interested if
>>> *additional* notes appear over time, as GCC evolves.  It seemed somewhat
>>> useful, but I'm not insisting on coupling the disabling of notes pruning
>>> on 'dg-note' usage, so if anyone feels strongly about that, please speak
>>> up.

(No comments received.)

> I think this is generally fine with the proper doc updates.

ACK, thanks; done.

>>> TODO 'gcc/testsuite/lib/lto.exp' change necessary/desirable?
>>>
>>> The latter got added in commit 824721f0905478ebc39e6a295cc8e95c22fa9d17
>>> "lto, testsuite: Fix ICE in -Wodr (PR lto/83121)".  David, do you happen
>>> to have an opinion on that one?

> I wouldn't
> think we'd want/need to treat LTO differently, so I'm not so sure about
> that specific hunk.

As it should turn out -- of course ;-) -- LTO does need some special
care; added, plus a few testcases adapted, too.

I've pushed "Add 'dg-note', 'dg-lto-note'" to master branch in commit
03eb779141a29f96600cd46904b88a33c4b49a66, see attached.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank Thürauf

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-dg-note-dg-lto-note.patch --]
[-- Type: text/x-diff, Size: 22077 bytes --]

From 03eb779141a29f96600cd46904b88a33c4b49a66 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Thu, 6 May 2021 11:59:42 +0200
Subject: [PATCH] Add 'dg-note', 'dg-lto-note'

That's 'dg-message "note: [...]"' with a twist: inhibit default notes pruning,
such that "if 'dg-note' is used at least once in a testcase, [notes] are not
pruned and instead must *all* be handled explicitly".

The rationale is that either you're not interested in notes at all (default
behavior of pruning all notes), but often, when you're interested in one note,
you're in fact interested in all notes, and especially interested if
*additional* notes appear over time, as GCC evolves.

	gcc/testsuite/
	* lib/gcc-dg.exp: Implement 'dg-note'.
	* lib/prune.exp: Likewise.
	* gcc.dg/vect/nodump-vect-opt-info-2.c: Use 'dg-note', and
	'dg-prune-output "note: ".
	* gfortran.dg/goacc/routine-external-level-of-parallelism-2.f: Use
	'dg-note', match up additional notes, one class of them with
	XFAILed 'dg-bogus'.
	* lib/lto.exp: Implement 'dg-lto-note'.
	* g++.dg/lto/odr-1_0.C: Use 'dg-lto-note', match up additional
	notes.
	* g++.dg/lto/odr-1_1.C: Likewise.
	* g++.dg/lto/odr-2_1.C: Likewise.
	libstdc++-v3/
	* testsuite/lib/prune.exp: Add note about 'dg-note'.
	gcc/
	* doc/sourcebuild.texi: Document 'dg-note'.
---
 gcc/doc/sourcebuild.texi                      | 22 +++++++++++--
 gcc/testsuite/g++.dg/lto/odr-1_0.C            |  4 ++-
 gcc/testsuite/g++.dg/lto/odr-1_1.C            |  9 +++---
 gcc/testsuite/g++.dg/lto/odr-2_1.C            |  2 +-
 .../gcc.dg/vect/nodump-vect-opt-info-2.c      |  4 ++-
 .../routine-external-level-of-parallelism-2.f | 26 +++++++++++++++
 gcc/testsuite/lib/gcc-dg.exp                  | 32 +++++++++++++++++++
 gcc/testsuite/lib/lto.exp                     | 22 ++++++++++---
 gcc/testsuite/lib/prune.exp                   |  7 ++--
 libstdc++-v3/testsuite/lib/prune.exp          |  2 ++
 10 files changed, 114 insertions(+), 16 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index ceb6b995283..ed811d103a5 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -1217,6 +1217,21 @@ If there is no message for that line or if the text of that message is
 not matched by @var{regexp} then the check fails and @var{comment} is
 included in the @code{FAIL} message.
 
+@item @{ dg-note @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
+The line is expected to get a @samp{note} message.
+If there is no message for that line or if the text of that message is
+not matched by @var{regexp} then the check fails and @var{comment} is
+included in the @code{FAIL} message.
+
+By default, any @emph{excess} @samp{note} messages are pruned, meaning
+their appearance doesn't trigger @emph{excess errors}.
+However, if @samp{dg-note} is used at least once in a testcase,
+they're not pruned and instead must @emph{all} be handled explicitly.
+Thus, if looking for just single instances of messages with
+@samp{note: } prefixes without caring for all of them, use
+@samp{dg-message "note: [@dots{}]"} instead of @samp{dg-note}, or use
+@samp{dg-note} together with @samp{dg-prune-output "note: "}.
+
 @item @{ dg-bogus @var{regexp} [@var{comment} [@{ target/xfail @var{selector} @} [@var{line}] ]] @}
 This DejaGnu directive appears on a source line that should not get a
 message matching @var{regexp}, or else specifies the source line
@@ -1227,7 +1242,8 @@ targets.
 @item @{ dg-line @var{linenumvar} @}
 This DejaGnu directive sets the variable @var{linenumvar} to the line number of
 the source line.  The variable @var{linenumvar} can then be used in subsequent
-@code{dg-error}, @code{dg-warning}, @code{dg-message} and @code{dg-bogus}
+@code{dg-error}, @code{dg-warning}, @code{dg-message}, @code{dg-note}
+and @code{dg-bogus}
 directives.  For example:
 
 @smallexample
@@ -1239,7 +1255,9 @@ float a; /* @{ dg-error "conflicting types of" @} */
 @item @{ dg-excess-errors @var{comment} [@{ target/xfail @var{selector} @}] @}
 This DejaGnu directive indicates that the test is expected to fail due
 to compiler messages that are not handled by @samp{dg-error},
-@samp{dg-warning} or @samp{dg-bogus}.  For this directive @samp{xfail}
+@samp{dg-warning}, @code{dg-message}, @samp{dg-note} or
+@samp{dg-bogus}.
+For this directive @samp{xfail}
 has the same effect as @samp{target}.
 
 @item @{ dg-prune-output @var{regexp} @}
diff --git a/gcc/testsuite/g++.dg/lto/odr-1_0.C b/gcc/testsuite/g++.dg/lto/odr-1_0.C
index 6fff88844c3..318a047cb70 100644
--- a/gcc/testsuite/g++.dg/lto/odr-1_0.C
+++ b/gcc/testsuite/g++.dg/lto/odr-1_0.C
@@ -1,8 +1,10 @@
 // PR c++/82414
 // { dg-lto-do link }
 enum vals {aa,cc}; // { dg-lto-warning "6: type 'vals' violates the C\\+\\+ One Definition Rule" }
+// { dg-lto-note "name 'cc' differs from name 'bb' defined in another translation unit" "" { target *-*-* } .-1 }
 struct a { // { dg-lto-warning "8: type 'struct a' violates the C\\+\\+ One Definition Rule" }
-  struct b *ptr; // { dg-lto-message "13: the first difference of corresponding definitions is field 'ptr'" }
+  struct b *ptr; // { dg-lto-note "13: the first difference of corresponding definitions is field 'ptr'" }
+  // { dg-lto-note "the incompatible type defined in another translation unit" "" { target *-*-* } .-1 }
   enum vals vals;
 };
 void test(struct a *a)
diff --git a/gcc/testsuite/g++.dg/lto/odr-1_1.C b/gcc/testsuite/g++.dg/lto/odr-1_1.C
index 494436a46c6..a57bb3898aa 100644
--- a/gcc/testsuite/g++.dg/lto/odr-1_1.C
+++ b/gcc/testsuite/g++.dg/lto/odr-1_1.C
@@ -1,9 +1,10 @@
 namespace {
-  struct b; // { dg-lto-message "type 'struct b' defined in anonymous namespace cannot match across the translation unit boundary" }
+  struct b; // { dg-lto-note "type 'struct b' defined in anonymous namespace cannot match across the translation unit boundary" }
  }
-enum vals {aa,bb,cc}; // { dg-lto-message "an enum with different value name is defined in another translation unit" }
-struct a { // { dg-lto-message "a different type is defined in another translation unit" }
-  struct b *ptr; // { dg-lto-message "a field of same name but different type is defined in another translation unit" }
+enum vals {aa,bb,cc}; // { dg-lto-note "an enum with different value name is defined in another translation unit" }
+// { dg-lto-note "mismatching definition" "" { target *-*-* } .-1 }
+struct a { // { dg-lto-note "a different type is defined in another translation unit" }
+  struct b *ptr; // { dg-lto-note "a field of same name but different type is defined in another translation unit" }
   enum vals vals;
 } a;
 void test(struct a *);
diff --git a/gcc/testsuite/g++.dg/lto/odr-2_1.C b/gcc/testsuite/g++.dg/lto/odr-2_1.C
index f384ae893b7..23cfccc241b 100644
--- a/gcc/testsuite/g++.dg/lto/odr-2_1.C
+++ b/gcc/testsuite/g++.dg/lto/odr-2_1.C
@@ -1,4 +1,4 @@
-class a { // { dg-lto-message "a different type is defined in another translation unit" }
+class a { // { dg-lto-note "a different type is defined in another translation unit" }
   int *b() const;
 };
 int *a::b() const { return 0; }
diff --git a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
index 23a3b39fbb3..bcdf7f07671 100644
--- a/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
+++ b/gcc/testsuite/gcc.dg/vect/nodump-vect-opt-info-2.c
@@ -3,7 +3,9 @@
 
 extern void accumulate (int x, int *a);
 
-int test_missing_function_defn (int *arr, int n) /* { dg-message "vectorized 0 loops in function" } */
+int test_missing_function_defn (int *arr, int n) /* { dg-note "5: vectorized 0 loops in function" } */
+/* { dg-prune-output "note: " } as we're not interested in matching any further
+   notes.  */
 {
   int sum = 0;
   for (int i = 0; i < n; ++i) /* { dg-missed "21: couldn't vectorize loop" } */
diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-external-level-of-parallelism-2.f b/gcc/testsuite/gfortran.dg/goacc/routine-external-level-of-parallelism-2.f
index 0e8dfb19e2b..04d507fef9a 100644
--- a/gcc/testsuite/gfortran.dg/goacc/routine-external-level-of-parallelism-2.f
+++ b/gcc/testsuite/gfortran.dg/goacc/routine-external-level-of-parallelism-2.f
@@ -22,6 +22,8 @@
 ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
          do j = 1, n
             call workerr (a, n) ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
+! { dg-bogus "note: routine 'workerr' declared here" "TODO" { xfail { ! offloading_enabled } } .-1 }
+! { dg-bogus "note: routine 'workerr_' declared here" "TODO" { xfail offloading_enabled } .-2 }
          end do
       end do
 !$acc end parallel loop
@@ -30,9 +32,12 @@
 ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
       do i = 1, n
 !$acc loop gang ! { dg-message "optimized: assigned OpenACC gang loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
          do j = 1, n
             call gangr (a, n) ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
+! { dg-bogus "note: routine 'gangr' declared here" "TODO" { xfail { ! offloading_enabled } } .-2 }
+! { dg-bogus "note: routine 'gangr_' declared here" "TODO" { xfail offloading_enabled } .-3 }
          end do
       end do
 !$acc end parallel loop
@@ -83,6 +88,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop gang ! { dg-message "optimized: assigned OpenACC gang loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          call gangr (a, n) ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -90,6 +96,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop worker ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          call gangr (a, n) ! { dg-message "optimized: assigned OpenACC gang vector loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -97,6 +104,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          call gangr (a, n) ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -126,6 +134,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop worker ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          call workerr (a, n) ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -133,6 +142,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          call workerr (a, n) ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -152,6 +162,8 @@
 !$acc parallel loop ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
       do i = 1, n
          call vectorr (a, n) ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+! { dg-bogus "note: routine 'vectorr' declared here" "TODO" { xfail { ! offloading_enabled } } .-1 }
+! { dg-bogus "note: routine 'vectorr_' declared here" "TODO" { xfail offloading_enabled } .-2 }
       end do
 !$acc end parallel loop
 
@@ -168,6 +180,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          call vectorr (a, n) ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -201,6 +214,8 @@
 ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
          do j = 1, n
             a(i) = workerf (a, n) ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
+! { dg-bogus "note: routine 'workerf' declared here" "TODO" { xfail { ! offloading_enabled } } .-1 }
+! { dg-bogus "note: routine 'workerf_' declared here" "TODO" { xfail offloading_enabled } .-2 }
          end do
       end do
 !$acc end parallel loop
@@ -209,9 +224,12 @@
 ! { dg-warning "insufficient partitioning available to parallelize loop" "" { target *-*-* } .-1 }
       do i = 1, n
 !$acc loop gang ! { dg-message "optimized: assigned OpenACC gang loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
          do j = 1, n
             a(i) = gangf (a, n) ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
+! { dg-bogus "note: routine 'gangf' declared here" "TODO" { xfail { ! offloading_enabled } } .-2 }
+! { dg-bogus "note: routine 'gangf_' declared here" "TODO" { xfail offloading_enabled } .-3 }
          end do
       end do
 !$acc end parallel loop
@@ -262,6 +280,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop gang ! { dg-message "optimized: assigned OpenACC gang loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          a(i) = gangf (a, n) ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -269,6 +288,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop worker ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          a(i) = gangf (a, n) ! { dg-message "optimized: assigned OpenACC gang vector loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -276,6 +296,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          a(i) = gangf (a, n) ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -305,6 +326,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop worker ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          a(i) = workerf (a, n) ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -312,6 +334,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          a(i) = workerf (a, n) ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
@@ -331,6 +354,8 @@
 !$acc parallel loop ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
       do i = 1, n
          a(i) = vectorf (a, n) ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+! { dg-bogus "note: routine 'vectorf' declared here" "TODO" { xfail { ! offloading_enabled } } .-1 }
+! { dg-bogus "note: routine 'vectorf_' declared here" "TODO" { xfail offloading_enabled } .-2 }
       end do
 !$acc end parallel loop
 
@@ -347,6 +372,7 @@
 !$acc end parallel loop
 
 !$acc parallel loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+! { dg-note "containing loop here" "" { target *-*-* } .-1 }
       do i = 1, n
          a(i) = vectorf (a, n) ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
 ! { dg-error "routine call uses same OpenACC parallelism as containing loop" "" { target *-*-* } .-1 }
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index e48a184f991..fce0989cd9c 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1012,6 +1012,8 @@ if { [info procs saved-dg-test] == [list] } {
 	    }
 	    unset save_linenr_varnames
 	}
+
+	initialize_prune_notes
     }
 
     proc dg-test { args } {
@@ -1245,6 +1247,36 @@ proc dg-missed { args } {
     process-message saved-dg-warning "missed:" "$args"
 }
 
+# Look for messages with 'note: ' prefixes.
+# In addition to standard compiler diagnostics ('DK_NOTE', 'inform' functions,
+# "for additional details on an error message"),
+# this also includes output from '-fopt-info' for 'MSG_NOTE':
+# a general optimization info.
+# By default, any *excess* notes are pruned, meaning their appearance doesn't
+# trigger *excess errors*.  However, if 'dg-note' is used at least once in a
+# testcase, they're not pruned and instead must *all* be handled explicitly.
+# Thus, if looking for just single instances of messages with 'note: ' prefixes
+# without caring for all of them, use 'dg-message "note: [...]"' instead of
+# 'dg-note', or use 'dg-note' together with 'dg-prune-output "note: "'.
+
+variable prune_notes
+
+proc initialize_prune_notes { } {
+    global prune_notes
+    set prune_notes 1
+}
+
+initialize_prune_notes
+
+proc dg-note { args } {
+    upvar dg-messages dg-messages
+
+    global prune_notes
+    set prune_notes 0
+
+    process-message saved-dg-warning "note:" "$args"
+}
+
 # Check the existence of a gdb in the path, and return true if there
 # is one.
 #
diff --git a/gcc/testsuite/lib/lto.exp b/gcc/testsuite/lib/lto.exp
index 77919e8443b..d0e0dc60138 100644
--- a/gcc/testsuite/lib/lto.exp
+++ b/gcc/testsuite/lib/lto.exp
@@ -161,9 +161,13 @@ proc lto_prune_warns { text } {
 
     # Ignore missing jobserver for tests that do more than 1 LTRANS unit
     regsub -all "(^|\n)\[^\n\]*: warning: using serial compilation of \[^\n\]*" $text "" text
+    regsub -all "(^|\n)\[^\n\]*: note: see the \[^\n\]*'-flto' option documentation\[^\n\]* for more information" $text "" text
 
-    # Ignore informational notes.
-    regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
+    global prune_notes
+    if { $prune_notes } {
+	# Ignore informational notes.
+	regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
+    }
 
     verbose "lto_prune_warns: exit: $text" 2
 
@@ -390,8 +394,8 @@ proc lto-can-handle-directive { op } {
     # A list of directives to recognize, and a list of directives
     # to remap them to.
     # For example, "dg-lto-warning" is implemented by calling "dg-warning".
-    set directives { dg-lto-warning dg-lto-message }
-    set remapped_directives { dg-warning dg-message }
+    set directives { dg-lto-warning dg-lto-message dg-lto-note }
+    set remapped_directives { dg-warning dg-message dg-note }
 
     set idx [lsearch -exact $directives $cmd]
     if { $idx != -1 } {
@@ -597,7 +601,7 @@ proc lto-get-options { src } {
 #
 # SRC1 is the full pathname of the main file of the testcase.
 # SID identifies a test suite in the names of temporary files.
-proc lto-execute { src1 sid } {
+proc lto-execute-1 { src1 sid } {
     global srcdir tmpdir
     global lto_option_list
     global tool
@@ -811,6 +815,14 @@ proc lto-execute { src1 sid } {
     }
 }
 
+proc lto-execute { src1 sid } {
+    lto-execute-1 $src1 $sid
+
+    # LTO testing doesn't use 'dg-runtest'/'dg-test', and thus doesn't call
+    # 'cleanup-after-saved-dg-test', so we have to clean up manually.
+    initialize_prune_notes
+}
+
 # Call pass if object readelf is ok, otherwise fail.
 # example: /* { dg-final { object-readelf Tag_ABI_enum_size int} } */
 proc object-readelf { args } {
diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index 2809f88b16f..91f165bec38 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -54,8 +54,11 @@ proc prune_gcc_output { text } {
     regsub -all "(^|\n)\[ \]+from \[^\n\]*" $text "" text
     regsub -all "(^|\n)(In|of) module( \[^\n \]*,)? imported at \[^\n\]*" $text "" text
 
-    # Ignore informational notes.
-    regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
+    global prune_notes
+    if { $prune_notes } {
+	# Ignore informational notes.
+	regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
+    }
 
     # Ignore harmless -fpic warnings.
     regsub -all "(^|\n)\[^\n\]*: warning: -f(pic|PIC) ignored for target\[^\n\]*" $text "" text
diff --git a/libstdc++-v3/testsuite/lib/prune.exp b/libstdc++-v3/testsuite/lib/prune.exp
index 45c77d210d7..fd4a0ac7f97 100644
--- a/libstdc++-v3/testsuite/lib/prune.exp
+++ b/libstdc++-v3/testsuite/lib/prune.exp
@@ -52,6 +52,8 @@ proc libstdc++-dg-prune { system text } {
     regsub -all "(^|\n)\[ \t\]*from \[^\n\]*" $text "" text
 
     # Ignore informational notes.
+    #TODO As this isn't even using 'gcc-dg.exp', cannot consider its
+    # 'variable prune_notes' (for 'dg-note') here.
     regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
 
     # Ignore errata warning from IA64 assembler.
-- 
2.30.2


^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2021-05-18 10:47 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25 21:55 [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION} David Malcolm
2018-09-28  9:44 ` Richard Biener
2018-09-29 23:06 ` Andreas Schwab
2018-10-01 14:20   ` David Malcolm
2018-10-01 14:29     ` Andreas Schwab
2018-10-04 11:34       ` Rainer Orth
2018-12-05 13:57         ` Rainer Orth
2020-11-06  8:38 ` Thomas Schwinge
2020-11-13 22:06   ` Jeff Law
2020-11-24  9:46     ` Thomas Schwinge
2020-11-06  8:50 ` Thomas Schwinge
2020-11-13 22:06   ` Jeff Law
2020-11-24  9:51     ` Thomas Schwinge
2020-11-06  9:26 ` Add 'dg-note' next to 'dg-optimized', 'dg-missed' (was: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}) Thomas Schwinge
2020-11-24  9:53   ` Thomas Schwinge
2020-11-30 19:28     ` Jeff Law
2021-05-18 10:46       ` Add 'dg-note', 'dg-lto-note' (was: Add 'dg-note' next to 'dg-optimized', 'dg-missed') Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).