-
Notifications
You must be signed in to change notification settings - Fork 221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DebugInfo] Fix instruction enumeration for template parameter #2314
base: main
Are you sure you want to change the base?
Conversation
These two opcodes were mistakenly swapped when they were originally added, at least according to the DebugInfo, OpenCL.DebugInfo.100, and NonSemantic.Shader.DebugInfo.100 extended instruction sets. This might break existing third-party SPIR-V translators if they are accommodating this bug, mistakenly or otherwise. Original author: Fraser Cormack
@frasercrmck sorry for the delay and please take a look. The plan is to get approvals for this PR, afterwards I'll create backport PRs to other release branches, that have OpenCL DebugInfo implemented and after merge with some graceful period - I'll merge the PR on the main branch. (you may also incorporate changes from this PR into yours, so we can proceed with your PR, I don't mind anyway :) ) |
// Workaround for the incorrect enum used for OpTypeTemplateTemplateParameter | ||
// and OpTypeTemplateParameterPack instructions previously. The W/A added | ||
// to enforce compatibility with previously generated SPIR-V modules. | ||
DINode *SPIRVToLLVMDbgTran::transTypeTemplateParameterInst( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is only tested locally. Ideally we should add an infrastructure to test pre-compiled binaries to ensure backward compatibility (that was probably also discussed during tooling wg call). I'll open an issue in github for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
// would be better. But we know, that the second parameter of | ||
// OpTypeTemplateTemplateParameter is 'Template Name', which for | ||
// OpTypeTemplateParameterPack it is 'Source'. | ||
if (BM->get<SPIRVValue>(Ops[IndexToCheck])->getOpCode() == OpString) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah, we have a workaround like this locally. However, I was worried that it could be DebugInfoNone
(I don't find the spec very clear about which operands are allowed to be DebugInfoNone
)
I came up with a multi-stage guesstimation firstly using the number of operands, which may be more than 10 for only DebugTypeTemplateParameterPack
, or failing that this operand being OpString
for DebugTypeTemplateTemplateParameter
, or this operand being DebugSource
for DebugTypeTemplateParameterPack
or if both of those are DebugInfoNone
then some tie breaker I've forgotten about. It was all a bit complicated.
If this can only truly ever be OpString
and never DebugInfoNone
then this looks fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
These two opcodes were mistakenly swapped when they were originally added, at least according to the DebugInfo, OpenCL.DebugInfo.100, and NonSemantic.Shader.DebugInfo.100 extended instruction sets.
This might break existing third-party SPIR-V translators if they are accommodating this bug, mistakenly or otherwise.
It's continuation of #2248
Original author: Fraser Cormack