drop -aux{dir,base}, revamp -dump{dir,base}

Alexandre Oliva oliva@adacore.com
Fri Jun 19 09:53:36 GMT 2020


On Jun 18, 2020, Tobias Burnus <tobias@codesourcery.com> wrote:

> Thus, without the offload_target prefix, they would dump into the same file!

Here's an incremental patch, on top of the one you kindly tested the
other day (thanks!), that attempts to introduce per-offload-target dump
name variation.

Could you possibly give it a spin with the offloading targets you've
got?

Thanks in advance,


introduce per-offload-target dumpbase

From: Alexandre Oliva <oliva@gnu.org>


---
 gcc/lto-wrapper.c                     |    5 +---
 gcc/testsuite/lib/scanoffload.exp     |   45 +++++++++++++++++++++++++++++++++
 gcc/testsuite/lib/scanoffloadrtl.exp  |   41 +++++++++++++++---------------
 gcc/testsuite/lib/scanoffloadtree.exp |   41 +++++++++++++++---------------
 libgomp/testsuite/lib/libgomp-dg.exp  |    8 ------
 libgomp/testsuite/lib/libgomp.exp     |    1 +
 6 files changed, 89 insertions(+), 52 deletions(-)
 create mode 100644 gcc/testsuite/lib/scanoffload.exp

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index e990961..939a83a 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -854,10 +854,7 @@ compile_offload_image (const char *target, const char *compiler_path,
 		 "could not find %s in %s (consider using %<-B%>)",
 		 suffix + 1, compiler_path);
 
-  /* ??? We should probably use the TARGET name instead of "target"
-     here, so as to create different file names for different offload
-     targets.  */
-  dumpbase = concat (dumppfx, "target", NULL);
+  dumpbase = concat (dumppfx, "x", target, NULL);
 
   /* Generate temporary output file name.  */
   if (save_temps)
diff --git a/gcc/testsuite/lib/scanoffload.exp b/gcc/testsuite/lib/scanoffload.exp
new file mode 100644
index 00000000..cbf9fcb
--- /dev/null
+++ b/gcc/testsuite/lib/scanoffload.exp
@@ -0,0 +1,45 @@
+#   Copyright (C) 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# Utility for scanning offloading dump output, used by libgomp.exp.
+
+# Format an offload dump suffix given the offload target name in
+# OFFTGT and any suffix, probably empty, in SUFFIX.
+proc scoff-format { offtgt suffix } {
+    return ".x$offtgt.mkoffload$suffix"
+}
+
+# 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.
+proc scoff { args } {
+    set idx [lindex $args 0]
+    set prc [lindex $args 1]
+    set args [lreplace $args 0 1]
+
+    global offload_target
+    if [info set offload_target] {
+	set target $offload_target
+	if { "$target" != "disable" } {
+	    eval $prc [lreplace $args $idx $idx "[scoff-format $target [lindex $args $idx]]"]
+	}
+    } else {
+	global offload_targets
+	foreach target [split $offload_targets ","] {
+	    eval $prc [lreplace $args $idx $idx "[scoff-format $target [lindex $args $idx]]"]
+	}
+    }
+}
diff --git a/gcc/testsuite/lib/scanoffloadrtl.exp b/gcc/testsuite/lib/scanoffloadrtl.exp
index e792450..be457f7 100644
--- a/gcc/testsuite/lib/scanoffloadrtl.exp
+++ b/gcc/testsuite/lib/scanoffloadrtl.exp
@@ -18,6 +18,7 @@
 # libgomp.exp.
 
 load_lib scandump.exp
+load_lib scanoffload.exp
 
 # Utility for scanning compiler result, invoked via dg-final.
 # Call pass if pattern is present, otherwise fail.
@@ -36,12 +37,12 @@ proc scan-offload-rtl-dump { args } {
 	return
     }
     if { [llength $args] >= 3 } {
-	scan-dump "offload-rtl" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".target.mkoffload" \
+	scoff end-1 scan-dump "offload-rtl" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" "" \
 	    [lindex $args 2]
     } else {
-	scan-dump "offload-rtl" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".target.mkoffload"
+	scoff end scan-dump "offload-rtl" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ""
     }
 }
 
@@ -61,12 +62,12 @@ proc scan-offload-rtl-dump-times { args } {
 	return
     }
     if { [llength $args] >= 4 } {
-	scan-dump-times "offload-rtl" [lindex $args 0] [lindex $args 1] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 2]" ".target.mkoffload" \
+	scoff end-1 scan-dump-times "offload-rtl" [lindex $args 0] \
+	    [lindex $args 1] "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 2]" "" \
 			[lindex $args 3]
     } else {
-	scan-dump-times "offload-rtl" [lindex $args 0] [lindex $args 1] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 2]" ".target.mkoffload"
+	scoff end scan-dump-times "offload-rtl" [lindex $args 0] \
+	    [lindex $args 1] "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 2]" ""
     }
 }
 
@@ -86,12 +87,12 @@ proc scan-offload-rtl-dump-not { args } {
 	return
     }
     if { [llength $args] >= 3 } {
-	scan-dump-not "offload-rtl" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".target.mkoffload" \
+	scoff end-1 scan-dump-not "offload-rtl" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" "" \
 	    [lindex $args 2]
     } else {
-	scan-dump-not "offload-rtl" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".target.mkoffload"
+	scoff end scan-dump-not "offload-rtl" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ""
     }
 }
 
@@ -112,12 +113,12 @@ proc scan-offload-rtl-dump-dem { args } {
 	return
     }
     if { [llength $args] >= 3 } {
-	scan-dump-dem "offload-rtl" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".target.mkoffload" \
+	scoff end-1 scan-dump-dem "offload-rtl" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" "" \
 	    [lindex $args 2]
     } else {
-	scan-dump-dem "offload-rtl" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".target.mkoffload"
+	scoff end scan-dump-dem "offload-rtl" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ""
     }
 }
 
