On Thu, Oct 31, 2013 at 09:39:11AM +0100, Jakub Jelinek wrote:
> On Thu, Oct 31, 2013 at 09:34:41AM +0100, Bernhard Reutner-Fischer wrote:
> > The cleanup routine would currently run 7 regexes on the incoming
> > compiler-flags which is supposedly pretty fast.
> > But yes, we could as well key off scan-dump. If we do that, i'd
> > suggest to simply wipe all potential dumps, regardless of the "family"
> > etc, like:
> > "$ltrans\[0-9\]\[0-9\]\[0-9\][itr].*"
> > What do you think?
> 
> Many tests (e.g. in gcc.dg/vect/) pass -fdump-* flags and require cleanups,
> even if they don't have any scan directives.

Right.

Mike, attaching a new, slightly simplified patch.

I do not have time nor interest to persue this any further.
Ok for trunk at this stage?

Otherwise i would suggest to either drop this idea altogether or that
you take over if you think this is a nice thing to have for the next
stage1.

Ontop of this patch you would have to

git grep -l -E "(cleanup-.*-dump|cleanup-saved-temps)" | egrep -v 
"(ChangeLog|/lib/)" | sed -e "s|[^/]*$||" | sort | uniq | \
while read d;
do
  find $d -type f -exec sed -i -e 
"/cleanup-[^-]*[-]*dump/d;/cleanup-saved-temps/d" {} +
done

diffstat -s:
 4874 files changed, 111 insertions(+), 5099 deletions(-)

Tested the same way as the initial incarnation against r205304 with no
regressions.
The ChangeLogs remain the same, i.e.:

gcc/testsuite/ChangeLog

2013-10-12  Bernhard Reutner-Fischer  <al...@gcc.gnu.org>

        * lib/gcc-dg.exp (cleanup-ipa-dump, cleanup-rtl-dump,
        cleanup-tree-dump, cleanup-dump): Remove. Adjust all callers.
        (schedule-cleanups): New proc.
        (gcc-dg-test-1): Call it.
        * lib/profopt.exp (profopt-execute): Likewise.
        * g++.dg/cdce3.C: Adjust expected line numbers.
        * gcc.dg/cdce1.c: Likewise.
        * gcc.dg/cdce2.c: Likewise.
        * gcc.dg/strlenopt-22.c: Fix comment delimiter.
        * gcc.dg/strlenopt-24.c: Likewise.
        * gcc.dg/tree-ssa/vrp26.c: Likewise.
        * gcc.dg/tree-ssa/vrp28.c: Likewise.
        * obj-c++.dg/encode-2.mm: Likewise.
        * lib/dg-pch.exp(pch-init): Remove pch-check objects.

libgomp/ChangeLog

2013-10-12  Bernhard Reutner-Fischer  <al...@gcc.gnu.org>

        * testsuite/libgomp.graphite/bounds.c: Adjust for
        cleanup-tree-dump removal.
        * testsuite/libgomp.graphite/force-parallel-1.c: Likewise.
        * testsuite/libgomp.graphite/force-parallel-2.c: Likewise.
        * testsuite/libgomp.graphite/force-parallel-3.c: Likewise.
        * testsuite/libgomp.graphite/force-parallel-4.c: Likewise.
        * testsuite/libgomp.graphite/force-parallel-5.c: Likewise.
        * testsuite/libgomp.graphite/force-parallel-6.c: Likewise.
        * testsuite/libgomp.graphite/force-parallel-7.c: Likewise.
        * testsuite/libgomp.graphite/force-parallel-8.c: Likewise.
        * testsuite/libgomp.graphite/force-parallel-9.c: Likewise.
        * testsuite/libgomp.graphite/pr41118.c: Likewise.


gcc/ChangeLog

2013-10-12  Bernhard Reutner-Fischer  <al...@gcc.gnu.org>

        * config/arm/neon-testgen.ml (emit_epilogue): Remove manual call
        to cleanup-saved-temps.

