Skip to content

Commit 3056050

Browse files
vmaksimojsji
authored andcommitted
Use untyped pointers when translating pointer to structure type (#2827)
This improves SPV_KHR_untyped_pointers extension. Removing struct type from special handling (translate as typed pointer) allowed to fix `spirv-val` error in `CXX/global-ctor.cl` test: ``` error: line 88: OpFunctionCall Argument <id> '25[%this1]'s type does not match Function <id> '11[%_ptr_Generic_class_Something]'s parameter type. %30 = OpFunctionCall %void %_ZNU3AS49SomethingC2Ei %this1 %26 ``` Other changes allow to translate structs in a new way without violating validation or test checks. Original commit: KhronosGroup/SPIRV-LLVM-Translator@15fd1cc50e12465
1 parent ed629d3 commit 3056050

File tree

12 files changed

+65
-33
lines changed

12 files changed

+65
-33
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2218,7 +2218,7 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
22182218
case OpUntypedInBoundsPtrAccessChainKHR: {
22192219
auto *AC = static_cast<SPIRVAccessChainBase *>(BV);
22202220
auto *Base = transValue(AC->getBase(), F, BB);
2221-
SPIRVType *BaseSPVTy = AC->getBase()->getType();
2221+
SPIRVType *BaseSPVTy = AC->getBaseType();
22222222
if (BaseSPVTy->isTypePointer() &&
22232223
BaseSPVTy->getPointerElementType()->isTypeCooperativeMatrixKHR()) {
22242224
return mapValue(BV, transSPIRVBuiltinFromInst(AC, BB));
@@ -2227,7 +2227,9 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
22272227
BaseSPVTy->isTypeVector()
22282228
? transType(
22292229
BaseSPVTy->getVectorComponentType()->getPointerElementType())
2230-
: transType(BaseSPVTy->getPointerElementType());
2230+
: BaseSPVTy->isTypePointer()
2231+
? transType(BaseSPVTy->getPointerElementType())
2232+
: transType(BaseSPVTy);
22312233
auto Index = transValue(AC->getIndices(), F, BB);
22322234
if (!AC->hasPtrIndex())
22332235
Index.insert(Index.begin(), getInt32(M, 0));

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -758,8 +758,7 @@ SPIRVType *LLVMToSPIRVBase::transPointerType(SPIRVType *ET, unsigned AddrSpc) {
758758
!BM->shouldEmitFunctionPtrAddrSpace())
759759
return transPointerType(ET, SPIRAS_Private);
760760
if (BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_untyped_pointers) &&
761-
!(ET->isTypeArray() || ET->isTypeVector() || ET->isTypeStruct() ||
762-
ET->isSPIRVOpaqueType())) {
761+
!(ET->isTypeArray() || ET->isTypeVector() || ET->isSPIRVOpaqueType())) {
763762
TranslatedTy = BM->addUntypedPointerKHRType(
764763
SPIRSPIRVAddrSpaceMap::map(static_cast<SPIRAddressSpace>(AddrSpc)));
765764
} else {
@@ -2326,11 +2325,17 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
23262325
BM->addInstTemplate(OpVariableLengthArrayINTEL,
23272326
{Length->getId()}, BB, TranslatedTy));
23282327
}
2329-
SPIRVType *VarTy =
2330-
V->getType()->getPointerAddressSpace() == SPIRAS_Generic
2331-
? BM->addPointerType(StorageClassFunction,
2332-
TranslatedTy->getPointerElementType())
2333-
: TranslatedTy;
2328+
SPIRVType *VarTy = TranslatedTy;
2329+
if (V->getType()->getPointerAddressSpace() == SPIRAS_Generic) {
2330+
// TODO: refactor addPointerType and addUntypedPointerKHRType in one
2331+
// method if possible.
2332+
if (TranslatedTy->isTypeUntypedPointerKHR())
2333+
VarTy = BM->addUntypedPointerKHRType(StorageClassFunction);
2334+
else
2335+
VarTy = BM->addPointerType(StorageClassFunction,
2336+
TranslatedTy->getPointerElementType());
2337+
}
2338+
23342339
SPIRVValue *Var = BM->addVariable(
23352340
VarTy,
23362341
VarTy->isTypeUntypedPointerKHR() ? transType(Alc->getAllocatedType())
@@ -2501,7 +2506,8 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
25012506

25022507
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(V)) {
25032508
auto *PointerOperand = GEP->getPointerOperand();
2504-
std::vector<SPIRVWord> Ops = {transValue(PointerOperand, BB)->getId()};
2509+
auto *SPVPointerOperand = transValue(PointerOperand, BB);
2510+
std::vector<SPIRVWord> Ops = {SPVPointerOperand->getId()};
25052511
for (unsigned I = 0, E = GEP->getNumIndices(); I != E; ++I)
25062512
Ops.push_back(transValue(GEP->getOperand(I + 1), BB)->getId());
25072513

@@ -2544,14 +2550,20 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
25442550
// GEP can return a vector of pointers, in this case GEP will calculate
25452551
// addresses for each pointer in the vector
25462552
SPIRVType *TranslatedTy = transScavengedType(GEP);
2547-
if (TranslatedTy->isTypeUntypedPointerKHR()) {
2553+
if (TranslatedTy->isTypeUntypedPointerKHR() ||
2554+
SPVPointerOperand->getType()->isTypeUntypedPointerKHR()) {
25482555
llvm::Type *Ty = Scavenger->getScavengedType(PointerOperand);
25492556
SPIRVType *PtrTy = nullptr;
25502557
if (auto *TPT = dyn_cast<TypedPointerType>(Ty)) {
25512558
PtrTy = transType(TPT->getElementType());
25522559
Ops = getVec(PtrTy->getId(), Ops);
25532560
}
25542561
}
2562+
if (SPVPointerOperand->getType()->isTypeUntypedPointerKHR())
2563+
// Untyped pointer as an input operand implies we should use untyped
2564+
// access chain instructions. Replace return type to do that.
2565+
TranslatedTy = SPVPointerOperand->getType();
2566+
25552567
return mapValue(
25562568
V, BM->addPtrAccessChainInst(TranslatedTy, Ops, BB, GEP->isInBounds()));
25572569
}

llvm-spirv/test/CXX/global-ctor.cl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
// RUN: llvm-spirv -r %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM
66
// RUN: not llvm-spirv %t.bc --spirv-max-version=1.0 2>&1 | FileCheck %s --check-prefix=CHECK-SPV10
77

8+
// RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_KHR_untyped_pointers
9+
// RUN: spirv-val %t.spv
10+
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
11+
// RUN: llvm-spirv -r %t.spv -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM
12+
// RUN: not llvm-spirv %t.bc --spirv-max-version=1.0 2>&1 | FileCheck %s --check-prefix=CHECK-SPV10
13+
814
class Something {
915
public:
1016
Something(int a) : v(a) {}

llvm-spirv/test/EnqueueEmptyKernel.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ target triple = "spir64-unknown-unknown"
3535
; CHECK-SPIRV: TypeVoid [[Void:[0-9]+]]
3636
; CHECK-SPIRV-TYPED-PTR: TypePointer [[Int8PtrGen:[0-9]+]] 8 [[Int8]]
3737
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[Int8PtrGen:[0-9]+]] 8
38-
; CHECK-SPIRV: Variable {{[0-9]+}} [[Block:[0-9]+]]
38+
; CHECK-SPIRV-TYPED-PTR: Variable {{[0-9]+}} [[Block:[0-9]+]]
39+
; CHECK-SPIRV-UNTYPED-PTR: UntypedVariableKHR {{[0-9]+}} [[Block:[0-9]+]]
3940

4041
; Function Attrs: convergent nounwind
4142
define spir_kernel void @test_enqueue_empty() #0 !kernel_arg_addr_space !0 !kernel_arg_access_qual !0 !kernel_arg_type !0 !kernel_arg_base_type !0 !kernel_arg_type_qual !0 {

llvm-spirv/test/SpecConstants/spec-constant-length-array.ll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
; CHECK-SPV-DAG: TypePointer [[#ARR_PTR_TY_1:]] [[#FUNCTION_SC]] [[#ARR_TY_1]]
3535
; CHECK-SPV-DAG: TypeFloat [[#DOUBLE_TY:]] 64
3636
; CHECK-SPV-DAG: TypeStruct [[#STR_TY:]] [[#DOUBLE_TY]] [[#DOUBLE_TY]]
37-
; CHECK-SPV-DAG: TypePointer [[#STR_PTR_TY:]] [[#FUNCTION_SC]] [[#STR_TY]]
37+
; CHECK-SPV-TYPED-PTR-DAG: TypePointer [[#STR_PTR_TY:]] [[#FUNCTION_SC]] [[#STR_TY]]
3838
; CHECK-SPV-DAG: TypeArray [[#ARR_TY_2:]] [[#STR_TY]] [[#LENGTH_2]]
3939
; CHECK-SPV-DAG: TypePointer [[#ARR_PTR_TY_2:]] [[#FUNCTION_SC]] [[#ARR_TY_2:]]
4040

@@ -69,7 +69,8 @@ define spir_kernel void @test() {
6969
; CHECK-LLVM: %[[VAR1:.*]] = bitcast ptr %[[ALLOCA1]] to ptr
7070
%scla1 = alloca i8, i32 %length1, align 2
7171

72-
; CHECK-SPV: Bitcast [[#STR_PTR_TY]] [[#]] [[#SCLA_2]]
72+
; CHECK-SPV-TYPED-PTR: Bitcast [[#STR_PTR_TY]] [[#]] [[#SCLA_2]]
73+
; CHECK-SPV-UNTYPED-PTR: Bitcast [[#PTR_TY]] [[#]] [[#SCLA_2]]
7374

7475
; CHECK-LLVM: %[[VAR2:.*]] = bitcast ptr %[[ALLOCA2]] to ptr
7576
%scla2 = alloca %struct_type, i8 %length2, align 16

llvm-spirv/test/extensions/INTEL/SPV_INTEL_task_sequence/task_sequence.ll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
; RUN: llvm-as %s -o %t.bc
22
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_task_sequence -o %t.spv
33
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
4-
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
4+
; RUN: FileCheck < %t.spt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-TYPED-PTR
55

66
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
77
; RUN: llvm-dis %t.rev.bc
88
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM
99

1010
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_task_sequence,+SPV_KHR_untyped_pointers -o %t.spv
1111
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
12-
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
12+
; RUN: FileCheck < %t.spt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-UNTYPED-PTR
1313

1414
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
1515
; RUN: llvm-dis %t.rev.bc
@@ -54,12 +54,15 @@
5454

5555
; CHECK-SPIRV: TypeInt [[#IntTy:]] 32 0
5656
; CHECK-SPIRV: TypeTaskSequenceINTEL [[#TypeTS:]]
57+
; CHECK-SPIRV-UNTYPED-PTR: TypeStruct [[#StructTS:]] [[#TypeTS]]
58+
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[#Ptr:]] 7
5759
; CHECK-SPIRV: TypeFunction [[#FuncTy:]] [[#IntTy]] [[#IntTy]] [[#IntTy]]
58-
; CHECK-SPIRV: TypePointer [[#PtrTS:]] 7 [[#TypeTS]]
60+
; CHECK-SPIRV-TYPED-PTR: TypePointer [[#PtrTS:]] 7 [[#TypeTS]]
5961

6062
; <id> Result Type <id> Result <id> Function Literal Pipelined Literal UseStallEnableClusters Literal GetCapacity Literal AsyncCapacity
6163
; CHECK-SPIRV: TaskSequenceCreateINTEL [[#TypeTS]] [[#CreateRes:]] [[#FuncId:]] 10 4294967295 17 1
62-
; CHECK-SPIRV: InBoundsPtrAccessChain [[#PtrTS]] [[#GEP:]]
64+
; CHECK-SPIRV-TYPED-PTR: InBoundsPtrAccessChain [[#PtrTS]] [[#GEP:]]
65+
; CHECK-SPIRV-UNTYPED-PTR: UntypedInBoundsPtrAccessChainKHR [[#Ptr]] [[#GEP:]] [[#StructTS]]
6366
; CHECK-SPIRV: Store [[#GEP]] [[#CreateRes]]
6467

6568
; CHECK-SPIRV: Load [[#IntTy]] [[#LoadIntVar:]]

llvm-spirv/test/extensions/INTEL/SPV_INTEL_task_sequence/task_sequence_zero_capacity_literals.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
; RUN: llvm-as %s -o %t.bc
22
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_task_sequence -o %t.spv
33
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
4-
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
4+
; RUN: FileCheck < %t.spt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-TYPED-PTR
55

66
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
77
; RUN: llvm-dis %t.rev.bc
88
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM
99

1010
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_task_sequence,+SPV_KHR_untyped_pointers -o %t.spv
1111
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
12-
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
12+
; RUN: FileCheck < %t.spt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-UNTYPED-PTR
1313

1414
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
1515
; RUN: llvm-dis %t.rev.bc
@@ -22,7 +22,8 @@
2222

2323
; <id> Result Type <id> Result <id> Function Literal Pipelined Literal UseStallEnableClusters Literal GetCapacity Literal AsyncCapacity
2424
; CHECK-SPIRV: TaskSequenceCreateINTEL [[#TypeTS]] [[#CreateRes:]] [[#FuncId:]] 10 4294967295 0 0
25-
; CHECK-SPIRV: InBoundsPtrAccessChain [[#PtrTS]] [[#GEP:]]
25+
; CHECK-SPIRV-TYPED-PTR: InBoundsPtrAccessChain [[#PtrTS]] [[#GEP:]]
26+
; CHECK-SPIRV-UNTYPED-PTR: UntypedInBoundsPtrAccessChainKHR [[#]] [[#GEP:]] [[#]]
2627
; CHECK-SPIRV: Store [[#GEP]] [[#CreateRes]]
2728

2829
; CHECK-SPIRV: Function [[#IntTy]] [[#FuncId]] 0 [[#FuncTy]]

llvm-spirv/test/extensions/KHR/SPV_KHR_untyped_pointers/untyped_ptr_access_chain.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
; CHECK-SPIRV: Constant [[#IntTy]] [[#Const1:]] 1
2424
; CHECK-SPIRV: TypeUntypedPointerKHR [[#UntypedPtrTy:]] 7
2525
; CHECK-SPIRV: TypeStruct [[#StructTy:]] [[#IntTy]] [[#IntTy]]
26-
; CHECK-SPIRV: TypePointer [[#PtrStructTy:]] 7 [[#StructTy]]
2726

28-
; CHECK-SPIRV: Variable [[#PtrStructTy]] [[#StructVarId:]] 7
27+
; CHECK-SPIRV: UntypedVariableKHR [[#UntypedPtrTy]] [[#StructVarId:]] 7 [[#StructTy]]
2928
; CHECK-SPIRV: UntypedInBoundsPtrAccessChainKHR [[#UntypedPtrTy]] [[#]] [[#StructTy]] [[#StructVarId]] [[#Const0]] [[#Const1]]
3029

3130
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"

llvm-spirv/test/llvm-intrinsics/memset-opaque.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
; CHECK-SPIRV: Constant {{[0-9]+}} [[Lenmemset21:[0-9]+]] 4
1717
; CHECK-SPIRV: Constant {{[0-9]+}} [[Lenmemset0:[0-9]+]] 12
1818
; CHECK-SPIRV: Constant {{[0-9]+}} [[Const21:[0-9]+]] 21
19+
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[Int8Ptr:[0-9]+]] 8
1920
; CHECK-SPIRV: TypeArray [[Int8x4:[0-9]+]] [[Int8]] [[Lenmemset21]]
2021
; CHECK-SPIRV-TYPED-PTR: TypePointer [[Int8Ptr:[0-9]+]] 8 [[Int8]]
21-
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[Int8Ptr:[0-9]+]] 8
2222
; CHECK-SPIRV: TypeArray [[Int8x12:[0-9]+]] [[Int8]] [[Lenmemset0]]
2323
; CHECK-SPIRV-TYPED-PTR: TypePointer [[Int8PtrConst:[0-9]+]] 0 [[Int8]]
2424
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[Int8PtrConst:[0-9]+]] 0

llvm-spirv/test/transcoding/CreatePipeFromPipeStorage.ll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@
3131

3232
; CHECK-SPIRV: TypePipe [[READ_PIPE:[0-9]+]] 0
3333
; CHECK-SPIRV: TypeStruct [[READ_PIPE_WRAPPER:[0-9]+]] [[READ_PIPE]]
34-
; CHECK-SPIRV: TypePointer [[READ_PIPE_WRAPPER_PTR:[0-9]+]] 7 [[READ_PIPE_WRAPPER]]
34+
; CHECK-SPIRV-TYPED-PTR: TypePointer [[READ_PIPE_WRAPPER_PTR:[0-9]+]] 7 [[READ_PIPE_WRAPPER]]
35+
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[PTR:[0-9]+]] 7
3536
; CHECK-SPIRV: TypePipe [[WRITE_PIPE:[0-9]+]] 1
3637
; CHECK-SPIRV: TypeStruct [[WRITE_PIPE_WRAPPER:[0-9]+]] [[WRITE_PIPE]]
3738

38-
; CHECK-SPIRV: TypePointer [[WRITE_PIPE_WRAPPER_PTR:[0-9]+]] 7 [[WRITE_PIPE_WRAPPER]]
39+
; CHECK-SPIRV-TYPED-PTR: TypePointer [[WRITE_PIPE_WRAPPER_PTR:[0-9]+]] 7 [[WRITE_PIPE_WRAPPER]]
3940

4041

4142
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"
@@ -56,8 +57,10 @@ entry:
5657
; CHECK-SPV-IR: %myrpipe = alloca %"[[CL_READ_PIPE_NAME]]", align 4
5758
; CHECK-SPV-IR: %mywpipe = alloca %"[[CL_WRITE_PIPE_NAME]]", align 4
5859

59-
; CHECK-SPIRV: Variable [[READ_PIPE_WRAPPER_PTR]] [[READ_PIPE_WRAPPER_ID]] 7
60-
; CHECK-SPIRV: Variable [[WRITE_PIPE_WRAPPER_PTR]] [[WRITE_PIPE_WRAPPER_ID]] 7
60+
; CHECK-SPIRV-TYPED-PTR: Variable [[READ_PIPE_WRAPPER_PTR]] [[READ_PIPE_WRAPPER_ID]] 7
61+
; CHECK-SPIRV-TYPED-PTR: Variable [[WRITE_PIPE_WRAPPER_PTR]] [[WRITE_PIPE_WRAPPER_ID]] 7
62+
; CHECK-SPIRV-UNTYPED-PTR: UntypedVariableKHR [[PTR]] [[READ_PIPE_WRAPPER_ID]] 7 [[READ_PIPE_WRAPPER]]
63+
; CHECK-SPIRV-UNTYPED-PTR: UntypedVariableKHR [[PTR]] [[WRITE_PIPE_WRAPPER_ID]] 7 [[WRITE_PIPE_WRAPPER]]
6164

6265
%myrpipe = alloca %"class.cl::pipe<int __attribute__((ext_vector_type(4))), cl::pipe_access::read>", align 4
6366
%mywpipe = alloca %"class.cl::pipe<int __attribute__((ext_vector_type(4))), cl::pipe_access::write>", align 4

llvm-spirv/test/transcoding/constant-vars.ll

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ target triple = "spir-unknown-unknown"
4040
; CHECK-SPIRV-UNTYPED-PTR: 8 SpecConstantOp [[AS2]] [[ASTRC:[0-9]+]] 4424 [[#]] [[ASTR]] [[I320]] [[I320]]
4141
; CHECK-SPIRV: 5 SpecConstantOp [[AS1]] [[I64ARRC:[0-9]+]] 124 [[I64ARR]]
4242
; CHECK-SPIRV: 5 ConstantComposite [[STRUCTTY]] [[STRUCT_INIT:[0-9]+]] [[ASTRC]] [[I64ARRC]]
43-
; CHECK-SPIRV: 5 Variable {{[0-9]+}} [[STRUCT:[0-9]+]] 5 [[STRUCT_INIT]]
43+
; CHECK-SPIRV-TYPED-PTR: 5 Variable {{[0-9]+}} [[STRUCT:[0-9]+]] 5 [[STRUCT_INIT]]
44+
; CHECK-SPIRV-UNTYPED-PTR: 6 UntypedVariableKHR {{[0-9]+}} [[STRUCT:[0-9]+]] 5 [[STRUCTTY]] [[STRUCT_INIT]]
4445

4546
@array = addrspace(1) global [3 x ptr addrspace(1)] [ptr addrspace(1) @i64arr, ptr addrspace(1) @struct, ptr addrspace(1) getelementptr ([3 x i64], ptr addrspace(1) @i64arr, i64 0, i64 1) ]
4647

4748
; CHECK-SPIRV: 5 SpecConstantOp [[AS1]] [[I64ARRC2:[0-9]+]] 124 [[I64ARR]]
48-
; CHECK-SPIRV: 5 SpecConstantOp [[AS1]] [[STRUCTC:[0-9]+]] 124 [[STRUCT]]
49+
; CHECK-SPIRV-TYPED-PTR: 5 SpecConstantOp [[AS1]] [[STRUCTC:[0-9]+]] 124 [[STRUCT]]
4950
; CHECK-SPIRV-TYPED-PTR: 7 SpecConstantOp {{[0-9]+}} [[GEP:[0-9]+]] 67 [[I64ARR]]
5051
; CHECK-SPIRV-UNTYPED-PTR: 8 SpecConstantOp {{[0-9]+}} [[GEP:[0-9]+]] 4423 [[#]] [[I64ARR]]
51-
; CHECK-SPIRV: 6 ConstantComposite [[ARRAYTY]] [[ARRAY_INIT:[0-9]+]] [[I64ARRC2]] [[STRUCTC]] [[GEP]]
52+
; CHECK-SPIRV-TYPED-PTR: 6 ConstantComposite [[ARRAYTY]] [[ARRAY_INIT:[0-9]+]] [[I64ARRC2]] [[STRUCTC]] [[GEP]]
53+
; CHECK-SPIRV-UNTYPED-PTR: 6 ConstantComposite [[ARRAYTY]] [[ARRAY_INIT:[0-9]+]] [[I64ARRC2]] [[STRUCT]] [[GEP]]
5254
; CHECK-SPIRV: 5 Variable {{[0-9]+}} [[ARRAY:[0-9]+]] 5 [[ARRAY_INIT]]
5355

5456
; CHECK-LLVM: %structtype = type { ptr addrspace(2), ptr addrspace(1) }

llvm-spirv/test/transcoding/kernel_query.ll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,18 @@ target triple = "spir-unknown-unknown"
6363
; CHECK-SPIRV: Constant [[Int32Ty]] [[ConstInt8:[0-9]+]] 8
6464
; CHECK-SPIRV: TypeVoid [[VoidTy:[0-9]+]]
6565
; CHECK-SPIRV: TypeStruct [[NDRangeTy:[0-9]+]] [[Int32Ty]] {{$}}
66-
; CHECK-SPIRV: TypePointer [[NDRangePtrTy:[0-9]+]] 7 [[NDRangeTy]]
66+
; CHECK-SPIRV-TYPED-PTR: TypePointer [[NDRangePtrTy:[0-9]+]] 7 [[NDRangeTy]]
6767
; CHECK-SPIRV-TYPED-PTR: TypePointer [[Int8PtrGenTy:[0-9]+]] 8 [[Int8Ty]]
68+
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[NDRangePtrTy:[0-9]+]] 7
6869
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[Int8PtrGenTy:[0-9]+]] 8
6970
; CHECK-SPIRV: TypeFunction [[BlockKerTy:[0-9]+]] [[VoidTy]] [[Int8PtrGenTy]]
7071

7172
; Function Attrs: convergent noinline nounwind optnone
7273
define spir_kernel void @device_side_enqueue() #0 !kernel_arg_addr_space !2 !kernel_arg_access_qual !2 !kernel_arg_type !2 !kernel_arg_base_type !2 !kernel_arg_type_qual !2 {
7374
entry:
7475

75-
; CHECK-SPIRV: Variable [[NDRangePtrTy]] [[NDRange:[0-9]+]]
76+
; CHECK-SPIRV-TYPED-PTR: Variable [[NDRangePtrTy]] [[NDRange:[0-9]+]]
77+
; CHECK-SPIRV-UNTYPED-PTR: UntypedVariableKHR [[NDRangePtrTy]] [[NDRange:[0-9]+]] [[#]] [[NDRangeTy]]
7678

7779
%ndrange = alloca %struct.ndrange_t, align 4
7880

0 commit comments

Comments
 (0)