This PR improves type inference of operand presented by opaque pointers and aggregate types: * tries to restore original function return type for aggregate types so that it's possible to deduce a correct type during emit-intrinsics step (see llvm/test/CodeGen/SPIRV/SpecConstants/restore-spec-type.ll for the reproducer of the previously existed issue when spirv-val found a mismatch between object and ptr types in OpStore due to the incorrect aggregate types tracing), * explores untyped pointer operands of store to deduce correct pointee types, * creates an extension type to track pointee types from emit-intrinsics step and further instead of direct and naive usage of TypePointerType that led previously to crashes due to ban of creation of Value of TypePointerType type, * tracks instructions with uncomplete type information and tries to improve their type info after pass calculated types for all machine functions (it doesn't traverse a code but rather checks only those instructions which were tracked as uncompleted), * address more cases of removing unnecessary bitcasts (see, for example, changes in test/CodeGen/SPIRV/transcoding/OpGenericCastToPtr.ll where `CHECK-SPIRV-NEXT` in LIT checks show absence of unneeded bitcasts and unmangled/mangled versions have proper typing now with equivalent type info), * address more cases of well known types or relations between types within instructions (see, for example, atomic*.ll test cases and Event-related test cases for improved SPIR-V code generated by the Backend), * fix the issue of removing unneeded ptrcast instructions in pre-legalizer pass that led to creation of new assign-type instructions with the same argument as source in ptrcast and caused errors in type inference (the reproducer `complex.ll` test case is added to the PR).
39 lines
1.6 KiB
LLVM
39 lines
1.6 KiB
LLVM
; The goal of the test case is to ensure that the Backend doesn't crash on the stage
|
|
; of type inference. Result SPIR-V is not expected to be valid from the perspective
|
|
; of spirv-val in this case, because there is a difference of accepted return types
|
|
; between atomicrmw and OpAtomicExchange.
|
|
|
|
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
|
|
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
|
|
|
|
; CHECK-DAG: %[[#LongTy:]] = OpTypeInt 64 0
|
|
; CHECK-DAG: %[[#PtrLongTy:]] = OpTypePointer CrossWorkgroup %[[#LongTy]]
|
|
; CHECK-DAG: %[[#IntTy:]] = OpTypeInt 32 0
|
|
; CHECK-DAG: %[[#Scope:]] = OpConstant %[[#IntTy]] 1
|
|
; CHECK-DAG: %[[#MemSem:]] = OpConstant %[[#IntTy]] 8
|
|
; CHECK-DAG: %[[#PtrPtrLongTy:]] = OpTypePointer CrossWorkgroup %[[#PtrLongTy]]
|
|
|
|
; CHECK: OpFunction
|
|
; CHECK: %[[#Arg1:]] = OpFunctionParameter %[[#PtrPtrLongTy]]
|
|
; CHECK: %[[#Arg2:]] = OpFunctionParameter %[[#PtrLongTy]]
|
|
; CHECK: OpAtomicExchange %[[#PtrLongTy]] %[[#Arg1]] %[[#Scope]] %[[#MemSem]] %[[#Arg2]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
define dso_local spir_func void @test1(ptr addrspace(1) %arg1, ptr addrspace(1) byval(i64) %arg_ptr) {
|
|
entry:
|
|
%r = atomicrmw xchg ptr addrspace(1) %arg1, ptr addrspace(1) %arg_ptr acq_rel
|
|
ret void
|
|
}
|
|
|
|
; CHECK: OpFunction
|
|
; CHECK: %[[#Arg3:]] = OpFunctionParameter %[[#PtrLongTy]]
|
|
; CHECK: %[[#Arg4:]] = OpFunctionParameter %[[#LongTy]]
|
|
; CHECK: OpAtomicExchange %[[#LongTy]] %[[#Arg3]] %[[#Scope]] %[[#MemSem]] %[[#Arg4]]
|
|
; CHECK: OpFunctionEnd
|
|
|
|
define dso_local spir_func void @test2(ptr addrspace(1) %arg1, i64 %arg_ptr) {
|
|
entry:
|
|
%r = atomicrmw xchg ptr addrspace(1) %arg1, i64 %arg_ptr acq_rel
|
|
ret void
|
|
}
|