aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2023-11-21 17:31:37 +0100
committerThomas Schwinge <thomas@codesourcery.com>2023-11-29 15:10:01 +0100
commit27c79b91f6008a21006d4e7053a98e63f2990bb2 (patch)
tree9cf70c7e566c15ed176f7365a091efc21aa9212f /gcc
parent8ee480441eaec87ca6e0b0963fe9aade7edd1e8a (diff)
downloadgcc-27c79b91f6008a21006d4e7053a98e63f2990bb2.zip
gcc-27c79b91f6008a21006d4e7053a98e63f2990bb2.tar.gz
gcc-27c79b91f6008a21006d4e7053a98e63f2990bb2.tar.bz2
testsuite: Add 'only_for_offload_target' wrapper for 'scan-offload-tree-dump' etc.
This allows restricting scans to one specific offload target only. gcc/ * doc/sourcebuild.texi (Final Actions): Document 'only_for_offload_target' wrapper. gcc/testsuite/ * lib/scanoffload.exp (only_for_offload_target): New 'proc'.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/doc/sourcebuild.texi37
-rw-r--r--gcc/testsuite/lib/scanoffload.exp21
2 files changed, 56 insertions, 2 deletions
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index fbd45b5..d3f68f3 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -3443,8 +3443,8 @@ stands for zero or more unmatched lines; the whitespace after
@subsubsection Scan optimization dump files
These commands are available for @var{kind} of @code{tree}, @code{ltrans-tree},
-@code{offload-tree}, @code{rtl}, @code{offload-rtl}, @code{ipa}, and
-@code{wpa-ipa}.
+@code{offload-tree}, @code{rtl}, @code{offload-rtl}, @code{ipa},
+@code{offload-ipa}, and @code{wpa-ipa}.
@table @code
@item scan-@var{kind}-dump @var{regex} @var{suffix} [@{ target/xfail @var{selector} @}]
@@ -3479,6 +3479,39 @@ occurrences of the string ``code has been optimized'', use:
/* @{ dg-final @{ scan-tree-dump "code has been optimized" "mypass\[1-3\]" @} @} */
@end smallexample
+The @code{offload-@dots{}} ones by default separately scan the dump
+file of each enabled offload target.
+You may use the @code{only_for_offload_target} wrapper to restrict the
+scanning to one specific offload target:
+
+@smallexample
+/* @{ dg-do link @{ target offload_target_amdgcn @} @} */
+/* @{ dg-additional-options -foffload-options=-fdump-ipa-simdclone-details @} */
+/* @{ dg-final @{ only_for_offload_target amdgcn-amdhsa scan-offload-ipa-dump @var{regex_amdgcn} simdclone @} @} */
+@end smallexample
+
+This test case is active if GCN offload compilation is enabled (but
+potentially also additional offload targets).
+The @code{simdclone} IPA dump file is (potentially) produced for all
+offload targets, but only the GCN offload one is scanned.
+
+If a test case doesn't have a @samp{@{ target @var{selector} @}}, and
+you need to scan, for example, for different @var{regex}es for each of
+host and potentially several offload targets, use a pattern like this:
+
+@smallexample
+/* @{ dg-final @{ scan-tree-dump @var{regex_host} optimized @} @}
+ @{ dg-final @{ only_for_offload_target amdgcn-amdhsa scan-offload-tree-dump @var{regex_amdgcn} optimized @{ target offload_target_amdgcn @} @} @}
+ @{ dg-final @{ only_for_offload_target nvptx-none scan-offload-tree-dump @var{regex_nvptx} optimized @{ target offload_target_nvptx @} @} @} */
+@end smallexample
+
+Here, unconditionally @var{regex_host} is scanned for in the host dump
+file.
+If GCN offloading compilation is actually enabled, @var{regex_amdgcn}
+is scanned for in the GCN offload compilation dump file.
+If nvptx offloading compilation is actually enabled, @var{regex_nvptx}
+is scanned for in the nvptx offload compilation dump file.
+
@subsubsection Check for output files
diff --git a/gcc/testsuite/lib/scanoffload.exp b/gcc/testsuite/lib/scanoffload.exp
index 8315820..c199798 100644
--- a/gcc/testsuite/lib/scanoffload.exp
+++ b/gcc/testsuite/lib/scanoffload.exp
@@ -38,6 +38,8 @@ proc scoff-adjust { args idx target } {
# Wrapper for scan procs.
# Argument 0 is the index of the argument to replace when calling
# argument 1 with the remaining arguments. Use end-1 or end or so.
+# If set, the 'global offload_target' specifies one specific offload target to
+# test, otherwise iterate over all 'global offload_targets'.
proc scoff { args } {
set idx [lindex $args 0]
set prc [lindex $args 1]
@@ -59,3 +61,22 @@ proc scoff { args } {
}
}
}
+
+# Wrapper so that only for a specific offload target (first argument) we
+# execute a 'dg-final' command (remaining arguments).
+proc only_for_offload_target { args } {
+ set override_offload_target [lindex $args 0]
+ set cmd [lreplace $args 0 0]
+
+ global offload_target
+ if [info exists offload_target] {
+ set original_offload_target $offload_target
+ }
+ set offload_target $override_offload_target
+ eval $cmd
+ if [info exists original_offload_target] {
+ set offload_target $original_offload_target
+ } else {
+ unset offload_target
+ }
+}