1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
2 ; RUN: opt -S -passes=openmp-opt < %s | FileCheck %s
5 ; #pragma omp target map(from:x)
13 target triple = "nvptx64"
15 %struct.ident_t = type { i32, i32, i32, i32, ptr }
16 %struct.KernelEnvironmentTy = type { %struct.ConfigurationEnvironmentTy, ptr, ptr }
17 %struct.ConfigurationEnvironmentTy = type { i8, i8, i8, i32, i32, i32, i32 }
19 @0 = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1
20 @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, ptr @0 }, align 8
21 @__omp_offloading_fd02_404433c2_main_l5_kernel_environment = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 0, i8 0, i8 1, i32 0, i32 0, i32 0, i32 0 }, ptr @1, ptr null }
24 ; Function Attrs: alwaysinline convergent norecurse nounwind
26 ; CHECK: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [23 x i8] c"
27 ; CHECK: @[[GLOB1:[0-9]+]] = private unnamed_addr constant [[STRUCT_IDENT_T:%.*]] { i32 0, i32 2, i32 0, i32 0, ptr @[[GLOB0]] }, align 8
28 ; CHECK: @[[__OMP_OFFLOADING_FD02_404433C2_MAIN_L5_KERNEL_ENVIRONMENT:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr constant [[STRUCT_KERNELENVIRONMENTTY:%.*]] { [[STRUCT_CONFIGURATIONENVIRONMENTTY:%.*]] { i8 0, i8 0, i8 3, i32 0, i32 0, i32 0, i32 0 }, ptr @[[GLOB1]], ptr null }
29 ; CHECK: @[[GLOB2:[0-9]+]] = private unnamed_addr constant [[STRUCT_IDENT_T:%.*]] { i32 0, i32 2, i32 0, i32 22, ptr @[[GLOB0]] }, align 8
31 define weak void @__omp_offloading_fd02_404433c2_main_l5(ptr %dyn, ptr nonnull align 8 dereferenceable(8) %x) local_unnamed_addr #0 {
32 ; CHECK-LABEL: define {{[^@]+}}@__omp_offloading_fd02_404433c2_main_l5
33 ; CHECK-SAME: (ptr [[DYN:%.*]], ptr nonnull align 8 dereferenceable(8) [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
35 ; CHECK-NEXT: [[CAPTURED_VARS_ADDRS:%.*]] = alloca [0 x ptr], align 8
36 ; CHECK-NEXT: [[TMP0:%.*]] = call i32 @__kmpc_target_init(ptr nonnull @__omp_offloading_fd02_404433c2_main_l5_kernel_environment, ptr [[DYN]]) #[[ATTR3:[0-9]+]]
37 ; CHECK-NEXT: [[EXEC_USER_CODE:%.*]] = icmp eq i32 [[TMP0]], -1
38 ; CHECK-NEXT: br i1 [[EXEC_USER_CODE]], label [[USER_CODE_ENTRY:%.*]], label [[COMMON_RET:%.*]]
40 ; CHECK-NEXT: ret void
41 ; CHECK: user_code.entry:
42 ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @__kmpc_global_thread_num(ptr nonnull @[[GLOB1]]) #[[ATTR3]]
43 ; CHECK-NEXT: [[CALL_I:%.*]] = call double @__nv_sin(double 0x400921FB54442D18) #[[ATTR7:[0-9]+]]
44 ; CHECK-NEXT: br label [[REGION_CHECK_TID:%.*]]
45 ; CHECK: region.check.tid:
46 ; CHECK-NEXT: [[TMP2:%.*]] = call i32 @__kmpc_get_hardware_thread_id_in_block()
47 ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i32 [[TMP2]], 0
48 ; CHECK-NEXT: br i1 [[TMP3]], label [[REGION_GUARDED:%.*]], label [[REGION_BARRIER:%.*]]
49 ; CHECK: region.guarded:
50 ; CHECK-NEXT: store double [[CALL_I]], ptr [[X]], align 8, !tbaa [[TBAA8:![0-9]+]]
51 ; CHECK-NEXT: br label [[REGION_GUARDED_END:%.*]]
52 ; CHECK: region.guarded.end:
53 ; CHECK-NEXT: br label [[REGION_BARRIER]]
54 ; CHECK: region.barrier:
55 ; CHECK-NEXT: call void @__kmpc_barrier_simple_spmd(ptr @[[GLOB2]], i32 [[TMP2]])
56 ; CHECK-NEXT: br label [[REGION_EXIT:%.*]]
58 ; CHECK-NEXT: call void @__kmpc_parallel_51(ptr nonnull @[[GLOB1]], i32 [[TMP1]], i32 1, i32 -1, i32 -1, ptr @__omp_outlined__, ptr @__omp_outlined___wrapper, ptr nonnull [[CAPTURED_VARS_ADDRS]], i64 0) #[[ATTR3]]
59 ; CHECK-NEXT: call void @__kmpc_target_deinit() #[[ATTR3]]
60 ; CHECK-NEXT: br label [[COMMON_RET]]
63 %captured_vars_addrs = alloca [0 x ptr], align 8
64 %0 = call i32 @__kmpc_target_init(ptr nonnull @__omp_offloading_fd02_404433c2_main_l5_kernel_environment, ptr %dyn) #3
65 %exec_user_code = icmp eq i32 %0, -1
66 br i1 %exec_user_code, label %user_code.entry, label %common.ret
68 common.ret: ; preds = %entry, %user_code.entry
71 user_code.entry: ; preds = %entry
72 %1 = call i32 @__kmpc_global_thread_num(ptr nonnull @1)
73 %call.i = call double @__nv_sin(double 0x400921FB54442D18) #6
74 store double %call.i, ptr %x, align 8, !tbaa !8
75 call void @__kmpc_parallel_51(ptr nonnull @1, i32 %1, i32 1, i32 -1, i32 -1, ptr @__omp_outlined__, ptr @__omp_outlined___wrapper, ptr nonnull %captured_vars_addrs, i64 0) #3
76 call void @__kmpc_target_deinit() #3
80 declare i32 @__kmpc_target_init(ptr, ptr) local_unnamed_addr
82 ; Function Attrs: alwaysinline mustprogress nofree norecurse nosync nounwind readnone willreturn
83 define internal void @__omp_outlined__(ptr noalias nocapture %.global_tid., ptr noalias nocapture %.bound_tid.) #1 {
84 ; CHECK-LABEL: define {{[^@]+}}@__omp_outlined__
85 ; CHECK-SAME: (ptr noalias nocapture [[DOTGLOBAL_TID_:%.*]], ptr noalias nocapture [[DOTBOUND_TID_:%.*]]) #[[ATTR1:[0-9]+]] {
87 ; CHECK-NEXT: ret void
93 ; Function Attrs: norecurse nounwind
94 define internal void @__omp_outlined___wrapper(i16 zeroext %0, i32 %1) #2 {
95 ; CHECK-LABEL: define {{[^@]+}}@__omp_outlined___wrapper
96 ; CHECK-SAME: (i16 zeroext [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR2:[0-9]+]] {
98 ; CHECK-NEXT: [[GLOBAL_ARGS:%.*]] = alloca ptr, align 8
99 ; CHECK-NEXT: call void @__kmpc_get_shared_variables(ptr nonnull [[GLOBAL_ARGS]]) #[[ATTR3]]
100 ; CHECK-NEXT: ret void
103 %global_args = alloca ptr, align 8
104 call void @__kmpc_get_shared_variables(ptr nonnull %global_args) #3
108 declare void @__kmpc_get_shared_variables(ptr) local_unnamed_addr
110 ; Function Attrs: nounwind
111 declare i32 @__kmpc_global_thread_num(ptr) local_unnamed_addr #3
113 ; Function Attrs: alwaysinline
114 declare void @__kmpc_parallel_51(ptr, i32, i32, i32, i32, ptr, ptr, ptr, i64) local_unnamed_addr #4
116 declare void @__kmpc_target_deinit() local_unnamed_addr
118 ; Function Attrs: convergent
119 declare double @__nv_sin(double) local_unnamed_addr #5
121 attributes #0 = { alwaysinline convergent norecurse nounwind "kernel" "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
122 attributes #1 = { alwaysinline mustprogress nofree norecurse nosync nounwind readnone willreturn "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
123 attributes #2 = { norecurse nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
124 attributes #3 = { nounwind }
125 attributes #4 = { alwaysinline }
126 attributes #5 = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
127 attributes #6 = { convergent nounwind "llvm.assume"="ompx_spmd_amenable" }
129 !omp_offload.info = !{!0}
130 !nvvm.annotations = !{!1}
131 !llvm.module.flags = !{!2, !3, !4, !5, !6}
134 !0 = !{i32 0, i32 64770, i32 1078211522, !"main", i32 5, i32 0}
135 !1 = !{ptr @__omp_offloading_fd02_404433c2_main_l5, !"kernel", i32 1}
136 !2 = !{i32 1, !"wchar_size", i32 4}
137 !3 = !{i32 7, !"openmp", i32 50}
138 !4 = !{i32 7, !"openmp-device", i32 50}
139 !5 = !{i32 8, !"PIC Level", i32 2}
140 !6 = !{i32 7, !"frame-pointer", i32 2}
141 !7 = !{!"clang version 14.0.0"}
142 !8 = !{!9, !9, i64 0}
143 !9 = !{!"double", !10, i64 0}
144 !10 = !{!"omnipotent char", !11, i64 0}
145 !11 = !{!"Simple C/C++ TBAA"}
147 ; CHECK: attributes #[[ATTR0]] = { alwaysinline convergent norecurse nounwind "frame-pointer"="all" "kernel" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
148 ; CHECK: attributes #[[ATTR1]] = { alwaysinline mustprogress nofree norecurse nosync nounwind willreturn memory(none) "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
149 ; CHECK: attributes #[[ATTR2]] = { norecurse nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
150 ; CHECK: attributes #[[ATTR3]] = { nounwind }
151 ; CHECK: attributes #[[ATTR4:[0-9]+]] = { alwaysinline }
152 ; CHECK: attributes #[[ATTR5:[0-9]+]] = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
153 ; CHECK: attributes #[[ATTR6:[0-9]+]] = { convergent nounwind }
154 ; CHECK: attributes #[[ATTR7]] = { convergent nounwind "llvm.assume"="ompx_spmd_amenable" }
156 ; CHECK: [[META0:![0-9]+]] = !{i32 0, i32 64770, i32 1078211522, !"main", i32 5, i32 0}
157 ; CHECK: [[META1:![0-9]+]] = !{ptr @__omp_offloading_fd02_404433c2_main_l5, !"kernel", i32 1}
158 ; CHECK: [[META2:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
159 ; CHECK: [[META3:![0-9]+]] = !{i32 7, !"openmp", i32 50}
160 ; CHECK: [[META4:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
161 ; CHECK: [[META5:![0-9]+]] = !{i32 8, !"PIC Level", i32 2}
162 ; CHECK: [[META6:![0-9]+]] = !{i32 7, !"frame-pointer", i32 2}
163 ; CHECK: [[META7:![0-9]+]] = !{!"clang version 14.0.0"}
164 ; CHECK: [[TBAA8]] = !{!9, !9, i64 0}
165 ; CHECK: [[META9:![0-9]+]] = !{!"double", !10, i64 0}
166 ; CHECK: [[META10:![0-9]+]] = !{!"omnipotent char", !11, i64 0}
167 ; CHECK: [[META11:![0-9]+]] = !{!"Simple C/C++ TBAA"}