xref: /llvm-project/clang/test/OpenMP/openmp_offload_codegen.cpp (revision 965c7e9c6e176d8241e3cbf0e003c20d8fa7c189)
1 // Test device for mapping codegen.
2 ///==========================================================================///
3 
4 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -S -emit-llvm %s -o - 2>&1 \
5 // RUN:   | FileCheck -check-prefix=CK1 %s
6 
7 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
8 // RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ -triple powerpc64le-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-DEVICE
9 
10 // expected-no-diagnostics
11 
12 #ifdef CK1
13 
14 void target_maps_parallel_integer(int a){
15   int ParamToKernel = a;
16 #pragma omp target map(tofrom: ParamToKernel)
17   {
18     ParamToKernel += 1;
19   }
20 }
21 
22 // CK1-DEVICE: {{.*}}void @__omp_offloading_{{.*}}(i32* dereferenceable(4){{.*}}
23 
24 // CK1: {{.*}}void {{.*}}target_maps_parallel_integer{{.*}} {
25 
26 // CK1: [[GEPOBP:%.+]] = getelementptr inbounds {{.*}}
27 // CK1: [[GEPOBPBIT:%.+]] = bitcast i8** [[GEPOBP]]
28 // CK1: store i32* %ParamToKernel, i32** [[GEPOBPBIT]]
29 // CK1: [[GEPOP:%.+]] = getelementptr inbounds {{.*}}
30 // CK1: [[GEPOPBIT:%.+]] = bitcast i8** [[GEPOP]]
31 // CK1: store i32* %ParamToKernel, i32** [[GEPOPBIT]]
32 // CK1: [[GEPOBPARG:%.+]] = getelementptr inbounds {{.*}}
33 // CK1: [[GEPOPARG:%.+]] = getelementptr inbounds {{.*}}
34 // CK1: call {{.*}}tgt_target({{.*}}i8** [[GEPOBPARG]], i8** [[GEPOPARG]]
35 
36 #endif