Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,13 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
ConstantInt::get(getSizetType(), ArraySize, false), nullptr)));
mapType(T, TransType);
if (ElTy->isPointerTy()) {
mapType(
Type *ArrTy =
ArrayType::get(TypedPointerType::get(Type::getInt8Ty(*Ctx),
ElTy->getPointerAddressSpace()),
ArraySize),
TransType);
ArraySize);
LLVMToSPIRVTypeMap::iterator Loc = TypeMap.find(ArrTy);
if (Loc == TypeMap.end())
mapType(ArrTy, TransType);
}
return TransType;
}
Expand Down
19 changes: 19 additions & 0 deletions test/duplicate-types.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; Check that we don't end up with duplicated array types in TypeMap.
; No FileCheck needed, we only want to check the absence of errors.
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv %t.bc -o %t.spv
; RUN: spirv-val %t.spv

; ModuleID = 'duplicate-array-types'
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1"
target triple = "spir64-unknown-unknown"

%duplicate = type { [2 x ptr addrspace(4)] }

; Function Attrs: mustprogress norecurse nounwind
define spir_kernel void @foo() {
entry:
alloca [2 x ptr addrspace(4)], align 8
alloca %duplicate, align 8
ret void
}