From: Dmitry Sidorov Date: Sun, 28 May 2023 16:41:04 +0000 (+0200) Subject: [PATCH 56/79] [DebugInfo] Relax consumer checks for checksum info (#2011) X-Git-Tag: archive/raspbian/15.0.1-1+rpi1^2^2~29 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=76d5c1692a583a40b4904d1cdbbe66cdc09cd6a0;p=spirv-llvm-translator-15.git [PATCH 56/79] [DebugInfo] Relax consumer checks for checksum info (#2011) It's a follow up for https://github.com/KhronosGroup/SPIRV-LLVM-Translator/pull/1996 since I couldn't update the PR Signed-off-by: Sidorov, Dmitry Gbp-Pq: Name 0056-DebugInfo-Relax-consumer-checks-for-checksum-info-20.patch --- diff --git a/lib/SPIRV/SPIRVToLLVMDbgTran.cpp b/lib/SPIRV/SPIRVToLLVMDbgTran.cpp index 65bb017..9dd9c93 100644 --- a/lib/SPIRV/SPIRVToLLVMDbgTran.cpp +++ b/lib/SPIRV/SPIRVToLLVMDbgTran.cpp @@ -1507,18 +1507,25 @@ DIFile *SPIRVToLLVMDbgTran::getFile(const SPIRVId SourceId) { Optional> CS; SPIRVWord StrIdx = SourceArgs[TextIdx]; if (Source->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) { - if (!getDbgInst(SourceArgs[ChecksumKind]) && - !getDbgInst(SourceArgs[ChecksumValue])) { - llvm::DIFile::ChecksumKind Kind = SPIRV::DbgChecksumKindMap::rmap( - static_cast( - BM->get(SourceArgs[ChecksumKind]) - ->getZExtIntValue())); - StringRef Checksum = getString(SourceArgs[ChecksumValue]); - size_t ChecksumEndPos = Checksum.find_if_not(llvm::isHexDigit); - CS.emplace(Kind, Checksum.substr(0, ChecksumEndPos)); + if (SourceArgs.size() >= MaxOperandCount - 1) { + // 2 optional parameters are ChecksumKind and ChecksumValue - they should + // go together + if (!getDbgInst(SourceArgs[ChecksumKind]) && + !getDbgInst(SourceArgs[ChecksumValue])) { + llvm::DIFile::ChecksumKind Kind = SPIRV::DbgChecksumKindMap::rmap( + static_cast( + BM->get(SourceArgs[ChecksumKind]) + ->getZExtIntValue())); + StringRef Checksum = getString(SourceArgs[ChecksumValue]); + size_t ChecksumEndPos = Checksum.find_if_not(llvm::isHexDigit); + CS.emplace(Kind, Checksum.substr(0, ChecksumEndPos)); + } } - if (SourceArgs.size() == MaxOperandCount) + // Among optional parameters - text is always the last one (either 1st or + // 3rd) + if (SourceArgs.size() == MaxOperandCount || + SourceArgs.size() == MaxOperandCount - 2) StrIdx = SourceArgs[TextNonSemIdx]; else StrIdx = SPIRVID_INVALID;