1; RUN: llvm-as %s -o %t.bc 2; RUN: llvm-spirv %t.bc -spirv-text -o %t.txt 3; RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV 4; RUN: llvm-spirv %t.bc -o %t.spv 5; RUN: llvm-spirv -r %t.spv -o %t.rev.bc 6; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM 7 8; CHECK-LLVM: call spir_func void @_Z17sub_group_barrierji(i32 2, i32 1) #{{[0-9]+}} 9; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 1, i32 1) #{{[0-9]+}} 10; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 4, i32 1) #{{[0-9]+}} 11; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 3, i32 1) #{{[0-9]+}} 12; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 5, i32 1) #{{[0-9]+}} 13; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 7, i32 1) #{{[0-9]+}} 14 15; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 2, i32 0) #{{[0-9]+}} 16; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 2, i32 1) #{{[0-9]+}} 17; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 2, i32 2) #{{[0-9]+}} 18; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 2, i32 3) #{{[0-9]+}} 19 20; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 1, i32 0) #{{[0-9]+}} 21; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 1, i32 1) #{{[0-9]+}} 22; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 1, i32 2) #{{[0-9]+}} 23; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 1, i32 3) #{{[0-9]+}} 24 25; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 4, i32 0) #{{[0-9]+}} 26; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 4, i32 1) #{{[0-9]+}} 27; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 4, i32 2) #{{[0-9]+}} 28; CHECK-LLVM-NEXT: call spir_func void @_Z17sub_group_barrierji(i32 4, i32 3) #{{[0-9]+}} 29 30 31; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[MemSema1:[0-9]+]] 512 32; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[MemSema2:[0-9]+]] 256 33; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[MemSema3:[0-9]+]] 2048 34; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[MemSema4:[0-9]+]] 768 35; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[MemSema5:[0-9]+]] 2304 36; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[MemSema6:[0-9]+]] 2816 37 38; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[ScopeWorkItem:[0-9]+]] 4 39; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[ScopeWorkGroup:[0-9]+]] 2 40; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[ScopeDevice:[0-9]+]] 1 41; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[ScopeCrossDevice:[0-9]+]] 0 42; CHECK-SPIRV-DAG: 4 Constant {{[0-9]+}} [[ScopeSubGroup:[0-9]+]] 3 43 44; CHECK-SPIRV: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema1]] 45; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema2]] 46; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema3]] 47; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema4]] 48; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema5]] 49; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema6]] 50 51; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkItem]] [[MemSema1]] 52; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema1]] 53; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeDevice]] [[MemSema1]] 54; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeCrossDevice]] [[MemSema1]] 55 56; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkItem]] [[MemSema2]] 57; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema2]] 58; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeDevice]] [[MemSema2]] 59; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeCrossDevice]] [[MemSema2]] 60 61; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkItem]] [[MemSema3]] 62; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeWorkGroup]] [[MemSema3]] 63; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeDevice]] [[MemSema3]] 64; CHECK-SPIRV-NEXT: 4 ControlBarrier [[ScopeSubGroup]] [[ScopeCrossDevice]] [[MemSema3]] 65 66; ModuleID = 'sub_group_barrier.cl' 67target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" 68target triple = "spir-unknown-unknown" 69 70; Function Attrs: nounwind 71define spir_kernel void @test() #0 { 72entry: 73 call spir_func void @_Z17sub_group_barrierj(i32 2) ; global mem fence 74 call spir_func void @_Z17sub_group_barrierj(i32 1) ; local mem fence 75 call spir_func void @_Z17sub_group_barrierj(i32 4) ; image mem fence 76 77 call spir_func void @_Z17sub_group_barrierj(i32 3) ; global | local 78 call spir_func void @_Z17sub_group_barrierj(i32 5) ; local | image 79 call spir_func void @_Z17sub_group_barrierj(i32 7) ; global | local | image 80 81 call spir_func void @_Z17sub_group_barrierji(i32 2, i32 0) ; global mem fence + memory_scope_work_item 82 call spir_func void @_Z17sub_group_barrierji(i32 2, i32 1) ; global mem fence + memory_scope_work_group 83 call spir_func void @_Z17sub_group_barrierji(i32 2, i32 2) ; global mem fence + memory_scope_device 84 call spir_func void @_Z17sub_group_barrierji(i32 2, i32 3) ; global mem fence + memory_scope_all_svm_devices 85 86 call spir_func void @_Z17sub_group_barrierji(i32 1, i32 0) ; local mem fence + memory_scope_work_item 87 call spir_func void @_Z17sub_group_barrierji(i32 1, i32 1) ; local mem fence + memory_scope_work_group 88 call spir_func void @_Z17sub_group_barrierji(i32 1, i32 2) ; local mem fence + memory_scope_device 89 call spir_func void @_Z17sub_group_barrierji(i32 1, i32 3) ; local mem fence + memory_scope_all_svm_devices 90 91 call spir_func void @_Z17sub_group_barrierji(i32 4, i32 0) ; image mem fence + memory_scope_work_item 92 call spir_func void @_Z17sub_group_barrierji(i32 4, i32 1) ; image mem fence + memory_scope_work_group 93 call spir_func void @_Z17sub_group_barrierji(i32 4, i32 2) ; image mem fence + memory_scope_device 94 call spir_func void @_Z17sub_group_barrierji(i32 4, i32 3) ; image mem fence + memory_scope_all_svm_devices 95 96 ret void 97} 98 99declare spir_func void @_Z17sub_group_barrierj(i32) #1 100declare spir_func void @_Z17sub_group_barrierji(i32, i32) #1 101 102attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 103attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 104attributes #2 = { nounwind } 105 106!opencl.kernels = !{!0} 107!opencl.enable.FP_CONTRACT = !{} 108!opencl.spir.version = !{!6} 109!opencl.ocl.version = !{!7} 110!opencl.used.extensions = !{!8} 111!opencl.used.optional.core.features = !{!8} 112!opencl.compiler.options = !{!8} 113 114!0 = !{void ()* @test, !1, !2, !3, !4, !5} 115!1 = !{!"kernel_arg_addr_space"} 116!2 = !{!"kernel_arg_access_qual"} 117!3 = !{!"kernel_arg_type"} 118!4 = !{!"kernel_arg_base_type"} 119!5 = !{!"kernel_arg_type_qual"} 120!6 = !{i32 1, i32 2} 121!7 = !{i32 2, i32 1} 122!8 = !{} 123