testsuite: Fix missing EFFECTIVE_TARGETS variable errors
Checks
Commit Message
Permit running vector tests outside `check_vect_support_and_set_flags'
environment, removing errors such as:
ERROR: gcc.dg/analyzer/torture/pr93350.c -O0 : can't read "EFFECTIVE_TARGETS": no such variable for " dg-require-effective-target 1 vect_int "
or:
ERROR: gcc.dg/bic-bitmask-13.c: error executing dg-final: can't read "EFFECTIVE_TARGETS": no such variable
with `mips-linux-gnu' target testing.
The EFFECTIVE_TARGETS variable has originated from commit 9b7937cf8a06
("Add support to run auto-vectorization tests for multiple effective
targets."), where arrangements have been made to run vector tests run
within `check_vect_support_and_set_flags' environment iteratively over
all the vector unit variants available in the architecture using extra
compilation flags regardless of whether the target environment arranged
for a particular testsuite run has vector support enabled by default.
So far this has been used for the MIPS target only.
Vector tests have since been added though that run outside environment
set up by `check_vect_support_and_set_flags' just using the current
compilation environment with no extra flags added. This works for most
targets, however causes problems with the MIPS target, because outside
`check_vect_support_and_set_flags' environment the EFFECTIVE_TARGETS
variable will not have been correctly set up even if it was added to
the particular script invoking the test in question.
Fix this by using just the current compilation environment whenever a
vector feature is requested by `et-is-effective-target' in the absence
of the EFFECTIVE_TARGETS variable. This required some modification to
individual vector feature tests, which always added the compilation
flags required for the determination of whether the given vector unit
variant can be verified with the current testsuite run (except for the
Loongson MMI variant). Now explicit flags are only passed in setting up
EFFECTIVE_TARGETS and otherwise the current compilation environment will
determine whether such a vector test is applicable.
This changes how Loongson MMI is handled in that the `-mloongson-mmi'
flag is explicitly passed for the determination of whether this vector
unit variant can be verified, which I gather is how it was supposed to
be arranged anyway because the flag is then added for testing the
Loongson MMI variant.
gcc/testsuite/
* lib/target-supports.exp
(check_effective_target_mpaired_single): Add `args' argument and
pass it to `check_no_compiler_messages' replacing
`-mpaired-single'.
(add_options_for_mips_loongson_mmi): Add `args' argument and
pass it to `check_no_compiler_messages'.
(check_effective_target_mips_msa): Add `args' argument and pass
it to `check_no_compiler_messages' replacing `-mmsa'.
(check_effective_target_mpaired_single_runtime)
(add_options_for_mpaired_single): Pass `-mpaired-single' to
`check_effective_target_mpaired_single'.
(check_effective_target_mips_loongson_mmi_runtime)
(add_options_for_mips_loongson_mmi): Pass `-mloongson-mmi' to
`check_effective_target_mips_loongson_mmi'.
(check_effective_target_mips_msa_runtime)
(add_options_for_mips_msa): Pass `-mmsa' to
`check_effective_target_mips_msa'.
(et-is-effective-target): Verify that EFFECTIVE_TARGETS exists
and if not, just check if the current compilation environment
supports the target feature requested.
(check_vect_support_and_set_flags): Pass `-mpaired-single',
`-mloongson-mmi', and `-mmsa' to the respective target feature
checks.
---
Hi,
This removes said errors and depending on the compilation flags used with
a testsuite invocation may give scores such as:
UNSUPPORTED: gcc.dg/analyzer/torture/pr93350.c -O0
or:
PASS: gcc.dg/analyzer/torture/pr93350.c -O0 (test for excess errors)
In some cases, including in particular Loongson MMI now enabled, it causes
extra failures to appear, but my interpretation is they are preexisting
issues either with the compiler or the respective test cases, which just
did not previously show up simply because the test cases were not run.
Therefore I conclude they are not issues with the test framework update
proposed here.
OK to apply then?
Maciej
---
gcc/testsuite/lib/target-supports.exp | 41 +++++++++++++++++++---------------
1 file changed, 23 insertions(+), 18 deletions(-)
gcc-test-effective-targets.diff
Comments
On 11/15/22 10:02, Maciej W. Rozycki wrote:
> Permit running vector tests outside `check_vect_support_and_set_flags'
> environment, removing errors such as:
>
> ERROR: gcc.dg/analyzer/torture/pr93350.c -O0 : can't read "EFFECTIVE_TARGETS": no such variable for " dg-require-effective-target 1 vect_int "
>
> or:
>
> ERROR: gcc.dg/bic-bitmask-13.c: error executing dg-final: can't read "EFFECTIVE_TARGETS": no such variable
>
> with `mips-linux-gnu' target testing.
>
> The EFFECTIVE_TARGETS variable has originated from commit 9b7937cf8a06
> ("Add support to run auto-vectorization tests for multiple effective
> targets."), where arrangements have been made to run vector tests run
> within `check_vect_support_and_set_flags' environment iteratively over
> all the vector unit variants available in the architecture using extra
> compilation flags regardless of whether the target environment arranged
> for a particular testsuite run has vector support enabled by default.
> So far this has been used for the MIPS target only.
>
> Vector tests have since been added though that run outside environment
> set up by `check_vect_support_and_set_flags' just using the current
> compilation environment with no extra flags added. This works for most
> targets, however causes problems with the MIPS target, because outside
> `check_vect_support_and_set_flags' environment the EFFECTIVE_TARGETS
> variable will not have been correctly set up even if it was added to
> the particular script invoking the test in question.
>
> Fix this by using just the current compilation environment whenever a
> vector feature is requested by `et-is-effective-target' in the absence
> of the EFFECTIVE_TARGETS variable. This required some modification to
> individual vector feature tests, which always added the compilation
> flags required for the determination of whether the given vector unit
> variant can be verified with the current testsuite run (except for the
> Loongson MMI variant). Now explicit flags are only passed in setting up
> EFFECTIVE_TARGETS and otherwise the current compilation environment will
> determine whether such a vector test is applicable.
>
> This changes how Loongson MMI is handled in that the `-mloongson-mmi'
> flag is explicitly passed for the determination of whether this vector
> unit variant can be verified, which I gather is how it was supposed to
> be arranged anyway because the flag is then added for testing the
> Loongson MMI variant.
>
> gcc/testsuite/
> * lib/target-supports.exp
> (check_effective_target_mpaired_single): Add `args' argument and
> pass it to `check_no_compiler_messages' replacing
> `-mpaired-single'.
> (add_options_for_mips_loongson_mmi): Add `args' argument and
> pass it to `check_no_compiler_messages'.
> (check_effective_target_mips_msa): Add `args' argument and pass
> it to `check_no_compiler_messages' replacing `-mmsa'.
> (check_effective_target_mpaired_single_runtime)
> (add_options_for_mpaired_single): Pass `-mpaired-single' to
> `check_effective_target_mpaired_single'.
> (check_effective_target_mips_loongson_mmi_runtime)
> (add_options_for_mips_loongson_mmi): Pass `-mloongson-mmi' to
> `check_effective_target_mips_loongson_mmi'.
> (check_effective_target_mips_msa_runtime)
> (add_options_for_mips_msa): Pass `-mmsa' to
> `check_effective_target_mips_msa'.
> (et-is-effective-target): Verify that EFFECTIVE_TARGETS exists
> and if not, just check if the current compilation environment
> supports the target feature requested.
> (check_vect_support_and_set_flags): Pass `-mpaired-single',
> `-mloongson-mmi', and `-mmsa' to the respective target feature
> checks.
OK.
jeff
On Mon, 21 Nov 2022, Jeff Law wrote:
> > gcc/testsuite/
> > * lib/target-supports.exp
> > (check_effective_target_mpaired_single): Add `args' argument and
> > pass it to `check_no_compiler_messages' replacing
> > `-mpaired-single'.
> > (add_options_for_mips_loongson_mmi): Add `args' argument and
> > pass it to `check_no_compiler_messages'.
> > (check_effective_target_mips_msa): Add `args' argument and pass
> > it to `check_no_compiler_messages' replacing `-mmsa'.
> > (check_effective_target_mpaired_single_runtime)
> > (add_options_for_mpaired_single): Pass `-mpaired-single' to
> > `check_effective_target_mpaired_single'.
> > (check_effective_target_mips_loongson_mmi_runtime)
> > (add_options_for_mips_loongson_mmi): Pass `-mloongson-mmi' to
> > `check_effective_target_mips_loongson_mmi'.
> > (check_effective_target_mips_msa_runtime)
> > (add_options_for_mips_msa): Pass `-mmsa' to
> > `check_effective_target_mips_msa'.
> > (et-is-effective-target): Verify that EFFECTIVE_TARGETS exists
> > and if not, just check if the current compilation environment
> > supports the target feature requested.
> > (check_vect_support_and_set_flags): Pass `-mpaired-single',
> > `-mloongson-mmi', and `-mmsa' to the respective target feature
> > checks.
>
> OK.
I have committed it now, thanks for your review.
Maciej
===================================================================
@@ -1329,10 +1329,10 @@ proc check_effective_target_pie { } {
# Return true if the target supports -mpaired-single (as used on MIPS).
-proc check_effective_target_mpaired_single { } {
+proc check_effective_target_mpaired_single { args } {
return [check_no_compiler_messages mpaired_single object {
void foo (void) { }
- } "-mpaired-single"]
+ } "$args"]
}
# Return true if the target has access to FPU instructions.
@@ -2144,7 +2144,7 @@ proc check_mips_msa_hw_available { } {
# executables, 0 otherwise.
proc check_effective_target_mpaired_single_runtime { } {
- if { [check_effective_target_mpaired_single]
+ if { [check_effective_target_mpaired_single "-mpaired-single"]
&& [check_mpaired_single_hw_available] } {
return 1
}
@@ -2154,7 +2154,7 @@ proc check_effective_target_mpaired_sing
# Return 1 if the target supports running Loongson executables, 0 otherwise.
proc check_effective_target_mips_loongson_mmi_runtime { } {
- if { [check_effective_target_mips_loongson_mmi]
+ if { [check_effective_target_mips_loongson_mmi "-mloongson-mmi"]
&& [check_mips_loongson_mmi_hw_available] } {
return 1
}
@@ -2164,7 +2164,7 @@ proc check_effective_target_mips_loongso
# Return 1 if the target supports running MIPS MSA executables, 0 otherwise.
proc check_effective_target_mips_msa_runtime { } {
- if { [check_effective_target_mips_msa]
+ if { [check_effective_target_mips_msa "-mmsa"]
&& [check_mips_msa_hw_available] } {
return 1
}
@@ -6095,7 +6095,7 @@ proc check_effective_target_arm_acq_rel
# Add the options needed for MIPS Paired-Single.
proc add_options_for_mpaired_single { flags } {
- if { ! [check_effective_target_mpaired_single] } {
+ if { ! [check_effective_target_mpaired_single "-mpaired-single"] } {
return "$flags"
}
return "$flags -mpaired-single"
@@ -6104,7 +6104,7 @@ proc add_options_for_mpaired_single { fl
# Add the options needed for MIPS SIMD Architecture.
proc add_options_for_mips_msa { flags } {
- if { ! [check_effective_target_mips_msa] } {
+ if { ! [check_effective_target_mips_msa "-mmsa"] } {
return "$flags"
}
return "$flags -mmsa"
@@ -6113,7 +6113,7 @@ proc add_options_for_mips_msa { flags }
# Add the options needed for MIPS Loongson MMI Architecture.
proc add_options_for_mips_loongson_mmi { flags } {
- if { ! [check_effective_target_mips_loongson_mmi] } {
+ if { ! [check_effective_target_mips_loongson_mmi "-mloongson-mmi"] } {
return "$flags"
}
return "$flags -mloongson-mmi"
@@ -6123,7 +6123,7 @@ proc add_options_for_mips_loongson_mmi {
# Return 1 if this a Loongson-2E or -2F target using an ABI that supports
# the Loongson vector modes.
-proc check_effective_target_mips_loongson_mmi { } {
+proc check_effective_target_mips_loongson_mmi { args } {
return [check_no_compiler_messages loongson assembly {
#if !defined(__mips_loongson_mmi)
#error !__mips_loongson_mmi
@@ -6131,7 +6131,7 @@ proc check_effective_target_mips_loongso
#if !defined(__mips_loongson_vector_rev)
#error !__mips_loongson_vector_rev
#endif
- }]
+ } "$args"]
}
# Return 1 if this is a MIPS target that supports the legacy NAN.
@@ -6145,7 +6145,7 @@ proc check_effective_target_mips_nanlega
# Return 1 if an MSA program can be compiled to object
-proc check_effective_target_mips_msa { } {
+proc check_effective_target_mips_msa { args } {
if ![check_effective_target_nomips16] {
return 0
}
@@ -6171,7 +6171,7 @@ proc check_effective_target_mips_msa { }
return v[0];
}
#endif
- } "-mmsa" ]
+ } "$args"]
}
# Return 1 if this is an ARM target that adheres to the ABI for the ARM
@@ -9049,11 +9049,16 @@ proc et-is-effective-target { target } {
global EFFECTIVE_TARGETS
global et_index
- if { [llength $EFFECTIVE_TARGETS] > $et_index
- && [lindex $EFFECTIVE_TARGETS $et_index] == $target } {
+ if { [info exists EFFECTIVE_TARGETS] } {
+ if { [llength $EFFECTIVE_TARGETS] > $et_index
+ && [lindex $EFFECTIVE_TARGETS $et_index] == $target } {
return 1
+ } else {
+ return 0
+ }
+ } else {
+ return [check_effective_target_${target}]
}
- return 0
}
# Return 1 if target default to short enums
@@ -10647,13 +10652,13 @@ proc check_vect_support_and_set_flags {
}
} elseif { [istarget mips*-*-*]
&& [check_effective_target_nomips16] } {
- if { [check_effective_target_mpaired_single] } {
+ if { [check_effective_target_mpaired_single "-mpaired-single"] } {
lappend EFFECTIVE_TARGETS mpaired_single
}
- if { [check_effective_target_mips_loongson_mmi] } {
+ if { [check_effective_target_mips_loongson_mmi "-mloongson-mmi"] } {
lappend EFFECTIVE_TARGETS mips_loongson_mmi
}
- if { [check_effective_target_mips_msa] } {
+ if { [check_effective_target_mips_msa "-mmsa"] } {
lappend EFFECTIVE_TARGETS mips_msa
}
return [llength $EFFECTIVE_TARGETS]