]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: Ensure ltrans dump files get cleaned up properly [PR116140]
authorAlex Coplan <alex.coplan@arm.com>
Thu, 8 Aug 2024 13:15:39 +0000 (13:15 +0000)
committerAlex Coplan <alex.coplan@arm.com>
Wed, 11 Sep 2024 10:50:48 +0000 (11:50 +0100)
I noticed while working on a test that uses LTO and requests a dump
file, that we are failing to cleanup ltrans dump files in the testsuite.

E.g. the test I was working on compiles with -flto
-fdump-rtl-loop2_unroll, and we end up with the following file:

./gcc/testsuite/g++/pr116140.ltrans0.ltrans.287r.loop2_unroll

being left behind by the testsuite.  This is problematic not just from a
"missing cleanup" POV, but also because it can cause the test to pass
spuriously when the test is re-run wtih an unpatched compiler (without
the bug fix).  In the broken case, loop2_unroll isn't run at all, so we
end up scanning the old dumpfile (from the previous test run) and making
the dumpfile scan pass.

Running with `-v -v` in RUNTESTFLAGS we can see the following cleanup
attempt is made:

remove-build-file `pr116140.{C,exe}.{ltrans[0-9]*.,}[0-9][0-9][0-9]{l,i,r,t}.*'

looking again at the ltrans dump file above we can see this will fail for two
reasons:

 - The actual dump file has no {C,exe} extension between the basename and
   ltrans0.
 - The actual dump file has an additional `.ltrans` component after `.ltrans0`.

This patch therefore relaxes the pattern constructed for cleaning up such
dumpfiles to also match dumpfiles with the above form.

Running the testsuite before/after this patch shows the number of files in
gcc/testsuite (in the build dir) with "ltrans" in the name goes from 1416 to 62
on aarch64.

gcc/testsuite/ChangeLog:

PR libstdc++/116140
* lib/gcc-dg.exp (schedule-cleanups): Relax ltrans dumpfile
cleanup pattern to handle missing cases.

gcc/testsuite/lib/gcc-dg.exp

index d9513e2859ce2cf7a8cc2e3da0af5d0738275384..cb401a704359ac0268882992144e4e26b3f68c20 100644 (file)
@@ -190,7 +190,7 @@ proc schedule-cleanups { opts } {
     # Handle ltrans files around -flto
     if [regexp -- {(^|\s+)-flto(\s+|$)} $opts] {
        verbose "Cleanup -flto seen" 4
-       set ltrans "{ltrans\[0-9\]*.,}"
+       set ltrans "{ltrans\[0-9\]*{.ltrans,}.,}"
     } else {
        set ltrans ""
     }
@@ -206,7 +206,7 @@ proc schedule-cleanups { opts } {
            if {$basename_ext != ""} {
                regsub -- {^.*\.} $basename_ext {} basename_ext
            }
-           lappend tfiles "$stem.{$basename_ext,exe}"
+           lappend tfiles "$stem{.$basename_ext,.exe,}"
            unset basename_ext
        } else {
            lappend tfiles $basename