192327c50SAlexey Bataev // 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 --check-prefix CHECK 292327c50SAlexey Bataev // 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 392327c50SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix DEVICE --check-prefix CHECK 492327c50SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t 592327c50SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - | FileCheck %s --check-prefix DEVICE --check-prefix CHECK 692327c50SAlexey Bataev 792327c50SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix SIMD-ONLY 892327c50SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc 992327c50SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o -| FileCheck %s --check-prefix SIMD-ONLY 1092327c50SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t 1192327c50SAlexey Bataev // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -o - | FileCheck %s --check-prefix SIMD-ONLY 1292327c50SAlexey Bataev 1392327c50SAlexey Bataev // expected-no-diagnostics 1492327c50SAlexey Bataev 1592327c50SAlexey Bataev // SIMD-ONLY-NOT: {{__kmpc|__tgt}} 1692327c50SAlexey Bataev 1792327c50SAlexey Bataev #ifndef HEADER 1892327c50SAlexey Bataev #define HEADER 1992327c50SAlexey Bataev 20d01b7497SAlexey Bataev // HOST-DAG: @c = external global i32, 21*625f59d1SGheorghe-Teodor Bercea // HOST-DAG: @c_decl_tgt_ref_ptr = weak global i32* @c 22*625f59d1SGheorghe-Teodor Bercea // HOST-DAG: @[[D:.+]] = internal global i32 2 23*625f59d1SGheorghe-Teodor Bercea // HOST-DAG: @[[D_PTR:.+]] = weak global i32* @[[D]] 2492327c50SAlexey Bataev // DEVICE-NOT: @c = 25*625f59d1SGheorghe-Teodor Bercea // DEVICE: @c_decl_tgt_ref_ptr = weak global i32* null 26*625f59d1SGheorghe-Teodor Bercea // HOST: [[SIZES:@.+]] = private unnamed_addr constant [3 x i64] [i64 4, i64 4, i64 4] 27*625f59d1SGheorghe-Teodor Bercea // HOST: [[MAPTYPES:@.+]] = private unnamed_addr constant [3 x i64] [i64 35, i64 531, i64 531] 280034e84aSGheorghe-Teodor Bercea // HOST: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_decl_tgt_ref_ptr\00" 290034e84aSGheorghe-Teodor Bercea // HOST: @.omp_offloading.entry.c_decl_tgt_ref_ptr = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32** @c_decl_tgt_ref_ptr to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @.omp_offloading.entry_name, i32 0, i32 0), i64 8, i32 1, i32 0 }, section ".omp_offloading.entries", align 1 30*625f59d1SGheorghe-Teodor Bercea // DEVICE-NOT: internal unnamed_addr constant [{{[0-9]+}} x i8] c"c_{{.*}}_decl_tgt_ref_ptr\00" 31*625f59d1SGheorghe-Teodor Bercea // HOST: @.omp_offloading.entry_name{{.*}} = internal unnamed_addr constant [{{[0-9]+}} x i8] c"_{{.*}}d_{{.*}}_decl_tgt_ref_ptr\00" 32*625f59d1SGheorghe-Teodor Bercea // HOST: @.omp_offloading.entry.[[D_PTR]] = weak constant %struct.__tgt_offload_entry { i8* bitcast (i32** @[[D_PTR]] to i8*), i8* getelementptr inbounds ([{{[0-9]+}} x i8], [{{[0-9]+}} x i8]* @.omp_offloading.entry_name{{.*}}, i32 0, i32 0 3392327c50SAlexey Bataev 3492327c50SAlexey Bataev extern int c; 3592327c50SAlexey Bataev #pragma omp declare target link(c) 3692327c50SAlexey Bataev 37*625f59d1SGheorghe-Teodor Bercea static int d = 2; 38*625f59d1SGheorghe-Teodor Bercea #pragma omp declare target link(d) 39*625f59d1SGheorghe-Teodor Bercea 4092327c50SAlexey Bataev int maini1() { 4192327c50SAlexey Bataev int a; 4292327c50SAlexey Bataev #pragma omp target map(tofrom : a) 4392327c50SAlexey Bataev { 4492327c50SAlexey Bataev a = c; 45*625f59d1SGheorghe-Teodor Bercea d++; 4692327c50SAlexey Bataev } 47a495c640SAlexey Bataev #pragma omp target 48a495c640SAlexey Bataev #pragma omp teams 49a495c640SAlexey Bataev c = a; 5092327c50SAlexey Bataev return 0; 5192327c50SAlexey Bataev } 5292327c50SAlexey Bataev 53*625f59d1SGheorghe-Teodor Bercea // DEVICE: define weak void @__omp_offloading_{{.*}}_{{.*}}maini1{{.*}}_l42(i32* dereferenceable{{[^,]*}} 540034e84aSGheorghe-Teodor Bercea // DEVICE: [[C_REF:%.+]] = load i32*, i32** @c_decl_tgt_ref_ptr, 5592327c50SAlexey Bataev // DEVICE: [[C:%.+]] = load i32, i32* [[C_REF]], 5692327c50SAlexey Bataev // DEVICE: store i32 [[C]], i32* % 5792327c50SAlexey Bataev 5892327c50SAlexey Bataev // HOST: define {{.*}}i32 @{{.*}}maini1{{.*}}() 59*625f59d1SGheorghe-Teodor Bercea // HOST: [[BASEPTRS:%.+]] = alloca [3 x i8*], 60*625f59d1SGheorghe-Teodor Bercea // HOST: [[PTRS:%.+]] = alloca [3 x i8*], 61*625f59d1SGheorghe-Teodor Bercea // HOST: getelementptr inbounds [3 x i8*], [3 x i8*]* [[BASEPTRS]], i{{[0-9]+}} 0, i{{[0-9]+}} 0 62*625f59d1SGheorghe-Teodor Bercea // HOST: getelementptr inbounds [3 x i8*], [3 x i8*]* [[PTRS]], i{{[0-9]+}} 0, i{{[0-9]+}} 0 63*625f59d1SGheorghe-Teodor Bercea 64*625f59d1SGheorghe-Teodor Bercea // HOST: [[BP1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BASEPTRS]], i{{[0-9]+}} 0, i{{[0-9]+}} 1 6592327c50SAlexey Bataev // HOST: [[BP1_CAST:%.+]] = bitcast i8** [[BP1]] to i32*** 660034e84aSGheorghe-Teodor Bercea // HOST: store i32** @c_decl_tgt_ref_ptr, i32*** [[BP1_CAST]], 67*625f59d1SGheorghe-Teodor Bercea // HOST: [[P1:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PTRS]], i{{[0-9]+}} 0, i{{[0-9]+}} 1 6892327c50SAlexey Bataev // HOST: [[P1_CAST:%.+]] = bitcast i8** [[P1]] to i32** 6992327c50SAlexey Bataev // HOST: store i32* @c, i32** [[P1_CAST]], 7092327c50SAlexey Bataev 71*625f59d1SGheorghe-Teodor Bercea // HOST: [[BP2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BASEPTRS]], i{{[0-9]+}} 0, i{{[0-9]+}} 2 72*625f59d1SGheorghe-Teodor Bercea // HOST: [[BP2_CAST:%.+]] = bitcast i8** [[BP2]] to i32*** 73*625f59d1SGheorghe-Teodor Bercea // HOST: store i32** @[[D_PTR]], i32*** [[BP2_CAST]], 74*625f59d1SGheorghe-Teodor Bercea // HOST: [[P2:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PTRS]], i{{[0-9]+}} 0, i{{[0-9]+}} 2 75*625f59d1SGheorghe-Teodor Bercea // HOST: [[P2_CAST:%.+]] = bitcast i8** [[P2]] to i32** 76*625f59d1SGheorghe-Teodor Bercea // HOST: store i32* @[[D]], i32** [[P2_CAST]], 77*625f59d1SGheorghe-Teodor Bercea 78*625f59d1SGheorghe-Teodor Bercea // HOST: [[BP0:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[BASEPTRS]], i{{[0-9]+}} 0, i{{[0-9]+}} 0 79*625f59d1SGheorghe-Teodor Bercea // HOST: [[P0:%.+]] = getelementptr inbounds [3 x i8*], [3 x i8*]* [[PTRS]], i{{[0-9]+}} 0, i{{[0-9]+}} 0 80*625f59d1SGheorghe-Teodor Bercea // HOST: call i32 @__tgt_target(i64 -1, i8* @{{[^,]+}}, i32 3, i8** [[BP0]], i8** [[P0]], i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[SIZES]], i{{[0-9]+}} 0, i{{[0-9]+}} 0), i64* getelementptr inbounds ([3 x i64], [3 x i64]* [[MAPTYPES]], i{{[0-9]+}} 0, i{{[0-9]+}} 0)) 81*625f59d1SGheorghe-Teodor Bercea // HOST: call void @__omp_offloading_{{.*}}_{{.*}}_{{.*}}maini1{{.*}}_l42(i32* %{{[^,]+}}) 82*625f59d1SGheorghe-Teodor Bercea // HOST: call i32 @__tgt_target_teams(i64 -1, i8* @.__omp_offloading_{{.+}}_l47.region_id, i32 2, {{.+}}) 83*625f59d1SGheorghe-Teodor Bercea 84*625f59d1SGheorghe-Teodor Bercea // HOST: define internal void @__omp_offloading_{{.*}}_{{.*}}maini1{{.*}}_l42(i32* dereferenceable{{.*}}) 8592327c50SAlexey Bataev // HOST: [[C:%.*]] = load i32, i32* @c, 8692327c50SAlexey Bataev // HOST: store i32 [[C]], i32* % 8792327c50SAlexey Bataev 880034e84aSGheorghe-Teodor Bercea // CHECK: !{i32 1, !"c_decl_tgt_ref_ptr", i32 1, i32 {{[0-9]+}}} 8992327c50SAlexey Bataev #endif // HEADER 90