gcc/doc/ChangeLog

2013-10-12  Bernhard Reutner-Fischer  <al...@gcc.gnu.org>

        * doc/sourcebuild.texi (Clean up generated test files): Expand
        introduction.
        (cleanup-ipa-dump, cleanup-rtl-dump, cleanup-tree-dump,
        cleanup-saved-temps): Remove.

PS: As you can see, i had to touch a couple of files that had broken
comments like the vrp and strlenopt files. Should the testsuite
add -Wcomment per default?

cheers,
>From ac5690774eb2134b063464be56bfc56826305d01 Mon Sep 17 00:00:00 2001
From: Bernhard Reutner-Fischer <rep.dot....@gmail.com>
Date: Fri, 18 Oct 2013 21:08:49 +0200
Subject: [PATCH] auto-wipe dump files

Signed-off-by: Bernhard Reutner-Fischer <rep.dot....@gmail.com>
---
 gcc/config/arm/neon-testgen.ml        |   1 -
 gcc/doc/sourcebuild.texi              |  19 ++---
 gcc/testsuite/g++.dg/cdce3.C          |   5 +-
 gcc/testsuite/gcc.dg/cdce1.c          |   3 +-
 gcc/testsuite/gcc.dg/cdce2.c          |   3 +-
 gcc/testsuite/gcc.dg/strlenopt-22.c   |   3 +-
 gcc/testsuite/gcc.dg/strlenopt-24.c   |   3 +-
 gcc/testsuite/gcc.dg/tree-ssa/vrp26.c |   3 +-
 gcc/testsuite/gcc.dg/tree-ssa/vrp28.c |   3 +-
 gcc/testsuite/lib/dg-pch.exp          |   2 +
 gcc/testsuite/lib/gcc-dg.exp          | 134 +++++++++++++++++++++++-----------
 gcc/testsuite/lib/profopt.exp         |   3 +
 gcc/testsuite/obj-c++.dg/encode-2.mm  |   3 +-
 13 files changed, 111 insertions(+), 74 deletions(-)

diff --git a/gcc/config/arm/neon-testgen.ml b/gcc/config/arm/neon-testgen.ml
index 543318b..4734ac0 100644
--- a/gcc/config/arm/neon-testgen.ml
+++ b/gcc/config/arm/neon-testgen.ml
@@ -139,7 +139,6 @@ let emit_epilogue chan features regexps =
      else
        ()
     );
-    Printf.fprintf chan "/* { dg-final { cleanup-saved-temps } } */\n"
 
 (* Check a list of C types to determine which ones are pointers and which
    ones are const.  *)
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 2947ac8..84ca198 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -2145,13 +2145,17 @@ Check branch and/or call counts, in addition to line counts, in
 
 @subsubsection Clean up generated test files
 
+Usually the test-framework removes files that were generated during
+testing. If a testcase, for example, uses any dumping mechanism to
+inspect a passes dump file, the testsuite recognized the dumping option
+passed to the tool and schedules a final cleanup to remove these files.
+
+There are, however, following additional cleanup directives that can be
+used to annotate a testcase "manually".
 @table @code
 @item cleanup-coverage-files
 Removes coverage data files generated for this test.
 
-@item cleanup-ipa-dump @var{suffix}
-Removes IPA dump files generated for this test.
-
 @item cleanup-modules "@var{list-of-extra-modules}"
 Removes Fortran module files generated for this test, excluding the
 module names listed in keep-modules.
@@ -2192,15 +2196,6 @@ Removes profiling files generated for this test.
 @item cleanup-repo-files
 Removes files generated for this test for @option{-frepo}.
 
