]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add 'throw', dead code test cases for GCN, nvptx target and OpenACC, OpenMP 'target...
authorThomas Schwinge <tschwinge@baylibre.com>
Thu, 27 Mar 2025 13:46:20 +0000 (14:46 +0100)
committerThomas Schwinge <tschwinge@baylibre.com>
Mon, 14 Apr 2025 21:54:54 +0000 (23:54 +0200)
gcc/testsuite/
* g++.target/gcn/exceptions-throw-3.C: New.
* g++.target/nvptx/exceptions-throw-3.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-throw-3.C: New.
* testsuite/libgomp.oacc-c++/exceptions-throw-3.C: Likewise.

gcc/testsuite/g++.target/gcn/exceptions-throw-3.C [new file with mode: 0644]
gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.target/gcn/exceptions-throw-3.C b/gcc/testsuite/g++.target/gcn/exceptions-throw-3.C
new file mode 100644 (file)
index 0000000..5c1ad7a
--- /dev/null
@@ -0,0 +1,11 @@
+/* 'throw', dead code.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized } } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C b/gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C
new file mode 100644 (file)
index 0000000..5c1ad7a
--- /dev/null
@@ -0,0 +1,11 @@
+/* 'throw', dead code.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized } } */
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C
new file mode 100644 (file)
index 0000000..c35180d
--- /dev/null
@@ -0,0 +1,19 @@
+/* 'throw' in OpenMP 'target' region, dead code.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -DDEFAULT=defaultmap(to) }
+   ... to avoid wrong code for offloading execution; PR119692.
+   With this, the device code still isn't correct, but the defects are in dead code.
+   { dg-additional-options -fdump-tree-gimple } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "../libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target .* defaultmap\(to\) map\(to:_ZTI11MyException \[len: [0-9]+\] \[runtime_implicit\]\)$} gimple { xfail *-*-* } } } */
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized } }
+   { dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_allocate_exception, } 1 optimized } }
+   { dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized } } */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C
new file mode 100644 (file)
index 0000000..74a62b3
--- /dev/null
@@ -0,0 +1,43 @@
+/* 'throw' in OpenACC compute region, dead code.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* Wrong code for offloading execution.
+   { dg-skip-if PR119692 { ! openacc_host_selected } }
+   { dg-additional-options -fdump-tree-gimple } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+/* See also '../libgomp.c++/target-exceptions-throw-3.C'.  */
+
+/* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-throw-3.C',
+   '../../../gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C'.  */
+
+/* For PR119692 workarounds.  */
+#ifndef DEFAULT
+# define DEFAULT
+#endif
+
+class MyException
+{
+};
+
+int main()
+{
+#pragma omp target DEFAULT
+#pragma acc serial DEFAULT
+  /* { dg-bogus {using 'vector_length \(32\)', ignoring 1} {} { target openacc_nvidia_accel_selected xfail *-*-* } .-1 } */
+  {
+    bool a = false;
+    asm volatile ("" : : "r" (&a) : "memory");
+    if (a)
+      {
+       MyException e1;
+       throw e1;
+      }
+  }
+}
+
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target oacc_serial map\(tofrom:_ZTI11MyException \[len: [0-9]+\]\)$} gimple { xfail *-*-* } } } */
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized } } */