diff --git a/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp b/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp index 8071d6dfcdc5e..f5b5f8ec4b43a 100644 --- a/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp +++ b/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp @@ -1794,10 +1794,11 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB, SPIRVType *LLVMToSPIRVBase::mapType(Type *T, SPIRVType *BT) { auto EmplaceStatus = TypeMap.try_emplace(T, BT); - (void)EmplaceStatus; // TODO: Uncomment the assertion, once the type mapping issue is resolved // assert(EmplaceStatus.second && "The type was already added to the map"); SPIRVDBG(dbgs() << "[mapType] " << *T << " => "; spvdbgs() << *BT << '\n'); + if (!EmplaceStatus.second) + return TypeMap[T]; return BT; } diff --git a/llvm-spirv/test/pointer_type_mapping.ll b/llvm-spirv/test/pointer_type_mapping.ll index e76b360d1cd48..0b009fc3c41b2 100644 --- a/llvm-spirv/test/pointer_type_mapping.ll +++ b/llvm-spirv/test/pointer_type_mapping.ll @@ -5,8 +5,8 @@ ; CHECK: Name [[#NAME:]] "struct._ZTS6Object.Object" ; CHECK-COUNT-1: TypeStruct [[#NAME]] ; TODO add check count one and remove unused, when the type mapping bug is fixed -; CHECK: TypePointer [[#UNUSED:]] {{.*}} [[#NAME]] ; CHECK: TypePointer [[#PTRTY:]] {{.*}} [[#NAME]] +; CHECK: TypePointer [[#UNUSED:]] {{.*}} [[#NAME]] ; CHECK: FunctionParameter [[#PTRTY]] ; CHECK-NOT: FunctionParameter [[#UNUSED]]