Debian Codegraph @

libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C

raw
1 /* Exception handling constructs in dead code. */
2
3 /* { dg-require-effective-target exceptions }
4 { dg-additional-options -fexceptions } */
5 /* { dg-additional-options -O0 } */
6 /* { dg-additional-options -fdump-tree-optimized-raw }
7 { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
8
9 /* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C',
10 '../../../gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C'. */
11
12 #pragma omp begin declare target
13
14 bool ok = false;
15
16 template <typename T>
17 struct C
18 {
19 C()
20 {
21 ok = true;
22 }
23 C(int) {};
24 ~C() {};
25
26 __attribute__((noipa))
27 void m()
28 {
29 C c;
30 }
31 };
32
33 inline void f()
34 {
35 C<double> c(1);
36 c.m();
37 }
38
39 #pragma omp end declare target
40
41 int main()
42 {
43 #pragma omp target
44 {
45 f();
46 }
47 #pragma omp target update from(ok)
48 if (!ok)
49 __builtin_abort();
50 }
51
52 /* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
53 '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
54 { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 optimized { target { ! { arm_eabi || tic6x-*-* } } } } }
55 { dg-final { scan-tree-dump-times {gimple_call <__builtin_unwind_resume, } 1 optimized { target { ! { arm_eabi || tic6x-*-* } } } } }
56 ..., just 'targetm.arm_eabi_unwinder' is different:
57 { dg-final { scan-tree-dump-times {gimple_call <__builtin_cxa_end_cleanup, } 1 optimized { target { arm_eabi || tic6x-*-* } } } }
58 { dg-final { scan-offload-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 optimized } }
59 { dg-final { scan-offload-tree-dump-times {gimple_call <__builtin_unwind_resume, } 1 optimized } } */