blob: 4b8d2df1dab3e6a8a65d56b7e1ed4c5ad08abe08 [file] [log] [blame]
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +00001// Test device data sharing codegen.
2///==========================================================================///
3
4// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
5// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CK1
6
7// expected-no-diagnostics
8
9#ifndef HEADER
10#define HEADER
11
12void test_ds(){
13 #pragma omp target
14 {
15 int a = 10;
16 #pragma omp parallel
17 {
18 a = 1000;
19 }
20 }
21}
22
23/// ========= In the worker function ========= ///
24
25// CK1: define internal void @__omp_offloading_{{.*}}test_ds{{.*}}worker(){{.*}}{
26// CK1: [[SHAREDARGS:%.+]] = alloca i8**
27// CK1: call i1 @__kmpc_kernel_parallel(i8** %work_fn, i8*** [[SHAREDARGS]])
28// CK1: [[SHARGSTMP:%.+]] = load i8**, i8*** [[SHAREDARGS]]
Jonas Hahnfeldcfd162d2017-11-21 16:49:11 +000029// CK1: call void @__omp_outlined___wrapper{{.*}}({{.*}}, i8** [[SHARGSTMP]])
Gheorghe-Teodor Berceaeb89b1d2017-11-21 15:54:54 +000030
31/// ========= In the kernel function ========= ///
32
33// CK1: {{.*}}define void @__omp_offloading{{.*}}test_ds{{.*}}()
34// CK1: [[SHAREDARGS1:%.+]] = alloca i8**
35// CK1: call void @__kmpc_kernel_prepare_parallel({{.*}}, i8*** [[SHAREDARGS1]], i32 1)
36// CK1: [[SHARGSTMP1:%.+]] = load i8**, i8*** [[SHAREDARGS1]]
37// CK1: [[SHARGSTMP2:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP1]]
38// CK1: [[SHAREDVAR:%.+]] = bitcast i32* {{.*}} to i8*
39// CK1: store i8* [[SHAREDVAR]], i8** [[SHARGSTMP2]]
40
41/// ========= In the data sharing wrapper function ========= ///
42
43// CK1: {{.*}}define internal void @__omp_outlined___wrapper({{.*}}i8**){{.*}}{
44// CK1: [[SHAREDARGS2:%.+]] = alloca i8**
45// CK1: store i8** %2, i8*** [[SHAREDARGS2]]
46// CK1: [[SHARGSTMP3:%.+]] = load i8**, i8*** [[SHAREDARGS2]]
47// CK1: [[SHARGSTMP4:%.+]] = getelementptr inbounds i8*, i8** [[SHARGSTMP3]]
48// CK1: [[SHARGSTMP5:%.+]] = bitcast i8** [[SHARGSTMP4]] to i32**
49// CK1: [[SHARGSTMP6:%.+]] = load i32*, i32** [[SHARGSTMP5]]
50// CK1: call void @__omp_outlined__({{.*}}, i32* [[SHARGSTMP6]])
51
Jonas Hahnfeldcfd162d2017-11-21 16:49:11 +000052#endif