@@ -137,11 +138,11 @@ proc scan-offload-rtl-dump-dem-not { args } {
 	return
     }
     if { [llength $args] >= 3 } {
-	scan-dump-dem-not "offload-rtl" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".target.mkoffload" \
+	scoff end-1 scan-dump-dem-not "offload-rtl" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" "" \
 	    [lindex $args 2]
     } else {
-	scan-dump-dem-not "offload-rtl" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ".target.mkoffload"
+	scoff end scan-dump-dem-not "offload-rtl" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]r.[lindex $args 1]" ""
     }
 }
diff --git a/gcc/testsuite/lib/scanoffloadtree.exp b/gcc/testsuite/lib/scanoffloadtree.exp
index 3a3b64d2..e51085c 100644
--- a/gcc/testsuite/lib/scanoffloadtree.exp
+++ b/gcc/testsuite/lib/scanoffloadtree.exp
@@ -18,6 +18,7 @@
 # libgomp.exp.
 
 load_lib scandump.exp
+load_lib scanoffload.exp
 
 # Utility for scanning compiler result, invoked via dg-final.
 # Call pass if pattern is present, otherwise fail.
@@ -36,12 +37,12 @@ proc scan-offload-tree-dump { args } {
 	return
     }
     if { [llength $args] >= 3 } {
-	scan-dump "offload-tree" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".target.mkoffload" \
+	scoff end-1 scan-dump "offload-tree" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" "" \
 	    [lindex $args 2]
     } else {
-	scan-dump "offload-tree" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".target.mkoffload"
+	scoff end scan-dump "offload-tree" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ""
     }
 }
 
@@ -61,12 +62,12 @@ proc scan-offload-tree-dump-times { args } {
 	return
     }
     if { [llength $args] >= 4 } {
-	scan-dump-times "offload-tree" [lindex $args 0] [lindex $args 1] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 2]" ".target.mkoffload" \
+	scoff end-1 scan-dump-times "offload-tree" [lindex $args 0] \
+	    [lindex $args 1] "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 2]" "" \
 	    [lindex $args 3]
     } else {
-	scan-dump-times "offload-tree" [lindex $args 0] [lindex $args 1] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 2]" ".target.mkoffload"
+	scoff end scan-dump-times "offload-tree" [lindex $args 0] \
+	    [lindex $args 1] "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 2]" ""
     }
 }
 
@@ -86,12 +87,12 @@ proc scan-offload-tree-dump-not { args } {
 	return
     }
     if { [llength $args] >= 3 } {
-	scan-dump-not "offload-tree" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".target.mkoffload" \
+	scoff end-1 scan-dump-not "offload-tree" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" "" \
 	    [lindex $args 2]
     } else {
-	scan-dump-not "offload-tree" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".target.mkoffload"
+	scoff end scan-dump-not "offload-tree" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ""
     }
 }
 
@@ -112,12 +113,12 @@ proc scan-offload-tree-dump-dem { args } {
 	return
     }
     if { [llength $args] >= 3 } {
-	scan-dump-dem "offload-tree" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".target.mkoffload" \
+	scoff end-1 scan-dump-dem "offload-tree" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" "" \
 	    [lindex $args 2]
     } else {
-	scan-dump-dem "offload-tree" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".target.mkoffload"
+	scoff end scan-dump-dem "offload-tree" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ""
     }
 }
 
@@ -137,11 +138,11 @@ proc scan-offload-tree-dump-dem-not { args } {
 	return
     }
     if { [llength $args] >= 3 } {
-	scan-dump-dem-not "offload-tree" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".target.mkoffload" \
+	scoff end-1 scan-dump-dem-not "offload-tree" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" "" \
 	    [lindex $args 2]
     } else {
-	scan-dump-dem-not "offload-tree" [lindex $args 0] \
-	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ".target.mkoffload"
+	scoff end scan-dump-dem-not "offload-tree" [lindex $args 0] \
+	    "\[0-9\]\[0-9\]\[0-9]t.[lindex $args 1]" ""
     }
 }
diff --git a/libgomp/testsuite/lib/libgomp-dg.exp b/libgomp/testsuite/lib/libgomp-dg.exp
index 726b924..ebf78e1 100644
--- a/libgomp/testsuite/lib/libgomp-dg.exp
+++ b/libgomp/testsuite/lib/libgomp-dg.exp
@@ -1,12 +1,4 @@
 proc libgomp-dg-test { prog do_what extra_tool_flags } {
-    # Force the dumpbase for test.c to test.o, such that scan-offload-*-dump
-    # will work.
-    foreach opt $extra_tool_flags {
-	if { [regexp ^-foffload=-fdump- $opt] } {
-	    lappend extra_tool_flags "-save-temps"
-	}
-    }
-
     return [gcc-dg-test-1 libgomp_target_compile $prog $do_what $extra_tool_flags]
 }
 
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index ee5f0e5..8ccb78f4 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -30,6 +30,7 @@ load_gcc_lib scanlang.exp
 load_gcc_lib scanrtl.exp
 load_gcc_lib scantree.exp
 load_gcc_lib scanltranstree.exp
+load_gcc_lib scanoffload.exp
 load_gcc_lib scanoffloadtree.exp
 load_gcc_lib scanoffloadrtl.exp
 load_gcc_lib scanipa.exp


-- 
Alexandre Oliva, freedom fighter    he/him    https://FSFLA.org/blogs/lxo/
Free Software Evangelist              Stallman was right, but he's left :(
GNU Toolchain Engineer           Live long and free, and prosper ethically


More information about the Gcc-patches mailing list