Message ID | 87k0uyesyx.fsf@euler.schwinge.homeip.net |
---|---|
State | New |
Headers | show |
Series | Add 'dg-note' next to 'dg-optimized', 'dg-missed' (was: [PATCH] dumpfile.c: use prefixes other that 'note: ' for MSG_{OPTIMIZED_LOCATIONS|MISSED_OPTIMIZATION}) | expand |
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
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
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