Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MrSidims
Copy link
Contributor

@MrSidims MrSidims commented Jan 23, 2024

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

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
@MrSidims
Copy link
Contributor Author

MrSidims commented Jan 23, 2024

@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(
Copy link
Contributor Author

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.

Copy link
Contributor

@LU-JOHN LU-JOHN left a 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)
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants