Skip to content

Commit 23a3ea0

Browse files
MrSidimssys-ce-bb
authored andcommitted
Relax consumer checks for checksum info (#2011)
It's a follow up for KhronosGroup/SPIRV-LLVM-Translator#1996 since I couldn't update the PR Signed-off-by: Sidorov, Dmitry <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@8cbf726
1 parent e4ad410 commit 23a3ea0

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

llvm-spirv/lib/SPIRV/SPIRVToLLVMDbgTran.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,18 +1505,25 @@ DIFile *SPIRVToLLVMDbgTran::getFile(const SPIRVId SourceId) {
15051505
std::optional<DIFile::ChecksumInfo<StringRef>> CS;
15061506
SPIRVWord StrIdx = SourceArgs[TextIdx];
15071507
if (Source->getExtSetKind() == SPIRVEIS_NonSemantic_Shader_DebugInfo_200) {
1508-
if (!getDbgInst<SPIRVDebug::DebugInfoNone>(SourceArgs[ChecksumKind]) &&
1509-
!getDbgInst<SPIRVDebug::DebugInfoNone>(SourceArgs[ChecksumValue])) {
1510-
llvm::DIFile::ChecksumKind Kind = SPIRV::DbgChecksumKindMap::rmap(
1511-
static_cast<SPIRVDebug::FileChecksumKind>(
1512-
BM->get<SPIRVConstant>(SourceArgs[ChecksumKind])
1513-
->getZExtIntValue()));
1514-
StringRef Checksum = getString(SourceArgs[ChecksumValue]);
1515-
size_t ChecksumEndPos = Checksum.find_if_not(llvm::isHexDigit);
1516-
CS.emplace(Kind, Checksum.substr(0, ChecksumEndPos));
1508+
if (SourceArgs.size() >= MaxOperandCount - 1) {
1509+
// 2 optional parameters are ChecksumKind and ChecksumValue - they should
1510+
// go together
1511+
if (!getDbgInst<SPIRVDebug::DebugInfoNone>(SourceArgs[ChecksumKind]) &&
1512+
!getDbgInst<SPIRVDebug::DebugInfoNone>(SourceArgs[ChecksumValue])) {
1513+
llvm::DIFile::ChecksumKind Kind = SPIRV::DbgChecksumKindMap::rmap(
1514+
static_cast<SPIRVDebug::FileChecksumKind>(
1515+
BM->get<SPIRVConstant>(SourceArgs[ChecksumKind])
1516+
->getZExtIntValue()));
1517+
StringRef Checksum = getString(SourceArgs[ChecksumValue]);
1518+
size_t ChecksumEndPos = Checksum.find_if_not(llvm::isHexDigit);
1519+
CS.emplace(Kind, Checksum.substr(0, ChecksumEndPos));
1520+
}
15171521
}
15181522

1519-
if (SourceArgs.size() == MaxOperandCount)
1523+
// Among optional parameters - text is always the last one (either 1st or
1524+
// 3rd)
1525+
if (SourceArgs.size() == MaxOperandCount ||
1526+
SourceArgs.size() == MaxOperandCount - 2)
15201527
StrIdx = SourceArgs[TextNonSemIdx];
15211528
else
15221529
StrIdx = SPIRVID_INVALID;

0 commit comments

Comments
 (0)