1; The goal of the test is to ensure that type inference doesn't break validity of the generated SPIR-V code. 2; The only pass criterion is that spirv-val considers output valid. 3 4; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s 5; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} 6 7; CHECK-DAG: %[[#Int:]] = OpTypeInt 32 0 8; CHECK-DAG: %[[#Char:]] = OpTypeInt 8 0 9; CHECK-DAG: %[[#PtrChar:]] = OpTypePointer Function %[[#Char]] 10; CHECK-DAG: %[[#PtrCharCW:]] = OpTypePointer CrossWorkgroup %[[#Char]] 11; CHECK-DAG: %[[#PtrCharGen:]] = OpTypePointer Generic %[[#Char]] 12; CHECK-DAG: %[[#Struct:]] = OpTypeStruct %[[#]] %[[#]] %[[#]] 13; CHECK-DAG: %[[#PtrInt:]] = OpTypePointer Function %[[#Int]] 14; CHECK-DAG: %[[#PtrPtrCharGen:]] = OpTypePointer Function %[[#PtrCharGen]] 15; CHECK-DAG: %[[#PtrStruct:]] = OpTypePointer Function %[[#Struct]] 16; CHECK: OpFunction 17; CHECK: %[[#Arg1:]] = OpFunctionParameter %[[#Int]] 18; CHECK: %[[#Arg2:]] = OpFunctionParameter %[[#PtrCharCW]] 19; CHECK: %[[#Kernel:]] = OpVariable %[[#PtrStruct]] Function 20; CHECK: %[[#IntKernel:]] = OpBitcast %[[#PtrInt]] %[[#Kernel]] 21; CHECK: OpStore %[[#IntKernel]] %[[#Arg1]] 22; CHECK: %[[#CharKernel:]] = OpBitcast %[[#PtrChar]] %[[#Kernel]] 23; CHECK: %[[#P:]] = OpInBoundsPtrAccessChain %[[#PtrChar]] %[[#CharKernel]] %[[#]] 24; CHECK: %[[#R0:]] = OpPtrCastToGeneric %[[#PtrCharGen]] %[[#Arg2]] 25; CHECK: %[[#P2:]] = OpBitcast %[[#PtrPtrCharGen]] %[[#P]] 26; CHECK: OpStore %[[#P2]] %[[#R0]] 27; CHECK: %[[#P3:]] = OpBitcast %[[#PtrPtrCharGen]] %[[#P]] 28; CHECK: %[[#]] = OpLoad %[[#PtrCharGen]] %[[#P3]] 29 30%"class.std::complex" = type { { double, double } } 31%class.anon = type { i32, ptr addrspace(4), [2 x [2 x %"class.std::complex"]] } 32 33define weak_odr dso_local spir_kernel void @foo(i32 noundef %_arg_N, ptr addrspace(1) noundef align 8 %_arg_p) { 34entry: 35 %Kernel = alloca %class.anon, align 8 36 store i32 %_arg_N, ptr %Kernel, align 8 37 %p = getelementptr inbounds i8, ptr %Kernel, i64 8 38 %r0 = addrspacecast ptr addrspace(1) %_arg_p to ptr addrspace(4) 39 store ptr addrspace(4) %r0, ptr %p, align 8 40 %r3 = load ptr addrspace(4), ptr %p, align 8 41 ret void 42} 43