1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s 2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 4 5 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 6 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 7 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 8 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 9 10 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s 11 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 12 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 13 14 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 15 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 16 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 17 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 18 19 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple aarch64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s 20 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple aarch64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 21 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple aarch64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 22 23 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple aarch64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 24 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple aarch64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 25 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple aarch64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 26 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 27 28 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple aarch64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s 29 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple aarch64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 30 // RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple aarch64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s 31 32 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple aarch64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix SIMD-ONLY0 %s 33 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple aarch64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s 34 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple aarch64-unknown-unknown -fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s 35 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}} 36 37 // expected-no-diagnostics 38 #ifndef HEADER 39 #define HEADER 40 41 typedef __INTPTR_TYPE__ intptr_t; 42 43 // CHECK-DAG: [[IDENT_T_TY:%.+]] = type { i32, i32, i32, i32, i8* } 44 // CHECK-DAG: [[S_TY:%.+]] = type { [[INTPTR_T_TY:i[0-9]+]], [[INTPTR_T_TY]], [[INTPTR_T_TY]] } 45 // CHECK-DAG: [[STR:@.+]] = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00" 46 // CHECK-DAG: [[DEF_LOC_2:@.+]] = private unnamed_addr constant [[IDENT_T_TY]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* [[STR]], i32 0, i32 0) } 47 48 void foo(); 49 50 struct S { 51 intptr_t a, b, c; 52 S(intptr_t a) : a(a) {} 53 operator char() { extern void mayThrow(); mayThrow(); return a; } 54 ~S() {} 55 }; 56 57 template <typename T, int C> 58 int tmain() { 59 #pragma omp target 60 #pragma omp teams 61 #pragma omp distribute parallel for num_threads(C) 62 for (int i = 0; i < 100; i++) 63 foo(); 64 #pragma omp target 65 #pragma omp teams 66 #pragma omp distribute parallel for num_threads(T(23)) 67 for (int i = 0; i < 100; i++) 68 foo(); 69 return 0; 70 } 71 72 int main() { 73 S s(0); 74 char a = s; 75 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper( 76 // CHECK: call void [[OFFLOADING_FUN_0:@.+]]( 77 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper( 78 // CHECK: call void [[OFFLOADING_FUN_1:@.+]]( 79 // CHECK: invoke{{.+}} [[TMAIN_5:@.+]]() 80 // CHECK: invoke{{.+}} [[TMAIN_1:@.+]]() 81 #pragma omp target 82 #pragma omp teams 83 // CHECK: define internal void [[OFFLOADING_FUN_0]]( 84 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}}* [[OMP_TEAMS_OUTLINED_0:@.+]] to {{.+}}) 85 #pragma omp distribute parallel for num_threads(2) 86 for (int i = 0; i < 100; i++) { 87 // CHECK: define{{.+}} void [[OMP_TEAMS_OUTLINED_0]]( 88 // CHECK: call {{.*}}void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 {{.+}}, i32 2) 89 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( 90 foo(); 91 } 92 #pragma omp target 93 #pragma omp teams 94 // CHECK: define internal void [[OFFLOADING_FUN_1]]( 95 96 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 1, {{.+}}* [[OMP_TEAMS_OUTLINED_1:@.+]] to {{.+}}) 97 #pragma omp distribute parallel for num_threads(a) 98 for (int i = 0; i < 100; i++) { 99 // CHECK: define{{.+}} void [[OMP_TEAMS_OUTLINED_1]]( 100 // CHECK-DAG: [[A_ADDR:%.+]] = alloca i8*, 101 // CHECK-DAG: [[A_REF:%.+]] = load i8*, i8** [[A_ADDR]], 102 // CHECK-DAG: [[A_VAL:%.+]] = load i8, i8* [[A_REF]], 103 // CHECK-DAG: [[A_EXT:%.+]] = sext i8 [[A_VAL]] to {{.+}} 104 // CHECK: call {{.*}}void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 {{.+}}, i32 [[A_EXT]]) 105 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( 106 foo(); 107 } 108 return a + tmain<char, 5>() + tmain<S, 1>(); 109 } 110 111 // tmain 5 112 // CHECK-DAG: define {{.*}}i{{[0-9]+}} [[TMAIN_5]]() 113 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper( 114 // CHECK: call void [[T_OFFLOADING_FUN_0:@.+]]( 115 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper( 116 // CHECK: call void [[T_OFFLOADING_FUN_1:@.+]]( 117 118 // tmain 1 119 // CHECK-DAG: define {{.*}}i{{[0-9]+}} [[TMAIN_1]]() 120 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper( 121 // CHECK: call void [[T_OFFLOADING_FUN_2:@.+]]( 122 // CHECK: call i{{[0-9]+}} @__tgt_target_teams_mapper( 123 // CHECK: call void [[T_OFFLOADING_FUN_3:@.+]]( 124 125 // CHECK: define internal void [[T_OFFLOADING_FUN_0]]( 126 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}}* [[T_OMP_TEAMS_OUTLINED_0:@.+]] to {{.+}}) 127 128 // CHECK: define{{.+}} void [[T_OMP_TEAMS_OUTLINED_0]]( 129 // CHECK: call {{.*}}void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 {{.+}}, i32 5) 130 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( 131 132 // CHECK: define internal void [[T_OFFLOADING_FUN_1]]( 133 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}}* [[T_OMP_TEAMS_OUTLINED_1:@.+]] to {{.+}}) 134 135 // CHECK: define{{.+}} void [[T_OMP_TEAMS_OUTLINED_1]]( 136 // CHECK: call {{.*}}void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 {{.+}}, i32 23) 137 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( 138 139 // CHECK: define internal void [[T_OFFLOADING_FUN_2]]( 140 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}}* [[T_OMP_TEAMS_OUTLINED_2:@.+]] to {{.+}}) 141 142 // CHECK: define{{.+}} void [[T_OMP_TEAMS_OUTLINED_2]]( 143 // CHECK: call {{.*}}void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 {{.+}}, i32 1) 144 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( 145 146 // CHECK: define internal void [[T_OFFLOADING_FUN_3]]( 147 // CHECK: call {{.*}}void {{.+}} @__kmpc_fork_teams({{.+}}, i32 0, {{.+}}* [[T_OMP_TEAMS_OUTLINED_3:@.+]] to {{.+}}) 148 149 // CHECK: define{{.+}} void [[T_OMP_TEAMS_OUTLINED_3]]( 150 // CHECK-DAG: [[CALL_RES:%.+]] = invoke{{.*}} i8 [[S_TY_CHAR_OP:@.+]]([[S_TY]]* {{.+}}) 151 // CHECK-DAG: [[CALL_RES_SEXT:%.+]] = sext i8 [[CALL_RES]] to {{.+}} 152 // CHECK: call {{.*}}void @__kmpc_push_num_threads([[IDENT_T_TY]]* [[DEF_LOC_2]], i32 {{.+}}, i32 [[CALL_RES_SEXT]]) 153 // CHECK: call {{.*}}void {{.*}} @__kmpc_fork_call( 154 #endif 155