1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
2 ; RUN: opt --mtriple=amdgcn-amd-amdhsa --data-layout=A5 -S -passes=openmp-opt < %s | FileCheck %s --check-prefixes=AMDGPU
4 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
5 target triple = "amdgcn-amd-amdhsa"
7 %struct.KernelEnvironmentTy = type { %struct.ConfigurationEnvironmentTy.8, ptr, ptr }
8 %struct.ConfigurationEnvironmentTy.8 = type { i8, i8, i8, i32, i32, i32, i32, i32, i32 }
10 @IsSPMDMode = internal addrspace(3) global i32 undef
11 @__omp_offloading_10302_b20a40e_main_l4_kernel_environment = addrspace(1) constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy.8 { i8 1, i8 0, i8 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }, ptr addrspacecast (ptr addrspace(1) null to ptr), ptr addrspacecast (ptr addrspace(1) null to ptr) }
14 ; AMDGPU: @IsSPMDMode = internal addrspace(3) global i32 undef
15 ; AMDGPU: @__omp_offloading_10302_b20a40e_main_l4_kernel_environment = addrspace(1) constant %struct.KernelEnvironmentTy { %struct.ConfigurationEnvironmentTy.8 { i8 0, i8 0, i8 1, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0 }, ptr addrspacecast (ptr addrspace(1) null to ptr), ptr addrspacecast (ptr addrspace(1) null to ptr) }
18 ; AMDGPU-LABEL: define {{[^@]+}}@fputs
19 ; AMDGPU-SAME: () #[[ATTR0:[0-9]+]] {
20 ; AMDGPU-NEXT: fence acquire
21 ; AMDGPU-NEXT: ret i32 0
27 define internal i32 @__kmpc_target_init(ptr %0, ptr %dyn) {
28 ; AMDGPU-LABEL: define {{[^@]+}}@__kmpc_target_init
29 ; AMDGPU-SAME: (ptr [[TMP0:%.*]], ptr [[DYN:%.*]]) #[[ATTR1:[0-9]+]] {
30 ; AMDGPU-NEXT: [[TMP2:%.*]] = load i8, ptr getelementptr (i8, ptr addrspacecast (ptr addrspace(1) @__omp_offloading_10302_b20a40e_main_l4_kernel_environment to ptr), i64 2), align 2
31 ; AMDGPU-NEXT: [[TMP3:%.*]] = and i8 [[TMP2]], 2
32 ; AMDGPU-NEXT: [[TMP4:%.*]] = icmp ne i8 [[TMP3]], 0
33 ; AMDGPU-NEXT: [[TMP5:%.*]] = tail call i32 @llvm.amdgcn.workitem.id.x() #[[ATTR3:[0-9]+]]
34 ; AMDGPU-NEXT: [[TMP6:%.*]] = icmp eq i32 [[TMP5]], 0
35 ; AMDGPU-NEXT: [[OR_COND:%.*]] = select i1 [[TMP4]], i1 [[TMP6]], i1 false
36 ; AMDGPU-NEXT: br i1 [[OR_COND]], label [[TMP7:%.*]], label [[TMP8:%.*]]
38 ; AMDGPU-NEXT: store i8 0, ptr addrspace(3) null, align 2147483648
39 ; AMDGPU-NEXT: br label [[TMP8]]
41 ; AMDGPU-NEXT: br label [[TMP10:%.*]]
43 ; AMDGPU-NEXT: unreachable
45 ; AMDGPU-NEXT: ret i32 0
47 %2 = getelementptr %struct.ConfigurationEnvironmentTy.8, ptr %0, i64 0, i32 2
48 %3 = load i8, ptr %2, align 2
51 %6 = tail call i32 @llvm.amdgcn.workitem.id.x()
52 %7 = icmp eq i32 %6, 0
53 %or.cond = select i1 %5, i1 %7, i1 false
54 br i1 %or.cond, label %8, label %9
57 store i32 1, ptr addrspace(3) @IsSPMDMode, align 4
58 store i8 0, ptr addrspace(3) null, align 2147483648
62 %10 = load i32, ptr addrspace(3) @IsSPMDMode, align 4
63 %11 = icmp eq i32 %10, 0
64 br i1 %11, label %12, label %13
73 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
74 declare i32 @llvm.amdgcn.workitem.id.x() #0
76 declare void @__kmpc_target_deinit()
78 define amdgpu_kernel void @__omp_offloading_10302_b20a40e_main_l4(ptr %dyn) {
79 ; AMDGPU-LABEL: define {{[^@]+}}@__omp_offloading_10302_b20a40e_main_l4
80 ; AMDGPU-SAME: (ptr [[DYN:%.*]]) {
81 ; AMDGPU-NEXT: [[TMP1:%.*]] = tail call i32 @__kmpc_target_init(ptr addrspacecast (ptr addrspace(1) @__omp_offloading_10302_b20a40e_main_l4_kernel_environment to ptr), ptr [[DYN]]) #[[ATTR4:[0-9]+]]
82 ; AMDGPU-NEXT: br label [[TMP2:%.*]]
84 ; AMDGPU-NEXT: [[TMP3:%.*]] = call i32 @fputs() #[[ATTR0]]
85 ; AMDGPU-NEXT: tail call void @__kmpc_target_deinit()
86 ; AMDGPU-NEXT: ret void
88 %1 = tail call i32 @__kmpc_target_init(ptr addrspacecast (ptr addrspace(1) @__omp_offloading_10302_b20a40e_main_l4_kernel_environment to ptr), ptr %dyn)
92 %3 = call i32 @fputs()
93 tail call void @__kmpc_target_deinit()
97 attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
99 !llvm.module.flags = !{!0}
101 !0 = !{i32 7, !"openmp", i32 51}
104 ; AMDGPU: attributes #[[ATTR0]] = { nounwind }
105 ; AMDGPU: attributes #[[ATTR1]] = { norecurse nosync nounwind }
106 ; AMDGPU: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
107 ; AMDGPU: attributes #[[ATTR3]] = { nosync }
108 ; AMDGPU: attributes #[[ATTR4]] = { nosync nounwind }
110 ; AMDGPU: [[META0:![0-9]+]] = !{i32 7, !"openmp", i32 51}