-@item cleanup-rtl-dump @var{suffix}
-Removes RTL dump files generated for this test.
-
-@item cleanup-saved-temps
-Removes files for the current test which were kept for @option{-save-temps}.
-
-@item cleanup-tree-dump @var{suffix}
-Removes tree dump files matching @var{suffix} which were generated for
-this test.
 @end table
 
 @node Ada Tests
diff --git a/gcc/testsuite/g++.dg/cdce3.C b/gcc/testsuite/g++.dg/cdce3.C
index 726e9ec..3937953 100644
--- a/gcc/testsuite/g++.dg/cdce3.C
+++ b/gcc/testsuite/g++.dg/cdce3.C
@@ -4,8 +4,9 @@
 /* { dg-additional-options "-DLARGE_LONG_DOUBLE" { target large_long_double } } */
 /* { dg-additional-options "-DGNU_EXTENSION" { target pow10 } } */
 /* { dg-add-options ieee } */
+/* { dg-final { scan-tree-dump  "cdce3.C:91: note: function call is shrink-wrapped into error conditions\." "cdce" { target pow10 } } } */
 /* { dg-final { scan-tree-dump  "cdce3.C:92: note: function call is shrink-wrapped into error conditions\." "cdce" { target pow10 } } } */
-/* { dg-final { scan-tree-dump  "cdce3.C:93: note: function call is shrink-wrapped into error conditions\." "cdce" { target pow10 } } } */
+/* { dg-final { scan-tree-dump  "cdce3.C:94: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
 /* { dg-final { scan-tree-dump  "cdce3.C:95: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
 /* { dg-final { scan-tree-dump  "cdce3.C:96: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
 /* { dg-final { scan-tree-dump  "cdce3.C:97: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
@@ -19,8 +20,6 @@
 /* { dg-final { scan-tree-dump  "cdce3.C:105: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
 /* { dg-final { scan-tree-dump  "cdce3.C:106: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
 /* { dg-final { scan-tree-dump  "cdce3.C:107: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
-/* { dg-final { scan-tree-dump  "cdce3.C:108: note: function call is shrink-wrapped into error conditions\." "cdce" } } */
-/* { dg-final { cleanup-tree-dump "cdce" } } */
 
 #include <stdlib.h>
 #include <math.h>
diff --git a/gcc/testsuite/gcc.dg/cdce1.c b/gcc/testsuite/gcc.dg/cdce1.c
index 2123f7f..02b47c0 100644
--- a/gcc/testsuite/gcc.dg/cdce1.c
+++ b/gcc/testsuite/gcc.dg/cdce1.c
@@ -1,8 +1,7 @@
 /* { dg-do  run  } */
 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details  -lm" } */
 /* { dg-require-effective-target int32plus } */
-/* { dg-final { scan-tree-dump  "cdce1.c:17: note: function call is shrink-wrapped into error conditions\."  "cdce" } } */
-/* { dg-final { cleanup-tree-dump "cdce" } } */
+/* { dg-final { scan-tree-dump  "cdce1.c:16: note: function call is shrink-wrapped into error conditions\."  "cdce" } } */
 /* { dg-require-effective-target large_double } */
 
 #include <stdlib.h>
diff --git a/gcc/testsuite/gcc.dg/cdce2.c b/gcc/testsuite/gcc.dg/cdce2.c
index a461ce7..dafaeab 100644
--- a/gcc/testsuite/gcc.dg/cdce2.c
+++ b/gcc/testsuite/gcc.dg/cdce2.c
@@ -1,8 +1,7 @@
 /* { dg-do  run  } */
 /* { dg-skip-if "doubles are floats" { "avr-*-*" } { "*" } { "" } } */
 /* { dg-options "-O2 -fmath-errno -fdump-tree-cdce-details  -lm" } */
-/* { dg-final { scan-tree-dump  "cdce2.c:16: note: function call is shrink-wrapped into error conditions\." "cdce" } }*/
-/* { dg-final { cleanup-tree-dump "cdce" } } */
+/* { dg-final { scan-tree-dump  "cdce2.c:15: note: function call is shrink-wrapped into error conditions\." "cdce" } }*/
  
 #include <stdlib.h>
 #include <math.h>
