1;; Test what ndrange_2D and ndrange_3D can coexist in the same module 2;; 3;; bash$ cat BuildNDRange_2.cl 4;; void test_ndrange_2D3D() { 5;; size_t lsize2[2] = {1, 1}; 6;; ndrange_2D(lsize2); 7;; 8;; size_t lsize3[3] = {1, 1, 1}; 9;; ndrange_3D(lsize3); 10;; } 11;; 12;; void test_ndrange_const_2D3D() { 13;; const size_t lsize2[2] = {1, 1}; 14;; ndrange_2D(lsize2); 15;; 16;; const size_t lsize3[3] = {1, 1, 1}; 17;; ndrange_3D(lsize3); 18;; } 19;; bash$ $PATH_TO_GEN/bin/clang -cc1 -x cl -cl-std=CL2.0 -triple spir64-unknonw-unknown -emit-llvm -include opencl-20.h BuildNDRange_2.cl -o BuildNDRange_2.ll 20 21; RUN: llvm-as %s -o %t.bc 22; RUN: llvm-spirv %t.bc -spirv-text -o %t.spv.txt 23; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV 24; RUN: llvm-spirv %t.bc -o %t.spv 25; RUN: llvm-spirv -r %t.spv -o %t.rev.bc 26; RUN: llvm-dis %t.rev.bc 27; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM 28 29; CHECK-SPIRV-DAG: Constant {{[0-9]+}} [[LEN2_ID:[0-9]+]] 2 30; CHECK-SPIRV-DAG: Constant {{[0-9]+}} [[LEN3_ID:[0-9]+]] 3 31; CHECK-SPIRV-DAG: TypeArray [[ARRAY_T2:[0-9]+]] {{[0-9]+}} [[LEN2_ID]] 32; CHECK-SPIRV-DAG: TypeArray [[ARRAY_T3:[0-9]+]] {{[0-9]+}} [[LEN3_ID]] 33 34; CHECK-SPIRV-LABEL: 5 Function 35; CHECK-SPIRV: Load [[ARRAY_T2]] [[LOAD2_ID:[0-9]+]] 36; CHECK-SPIRV: BuildNDRange {{[0-9]+}} {{[0-9]+}} [[LOAD2_ID]] 37; CHECK-SPIRV: Load [[ARRAY_T3]] [[LOAD3_ID:[0-9]+]] 38; CHECK-SPIRV: BuildNDRange {{[0-9]+}} {{[0-9]+}} [[LOAD3_ID]] 39; CHECK-SPIRV-LABEL: 1 FunctionEnd 40 41; CHECK-SPIRV-LABEL: 5 Function 42; CHECK-SPIRV: Load [[ARRAY_T2]] [[CONST_LOAD2_ID:[0-9]+]] 43; CHECK-SPIRV: BuildNDRange {{[0-9]+}} {{[0-9]+}} [[CONST_LOAD2_ID]] 44; CHECK-SPIRV: Load [[ARRAY_T3]] [[CONST_LOAD3_ID:[0-9]+]] 45; CHECK-SPIRV: BuildNDRange {{[0-9]+}} {{[0-9]+}} [[CONST_LOAD3_ID]] 46; CHECK-SPIRV-LABEL: 1 FunctionEnd 47 48; CHECK-LLVM-LABEL: @test_ndrange_2D3D 49; CHECK-LLVM: call spir_func void @_Z10ndrange_2D 50; CHECK-LLVM: call spir_func void @_Z10ndrange_3D 51; CHECK-LLVM-LABEL: @test_ndrange_const_2D3D 52; CHECK-LLVM: call spir_func void @_Z10ndrange_2D 53; CHECK-LLVM: call spir_func void @_Z10ndrange_3D 54 55target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" 56target triple = "spir64-unknonw-unknown" 57 58%struct.ndrange_t = type { i32, [3 x i64], [3 x i64], [3 x i64] } 59 60@test_ndrange_2D3D.lsize2 = private constant [2 x i64] [i64 1, i64 1], align 8 61@test_ndrange_2D3D.lsize3 = private constant [3 x i64] [i64 1, i64 1, i64 1], align 8 62 63 64; Function Attrs: nounwind 65define spir_func void @test_ndrange_2D3D() #0 { 66entry: 67 %lsize2 = alloca [2 x i64], align 8 68 %tmp = alloca %struct.ndrange_t, align 8 69 %lsize3 = alloca [3 x i64], align 8 70 %tmp3 = alloca %struct.ndrange_t, align 8 71 %0 = bitcast [2 x i64]* %lsize2 to i8* 72 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast ([2 x i64]* @test_ndrange_2D3D.lsize2 to i8*), i64 16, i32 8, i1 false) 73 %arraydecay = getelementptr inbounds [2 x i64], [2 x i64]* %lsize2, i64 0, i64 0 74 call spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret %tmp, i64* %arraydecay) #2 75 %1 = bitcast [3 x i64]* %lsize3 to i8* 76 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* bitcast ([3 x i64]* @test_ndrange_2D3D.lsize3 to i8*), i64 24, i32 8, i1 false) 77 %arraydecay2 = getelementptr inbounds [3 x i64], [3 x i64]* %lsize3, i64 0, i64 0 78 call spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret %tmp3, i64* %arraydecay2) #2 79 ret void 80} 81 82; Function Attrs: nounwind 83declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #2 84 85declare spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret, i64*) #1 86 87declare spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret, i64*) #1 88 89; Function Attrs: nounwind 90define spir_func void @test_ndrange_const_2D3D() #0 { 91entry: 92 %tmp = alloca %struct.ndrange_t, align 8 93 %tmp1 = alloca %struct.ndrange_t, align 8 94 call spir_func void @_Z10ndrange_2DPKm(%struct.ndrange_t* sret %tmp, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @test_ndrange_2D3D.lsize2, i64 0, i64 0)) #2 95 call spir_func void @_Z10ndrange_3DPKm(%struct.ndrange_t* sret %tmp1, i64* getelementptr inbounds ([3 x i64], [3 x i64]* @test_ndrange_2D3D.lsize3, i64 0, i64 0)) #2 96 ret void 97} 98 99attributes #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" } 100attributes #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" } 101attributes #2 = { nounwind } 102 103!opencl.enable.FP_CONTRACT = !{} 104!opencl.spir.version = !{!0} 105!opencl.ocl.version = !{!1} 106!opencl.used.extensions = !{!2} 107!opencl.used.optional.core.features = !{!2} 108!opencl.compiler.options = !{!2} 109 110!0 = !{i32 2, i32 0} 111!1 = !{i32 2, i32 0} 112!2 = !{} 113