From 7c034d0d8fa76ec9ea5b2a61b326a8eb0a8ebaaa Mon Sep 17 00:00:00 2001 From: Dmitry Sidorov Date: Thu, 3 Jun 2021 00:09:49 +0300 Subject: [PATCH] [SPIR-V] Change return value of mapType function It's a follow up change for https://github.com/intel/llvm/pull/3856 Signed-off-by: Dmitry Sidorov --- llvm-spirv/lib/SPIRV/SPIRVWriter.cpp | 3 ++- llvm-spirv/test/pointer_type_mapping.ll | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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]]