diff --git a/gcc/testsuite/gcc.dg/strlenopt-22.c b/gcc/testsuite/gcc.dg/strlenopt-22.c
index d6fd4df..aa55f5e 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-22.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-22.c
@@ -36,5 +36,4 @@ main ()
 /* { dg-final { scan-tree-dump-times "strcpy \\(" 1 "strlen" } } */
 /* { dg-final { scan-tree-dump-times "strcat \\(" 0 "strlen" } } */
 /* { dg-final { scan-tree-dump-times "strchr \\(" 1 "strlen" } } */
-/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } *
-/* { dg-final { cleanup-tree-dump "strlen" } } */
+/* { dg-final { scan-tree-dump-times "stpcpy \\(" 0 "strlen" } } */
diff --git a/gcc/testsuite/gcc.dg/strlenopt-24.c b/gcc/testsuite/gcc.dg/strlenopt-24.c
index 962e04f..639501a 100644
--- a/gcc/testsuite/gcc.dg/strlenopt-24.c
+++ b/gcc/testsuite/gcc.dg/strlenopt-24.c
@@ -13,5 +13,4 @@ main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } *
-/* { dg-final { cleanup-tree-dump "strlen" } } */
+/* { dg-final { scan-tree-dump-times "strlen \\(" 0 "strlen" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp26.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp26.c
index 6215416..021d2de 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp26.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp26.c
@@ -9,8 +9,7 @@ foo(int a)
 }
 
 /* VRP should optimize this to a trivial "return 1".   */
-/* { dg-final { scan-tree-dump-times "return 1" 1 "vrp1" } } * /
-/* { dg-final { cleanup-tree-dump "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "return 1" 1 "vrp1" } } */
 
 
 
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp28.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp28.c
index 6b2a1fd..8c2a72b 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp28.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp28.c
@@ -26,7 +26,6 @@ int f3 (unsigned char c)
     return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "if " 0 "vrp1" } } * /
