2018-03-16 02:10:54 +08:00
|
|
|
// 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
|
2019-05-21 23:11:58 +08:00
|
|
|
// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-nvidia-cuda -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -disable-llvm-optzns | FileCheck %s
|
2018-03-16 02:10:54 +08:00
|
|
|
// expected-no-diagnostics
|
|
|
|
|
|
|
|
int foo(int &a) { return a; }
|
|
|
|
|
|
|
|
int bar() {
|
|
|
|
int a;
|
|
|
|
return foo(a);
|
|
|
|
}
|
|
|
|
|
2020-05-19 02:29:11 +08:00
|
|
|
// CHECK: define weak void @__omp_offloading_{{.*}}maini1{{.*}}_l[[@LINE+5]](i32* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %{{.*}})
|
2018-11-03 00:08:31 +08:00
|
|
|
// CHECK-NOT: @__kmpc_data_sharing_coalesced_push_stack
|
2018-03-16 02:10:54 +08:00
|
|
|
|
|
|
|
int maini1() {
|
|
|
|
int a;
|
|
|
|
#pragma omp target parallel map(from:a)
|
|
|
|
{
|
|
|
|
int b;
|
|
|
|
a = foo(b) + bar();
|
|
|
|
}
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
// parallel region
|
2020-05-19 02:29:11 +08:00
|
|
|
// CHECK: define {{.*}}void @{{.*}}(i32* noalias {{.*}}, i32* noalias {{.*}}, i32* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) %{{.*}})
|
2018-11-03 00:08:31 +08:00
|
|
|
// CHECK-NOT: call i8* @__kmpc_data_sharing_coalesced_push_stack(
|
2018-07-10 01:43:58 +08:00
|
|
|
// CHECK: [[B_ADDR:%.+]] = alloca i32,
|
2020-05-19 02:29:11 +08:00
|
|
|
// CHECK: call {{.*}}[[FOO:@.*foo.*]](i32* nonnull align {{[0-9]+}} dereferenceable({{[0-9]+}}) [[B_ADDR]])
|
2018-03-16 02:10:54 +08:00
|
|
|
// CHECK: call {{.*}}[[BAR:@.*bar.*]]()
|
2018-07-10 01:43:58 +08:00
|
|
|
// CHECK-NOT: call void @__kmpc_data_sharing_pop_stack(
|
2018-03-16 02:10:54 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
2020-05-19 02:29:11 +08:00
|
|
|
// CHECK: define {{.*}}[[FOO]](i32* nonnull align {{[0-9]+}} dereferenceable{{.*}})
|
2018-11-03 00:08:31 +08:00
|
|
|
// CHECK-NOT: @__kmpc_data_sharing_coalesced_push_stack
|
2018-03-16 02:10:54 +08:00
|
|
|
|
|
|
|
// CHECK: define {{.*}}[[BAR]]()
|
2018-10-09 22:49:00 +08:00
|
|
|
// CHECK: alloca i32,
|
|
|
|
// CHECK: [[A_LOCAL_ADDR:%.+]] = alloca i32,
|
2018-08-30 02:32:21 +08:00
|
|
|
// CHECK: [[RES:%.+]] = call i8 @__kmpc_is_spmd_exec_mode()
|
|
|
|
// CHECK: [[IS_SPMD:%.+]] = icmp ne i8 [[RES]], 0
|
|
|
|
// CHECK: br i1 [[IS_SPMD]], label
|
|
|
|
// CHECK: br label
|
2018-11-03 00:08:31 +08:00
|
|
|
// CHECK: [[RES:%.+]] = call i8* @__kmpc_data_sharing_coalesced_push_stack(i64 128, i16 0)
|
2018-10-09 22:49:00 +08:00
|
|
|
// CHECK: [[GLOBALS:%.+]] = bitcast i8* [[RES]] to [[GLOBAL_ST:%.+]]*
|
2018-08-30 02:32:21 +08:00
|
|
|
// CHECK: br label
|
2018-10-09 22:49:00 +08:00
|
|
|
// CHECK: [[ITEMS:%.+]] = phi [[GLOBAL_ST]]* [ null, {{.+}} ], [ [[GLOBALS]], {{.+}} ]
|
2018-08-30 02:32:21 +08:00
|
|
|
// CHECK: [[A_ADDR:%.+]] = getelementptr inbounds [[GLOBAL_ST]], [[GLOBAL_ST]]* [[ITEMS]], i{{[0-9]+}} 0, i{{[0-9]+}} 0
|
2018-10-09 22:49:00 +08:00
|
|
|
// CHECK: [[TID:%.+]] = call i32 @llvm.nvvm.read.ptx.sreg.tid.x()
|
|
|
|
// CHECK: [[LID:%.+]] = and i32 [[TID]], 31
|
|
|
|
// CHECK: [[A_GLOBAL_ADDR:%.+]] = getelementptr inbounds [32 x i32], [32 x i32]* [[A_ADDR]], i32 0, i32 [[LID]]
|
|
|
|
// CHECK: [[A_ADDR:%.+]] = select i1 [[IS_SPMD]], i32* [[A_LOCAL_ADDR]], i32* [[A_GLOBAL_ADDR]]
|
2020-05-19 02:29:11 +08:00
|
|
|
// CHECK: call {{.*}}[[FOO]](i32* nonnull align {{[0-9]+}} dereferenceable{{.*}} [[A_ADDR]])
|
2018-08-30 02:32:21 +08:00
|
|
|
// CHECK: br i1 [[IS_SPMD]], label
|
|
|
|
// CHECK: [[BC:%.+]] = bitcast [[GLOBAL_ST]]* [[ITEMS]] to i8*
|
|
|
|
// CHECK: call void @__kmpc_data_sharing_pop_stack(i8* [[BC]])
|
|
|
|
// CHECK: br label
|
2018-03-16 02:10:54 +08:00
|
|
|
// CHECK: ret i32
|