[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / declare_target_only_one_side_compilation.cpp
blobac88cc0b779bdf09243d530214a08a9ee12c95ce
1 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix HOST
2 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc
3 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix DEVICE
5 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-pc-linux-gnu -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix HOST
6 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-pc-linux-gnu -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-i386-host.bc
7 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-i386-host.bc -o - | FileCheck %s --check-prefix DEVICE
9 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu -fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix HOST
10 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu -fopenmp-targets=x86_64-unknown-linux-gnu -emit-llvm-bc %s -o %t-x86_64-host.bc
11 // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86_64-host.bc -o - | FileCheck %s --check-prefix DEVICE
13 // expected-no-diagnostics
15 #pragma omp declare target
16 #pragma omp begin declare variant match(device = {kind(nohost)})
17 int G1;
18 static int G2;
19 #pragma omp end declare variant
20 #pragma omp end declare target
22 #pragma omp begin declare target device_type(nohost)
23 int G3;
24 static int G4;
25 #pragma omp end declare target
27 #pragma omp declare target
28 int G5;
29 static int G6;
30 #pragma omp end declare target
32 #pragma omp declare target to(G5, G6) device_type(nohost)
34 #pragma omp begin declare target device_type(host)
35 int G7;
36 static int G8;
37 #pragma omp end declare target
39 #pragma omp declare target
40 int G9;
41 static int G10;
42 #pragma omp end declare target
44 int G11;
45 static int G12;
46 #pragma omp declare target to(G9, G10, G11, G12) device_type(host)
48 // TODO: The code below should probably work but it is not 100% clear.
49 #if 0
50 #pragma omp declare target
51 #pragma omp begin declare variant match(device = {kind(host)})
52 int GX;
53 static int GY;
54 #pragma omp end declare variant
55 #pragma omp end declare target
56 #endif
58 // TODO: It is odd, probably wrong, that we don't mangle all variables.
60 // DEVICE-DAG: @G1 = {{.*}}global i32 0, align 4
61 // DEVICE-DAG: @_ZL2G2 = internal {{.*}}global i32 0, align 4
62 // DEVICE-DAG: @G3 = {{.*}}global i32 0, align 4
63 // DEVICE-DAG: @_ZL2G4 = internal {{.*}}global i32 0, align 4
64 // DEVICE-DAG: @G5 = {{.*}}global i32 0, align 4
65 // DEVICE-DAG: @_ZL2G6 = internal {{.*}}global i32 0, align 4
66 // DEVICE-NOT: ref
67 // DEVICE-NOT: llvm.used
68 // DEVICE-NOT: omp_offload
70 // HOST-DAG: @G7 = global i32 0, align 4
71 // HOST-DAG: @_ZL2G8 = internal global i32 0, align 4
72 // HOST-DAG: @G9 = global i32 0, align 4
73 // HOST-DAG: @_ZL3G10 = internal global i32 0, align 4
74 // HOST-DAG: @G11 = global i32 0, align 4
75 // HOST-DAG: @_ZL3G12 = internal global i32 0, align 4