| 1 |
// Test host codegen. |
| 2 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 |
| 3 |
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
| 4 |
// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 |
| 5 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 |
| 6 |
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
| 7 |
// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 |
| 8 |
|
| 9 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
| 10 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s |
| 11 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
| 12 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
| 13 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s |
| 14 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s |
| 15 |
// SIMD-ONLY0-NOT: {{__kmpc|__tgt}} |
| 16 |
|
| 17 |
// Test target codegen - host bc file has to be created first. |
| 18 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc |
| 19 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64 |
| 20 |
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s |
| 21 |
// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-64 |
| 22 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc |
| 23 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32 |
| 24 |
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s |
| 25 |
// RUN: %clang_cc1 -fopenmp -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck %s --check-prefix TCHECK --check-prefix TCHECK-32 |
| 26 |
|
| 27 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm-bc %s -o %t-ppc-host.bc |
| 28 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck --check-prefix SIMD-ONLY1 %s |
| 29 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o %t %s |
| 30 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s |
| 31 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm-bc %s -o %t-x86-host.bc |
| 32 |
// RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o - | FileCheck --check-prefix SIMD-ONLY1 %s |
| 33 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -o %t %s |
| 34 |
// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -fopenmp-is-target-device -fopenmp-host-ir-file-path %t-x86-host.bc -include-pch %t -verify -Wno-vla %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s |
| 35 |
// SIMD-ONLY1-NOT: {{__kmpc|__tgt}} |
| 36 |
|
| 37 |
// expected-no-diagnostics |
| 38 |
#ifndef HEADER |
| 39 |
#define HEADER |
| 40 |
|
| 41 |
// CHECK-DAG: [[TT:%.+]] = type { i64, i8 } |
| 42 |
// CHECK-DAG: [[ENTTY:%.+]] = type { i64, i16, i16, i32, ptr, ptr, i64, i64, ptr } |
| 43 |
|
| 44 |
// TCHECK: [[ENTTY:%.+]] = type { i64, i16, i16, i32, ptr, ptr, i64, i64, ptr } |
| 45 |
|
| 46 |
// CHECK-DAG: [[SIZET:@.+]] = private unnamed_addr constant [3 x i64] [i64 0, i64 4, i64 {{16|12}}] |
| 47 |
// CHECK-DAG: [[MAPT:@.+]] = private unnamed_addr constant [3 x i64] [i64 544, i64 800, i64 3] |
| 48 |
// CHECK-DAG: @{{.*}} = weak constant i8 0 |
| 49 |
|
| 50 |
// TCHECK: @{{.+}} = weak constant [[ENTTY]] |
| 51 |
// TCHECK: @{{.+}} = {{.*}}constant [[ENTTY]] |
| 52 |
// TCHECK-NOT: @{{.+}} = weak constant [[ENTTY]] |
| 53 |
|
| 54 |
template<typename tx, typename ty> |
| 55 |
struct TT{ |
| 56 |
tx X; |
| 57 |
ty Y; |
| 58 |
}; |
| 59 |
|
| 60 |
#pragma omp declare mapper(id \ |
| 61 |
: TT <long long, char> \ |
| 62 |
s) map(s.X, s.Y) |
| 63 |
int global; |
| 64 |
extern int global; |
| 65 |
|
| 66 |
// CHECK: define {{.*}}[[FOO:@.+]]( |
| 67 |
int foo(int n) { |
| 68 |
int a = 0; |
| 69 |
short aa = 0; |
| 70 |
float b[10]; |
| 71 |
float bn[n]; |
| 72 |
double c[5][10]; |
| 73 |
double cn[5][n]; |
| 74 |
TT<long long, char> d; |
| 75 |
static long *plocal; |
| 76 |
|
| 77 |
// CHECK: [[ADD:%.+]] = add nsw i32 |
| 78 |
// CHECK: store i32 [[ADD]], ptr [[DEVICE_CAP:%.+]], |
| 79 |
// CHECK: [[GEP:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 0 |
| 80 |
// CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]], |
| 81 |
// CHECK: store i32 [[DEV]], ptr [[GEP]], |
| 82 |
// CHECK: [[TASK:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[GTID:%.+]], i32 1, i[[SZ:32|64]] {{20|40}}, i[[SZ]] 4, ptr [[TASK_ENTRY0:@.+]]) |
| 83 |
// CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START:%.+]], i[[SZ]] 1 |
| 84 |
// CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START]], i[[SZ]] 2 |
| 85 |
// CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START]], i[[SZ]] 3 |
| 86 |
// CHECK: call void @__kmpc_omp_taskwait_deps_51(ptr @1, i32 [[GTID]], i32 4, ptr [[DEP_START]], i32 0, ptr null, i32 0) |
| 87 |
// CHECK: call void @__kmpc_omp_task_begin_if0(ptr @1, i32 [[GTID]], ptr [[TASK]]) |
| 88 |
// CHECK: call i32 [[TASK_ENTRY0]](i32 [[GTID]], ptr [[TASK]]) |
| 89 |
// CHECK: call void @__kmpc_omp_task_complete_if0(ptr @1, i32 [[GTID]], ptr [[TASK]]) |
| 90 |
#pragma omp target device(global + a) depend(in \ |
| 91 |
: global) depend(out \ |
| 92 |
: a, b, cn[4]) |
| 93 |
{ |
| 94 |
} |
| 95 |
|
| 96 |
// CHECK: [[ADD:%.+]] = add nsw i32 |
| 97 |
// CHECK: store i32 [[ADD]], ptr [[DEVICE_CAP:%.+]], |
| 98 |
|
| 99 |
// CHECK: [[BOOL:%.+]] = icmp ne i32 %{{.+}}, 0 |
| 100 |
// CHECK: br i1 [[BOOL]], label %[[THEN:.+]], label %[[ELSE:.+]] |
| 101 |
// CHECK: [[THEN]]: |
| 102 |
// CHECK-DAG: [[BPADDR0:%.+]] = getelementptr inbounds [3 x ptr], ptr [[BP:%.+]], i32 0, i32 0 |
| 103 |
// CHECK-DAG: [[PADDR0:%.+]] = getelementptr inbounds [3 x ptr], ptr [[P:%.+]], i32 0, i32 0 |
| 104 |
// CHECK-DAG: [[MADDR0:%.+]] = getelementptr inbounds [3 x ptr], ptr [[M:%.+]], i[[SZ]] 0, i[[SZ]] 0 |
| 105 |
// CHECK-DAG: store ptr [[BP0:%[^,]+]], ptr [[BPADDR0]] |
| 106 |
// CHECK-DAG: store ptr [[BP0]], ptr [[PADDR0]] |
| 107 |
// CHECK-DAG: store ptr null, ptr [[MADDR0]], |
| 108 |
|
| 109 |
// CHECK-DAG: [[BPADDR1:%.+]] = getelementptr inbounds [3 x ptr], ptr [[BP]], i32 0, i32 1 |
| 110 |
// CHECK-DAG: [[PADDR1:%.+]] = getelementptr inbounds [3 x ptr], ptr [[P]], i32 0, i32 1 |
| 111 |
// CHECK-DAG: [[MADDR1:%.+]] = getelementptr inbounds [3 x ptr], ptr [[M]], i[[SZ]] 0, i[[SZ]] 1 |
| 112 |
// CHECK-DAG: store i[[SZ]] [[BP1:%[^,]+]], ptr [[BPADDR1]] |
| 113 |
// CHECK-DAG: store i[[SZ]] [[BP1]], ptr [[PADDR1]] |
| 114 |
// CHECK-DAG: store ptr null, ptr [[MADDR1]], |
| 115 |
|
| 116 |
// CHECK-DAG: [[BPADDR2:%.+]] = getelementptr inbounds [3 x ptr], ptr [[BP]], i32 0, i32 2 |
| 117 |
// CHECK-DAG: [[PADDR2:%.+]] = getelementptr inbounds [3 x ptr], ptr [[P]], i32 0, i32 2 |
| 118 |
// CHECK-DAG: [[MADDR2:%.+]] = getelementptr inbounds [3 x ptr], ptr [[M]], i[[SZ]] 0, i[[SZ]] 2 |
| 119 |
// CHECK-DAG: store ptr [[D_ADDR:%.+]], ptr [[BPADDR2]] |
| 120 |
// CHECK-DAG: store ptr [[D_ADDR]], ptr [[PADDR2]] |
| 121 |
// CHECK-DAG: store ptr [[MAPPER_ID:@.+]], ptr [[MADDR2]], |
| 122 |
|
| 123 |
// CHECK-DAG: [[BP_START:%.+]] = getelementptr inbounds [3 x ptr], ptr [[BP]], i32 0, i32 0 |
| 124 |
// CHECK-DAG: [[P_START:%.+]] = getelementptr inbounds [3 x ptr], ptr [[P]], i32 0, i32 0 |
| 125 |
// CHECK: [[GEP:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 2 |
| 126 |
// CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]], |
| 127 |
// CHECK: store i32 [[DEV]], ptr [[GEP]], |
| 128 |
// CHECK: [[DEV1:%.+]] = load i32, ptr [[DEVICE_CAP]], |
| 129 |
// CHECK: [[DEV2:%.+]] = sext i32 [[DEV1]] to i64 |
| 130 |
|
| 131 |
// CHECK: [[TASK:%.+]] = call ptr @__kmpc_omp_target_task_alloc(ptr @{{.*}}, i32 [[GTID]], i32 1, i[[SZ]] {{152|88}}, i[[SZ]] {{16|12}}, ptr [[TASK_ENTRY1_:@.+]], i64 [[DEV2]]) |
| 132 |
// CHECK: [[BASE:%.+]] = getelementptr inbounds nuw [[TASK_TY1_:%.+]], ptr [[TASK]], i32 0, i32 1 |
| 133 |
// CHECK-64: [[BP_BASE:%.+]] = getelementptr inbounds nuw [[PRIVS_TY:%.+]], ptr [[BASE]], i32 0, i32 1 |
| 134 |
// CHECK-64: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[BP_BASE]], ptr align 8 [[BP_START]], i64 24, i1 false) |
| 135 |
// CHECK-64: [[P_BASE:%.+]] = getelementptr inbounds nuw [[PRIVS_TY:%.+]], ptr [[BASE]], i32 0, i32 2 |
| 136 |
// CHECK-64: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[P_BASE]], ptr align 8 [[P_START]], i64 24, i1 false) |
| 137 |
// CHECK-64: [[SZ_BASE:%.+]] = getelementptr inbounds nuw [[PRIVS_TY]], ptr [[BASE]], i32 0, i32 3 |
| 138 |
// CHECK-64: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[SZ_BASE]], ptr align 8 [[SIZET]], i64 24, i1 false) |
| 139 |
// CHECK-64: [[M_BASE:%.+]] = getelementptr inbounds nuw [[PRIVS_TY]], ptr [[BASE]], i32 0, i32 4 |
| 140 |
// CHECK-64: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[M_BASE]], ptr align 8 [[M]], i64 24, i1 false) |
| 141 |
// CHECK-32: [[SZ_BASE:%.+]] = getelementptr inbounds nuw [[PRIVS_TY:%.+]], ptr [[BASE]], i32 0, i32 0 |
| 142 |
// CHECK-32: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[SZ_BASE]], ptr align 4 [[SIZET]], i32 24, i1 false) |
| 143 |
// CHECK-32: [[BP_BASE:%.+]] = getelementptr inbounds nuw [[PRIVS_TY:%.+]], ptr [[BASE]], i32 0, i32 3 |
| 144 |
// CHECK-32: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[BP_BASE]], ptr align 4 [[BP_START]], i32 12, i1 false) |
| 145 |
// CHECK-32: [[P_BASE:%.+]] = getelementptr inbounds nuw [[PRIVS_TY]], ptr [[BASE]], i32 0, i32 4 |
| 146 |
// CHECK-32: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[P_BASE]], ptr align 4 [[P_START]], i32 12, i1 false) |
| 147 |
// CHECK-32: [[M_BASE:%.+]] = getelementptr inbounds nuw [[PRIVS_TY]], ptr [[BASE]], i32 0, i32 5 |
| 148 |
// CHECK-32: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[M_BASE]], ptr align 4 [[M]], i32 12, i1 false) |
| 149 |
// CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START:%.+]], i[[SZ]] 1 |
| 150 |
// CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START]], i[[SZ]] 2 |
| 151 |
// CHECK: call i32 @__kmpc_omp_task_with_deps(ptr @1, i32 [[GTID]], ptr [[TASK]], i32 3, ptr [[DEP_START]], i32 0, ptr null) |
| 152 |
// CHECK: br label %[[EXIT:.+]] |
| 153 |
|
| 154 |
// CHECK: [[ELSE]]: |
| 155 |
// CHECK-NOT: getelementptr inbounds [2 x ptr], ptr |
| 156 |
// CHECK: [[GEP:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 2 |
| 157 |
// CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]], |
| 158 |
// CHECK: store i32 [[DEV]], ptr [[GEP]], |
| 159 |
// CHECK: [[DEV1:%.+]] = load i32, ptr [[DEVICE_CAP]], |
| 160 |
// CHECK: [[DEV2:%.+]] = sext i32 [[DEV1]] to i64 |
| 161 |
|
| 162 |
// CHECK: [[TASK:%.+]] = call ptr @__kmpc_omp_target_task_alloc(ptr @1, i32 [[GTID]], i32 1, i[[SZ]] {{56|28}}, i[[SZ]] {{16|12}}, ptr [[TASK_ENTRY1__:@.+]], i64 [[DEV2]]) |
| 163 |
// CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START:%.+]], i[[SZ]] 1 |
| 164 |
// CHECK: getelementptr %struct.kmp_depend_info, ptr [[DEP_START]], i[[SZ]] 2 |
| 165 |
// CHECK: call i32 @__kmpc_omp_task_with_deps(ptr @1, i32 [[GTID]], ptr [[TASK]], i32 3, ptr [[DEP_START]], i32 0, ptr null) |
| 166 |
// CHECK: br label %[[EXIT:.+]] |
| 167 |
// CHECK: [[EXIT]]: |
| 168 |
|
| 169 |
#pragma omp target device(global + a) nowait depend(inout \ |
| 170 |
: global, a, bn) if (a) map(mapper(id), tofrom \ |
| 171 |
: d) |
| 172 |
{ |
| 173 |
static int local1; |
| 174 |
*plocal = global; |
| 175 |
local1 = global; |
| 176 |
} |
| 177 |
|
| 178 |
// CHECK: [[TASK:%.+]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 [[GTID]], i32 1, i[[SZ]] {{48|24}}, i[[SZ]] 4, ptr [[TASK_ENTRY2:@.+]]) |
| 179 |
// CHECK: call void @__kmpc_omp_taskwait_deps_51(ptr @1, i32 [[GTID]], i32 1, ptr %{{.+}}, i32 0, ptr null, i32 0) |
| 180 |
// CHECK: call void @__kmpc_omp_task_begin_if0(ptr @1, i32 [[GTID]], ptr [[TASK]]) |
| 181 |
// CHECK: call i32 [[TASK_ENTRY2]](i32 [[GTID]], ptr [[TASK]]) |
| 182 |
// CHECK: call void @__kmpc_omp_task_complete_if0(ptr @1, i32 [[GTID]], ptr [[TASK]]) |
| 183 |
#pragma omp target if (0) firstprivate(global) depend(out \ |
| 184 |
: global) |
| 185 |
{ |
| 186 |
global += 1; |
| 187 |
} |
| 188 |
|
| 189 |
return a; |
| 190 |
} |
| 191 |
|
| 192 |
// Check that the offloading functions are emitted and that the arguments are |
| 193 |
// correct and loaded correctly for the target regions in foo(). |
| 194 |
|
| 195 |
// CHECK: define internal void [[HVT0:@.+]]() |
| 196 |
|
| 197 |
// CHECK: define internal{{.*}} i32 [[TASK_ENTRY0]](i32{{.*}}, ptr noalias noundef %1) |
| 198 |
// CHECK: store ptr null, ptr % |
| 199 |
// CHECK: [[DEVICE_CAP:%.+]] = load ptr, |
| 200 |
// CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]], |
| 201 |
// CHECK: [[DEVICE:%.+]] = sext i32 [[DEV]] to i64 |
| 202 |
// CHECK: [[RET:%.+]] = call i32 @__tgt_target_kernel(ptr @{{.+}}, i64 [[DEVICE]], i32 -1, i32 0, ptr @.[[TGT_REGION:.+]].region_id, ptr %[[KERNEL_ARGS:.+]]) |
| 203 |
// CHECK: [[ERROR:%.+]] = icmp ne i32 [[RET]], 0 |
| 204 |
// CHECK: br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]] |
| 205 |
// CHECK: [[FAIL]] |
| 206 |
// CHECK: call void [[HVT0]]() |
| 207 |
// CHECK: br label %[[END]] |
| 208 |
// CHECK: [[END]] |
| 209 |
// CHECK: ret i32 0 |
| 210 |
|
| 211 |
// CHECK: define internal void [[HVT1:@.+]](ptr noundef %{{.+}}, i[[SZ]] noundef %{{.+}}) |
| 212 |
|
| 213 |
// CHECK: define internal void [[MAPPER_ID]](ptr noundef %{{.+}}, ptr noundef %{{.+}}, ptr noundef %{{.+}}, i64 noundef %{{.+}}, i64 noundef %{{.+}}) |
| 214 |
|
| 215 |
// CHECK: define internal{{.*}} i32 [[TASK_ENTRY1_]](i32{{.*}}, ptr noalias noundef %{{.+}}) |
| 216 |
// CHECK: call void %{{.+}}(ptr %{{.+}}, ptr %{{.+}}, ptr %{{.+}}, ptr [[BPTR_ADDR:%.+]], ptr [[PTR_ADDR:%.+]], ptr [[SZ_ADDR:%.+]], ptr [[M_ADDR:%.+]]) |
| 217 |
// CHECK: [[BPTR_REF:%.+]] = load ptr, ptr [[BPTR_ADDR]], |
| 218 |
// CHECK: [[PTR_REF:%.+]] = load ptr, ptr [[PTR_ADDR]], |
| 219 |
// CHECK: [[SZ_REF:%.+]] = load ptr, ptr [[SZ_ADDR]], |
| 220 |
// CHECK: [[M_REF:%.+]] = load ptr, ptr [[M_ADDR]], |
| 221 |
// CHECK: [[DEVICE_CAP:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 2 |
| 222 |
// CHECK: [[DEV:%.+]] = load i32, ptr [[DEVICE_CAP]], |
| 223 |
// CHECK: [[DEVICE:%.+]] = sext i32 [[DEV]] to i64 |
| 224 |
// CHECK: [[RET:%.+]] = call i32 @__tgt_target_kernel(ptr @{{.+}}, i64 [[DEVICE]], i32 -1, i32 0, ptr @.[[TGT_REGION:.+]].region_id, ptr %[[KERNEL_ARGS:.+]]) |
| 225 |
|
| 226 |
// CHECK: [[ERROR:%.+]] = icmp ne i32 [[RET]], 0 |
| 227 |
// CHECK: br i1 [[ERROR]], label %[[FAIL:[^,]+]], label %[[END:[^,]+]] |
| 228 |
// CHECK: [[FAIL]] |
| 229 |
// CHECK: [[BP0:%.+]] = load ptr, ptr % |
| 230 |
// CHECK: [[BP1_I32:%.+]] = load i32, ptr @ |
| 231 |
// CHECK-64: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]], |
| 232 |
// CHECK-32: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]], |
| 233 |
// CHECK: [[BP1:%.+]] = load i[[SZ]], ptr [[BP1_PTR]], |
| 234 |
// CHECK: call void [[HVT1]](ptr [[BP0]], i[[SZ]] [[BP1]]) |
| 235 |
// CHECK: br label %[[END]] |
| 236 |
// CHECK: [[END]] |
| 237 |
// CHECK: ret i32 0 |
| 238 |
|
| 239 |
// CHECK: define internal{{.*}} i32 [[TASK_ENTRY1__]](i32{{.*}}, ptr noalias noundef %1) |
| 240 |
// CHECK: call void {{%.*}}( |
| 241 |
// CHECK: [[DEVICE_CAP:%.+]] = getelementptr inbounds nuw %{{.+}}, ptr %{{.+}}, i32 0, i32 2 |
| 242 |
// CHECK: [[BP0:%.+]] = load ptr, ptr % |
| 243 |
// CHECK: [[BP1_I32:%.+]] = load i32, ptr @ |
| 244 |
// CHECK-64: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]], |
| 245 |
// CHECK-32: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]], |
| 246 |
// CHECK: [[BP1:%.+]] = load i[[SZ]], ptr [[BP1_PTR]], |
| 247 |
// CHECK: call void [[HVT1]](ptr [[BP0]], i[[SZ]] [[BP1]]) |
| 248 |
// CHECK: ret i32 0 |
| 249 |
|
| 250 |
// CHECK: define internal void [[HVT2:@.+]](i[[SZ]] noundef %{{.+}}) |
| 251 |
// Create stack storage and store argument in there. |
| 252 |
// CHECK: [[AA_ADDR:%.+]] = alloca i[[SZ]], align |
| 253 |
// CHECK: store i[[SZ]] %{{.+}}, ptr [[AA_ADDR]], align |
| 254 |
// CHECK-64: load i32, ptr [[AA_ADDR]], align |
| 255 |
// CHECK-32: load i32, ptr [[AA_ADDR]], align |
| 256 |
|
| 257 |
// CHECK: define internal{{.*}} i32 [[TASK_ENTRY2]](i32{{.*}}, ptr noalias noundef %1) |
| 258 |
// CHECK: call void {{%.*}}( |
| 259 |
// CHECK: [[BP1_I32:%.+]] = load i32, ptr % |
| 260 |
// CHECK-64: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]], |
| 261 |
// CHECK-32: store i32 [[BP1_I32]], ptr [[BP1_PTR:%[^,]+]], |
| 262 |
// CHECK: [[BP1:%.+]] = load i[[SZ]], ptr [[BP1_PTR]], |
| 263 |
// CHECK: call void [[HVT2]](i[[SZ]] [[BP1]]) |
| 264 |
// CHECK: ret i32 0 |
| 265 |
|
| 266 |
#endif |