1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals --include-generated-funcs
2 ; RUN: opt -S -passes='openmp-opt' < %s | FileCheck %s
3 ; RUN: opt -passes=openmp-opt -pass-remarks=openmp-opt -disable-output < %s 2>&1 | FileCheck %s -check-prefix=CHECK-REMARKS
4 target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
5 target triple = "nvptx64"
7 %struct.ident_t = type { i32, i32, i32, i32, i8* }
9 @S = external local_unnamed_addr global i8*
10 @0 = private unnamed_addr constant [113 x i8] c";llvm/test/Transforms/OpenMP/custom_state_machines_remarks.c;__omp_offloading_2a_d80d3d_test_fallback_l11;11;1;;\00", align 1
11 @1 = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([113 x i8], [113 x i8]* @0, i32 0, i32 0) }, align 8
13 ; CHECK-REMARKS: remark: replace_globalization.c:5:7: Replaced globalized variable with 16 bytes of shared memory
14 ; CHECK-REMARKS: remark: replace_globalization.c:5:14: Replaced globalized variable with 4 bytes of shared memory
15 ; CHECK-REMARKS-NOT: 6 bytes
17 define dso_local void @foo() {
19 %c = call i32 @__kmpc_target_init(%struct.ident_t* @1, i1 false, i1 true, i1 true)
20 %x = call i8* @__kmpc_alloc_shared(i64 4)
21 call void @unknown_no_openmp()
22 %x_on_stack = bitcast i8* %x to i32*
23 %0 = bitcast i32* %x_on_stack to i8*
24 call void @use(i8* %0)
25 call void @__kmpc_free_shared(i8* %x, i64 4)
26 call void @__kmpc_target_deinit(%struct.ident_t* @1, i1 false, i1 true)
31 %c = call i32 @__kmpc_target_init(%struct.ident_t* @1, i1 false, i1 true, i1 true)
32 call void @unknown_no_openmp()
35 call void @negative_qux_spmd()
36 call void @__kmpc_target_deinit(%struct.ident_t* @1, i1 false, i1 true)
40 define internal void @baz() {
42 %call = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @1, i1 false, i1 false, i1 true)
43 call void @unknown_no_openmp()
44 %cmp = icmp eq i32 %call, -1
45 br i1 %cmp, label %master, label %exit
47 %x = call i8* @__kmpc_alloc_shared(i64 16), !dbg !11
48 %x_on_stack = bitcast i8* %x to [4 x i32]*
49 %0 = bitcast [4 x i32]* %x_on_stack to i8*
50 call void @use(i8* %0)
51 call void @__kmpc_free_shared(i8* %x, i64 16)
57 define internal void @qux() {
59 %call = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @1, i1 false, i1 true, i1 true)
60 call void @unknown_no_openmp()
61 %0 = icmp eq i32 %call, -1
62 br i1 %0, label %master, label %exit
64 %y = call i8* @__kmpc_alloc_shared(i64 4), !dbg !12
65 %y_on_stack = bitcast i8* %y to [4 x i32]*
66 %1 = bitcast [4 x i32]* %y_on_stack to i8*
67 call void @use(i8* %1)
68 call void @__kmpc_free_shared(i8* %y, i64 4)
74 define internal void @negative_qux_spmd() {
76 %call = call i32 @__kmpc_target_init(%struct.ident_t* nonnull @1, i1 true, i1 true, i1 true)
77 call void @unknown_no_openmp()
78 %0 = icmp eq i32 %call, -1
79 br i1 %0, label %master, label %exit
81 %y = call i8* @__kmpc_alloc_shared(i64 24), !dbg !12
82 %y_on_stack = bitcast i8* %y to [6 x i32]*
83 %1 = bitcast [6 x i32]* %y_on_stack to i8*
84 call void @use(i8* %1)
85 call void @__kmpc_free_shared(i8* %y, i64 24)
92 define void @use(i8* %x) {
98 declare i8* @__kmpc_alloc_shared(i64)
100 declare void @__kmpc_free_shared(i8*, i64)
102 declare i32 @llvm.nvvm.read.ptx.sreg.tid.x()
104 declare i32 @llvm.nvvm.read.ptx.sreg.ntid.x()
106 declare i32 @llvm.nvvm.read.ptx.sreg.warpsize()
108 declare i32 @__kmpc_target_init(%struct.ident_t*, i1, i1, i1)
110 declare void @__kmpc_target_deinit(%struct.ident_t*, i1, i1)
112 declare void @unknown_no_openmp() "llvm.assume"="omp_no_openmp"
115 !llvm.module.flags = !{!3, !4, !5, !6}
116 !nvvm.annotations = !{!7, !8}
118 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
119 !1 = !DIFile(filename: "replace_globalization.c", directory: "/tmp/replace_globalization.c")
121 !3 = !{i32 2, !"Debug Info Version", i32 3}
122 !4 = !{i32 1, !"wchar_size", i32 4}
123 !5 = !{i32 7, !"openmp", i32 50}
124 !6 = !{i32 7, !"openmp-device", i32 50}
125 !7 = !{void ()* @foo, !"kernel", i32 1}
126 !8 = !{void ()* @bar, !"kernel", i32 1}
127 !9 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 1, type: !10, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
128 !10 = !DISubroutineType(types: !2)
129 !11 = !DILocation(line: 5, column: 7, scope: !9)
130 !12 = !DILocation(line: 5, column: 14, scope: !9)
132 ; CHECK: @[[S:[a-zA-Z0-9_$"\\.-]+]] = external local_unnamed_addr global i8*
133 ; CHECK: @[[GLOB0:[0-9]+]] = private unnamed_addr constant [113 x i8] c"
134 ; CHECK: @[[GLOB1:[0-9]+]] = private unnamed_addr constant [[STRUCT_IDENT_T:%.*]] { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([113 x i8], [113 x i8]* @[[GLOB0]], i32 0, i32 0) }, align 8
135 ; CHECK: @[[X:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global [16 x i8] undef, align 32
136 ; CHECK: @[[Y:[a-zA-Z0-9_$"\\.-]+]] = internal addrspace(3) global [4 x i8] undef, align 32
138 ; CHECK-LABEL: define {{[^@]+}}@foo() {
140 ; CHECK-NEXT: [[C:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* @[[GLOB1]], i1 false, i1 false, i1 true)
141 ; CHECK-NEXT: [[X:%.*]] = call i8* @__kmpc_alloc_shared(i64 4) #[[ATTR1:[0-9]+]]
142 ; CHECK-NEXT: call void @unknown_no_openmp()
143 ; CHECK-NEXT: call void @use.internalized(i8* nofree writeonly [[X]]) #[[ATTR4:[0-9]+]]
144 ; CHECK-NEXT: call void @__kmpc_free_shared(i8* [[X]], i64 4) #[[ATTR1]]
145 ; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* @[[GLOB1]], i1 false, i1 true)
146 ; CHECK-NEXT: ret void
149 ; CHECK-LABEL: define {{[^@]+}}@bar() {
150 ; CHECK-NEXT: [[C:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* @[[GLOB1]], i1 false, i1 true, i1 true)
151 ; CHECK-NEXT: call void @unknown_no_openmp()
152 ; CHECK-NEXT: call void @baz()
153 ; CHECK-NEXT: call void @qux()
154 ; CHECK-NEXT: call void @negative_qux_spmd()
155 ; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* @[[GLOB1]], i1 false, i1 true)
156 ; CHECK-NEXT: ret void
159 ; CHECK-LABEL: define {{[^@]+}}@baz() {
161 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* noundef nonnull @[[GLOB1]], i1 noundef false, i1 noundef false, i1 noundef true)
162 ; CHECK-NEXT: call void @unknown_no_openmp()
163 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[CALL]], -1
164 ; CHECK-NEXT: br i1 [[CMP]], label [[MASTER:%.*]], label [[EXIT:%.*]]
166 ; CHECK-NEXT: call void @use.internalized(i8* nofree writeonly addrspacecast (i8 addrspace(3)* getelementptr inbounds ([16 x i8], [16 x i8] addrspace(3)* @x, i32 0, i32 0) to i8*)) #[[ATTR4]]
167 ; CHECK-NEXT: br label [[EXIT]]
169 ; CHECK-NEXT: ret void
172 ; CHECK-LABEL: define {{[^@]+}}@qux() {
174 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* noundef nonnull @[[GLOB1]], i1 noundef false, i1 noundef true, i1 noundef true)
175 ; CHECK-NEXT: call void @unknown_no_openmp()
176 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[CALL]], -1
177 ; CHECK-NEXT: br i1 [[TMP0]], label [[MASTER:%.*]], label [[EXIT:%.*]]
179 ; CHECK-NEXT: call void @use.internalized(i8* nofree writeonly addrspacecast (i8 addrspace(3)* getelementptr inbounds ([4 x i8], [4 x i8] addrspace(3)* @y, i32 0, i32 0) to i8*)) #[[ATTR4]]
180 ; CHECK-NEXT: br label [[EXIT]]
182 ; CHECK-NEXT: ret void
185 ; CHECK-LABEL: define {{[^@]+}}@negative_qux_spmd() {
187 ; CHECK-NEXT: [[CALL:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* noundef nonnull @[[GLOB1]], i1 noundef true, i1 noundef true, i1 noundef true)
188 ; CHECK-NEXT: call void @unknown_no_openmp()
189 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i32 [[CALL]], -1
190 ; CHECK-NEXT: br i1 [[TMP0]], label [[MASTER:%.*]], label [[EXIT:%.*]]
192 ; CHECK-NEXT: [[Y:%.*]] = call i8* @__kmpc_alloc_shared(i64 noundef 24) #[[ATTR1]], !dbg [[DBG9:![0-9]+]]
193 ; CHECK-NEXT: call void @use.internalized(i8* nofree writeonly [[Y]]) #[[ATTR4]]
194 ; CHECK-NEXT: call void @__kmpc_free_shared(i8* [[Y]], i64 noundef 24) #[[ATTR1]]
195 ; CHECK-NEXT: br label [[EXIT]]
197 ; CHECK-NEXT: ret void
200 ; CHECK-LABEL: define {{[^@]+}}@use.internalized
201 ; CHECK-SAME: (i8* nofree writeonly [[X:%.*]]) #[[ATTR0:[0-9]+]] {
203 ; CHECK-NEXT: store i8* [[X]], i8** @S, align 8
204 ; CHECK-NEXT: ret void
207 ; CHECK-LABEL: define {{[^@]+}}@use
208 ; CHECK-SAME: (i8* [[X:%.*]]) {
210 ; CHECK-NEXT: store i8* [[X]], i8** @S, align 8
211 ; CHECK-NEXT: ret void
214 ; CHECK: attributes #[[ATTR0]] = { nofree nosync nounwind willreturn writeonly }
215 ; CHECK: attributes #[[ATTR1]] = { nounwind }
216 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { nounwind readnone }
217 ; CHECK: attributes #[[ATTR3:[0-9]+]] = { "llvm.assume"="omp_no_openmp" }
218 ; CHECK: attributes #[[ATTR4]] = { nounwind writeonly }
220 ; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
221 ; CHECK: [[META1:![0-9]+]] = !DIFile(filename: "replace_globalization.c", directory: "/tmp/replace_globalization.c")
222 ; CHECK: [[META2:![0-9]+]] = !{}
223 ; CHECK: [[META3:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
224 ; CHECK: [[META4:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
225 ; CHECK: [[META5:![0-9]+]] = !{i32 7, !"openmp", i32 50}
226 ; CHECK: [[META6:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
227 ; CHECK: [[META7:![0-9]+]] = !{void ()* @foo, !"kernel", i32 1}
228 ; CHECK: [[META8:![0-9]+]] = !{void ()* @bar, !"kernel", i32 1}
229 ; CHECK: [[DBG9]] = !DILocation(line: 5, column: 14, scope: !10)
230 ; CHECK: [[META10:![0-9]+]] = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 1, type: !11, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
231 ; CHECK: [[META11:![0-9]+]] = !DISubroutineType(types: !2)