-/* { dg-final { cleanup-tree-dump "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "if " 0 "vrp1" } } */
 
 
diff --git a/gcc/testsuite/lib/dg-pch.exp b/gcc/testsuite/lib/dg-pch.exp
index d82c669..7bc5c45 100644
--- a/gcc/testsuite/lib/dg-pch.exp
+++ b/gcc/testsuite/lib/dg-pch.exp
@@ -30,6 +30,7 @@ proc pch-init { args } {
     set pch_unsupported_debug \
 	[regexp "debug format cannot be used with pre-compiled headers" \
 		[lindex $result 0]]
+    remove-build-file [lindex $result 1]
 
     set pch_unsupported 0
     if { $pch_unsupported_debug } {
@@ -40,6 +41,7 @@ proc pch-init { args } {
 		[regexp "debug format cannot be used with pre-compiled headers" \
 			[lindex $result 0]]
     }
+    remove-build-file [lindex $result 1]
 }
 
 proc pch-finish { args } {
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index f64f4a1..07c8b8b 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -106,6 +106,95 @@ if { $orig_environment_saved == 0 } {
     set_ld_library_path_env_vars
 }
 
+# Deduce generated files from tool flags, return finalcode string
+proc schedule-cleanups { opts } {
+    global additional_sources
+    set finalcode ""
+    set testcases {}
+    lappend testcases [lindex [testname-for-summary] 0]
+    verbose "Cleanup testcases: $testcases" 4
+    if { [info exists additional_sources] && $additional_sources != "" } {
+	lappend testcases $additional_sources
+	verbose "Cleanup testcases, additional: $additional_sources" 4
+    }
+    verbose "Cleanup all options: $opts" 4
+
+    # First some fixups to transform stuff to something manageable ..
+    # --dump= should translate to -d with joined operand.
+    if [regexp -- {(^|\s+)--dump=[^\s]+(\s+|$)} $opts] {
+	regsub -all -- {--dump=} $opts {-d} opts
+    }
+    # -da and -dx are treated as shorthand for -fdump-rtl-all here
+    if [regexp -- {(^|\s+)-d[ax](\s+|$)} $opts] {
+	verbose "Cleanup -d seen" 4
+	lappend opts "-fdump-rtl-all"
+    }
+    # .. and don't question why there is --dump=? and -d?
+
+    # Then handle options that generate non-dump files
+    # TODO
+    # -fprofile-generate -> cleanup-coverage-files()
+    # -fstack-usage -> cleanup-stack-usage()
+    if [regexp -- {(^|\s+)-fstack-usage(\s+|$)} $opts] {
+	verbose "Cleanup -fstack-usage seen" 4
+#	append finalcode "cleanup-stack-usage\n"
+    }
+    # -save-temps -> cleanup-saved-temps()
+    if [regexp -- {(^|\s+)-save-temps(\s+|$)} $opts] {
+	verbose "Cleanup -save-temps seen" 4
+	append finalcode "cleanup-saved-temps\n"
+    }
+    # Finally see if there are any dumps in opts, otherwise we are done
+    if [regexp -- {(?=(?:^|[ \t]+)?)-fdump-[^ \t]+(?=(?:$|[ \t]+)?)} $opts] {
+        # Ipa, Rtl, Tree for simplicity
+        set ptn "{i,r,t}"
+    } else {
+        return $finalcode
+    }
+    # stem.ext.<passnum><fam>.<passname><pass-instances>
+    # (tree)passes can have multiple instances, thus optional trailing *
+    set ptn "\[0-9\]\[0-9\]\[0-9\]$ptn.*"
+    # Handle ltrans files around -flto
+    if [regexp -- {(^|\s+)-flto(\s+|$)} $opts] {
+	verbose "Cleanup -flto seen" 4
+	set ltrans "{ltrans\[0-9\]*.,}"
+    } else {
+	set ltrans ""
+    }
+    set ptn "$ltrans$ptn"
+    verbose "Cleanup final ptn: $ptn" 4
+    set tfiles {}
+    foreach src $testcases {
+	set basename [file tail $src]
+	if { $ltrans != "" } {
+	    # ??? should we use upvar 1 output_file instead of this (dup ?)
+	    set stem [file rootname $basename]
+	    set basename_ext [file extension $basename]
+	    if {$basename_ext != ""} {
+		regsub -- {^.*\.} $basename_ext {} basename_ext
+	    }
+	    lappend tfiles "$stem.{$basename_ext,exe}"
+	    unset basename_ext
+	} else {
+	    lappend tfiles $basename
+	}
+    }
+    if { [llength $tfiles] > 1 } {
+	set tfiles [join $tfiles ","]
+	set tfiles "{$tfiles}"
+    }
+    verbose "Cleanup final testcases: $tfiles" 4
+    # We have to quote the regex
+    regsub -all {([][$^?+*()|\\{}])} "$tfiles.$ptn" {\\\1} ptn
+    set final ""
+    append final {remove-build-file }
+    append final "\"$ptn\""
+    verbose "Cleanup final: $final" 4
+    append finalcode "$final\n"
+
+    return $finalcode
+}
+
 # Define gcc callbacks for dg.exp.
 
 proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
@@ -177,6 +266,7 @@ proc gcc-dg-test-1 { target_compile prog do_what extra_tool_flags } {
 	}
     }
 
+    append finalcode [schedule-cleanups "$options $extra_tool_flags"]
     if { $extra_tool_flags != "" } {
 	lappend options "additional_flags=$extra_tool_flags"
     }
@@ -518,27 +608,6 @@ proc cleanup-repo-files { } {
     }
 }
 
-# Remove compiler-generated RTL dump files for the current test.
-#
-# SUFFIX is the filename suffix pattern.
-proc cleanup-rtl-dump { suffix } {
-  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]r.$suffix"
-}
-
-# Remove a specific tree dump file for the current test.
-#
-# SUFFIX is the tree dump file suffix pattern.
-proc cleanup-tree-dump { suffix } {
-  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]t.$suffix"
-}
-
-# Remove a specific ipa dump file for the current test.
-#
-# SUFFIX is the ipa dump file suffix pattern.
-proc cleanup-ipa-dump { suffix } {
-  cleanup-dump "\[0-9\]\[0-9\]\[0-9\]i.$suffix"
-}
-
 # Remove a stack usage file for the current test.
 proc cleanup-stack-usage { } {
     set testcase [testname-for-summary]
@@ -567,29 +636,6 @@ proc cleanup-ada-spec { } {
     }
 }
 
-# Remove all dump files with the provided suffix.
-proc cleanup-dump { suffix } {
-    set testcase [testname-for-summary]
-    # The name might include a list of options; extract the file name.
-    set src [file tail [lindex $testcase 0]]
-    remove-build-file "[file tail $src].$suffix"
-    remove-build-file "[file rootname [file tail $src]].exe.$suffix"
-    remove-build-file "[file rootname [file tail $src]].exe.ltrans\[0-9\]*.$suffix"
-    # -fcompare-debug dumps
-    remove-build-file "[file tail $src].gk.$suffix"
-
-    # Clean up dump files for additional source files.
-    if [info exists additional_sources] {
-	foreach srcfile $additional_sources {
-	    remove-build-file "[file tail $srcfile].$suffix"
-	    remove-build-file "[file rootname [file tail $srcfile]].exe.$suffix"
-	    remove-build-file "[file rootname [file tail $srcfile]].exe.ltrans\[0-9\]*.$suffix"
-	    # -fcompare-debug dumps
-	    remove-build-file "[file tail $srcfile].gk.$suffix"
-	}
-    }
-}
-
 # Remove files kept by --save-temps for the current test.
 #
 # Currently this is only .i, .ii, .s and .o files, but more can be added
diff --git a/gcc/testsuite/lib/profopt.exp b/gcc/testsuite/lib/profopt.exp
index cdc6b00..a5aa84d 100644
--- a/gcc/testsuite/lib/profopt.exp
+++ b/gcc/testsuite/lib/profopt.exp
@@ -283,6 +283,9 @@ proc profopt-execute { src } {
 	    return
 	}
 
+	# schedule removal of dump files et al
+	# Do this before the call below destroys additional_sources..
+	append use_final_code [schedule-cleanups "$option $extra_flags"]
         set extra_options [dg-additional-files-options "" "$src"]
 
 	# Tree profiling requires TLS runtime support, which may need
diff --git a/gcc/testsuite/obj-c++.dg/encode-2.mm b/gcc/testsuite/obj-c++.dg/encode-2.mm
index 157bb52..77eb6ad 100644
--- a/gcc/testsuite/obj-c++.dg/encode-2.mm
+++ b/gcc/testsuite/obj-c++.dg/encode-2.mm
@@ -24,5 +24,4 @@ const char *enc3 = @encode(anonymous);
 
 /* { dg-final { scan-assembler "{Vec<float>=ffi}" } }  */
 /* { dg-final { scan-assembler "{Vec<double>=ddi}" } }  */
-/* { dg-final { scan-file "encode-2.o" "{?={Vec<double>=ddi}{Vec<float>=ffi}fd{Vec<signed char>=cci}i}" } }
-/* { dg-final cleanup-saved-temps } */
+/* { dg-final { scan-file "encode-2.o" "{?={Vec<double>=ddi}{Vec<float>=ffi}fd{Vec<signed char>=cci}i}" } } */
-- 
1.8.5.1

Reply via email to