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.KernelEnvironmentTy = type { %struct.ConfigurationEnvironmentTy, ptr, ptr }
6 %struct.ConfigurationEnvironmentTy = type { i8, i8, i8, i32, i32, i32, i32 }
8 @G = external global i16
9 @none_spmd_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 null, ptr null }
10 @spmd_kernel_environment = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 0, i8 0, i8 2, i32 0, i32 0, i32 0, i32 0 }, ptr null, ptr null }
11 @parallel_kernel_environment = local_unnamed_addr constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy { i8 0, i8 0, i8 2, i32 0, i32 0, i32 0, i32 0 }, ptr null, ptr null }
14 ; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = external global i16
15 ; CHECK: @[[NONE_SPMD_KERNEL_ENVIRONMENT:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr constant [[STRUCT_KERNELENVIRONMENTTY:%.*]] { [[STRUCT_CONFIGURATIONENVIRONMENTTY:%.*]] { i8 0, i8 0, i8 1, i32 0, i32 0, i32 0, i32 0 }, ptr null, ptr null }
16 ; CHECK: @[[SPMD_KERNEL_ENVIRONMENT:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr constant [[STRUCT_KERNELENVIRONMENTTY:%.*]] { [[STRUCT_CONFIGURATIONENVIRONMENTTY:%.*]] { i8 0, i8 0, i8 2, i32 0, i32 0, i32 0, i32 0 }, ptr null, ptr null }
17 ; CHECK: @[[PARALLEL_KERNEL_ENVIRONMENT:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr constant [[STRUCT_KERNELENVIRONMENTTY:%.*]] { [[STRUCT_CONFIGURATIONENVIRONMENTTY:%.*]] { i8 0, i8 1, i8 2, i32 0, i32 0, i32 0, i32 0 }, ptr null, ptr null }
19 define weak void @none_spmd() "kernel" {
20 ; CHECK-LABEL: define {{[^@]+}}@none_spmd
21 ; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
22 ; CHECK-NEXT: [[I:%.*]] = call i32 @__kmpc_target_init(ptr @none_spmd_kernel_environment, ptr null)
23 ; CHECK-NEXT: call void @none_spmd_helper()
24 ; CHECK-NEXT: call void @mixed_helper()
25 ; CHECK-NEXT: call void @__kmpc_target_deinit()
26 ; CHECK-NEXT: ret void
28 %i = call i32 @__kmpc_target_init(ptr @none_spmd_kernel_environment, ptr null)
29 call void @none_spmd_helper()
30 call void @mixed_helper()
31 call void @__kmpc_target_deinit()
35 define weak void @spmd() "kernel" {
36 ; CHECK-LABEL: define {{[^@]+}}@spmd
37 ; CHECK-SAME: () #[[ATTR0]] {
38 ; CHECK-NEXT: [[I:%.*]] = call i32 @__kmpc_target_init(ptr @spmd_kernel_environment, ptr null)
39 ; CHECK-NEXT: call void @spmd_helper()
40 ; CHECK-NEXT: call void @mixed_helper()
41 ; CHECK-NEXT: call void @__kmpc_target_deinit()
42 ; CHECK-NEXT: ret void
44 %i = call i32 @__kmpc_target_init(ptr @spmd_kernel_environment, ptr null)
45 call void @spmd_helper()
46 call void @mixed_helper()
47 call void @__kmpc_target_deinit()
51 define weak void @parallel() "kernel" {
52 ; CHECK-LABEL: define {{[^@]+}}@parallel
53 ; CHECK-SAME: () #[[ATTR0]] {
54 ; CHECK-NEXT: [[I:%.*]] = call i32 @__kmpc_target_init(ptr @parallel_kernel_environment, ptr null)
55 ; CHECK-NEXT: call void @spmd_helper()
56 ; CHECK-NEXT: call void @__kmpc_parallel_51(ptr null, i32 0, i32 0, i32 0, i32 0, ptr null, ptr null, ptr null, i64 0)
57 ; CHECK-NEXT: call void @__kmpc_target_deinit()
58 ; CHECK-NEXT: ret void
60 %i = call i32 @__kmpc_target_init(ptr @parallel_kernel_environment, ptr null)
61 call void @spmd_helper()
62 call void @__kmpc_parallel_51(ptr null, i32 0, i32 0, i32 0, i32 0, ptr null, ptr null, ptr null, i64 0)
63 call void @__kmpc_target_deinit()
67 define internal void @mixed_helper() {
68 ; CHECK-LABEL: define {{[^@]+}}@mixed_helper() {
69 ; CHECK-NEXT: [[LEVEL:%.*]] = call zeroext i16 @__kmpc_parallel_level(ptr null, i32 0)
70 ; CHECK-NEXT: store i16 [[LEVEL]], ptr @G, align 2
71 ; CHECK-NEXT: ret void
73 %level = call zeroext i16 @__kmpc_parallel_level(ptr null, i32 0)
74 store i16 %level, ptr @G
78 define internal void @none_spmd_helper() {
79 ; CHECK-LABEL: define {{[^@]+}}@none_spmd_helper() {
80 ; CHECK-NEXT: [[LEVEL12:%.*]] = call zeroext i16 @__kmpc_parallel_level(ptr null, i32 0)
81 ; CHECK-NEXT: [[C:%.*]] = icmp eq i16 [[LEVEL12]], 0
82 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
84 ; CHECK-NEXT: call void @foo()
85 ; CHECK-NEXT: ret void
87 ; CHECK-NEXT: call void @bar()
88 ; CHECK-NEXT: ret void
90 %level12 = call zeroext i16 @__kmpc_parallel_level(ptr null, i32 0)
91 %c = icmp eq i16 %level12, 0
92 br i1 %c, label %t, label %f
101 define internal void @spmd_helper() {
102 ; CHECK-LABEL: define {{[^@]+}}@spmd_helper() {
103 ; CHECK-NEXT: store i8 1, ptr @G, align 2
104 ; CHECK-NEXT: ret void
106 %level = call zeroext i16 @__kmpc_parallel_level(ptr null, i32 0)
107 store i16 %level, ptr @G
111 define internal void @__kmpc_parallel_51(ptr, i32, i32, i32, i32, ptr, ptr, ptr, i64) {
112 ; CHECK-LABEL: define {{[^@]+}}@__kmpc_parallel_51
113 ; CHECK-SAME: (ptr [[TMP0:%.*]], i32 [[TMP1:%.*]], i32 [[TMP2:%.*]], i32 [[TMP3:%.*]], i32 [[TMP4:%.*]], ptr [[TMP5:%.*]], ptr [[TMP6:%.*]], ptr [[TMP7:%.*]], i64 [[TMP8:%.*]]) #[[ATTR1:[0-9]+]] {
114 ; CHECK-NEXT: call void @parallel_helper()
115 ; CHECK-NEXT: ret void
117 call void @parallel_helper()
121 define internal void @parallel_helper() {
122 ; CHECK-LABEL: define {{[^@]+}}@parallel_helper() {
123 ; CHECK-NEXT: [[LEVEL:%.*]] = call zeroext i16 @__kmpc_parallel_level(ptr null, i32 0)
124 ; CHECK-NEXT: store i16 [[LEVEL]], ptr @G, align 2
125 ; CHECK-NEXT: ret void
127 %level = call zeroext i16 @__kmpc_parallel_level(ptr null, i32 0)
128 store i16 %level, ptr @G
134 declare zeroext i16 @__kmpc_parallel_level(ptr, i32)
135 declare i32 @__kmpc_target_init(ptr, ptr) #1
136 declare void @__kmpc_target_deinit() #1
138 !llvm.module.flags = !{!0, !1}
139 !nvvm.annotations = !{!2, !3, !4}
141 !0 = !{i32 7, !"openmp", i32 50}
142 !1 = !{i32 7, !"openmp-device", i32 50}
143 !2 = !{ptr @none_spmd, !"kernel", i32 1}
144 !3 = !{ptr @spmd, !"kernel", i32 1}
145 !4 = !{ptr @parallel, !"kernel", i32 1}
147 ; CHECK: attributes #[[ATTR0]] = { "kernel" }
148 ; CHECK: attributes #[[ATTR1]] = { alwaysinline }
150 ; CHECK: [[META0:![0-9]+]] = !{i32 7, !"openmp", i32 50}
151 ; CHECK: [[META1:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
152 ; CHECK: [[META2:![0-9]+]] = !{ptr @none_spmd, !"kernel", i32 1}
153 ; CHECK: [[META3:![0-9]+]] = !{ptr @spmd, !"kernel", i32 1}
154 ; CHECK: [[META4:![0-9]+]] = !{ptr @parallel, !"kernel", i32 1}