xref: /llvm-project/llvm/test/Transforms/OpenMP/spmdization_assumes.ll (revision 29441e4f5fa5f5c7709f7cf180815ba97f611297)
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
3
4; void foo(double x) {
5; #pragma omp target map(from:x)
6;   {
7;     x = sin(M_PI);
8; #pragma omp parallel
9;     { }
10;   }
11; }
12
13target triple = "nvptx64"
14
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, i32, i32 }
18
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, i32 0, i32 0 }, ptr @1, ptr null }
22
23
24; Function Attrs: alwaysinline convergent norecurse nounwind
25;.
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 = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 0, i8 0, i8 3, i32 0, i32 0, 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
30;.
31define weak ptx_kernel 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]+]] {
34; CHECK-NEXT:  entry:
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:%.*]]
39; CHECK:       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 [[TBAA7:![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:%.*]]
57; CHECK:       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]]
61;
62entry:
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
67
68common.ret:                                       ; preds = %entry, %user_code.entry
69  ret void
70
71user_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
77  br label %common.ret
78}
79
80declare i32 @__kmpc_target_init(ptr, ptr) local_unnamed_addr
81
82; Function Attrs: alwaysinline mustprogress nofree norecurse nosync nounwind readnone willreturn
83define 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 captures(none) [[DOTGLOBAL_TID_:%.*]], ptr noalias captures(none) [[DOTBOUND_TID_:%.*]]) #[[ATTR1:[0-9]+]] {
86; CHECK-NEXT:  entry:
87; CHECK-NEXT:    ret void
88;
89entry:
90  ret void
91}
92
93; Function Attrs: norecurse nounwind
94define 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]+]] {
97; CHECK-NEXT:  entry:
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
101;
102entry:
103  %global_args = alloca ptr, align 8
104  call void @__kmpc_get_shared_variables(ptr nonnull %global_args) #3
105  ret void
106}
107
108declare void @__kmpc_get_shared_variables(ptr) local_unnamed_addr
109
110; Function Attrs: nounwind
111declare i32 @__kmpc_global_thread_num(ptr) local_unnamed_addr #3
112
113; Function Attrs: alwaysinline
114declare void @__kmpc_parallel_51(ptr, i32, i32, i32, i32, ptr, ptr, ptr, i64) local_unnamed_addr #4
115
116declare void @__kmpc_target_deinit() local_unnamed_addr
117
118; Function Attrs: convergent
119declare double @__nv_sin(double) local_unnamed_addr #5
120
121attributes #0 = { alwaysinline convergent norecurse nounwind "kernel" "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
122attributes #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" }
123attributes #2 = { norecurse nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
124attributes #3 = { nounwind }
125attributes #4 = { alwaysinline }
126attributes #5 = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
127attributes #6 = { convergent nounwind "llvm.assume"="ompx_spmd_amenable" }
128
129!omp_offload.info = !{!0}
130!llvm.module.flags = !{!2, !3, !4, !5, !6}
131!llvm.ident = !{!7}
132
133!0 = !{i32 0, i32 64770, i32 1078211522, !"main", i32 5, i32 0}
134!2 = !{i32 1, !"wchar_size", i32 4}
135!3 = !{i32 7, !"openmp", i32 50}
136!4 = !{i32 7, !"openmp-device", i32 50}
137!5 = !{i32 8, !"PIC Level", i32 2}
138!6 = !{i32 7, !"frame-pointer", i32 2}
139!7 = !{!"clang version 14.0.0"}
140!8 = !{!9, !9, i64 0}
141!9 = !{!"double", !10, i64 0}
142!10 = !{!"omnipotent char", !11, i64 0}
143!11 = !{!"Simple C/C++ TBAA"}
144;.
145; 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" }
146; 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" }
147; CHECK: attributes #[[ATTR2]] = { norecurse nounwind "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
148; CHECK: attributes #[[ATTR3]] = { nounwind }
149; CHECK: attributes #[[ATTR4:[0-9]+]] = { alwaysinline }
150; CHECK: attributes #[[ATTR5:[0-9]+]] = { convergent "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
151; CHECK: attributes #[[ATTR6:[0-9]+]] = { convergent nounwind }
152; CHECK: attributes #[[ATTR7]] = { convergent nounwind "llvm.assume"="ompx_spmd_amenable" }
153;.
154; CHECK: [[META0:![0-9]+]] = !{i32 0, i32 64770, i32 1078211522, !"main", i32 5, i32 0}
155; CHECK: [[META1:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
156; CHECK: [[META2:![0-9]+]] = !{i32 7, !"openmp", i32 50}
157; CHECK: [[META3:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
158; CHECK: [[META4:![0-9]+]] = !{i32 8, !"PIC Level", i32 2}
159; CHECK: [[META5:![0-9]+]] = !{i32 7, !"frame-pointer", i32 2}
160; CHECK: [[META6:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
161; CHECK: [[TBAA7]] = !{[[META8:![0-9]+]], [[META8]], i64 0}
162; CHECK: [[META8]] = !{!"double", [[META9:![0-9]+]], i64 0}
163; CHECK: [[META9]] = !{!"omnipotent char", [[META10:![0-9]+]], i64 0}
164; CHECK: [[META10]] = !{!"Simple C/C++ TBAA"}
165;.
166