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 target triple = "nvptx64"
5 %struct.ident_t = type { i32, i32, i32, i32, i8* }
7 @is_spmd_exec_mode = weak constant i8 0
8 @will_be_spmd_exec_mode = weak constant i8 1
9 @non_spmd_exec_mode = weak constant i8 1
10 @will_not_be_spmd_exec_mode = weak constant i8 1
11 @G = external global i8
12 @llvm.compiler.used = appending global [4 x i8*] [i8* @is_spmd_exec_mode, i8* @will_be_spmd_exec_mode, i8* @non_spmd_exec_mode, i8* @will_not_be_spmd_exec_mode ], section "llvm.metadata"
15 ; CHECK: @[[IS_SPMD_EXEC_MODE:[a-zA-Z0-9_$"\\.-]+]] = weak constant i8 0
16 ; CHECK: @[[WILL_BE_SPMD_EXEC_MODE:[a-zA-Z0-9_$"\\.-]+]] = weak constant i8 2
17 ; CHECK: @[[NON_SPMD_EXEC_MODE:[a-zA-Z0-9_$"\\.-]+]] = weak constant i8 1
18 ; CHECK: @[[WILL_NOT_BE_SPMD_EXEC_MODE:[a-zA-Z0-9_$"\\.-]+]] = weak constant i8 1
19 ; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = external global i8
20 ; CHECK: @[[LLVM_COMPILER_USED:[a-zA-Z0-9_$"\\.-]+]] = appending global [4 x i8*] [i8* @is_spmd_exec_mode, i8* @will_be_spmd_exec_mode, i8* @non_spmd_exec_mode, i8* @will_not_be_spmd_exec_mode], section "llvm.metadata"
22 define weak void @is_spmd() {
23 ; CHECK-LABEL: define {{[^@]+}}@is_spmd() {
24 ; CHECK-NEXT: [[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
25 ; CHECK-NEXT: call void @is_spmd_helper1()
26 ; CHECK-NEXT: call void @is_spmd_helper2()
27 ; CHECK-NEXT: call void @is_mixed_helper()
28 ; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* null, i1 true, i1 false)
29 ; CHECK-NEXT: ret void
31 %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
32 call void @is_spmd_helper1()
33 call void @is_spmd_helper2()
34 call void @is_mixed_helper()
35 call void @__kmpc_target_deinit(%struct.ident_t* null, i1 true, i1 false)
39 define weak void @will_be_spmd() {
40 ; CHECK-LABEL: define {{[^@]+}}@will_be_spmd() {
41 ; CHECK-NEXT: [[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
42 ; CHECK-NEXT: call void @is_spmd_helper2()
43 ; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* null, i1 true, i1 false)
44 ; CHECK-NEXT: ret void
46 %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
47 call void @is_spmd_helper2()
48 call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
52 define weak void @non_spmd() {
53 ; CHECK-LABEL: define {{[^@]+}}@non_spmd() {
54 ; CHECK-NEXT: [[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
55 ; CHECK-NEXT: call void @is_generic_helper1()
56 ; CHECK-NEXT: call void @is_generic_helper2()
57 ; CHECK-NEXT: call void @is_mixed_helper()
58 ; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
59 ; CHECK-NEXT: ret void
61 %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
62 call void @is_generic_helper1()
63 call void @is_generic_helper2()
64 call void @is_mixed_helper()
65 call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
69 define weak void @will_not_be_spmd() {
70 ; CHECK-LABEL: define {{[^@]+}}@will_not_be_spmd() {
71 ; CHECK-NEXT: [[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
72 ; CHECK-NEXT: call void @is_generic_helper1()
73 ; CHECK-NEXT: call void @is_generic_helper2()
74 ; CHECK-NEXT: call void @is_mixed_helper()
75 ; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
76 ; CHECK-NEXT: ret void
78 %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
79 call void @is_generic_helper1()
80 call void @is_generic_helper2()
81 call void @is_mixed_helper()
82 call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
86 define internal void @is_spmd_helper1() {
87 ; CHECK-LABEL: define {{[^@]+}}@is_spmd_helper1() {
88 ; CHECK-NEXT: store i8 1, i8* @G, align 1
89 ; CHECK-NEXT: ret void
91 %isSPMD = call i8 @__kmpc_is_spmd_exec_mode()
92 store i8 %isSPMD, i8* @G
96 define internal void @is_spmd_helper2() {
97 ; CHECK-LABEL: define {{[^@]+}}@is_spmd_helper2() {
98 ; CHECK-NEXT: br label [[F:%.*]]
100 ; CHECK-NEXT: unreachable
102 ; CHECK-NEXT: ret void
104 %isSPMD = call i8 @__kmpc_is_spmd_exec_mode()
105 %c = icmp eq i8 %isSPMD, 0
106 br i1 %c, label %t, label %f
108 call void @spmd_compatible()
114 define internal void @is_generic_helper1() {
115 ; CHECK-LABEL: define {{[^@]+}}@is_generic_helper1() {
116 ; CHECK-NEXT: store i8 0, i8* @G, align 1
117 ; CHECK-NEXT: ret void
119 %isSPMD = call i8 @__kmpc_is_spmd_exec_mode()
120 store i8 %isSPMD, i8* @G
124 define internal void @is_generic_helper2() {
125 ; CHECK-LABEL: define {{[^@]+}}@is_generic_helper2() {
126 ; CHECK-NEXT: br label [[T:%.*]]
128 ; CHECK-NEXT: call void @foo()
129 ; CHECK-NEXT: ret void
131 ; CHECK-NEXT: call void @bar()
132 ; CHECK-NEXT: ret void
134 %isSPMD = call i8 @__kmpc_is_spmd_exec_mode()
135 %c = icmp eq i8 %isSPMD, 0
136 br i1 %c, label %t, label %f
145 define internal void @is_mixed_helper() {
146 ; CHECK-LABEL: define {{[^@]+}}@is_mixed_helper() {
147 ; CHECK-NEXT: [[ISSPMD:%.*]] = call i8 @__kmpc_is_spmd_exec_mode()
148 ; CHECK-NEXT: store i8 [[ISSPMD]], i8* @G, align 1
149 ; CHECK-NEXT: ret void
151 %isSPMD = call i8 @__kmpc_is_spmd_exec_mode()
152 store i8 %isSPMD, i8* @G
156 declare void @spmd_compatible() "llvm.assume"="ompx_spmd_amenable"
157 declare i8 @__kmpc_is_spmd_exec_mode()
158 declare i32 @__kmpc_target_init(%struct.ident_t*, i1 zeroext, i1 zeroext, i1 zeroext) #1
159 declare void @__kmpc_target_deinit(%struct.ident_t* nocapture readnone, i1 zeroext, i1 zeroext) #1
163 !llvm.module.flags = !{!0, !1}
164 !nvvm.annotations = !{!2, !3, !4, !5}
166 !0 = !{i32 7, !"openmp", i32 50}
167 !1 = !{i32 7, !"openmp-device", i32 50}
168 !2 = !{void ()* @is_spmd, !"kernel", i32 1}
169 !3 = !{void ()* @will_be_spmd, !"kernel", i32 1}
170 !4 = !{void ()* @non_spmd, !"kernel", i32 1}
171 !5 = !{void ()* @will_not_be_spmd, !"kernel", i32 1}
173 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { "llvm.assume"="ompx_spmd_amenable" }
175 ; CHECK: [[META0:![0-9]+]] = !{i32 7, !"openmp", i32 50}
176 ; CHECK: [[META1:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
177 ; CHECK: [[META2:![0-9]+]] = !{void ()* @is_spmd, !"kernel", i32 1}
178 ; CHECK: [[META3:![0-9]+]] = !{void ()* @will_be_spmd, !"kernel", i32 1}
179 ; CHECK: [[META4:![0-9]+]] = !{void ()* @non_spmd, !"kernel", i32 1}
180 ; CHECK: [[META5:![0-9]+]] = !{void ()* @will_not_be_spmd, !"kernel", i32 1}