From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2102) id 9C10C3857C66; Wed, 17 Nov 2021 08:17:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9C10C3857C66 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Frederik Harwath To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] Add dg-final option-based target selectors X-Act-Checkin: gcc X-Git-Author: Richard Sandiford X-Git-Refname: refs/heads/devel/omp/gcc-11 X-Git-Oldrev: fa558c2a66648ca20d569921ba4a8ffb2ea0361b X-Git-Newrev: 00b98b6cac250b32015757162510aaa4ab23bfae Message-Id: <20211117081709.9C10C3857C66@sourceware.org> Date: Wed, 17 Nov 2021 08:17:09 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Nov 2021 08:17:09 -0000 https://gcc.gnu.org/g:00b98b6cac250b32015757162510aaa4ab23bfae commit 00b98b6cac250b32015757162510aaa4ab23bfae Author: Richard Sandiford Date: Sat Apr 24 09:35:16 2021 +0100 Add dg-final option-based target selectors This patch adds target selectors of the form: { any-opts "opt1" ... "optn" } { no-opts "opt1" ... "optn" } for skipping or xfailing tests based on compiler options. It only works for dg-final selectors. The patch then uses no-opts to exclude -O0 and (sometimes) -Og from some guality.exp xfails. AFAICT (based on gcc-testresults) these tests pass for those options for all targets. gcc/ * doc/sourcebuild.texi: Document no-opts and any-opts target selectors. gcc/testsuite/ * lib/target-supports-dg.exp (selector_expression): Handle any-opts and no-opts. * gcc.dg/guality/pr41353-1.c: Exclude -O0 from xfail. * gcc.dg/guality/pr59776.c: Likewise. * gcc.dg/guality/pr54970.c: Likewise -O0 and -Og. Diff: --- gcc/doc/sourcebuild.texi | 90 ++++++++++++++++++++++++++++++-- gcc/testsuite/gcc.dg/guality/pr41353-1.c | 2 +- gcc/testsuite/gcc.dg/guality/pr54970.c | 16 +++--- gcc/testsuite/gcc.dg/guality/pr59776.c | 4 +- gcc/testsuite/lib/target-supports-dg.exp | 10 +++- 5 files changed, 107 insertions(+), 15 deletions(-) diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index b0001247795..d3200a42e44 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -1301,6 +1301,8 @@ A selector is: @item one or more target triplets, possibly including wildcard characters; use @samp{*-*-*} to match any target @item a single effective-target keyword (@pxref{Effective-Target Keywords}) +@item a list of compiler options that should be included or excluded +(as described in more detail below) @item a logical expression @end itemize @@ -1313,14 +1315,96 @@ test to fail for targets that match @var{selector2}. A selector expression appears within curly braces and uses a single logical operator: one of @samp{!}, @samp{&&}, or @samp{||}. An -operand is another selector expression, an effective-target keyword, -a single target triplet, or a list of target triplets within quotes or -curly braces. For example: +operand is one of the following: + +@itemize @bullet +@item +another selector expression, in curly braces + +@item +an effective-target keyword, such as @code{lp64} + +@item +a single target triplet + +@item +a list of target triplets within quotes or curly braces + +@item +one of the following: + +@table @samp +@item @{ any-opts @var{opt1} @dots{} @var{optn} @} +Each of @var{opt1} to @var{optn} is a space-separated list of option globs. +The selector expression evaluates to true if, for one of these strings, +every glob in the string matches an option that was passed to the compiler. +For example: + +@smallexample +@{ any-opts "-O3 -flto" "-O[2g]" @} +@end smallexample + +is true if any of the following are true: + +@itemize @bullet +@item +@option{-O2} was passed to the compiler + +@item +@option{-Og} was passed to the compiler + +@item +both @option{-O3} and @option{-flto} were passed to the compiler +@end itemize + +This kind of selector can only be used within @code{dg-final} directives. +Use @code{dg-skip-if}, @code{dg-xfail-if} or @code{dg-xfail-run-if} to +skip whole tests based on options, or to mark them as expected to fail +with certain options. + +@item @{ no-opts @var{opt1} @dots{} @var{optn} @} +As for @code{any-opts} above, each of @var{opt1} to @var{optn} is a +space-separated list of option globs. The selector expression +evaluates to true if, for all of these strings, there is at least +one glob that does not match an option that was passed to the compiler. +It is shorthand for: + +@smallexample +@{ ! @{ any-opts @var{opt1} @dots{} @var{optn} @} @} +@end smallexample + +For example: + +@smallexample +@{ no-opts "-O3 -flto" "-O[2g]" @} +@end smallexample + +is true if all of the following are true: + +@itemize @bullet +@item +@option{-O2} was not passed to the compiler + +@item +@option{-Og} was not passed to the compiler + +@item +at least one of @option{-O3} or @option{-flto} was not passed to the compiler +@end itemize + +Like @code{any-opts}, this kind of selector can only be used within +@code{dg-final} directives. + +@end table +@end itemize + +Here are some examples of full target selectors: @smallexample @{ target @{ ! "hppa*-*-* ia64*-*-*" @} @} @{ target @{ powerpc*-*-* && lp64 @} @} @{ xfail @{ lp64 || vect_no_align @} @} +@{ xfail @{ aarch64*-*-* && @{ any-opts "-O2" @} @} @} @end smallexample @node Effective-Target Keywords diff --git a/gcc/testsuite/gcc.dg/guality/pr41353-1.c b/gcc/testsuite/gcc.dg/guality/pr41353-1.c index cd306328fda..6639a524f0f 100644 --- a/gcc/testsuite/gcc.dg/guality/pr41353-1.c +++ b/gcc/testsuite/gcc.dg/guality/pr41353-1.c @@ -22,7 +22,7 @@ f2 (int i, int j) { j += i; /* { dg-final { gdb-test .+4 "i" "37" } } */ - /* { dg-final { gdb-test .+3 "j" "28 + 37" { xfail *-*-* } } } */ + /* { dg-final { gdb-test .+3 "j" "28 + 37" { xfail { no-opts "-O0" } } } } */ int i1 = 2 * i; /* { dg-final { gdb-test .+2 "i1" "2 * 37" } } */ int i2 = 3 * i; /* { dg-final { gdb-test .+1 "i2" "3 * 37" } } */ return j; diff --git a/gcc/testsuite/gcc.dg/guality/pr54970.c b/gcc/testsuite/gcc.dg/guality/pr54970.c index 2e0bc5784a9..e60cc043fc9 100644 --- a/gcc/testsuite/gcc.dg/guality/pr54970.c +++ b/gcc/testsuite/gcc.dg/guality/pr54970.c @@ -8,39 +8,39 @@ int main () { - int a[] = { 1, 2, 3 }; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { *-*-* } } } } */ + int a[] = { 1, 2, 3 }; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { no-opts "-O0" "-Og" } } } } */ int *p = a + 2; /* { dg-final { gdb-test .+3 "a\[1\]" "2" } } */ int *q = a + 1; /* { dg-final { gdb-test .+2 "a\[2\]" "3" } } */ /* { dg-final { gdb-test .+1 "*p" "3" } } */ asm volatile (NOP); /* { dg-final { gdb-test . "*q" "2" } } */ - *p += 10; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { *-*-* } } } } */ + *p += 10; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { no-opts "-O0" "-Og" } } } } */ /* { dg-final { gdb-test .+3 "a\[1\]" "2" } } */ /* { dg-final { gdb-test .+2 "a\[2\]" "13" } } */ /* { dg-final { gdb-test .+1 "*p" "13" } } */ asm volatile (NOP); /* { dg-final { gdb-test . "*q" "2" } } */ - *q += 10; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { *-*-* } } } } */ + *q += 10; /* { dg-final { gdb-test .+4 "a\[0\]" "1" { xfail { no-opts "-O0" "-Og" } } } } */ /* { dg-final { gdb-test .+3 "a\[1\]" "12" } } */ /* { dg-final { gdb-test .+2 "a\[2\]" "13" } } */ /* { dg-final { gdb-test .+1 "*p" "13" } } */ asm volatile (NOP); /* { dg-final { gdb-test . "*q" "12" } } */ __builtin_memcpy (&a, (int [3]) { 4, 5, 6 }, sizeof (a)); - /* { dg-final { gdb-test .+4 "a\[0\]" "4" { xfail { *-*-* } } } } */ + /* { dg-final { gdb-test .+4 "a\[0\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */ /* { dg-final { gdb-test .+3 "a\[1\]" "5" } } */ /* { dg-final { gdb-test .+2 "a\[2\]" "6" } } */ /* { dg-final { gdb-test .+1 "*p" "6" } } */ asm volatile (NOP); /* { dg-final { gdb-test . "*q" "5" } } */ - *p += 20; /* { dg-final { gdb-test .+4 "a\[0\]" "4" { xfail { *-*-* } } } } */ + *p += 20; /* { dg-final { gdb-test .+4 "a\[0\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */ /* { dg-final { gdb-test .+3 "a\[1\]" "5" } } */ /* { dg-final { gdb-test .+2 "a\[2\]" "26" } } */ /* { dg-final { gdb-test .+1 "*p" "26" } } */ asm volatile (NOP); /* { dg-final { gdb-test . "*q" "5" } } */ - *q += 20; /* { dg-final { gdb-test .+8 "a\[0\]" "4" { xfail { *-*-* } } } } */ + *q += 20; /* { dg-final { gdb-test .+8 "a\[0\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */ /* { dg-final { gdb-test .+7 "a\[1\]" "25" } } */ /* { dg-final { gdb-test .+6 "a\[2\]" "26" } } */ /* { dg-final { gdb-test .+5 "*p" "26" } } */ /* { dg-final { gdb-test .+4 "p\[-1\]" "25" } } */ - /* { dg-final { gdb-test .+3 "p\[-2\]" "4" { xfail { *-*-* } } } } */ - /* { dg-final { gdb-test .+2 "q\[-1\]" "4" { xfail { *-*-* } } } } */ + /* { dg-final { gdb-test .+3 "p\[-2\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */ + /* { dg-final { gdb-test .+2 "q\[-1\]" "4" { xfail { no-opts "-O0" "-Og" } } } } */ /* { dg-final { gdb-test .+1 "q\[1\]" "26" } } */ asm volatile (NOP); /* { dg-final { gdb-test . "*q" "25" } } */ return 0; diff --git a/gcc/testsuite/gcc.dg/guality/pr59776.c b/gcc/testsuite/gcc.dg/guality/pr59776.c index 7c95a9f9416..9777f6229de 100644 --- a/gcc/testsuite/gcc.dg/guality/pr59776.c +++ b/gcc/testsuite/gcc.dg/guality/pr59776.c @@ -12,11 +12,11 @@ foo (struct S *p) struct S s1, s2; /* { dg-final { gdb-test pr59776.c:17 "s1.f" "5.0" } } */ s1 = *p; /* { dg-final { gdb-test pr59776.c:17 "s1.g" "6.0" } } */ s2 = s1; /* { dg-final { gdb-test pr59776.c:17 "s2.f" "0.0" } } */ - *(int *) &s2.f = 0; /* { dg-final { gdb-test pr59776.c:17 "s2.g" "6.0" { xfail *-*-* } } } */ + *(int *) &s2.f = 0; /* { dg-final { gdb-test pr59776.c:17 "s2.g" "6.0" { xfail { no-opts "-O0" } } } } */ asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s1.f" "5.0" } } */ asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s1.g" "6.0" } } */ s2 = s1; /* { dg-final { gdb-test pr59776.c:20 "s2.f" "5.0" } } */ - asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s2.g" "6.0" { xfail *-*-* } } } */ + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s2.g" "6.0" { xfail { no-opts "-O0" } } } } */ asm volatile (NOP : : : "memory"); } diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp index c014abce4f5..94ba79eb4ae 100644 --- a/gcc/testsuite/lib/target-supports-dg.exp +++ b/gcc/testsuite/lib/target-supports-dg.exp @@ -570,7 +570,15 @@ if { [info procs saved-dg-process-target] == [list] } { # Evaluate a selector expression. proc selector_expression { exp } { - if { [llength $exp] == 2 } { + if { [llength $exp] >= 2 + && [string match "any-opts" [lindex $exp 0]] } { + set args [list "" { *-*-* } [lrange $exp 1 end] ""] + set answer [check_conditional_xfail $args] + } elseif { [llength $exp] >= 2 + && [string match "no-opts" [lindex $exp 0]] } { + set args [list "" { *-*-* } "*" [lrange $exp 1 end]] + set answer [check_conditional_xfail $args] + } elseif { [llength $exp] == 2 } { if [string match "!" [lindex $exp 0]] { set op1 [lindex $exp 1] set answer [expr { ! [selector_opd $op1] }]