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

(cherry picked from commit 1362d9d49449bec12741ef158f4bf81a8b3ff2cd)

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

index b04a06bf1e85b127c4ebe0a006dcac55ad36a3a6..62db33e1900074ecab07d197c2780f2000134054 100644 (file)
@@ -3,6 +3,12 @@
        Backported from trunk:
        2025-04-14  Thomas Schwinge  <tschwinge@baylibre.com>
 
+       * g++.target/gcn/exceptions-throw-1.C: New.
+       * g++.target/nvptx/exceptions-throw-1.C: Likewise.
+
+       Backported from trunk:
+       2025-04-14  Thomas Schwinge  <tschwinge@baylibre.com>
+
        * g++.target/gcn/exceptions-bad_cast-3.C: New.
        * g++.target/nvptx/exceptions-bad_cast-3.C: Likewise.
 
diff --git a/gcc/testsuite/g++.target/gcn/exceptions-throw-1.C b/gcc/testsuite/g++.target/gcn/exceptions-throw-1.C
new file mode 100644 (file)
index 0000000..6cadf58
--- /dev/null
@@ -0,0 +1,16 @@
+/* 'throw'.  */
+
+/* { 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-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { 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 } }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C b/gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C
new file mode 100644 (file)
index 0000000..6cadf58
--- /dev/null
@@ -0,0 +1,16 @@
+/* 'throw'.  */
+
+/* { 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-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { 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 } }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
index 24f3335cec75bb3a62c8074e8abccade2f18d2dd..7fbfac71f26627ee071800a0af670c7b97d91d0d 100644 (file)
@@ -3,6 +3,13 @@
        Backported from trunk:
        2025-04-14  Thomas Schwinge  <tschwinge@baylibre.com>
 
+       * testsuite/libgomp.c++/target-exceptions-throw-1.C: New.
+       * testsuite/libgomp.c++/target-exceptions-throw-1-O0.C: Likewise.
+       * testsuite/libgomp.oacc-c++/exceptions-throw-1.C: Likewise.
+
+       Backported from trunk:
+       2025-04-14  Thomas Schwinge  <tschwinge@baylibre.com>
+
        * testsuite/libgomp.c++/target-exceptions-bad_cast-3.C: New.
        * testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C: Likewise.
 
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1-O0.C b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1-O0.C
new file mode 100644 (file)
index 0000000..00d7c13
--- /dev/null
@@ -0,0 +1,23 @@
+/* 'throw' in OpenMP 'target' region.  */
+
+/* { dg-additional-options -O0 } */
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "target-exceptions-throw-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { 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 } }
+   For host execution, we print something like:
+       terminate called after throwing an instance of 'MyException'
+       Aborted (core dumped)
+   { dg-output {.*MyException} { target { ! offload_device } } }
+   For GCN, nvptx offload execution, we don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C
new file mode 100644 (file)
index 0000000..2467061
--- /dev/null
@@ -0,0 +1,25 @@
+/* 'throw' in OpenMP 'target' region.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+/* { dg-bogus {Size expression must be absolute\.} PR119737 { target offload_target_amdgcn xfail *-*-* } 0 }
+   { dg-ice PR119737 { offload_target_amdgcn } }
+   { dg-excess-errors {'mkoffload' failures etc.} { xfail offload_target_amdgcn } } */
+
+#include "../libgomp.oacc-c++/exceptions-throw-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { 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 } }
+   For host execution, we print something like:
+       terminate called after throwing an instance of 'MyException'
+       Aborted (core dumped)
+   { dg-output {.*MyException} { target { ! offload_device } } }
+   For GCN, nvptx offload execution, we don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C
new file mode 100644 (file)
index 0000000..f2ef751
--- /dev/null
@@ -0,0 +1,46 @@
+/* 'throw' in OpenACC compute region.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+/* { dg-bogus {Size expression must be absolute\.} PR119737 { target { openacc_radeon_accel_selected && __OPTIMIZE__ } xfail *-*-* } 0 }
+   { dg-ice PR119737 { openacc_radeon_accel_selected && __OPTIMIZE__ } }
+   { dg-excess-errors {'mkoffload' failure etc.} { xfail { openacc_radeon_accel_selected && __OPTIMIZE__ } } } */
+
+/* See also '../libgomp.c++/target-exceptions-throw-1.C'.  */
+
+/* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-throw-1.C',
+   '../../../gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C'.  */
+
+#include <iostream>
+
+class MyException
+{
+};
+
+int main()
+{
+  std::cerr << "CheCKpOInT\n";
+#pragma omp target
+#pragma acc serial
+  /* { dg-bogus {using 'vector_length \(32\)', ignoring 1} {} { target openacc_nvidia_accel_selected xfail *-*-* } .-1 } */
+  {
+    MyException e1;
+    throw e1;
+  }
+}
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { 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 } }
+   For host execution, we print something like:
+       terminate called after throwing an instance of 'MyException'
+       Aborted (core dumped)
+   { dg-output {.*MyException} { target openacc_host_selected } }
+   For GCN, nvptx offload execution, we don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */