llvm/llvm/test/Transforms/Attributor/reduced/openmp_opt_global_synced.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes --check-attributes --check-globals --include-generated-funcs
; RUN: opt -passes=openmp-opt -S < %s | FileCheck %s --check-prefixes=CHECK

@_ZN4ompx5state9TeamStateE = internal addrspace(3) global ptr undef

define internal fastcc i1 @__kmpc_kernel_parallel() {
bb:
  %i = load ptr, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
  %i1 = icmp eq ptr %i, null
  ret i1 %i1
}

define weak_odr amdgpu_kernel void @__omp_offloading_16_2e1d69__ZN11qmcplusplus7ompBLAS9gemv_implIfEEiRiciiT_PKS3_iS5_iS3_PS3_i_l44() #1 {
bb:
  call void @barrier()
  %i31 = call fastcc i1 @__kmpc_kernel_parallel()
  call void @barrier()
  store ptr @use, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
  call void @barrier()
  store ptr null, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
  call void @barrier()
  call void @use(i1 %i31)
  ret void
}

declare void @use(i1)
declare void @barrier() nocallback

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "kernel" }

!llvm.module.flags = !{!0, !1}

!0 = !{i32 7, !"openmp", i32 50}
!1 = !{i32 7, !"openmp-device", i32 50}
;.
; CHECK: @_ZN4ompx5state9TeamStateE = internal addrspace(3) global ptr undef
;.
; CHECK: Function Attrs: norecurse nosync nounwind memory(read)
; CHECK-LABEL: define {{[^@]+}}@__kmpc_kernel_parallel
; CHECK-SAME: () #[[ATTR0:[0-9]+]] {
; CHECK-NEXT:  bb:
; CHECK-NEXT:    [[I:%.*]] = load ptr, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
; CHECK-NEXT:    [[I1:%.*]] = icmp eq ptr [[I]], null
; CHECK-NEXT:    ret i1 [[I1]]
;
;
; CHECK-LABEL: define {{[^@]+}}@__omp_offloading_16_2e1d69__ZN11qmcplusplus7ompBLAS9gemv_implIfEEiRiciiT_PKS3_iS5_iS3_PS3_i_l44
; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
; CHECK-NEXT:  bb:
; CHECK-NEXT:    call void @barrier()
; CHECK-NEXT:    [[I31:%.*]] = call fastcc i1 @__kmpc_kernel_parallel()
; CHECK-NEXT:    call void @barrier()
; CHECK-NEXT:    store ptr @use, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
; CHECK-NEXT:    call void @barrier()
; CHECK-NEXT:    store ptr null, ptr addrspace(3) @_ZN4ompx5state9TeamStateE, align 16
; CHECK-NEXT:    call void @barrier()
; CHECK-NEXT:    call void @use(i1 [[I31]])
; CHECK-NEXT:    ret void
;
;.
; CHECK: attributes #[[ATTR0]] = { norecurse nosync nounwind memory(read) }
; CHECK: attributes #[[ATTR1]] = { "kernel" }
; CHECK: attributes #[[ATTR2:[0-9]+]] = { nocallback }
; CHECK: attributes #[[ATTR3:[0-9]+]] = { nosync nounwind memory(read) }
;.
; CHECK: [[META0:![0-9]+]] = !{i32 7, !"openmp", i32 50}
; CHECK: [[META1:![0-9]+]] = !{i32 7, !"openmp-device", i32 50}
;.