xref: /llvm-project/llvm/test/Transforms/OpenMP/deduplication_target.ll (revision 07ed8187acc31ac3f4779da452864a29d48799ac)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2; RUN: opt -passes=openmp-opt-cgscc -S < %s | FileCheck %s
3
4target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
5target triple = "nvptx64"
6
7%struct.ident_t = type { i32, i32, i32, i32, ptr }
8%struct.KernelEnvironmentTy = type { %struct.ConfigurationEnvironmentTy, ptr, ptr }
9%struct.ConfigurationEnvironmentTy = type { i8, i8, i8, i32, i32, i32, i32, i32, i32 }
10
11@0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1
12@1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, ptr @0 }, align 8
13@2 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 1, i32 0, ptr @0 }, align 8
14@__omp_offloading_50_a3e09bf8_foo_l2_kernel_environment = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 0, i8 0, i8 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }, ptr null, ptr null }
15
16declare void @use(i32)
17
18define weak ptx_kernel void @__omp_offloading_50_a3e09bf8_foo_l2(ptr %dyn) #0 {
19; CHECK-LABEL: define {{[^@]+}}@__omp_offloading_50_a3e09bf8_foo_l2
20; CHECK-SAME: (ptr [[DYN:%.*]]) #[[ATTR0:[0-9]+]] {
21; CHECK-NEXT:  entry:
22; CHECK-NEXT:    [[CAPTURED_VARS_ADDRS:%.*]] = alloca [0 x ptr], align 8
23; CHECK-NEXT:    [[TMP0:%.*]] = call i32 @__kmpc_target_init(ptr @__omp_offloading_50_a3e09bf8_foo_l2_kernel_environment, ptr [[DYN]])
24; CHECK-NEXT:    [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1
25; CHECK-NEXT:    br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[WORKER_EXIT:%.*]]
26; CHECK:       user_code.entry:
27; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB2:[0-9]+]])
28; CHECK-NEXT:    call void @__kmpc_target_deinit()
29; CHECK-NEXT:    ret void
30; CHECK:       worker.exit:
31; CHECK-NEXT:    ret void
32;
33entry:
34  %captured_vars_addrs = alloca [0 x ptr], align 8
35  %0 = call i32 @__kmpc_target_init(ptr @__omp_offloading_50_a3e09bf8_foo_l2_kernel_environment, ptr %dyn)
36  %exec_user_code = icmp eq i32 %0, -1
37  br i1 %exec_user_code, label %user_code.entry, label %worker.exit
38
39user_code.entry:                                  ; preds = %entry
40  %1 = call i32 @__kmpc_global_thread_num(ptr @2)
41  %2 = call i32 @__kmpc_global_thread_num(ptr @2)
42  call void @__kmpc_target_deinit()
43  ret void
44
45worker.exit:                                      ; preds = %entry
46  ret void
47}
48
49declare i32 @__kmpc_target_init(ptr, ptr)
50
51declare i32 @__kmpc_global_thread_num(ptr) #1
52
53declare void @__kmpc_target_deinit()
54
55attributes #0 = { convergent noinline norecurse nounwind "kernel" "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+ptx32,+sm_20" }
56attributes #1 = { nounwind }
57
58!omp_offload.info = !{!0}
59!llvm.module.flags = !{!2, !3, !4}
60
61!0 = !{i32 0, i32 80, i32 -1545561096, !"foo", i32 2, i32 0}
62!2 = !{i32 1, !"wchar_size", i32 4}
63!3 = !{i32 7, !"openmp", i32 50}
64!4 = !{i32 7, !"openmp-device", i32 50}
65