MIPS now uses an "effective target" mechanism to run the vectoriser
testsuite for multiple vector ISAs. This mechanism defines a couple
of wrapper procedures:
- et-dg-runtest wraps dg-runtest and invokes it for each effective
target. The procedure uses two global variables:
- EFFECTIVE_TARGETS gives the list of targets to test. This is
supplied by the test harness.
- et_index is the index of the current target in EFFECTIVE_TARGETS.
This is set by et-dg-runtest itself.
- et-is-effective-target wraps is-effective-target. When the effective
target mechanism is in use, et-is-effective-target tests whether the
supplied target matches index $et_index of $EFFECTIVE_TARGETS.
check_effective_target_* procedures that use et-is-effective-target
can therefore vary from one effective target to another. It seems
that all such procedures are expected to cache their results using
check_cached_effective_target_indexed instead of the standard
check_cached_effective_target.
check_cached_effective_target_indexed distinguishes effective targets by
adding $et_index to the cache key. One theoretical problem with this is
that it implicitly assumes that EFFECTIVE_TARGETS will always be set to
the same value (if it's set at all).
But the more immediate problem is that et_index is default-
initialised to 0 when the effective target mechanism is not in use.
This means that the same cached values are used for the default
target and for the first effective target. Also, et-dg-runtest
did not reset et_index after iterating through the targets,
leaving a stale value for later check_effective_target_*s.
As Richi points out in PR124066, a downside of the current
mechanism is that only et-is-effective-target tests are sensitive
to the current effective target. Automatic tests, like those that
use check_no_compiler_messages, do not use the flags for the current
effective target.
To cope with a future fix for PR124066, it seems better to add
the current effective target to all cache keys, rather than keep
the current distinction between check_cached_effective_target
and check_cached_effective_target_indexed. It should also be
less error prone.
Also, rather than expect et_index to be default-initialised,
it seems better to ensure that et_index is only defined while
running an effective target variant. Other procedures can then
key off whether et_index exists.
Doing this fixes some spurious failures on a plain mips64-linux-gnu
test run.
To make the patch easier to review and bisect, the mechanical
replacement of check_cached_effective_target_indexed is left
to a follow-on patch.
gcc/testsuite/
PR testsuite/124066
* lib/target-supports.exp (check_cached_effective_target): If
et_index is defined, add the associated EFFECTIVE_TARGETS element
to the cache key.
(check_cached_effective_target_indexed): Turn into a simple wrapper
around check_cached_effective_target.
(is-effective-target): Remove default-initialization of et_index.
(et-dg-runtest): Likewise. Unset et_index after each
EFFECTIVE_TARGETS run.
(et-is-effective-target): Key off the existence of et_index rather
than EFFECTIVE_TARGETS.
---
gcc/testsuite/lib/target-supports.exp | 36 +++++++++++----------------
1 file changed, 14 insertions(+), 22 deletions(-)
diff --git a/gcc/testsuite/lib/target-supports.exp
b/gcc/testsuite/lib/target-supports.exp
index 6f85277f46d..85bc4042720 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -138,10 +138,17 @@ proc current_target_name { } {
# the Tcl command ARGS and seeing if it returns true.
proc check_cached_effective_target { prop args } {
+ global EFFECTIVE_TARGETS
+ global et_index
global et_cache
+ if { [info exists et_index] } {
+ set et [lindex $EFFECTIVE_TARGETS $et_index]
+ } else {
+ set et "default"
+ }
set target [current_target_name]
- if {![info exists et_cache($prop,$target)]} {
+ if {![info exists et_cache($prop,$target,$et)]} {
verbose "check_cached_effective_target $prop: checking $target" 2
if {[string is true -strict $args] || [string is false -strict $args]} {
error {check_cached_effective_target condition already evaluated;
did you pass [...] instead of the expected {...}?}
@@ -150,10 +157,10 @@ proc check_cached_effective_target { prop args } {
if {$code != 0 && $code != 2} {
return -code $code $result
}
- set et_cache($prop,$target) $result
+ set et_cache($prop,$target,$et) $result
}
}
- set value $et_cache($prop,$target)
+ set value $et_cache($prop,$target,$et)
verbose "check_cached_effective_target $prop: returning $value for
$target" 2
return $value
}
@@ -161,11 +168,7 @@ proc check_cached_effective_target { prop args } {
# Implements a version of check_cached_effective_target that also takes
et_index
# into account when creating the key for the cache.
proc check_cached_effective_target_indexed { prop args } {
- global et_index
- set key "$et_index $prop"
- verbose "check_cached_effective_target_index $prop: returning $key" 2
-
- return [check_cached_effective_target $key [list uplevel eval $args]]
+ return [check_cached_effective_target $prop [list uplevel eval $args]]
}
# Clear effective-target cache. This is useful after testing
@@ -10637,13 +10640,7 @@ proc check_effective_target_init_priority {} {
# arguments with keywords that pass particular arguments.
proc is-effective-target { arg } {
- global et_index
set selected 0
- if { ![info exists et_index] } {
- # Initialize the effective target index that is used in some
- # check_effective_target_* procs.
- set et_index 0
- }
if { [info procs check_effective_target_${arg}] != [list] } {
set selected [check_effective_target_${arg}]
} else {
@@ -10725,9 +10722,9 @@ proc et-dg-runtest { runtest testcases flags
default-extra-flags } {
set dg-do-what-default run
}
$runtest $testcases $target_flags ${default-extra-flags}
+ unset et_index
}
} else {
- set et_index 0
$runtest $testcases $flags ${default-extra-flags}
}
}
@@ -10739,13 +10736,8 @@ proc et-is-effective-target { target } {
global EFFECTIVE_TARGETS
global et_index
- if { [info exists EFFECTIVE_TARGETS] } {
- if { [llength $EFFECTIVE_TARGETS] > $et_index
- && [lindex $EFFECTIVE_TARGETS $et_index] == $target } {
- return 1
- } else {
- return 0
- }
+ if { [info exists et_index] } {
+ return [string equal [lindex $EFFECTIVE_TARGETS $et_index] $target]
} else {
return [check_effective_target_${target}]
}
--
2.53.0