Skip to content

Commit

Permalink
Convert tests to use -emit-opaque-pointers (#2084)
Browse files Browse the repository at this point in the history
This fixes most of the tests to use -emit-opaque-pointers. There are a few tests not yet converted for various reasons:

Several tests only have check lines for opaque struct declarations. These are not emitted in opaque pointer mode, so the tests need deeper rewrites.
A few tests check both typed and opaque pointer output.
A few tests only make sense with typed pointer output (ForwardPtr.ll and RecursiveType.ll in particular).
One test has a crash in reverse translation.
Outside of these cases, all tests should now be using opaque pointer for testing reverse translation.

Original commit:
KhronosGroup/SPIRV-LLVM-Translator@0dc80be
  • Loading branch information
jcranmer-intel authored and sys-ce-bb committed Jul 17, 2023
1 parent d27b674 commit 6a57011
Show file tree
Hide file tree
Showing 40 changed files with 523 additions and 610 deletions.
15 changes: 7 additions & 8 deletions llvm-spirv/test/SamplerArgNonKernel.ll
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
; RUN: llvm-as -opaque-pointers=0 %s -o %t.bc
; RUN: llvm-spirv %t.bc -opaque-pointers=0 -spirv-text -o %t.txt
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv %t.bc -spirv-text -o %t.txt
; RUN: FileCheck < %t.txt %s
target 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"
target triple = "spir"

;CHECK: EntryPoint {{[0-9]+}} [[KernelId:[0-9]+]]

%opencl.image2d_t = type opaque
;CHECK: TypeImage [[image2d_t:[0-9]+]]
;CHECK: TypeSampler [[sampler_t:[0-9]+]]
;CHECK: TypeSampledImage [[sampled_image_t:[0-9]+]]

; Function Attrs: nounwind
define spir_func float @test(%opencl.image2d_t addrspace(1)* %Img, i32 %Smp) #0 {
define spir_func float @test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, i32 %Smp) #0 {
;CHECK-NOT: Function {{[0-9]+}} [[KernelId]]
;CHECK: Function
;CHECK: FunctionParameter [[image2d_t]] [[image:[0-9]+]]
;CHECK: FunctionParameter [[sampler_t]] [[sampler:[0-9]+]]
entry:
%call = call spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)* %Img, i32 %Smp, <2 x i32> zeroinitializer)
%call = call spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, i32 %Smp, <2 x i32> zeroinitializer)
;CHECK: SampledImage [[sampled_image_t]] [[sampled_image:[0-9]+]] [[image]] [[sampler]]
;CHECK: ImageSampleExplicitLod {{[0-9]+}} {{[0-9]+}} [[sampled_image]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}

Expand All @@ -27,13 +26,13 @@ entry:
ret float %conv
}

declare spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(%opencl.image2d_t addrspace(1)*, i32, <2 x i32>) #1
declare spir_func <4 x i32> @_Z11read_imagef11ocl_image2d11ocl_samplerDv2_i(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0), i32, <2 x i32>) #1

; Function Attrs: nounwind
define spir_kernel void @test2(%opencl.image2d_t addrspace(1)* %Img, float addrspace(1)* %result) #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !4 !kernel_arg_type_qual !5 {
define spir_kernel void @test2(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, float addrspace(1)* %result) #0 !kernel_arg_addr_space !1 !kernel_arg_access_qual !2 !kernel_arg_type !3 !kernel_arg_base_type !4 !kernel_arg_type_qual !5 {
;CHECK: Function {{[0-9]+}} [[KernelId]]
entry:
%call = call spir_func float @test(%opencl.image2d_t addrspace(1)* %Img, i32 0)
%call = call spir_func float @test(target("spirv.Image", void, 1, 0, 0, 0, 0, 0, 0) %Img, i32 0)
%arrayidx = getelementptr inbounds float, float addrspace(1)* %result, i32 0
%0 = load float, float addrspace(1)* %arrayidx, align 4
%add = fadd float %0, %call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
; FIXME: add more negative test cases
; RUN: llvm-spirv %t.spt -to-binary -o %t.spv
; RUN: llvm-spirv -r -emit-opaque-pointers=0 %t.spv -o %t.bc
; RUN: llvm-dis -opaque-pointers=0 < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM
; RUN: llvm-spirv -r %t.spv -o %t.bc
; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-LLVM

; RUN: llvm-spirv -r %t.spv -o %t.bc --spirv-target-env=SPV-IR
; RUN: llvm-dis < %t.bc | FileCheck %s --check-prefix=CHECK-SPV-IR
Expand All @@ -30,15 +30,12 @@ target triple = "spir64-unknown-unknown"
; CHECK-SPIRV: 6 Load [[PipeWTy]] [[PipeW:[0-9]+]] {{[0-9]+}} {{[0-9]+}}
; CHECK-SPIRV: 5 WritePipeBlockingINTEL [[PipeW]] {{[0-9]+}} {{[0-9]+}} {{[0-9]+}}

; CHECK-LLVM: %opencl.pipe_ro_t = type opaque
; CHECK-LLVM: %opencl.pipe_wo_t = type opaque
; CHECK-LLVM: call spir_func void @__read_pipe_2_bl(ptr addrspace(1) %0, ptr addrspace(4) %{{[0-9]+}}, i32 4, i32 4)
; CHECK-LLVM: call spir_func void @__read_pipe_2_bl(ptr addrspace(1) %0, ptr addrspace(4) %{{[0-9]+}}, i32 4, i32 4)
; CHECK-LLVM: call spir_func void @__write_pipe_2_bl(ptr addrspace(1) %0, ptr addrspace(4) %{{[0-9]+}}, i32 4, i32 4)
; CHECK-LLVM: call spir_func void @__write_pipe_2_bl(ptr addrspace(1) %0, ptr addrspace(4) %{{[0-9]+}}, i32 4, i32 4)

; CHECK-LLVM: call spir_func void @__read_pipe_2_bl(%opencl.pipe_ro_t addrspace(1)* %0, i8 addrspace(4)* %{{[0-9]+}}, i32 4, i32 4)
; CHECK-LLVM: call spir_func void @__read_pipe_2_bl(%opencl.pipe_ro_t addrspace(1)* %0, i8 addrspace(4)* %{{[0-9]+}}, i32 4, i32 4)
; CHECK-LLVM: call spir_func void @__write_pipe_2_bl(%opencl.pipe_wo_t addrspace(1)* %0, i8 addrspace(4)* %{{[0-9]+}}, i32 4, i32 4)
; CHECK-LLVM: call spir_func void @__write_pipe_2_bl(%opencl.pipe_wo_t addrspace(1)* %0, i8 addrspace(4)* %{{[0-9]+}}, i32 4, i32 4)

; CHECK-LLVM: call spir_func void @__write_pipe_2_bl(%opencl.pipe_wo_t addrspace(1)*{{.*}}, i8 addrspace(4)* %{{[0-9]+}}, i32 2, i32 2)
; CHECK-LLVM: call spir_func void @__write_pipe_2_bl(ptr addrspace(1){{.*}}, ptr addrspace(4) %{{[0-9]+}}, i32 2, i32 2)

; CHECK-SPV-IR: call spir_func void @_Z30__spirv_WritePipeBlockingINTEL{{.*}}(target("spirv.Pipe", 1){{.*}}, ptr addrspace(4){{.*}}, i32 2, i32 2)

Expand Down Expand Up @@ -106,8 +103,8 @@ entry:

declare dso_local spir_func void @_Z30__spirv_WritePipeBlockingINTELIKiEv8ocl_pipePvii(%opencl.pipe_wo_t addrspace(1)*, i8 addrspace(4)*, i32, i32)

; CHECK-LLVM: declare spir_func void @__read_pipe_2_bl(%opencl.pipe_ro_t addrspace(1)*, i8 addrspace(4)*, i32, i32)
; CHECK-LLVM: declare spir_func void @__write_pipe_2_bl(%opencl.pipe_wo_t addrspace(1)*, i8 addrspace(4)*, i32, i32)
; CHECK-LLVM: declare spir_func void @__read_pipe_2_bl(ptr addrspace(1), ptr addrspace(4), i32, i32)
; CHECK-LLVM: declare spir_func void @__write_pipe_2_bl(ptr addrspace(1), ptr addrspace(4), i32, i32)

; Function Attrs: convergent mustprogress norecurse nounwind
define linkonce_odr dso_local spir_func void @WritePipeBLockingi9Pointer(i9 addrspace(4)* align 2 dereferenceable(2) %_Data) {
Expand Down
Loading

0 comments on commit 6a57011

Please sign in to comment.