microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] debug info omits scope necessary for for-loops

Open
#8,514 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage spirv
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
When outputting NS100 debug info, SpirvEmitter currently skips a lexical scope that coincides with the '(' and ')' of the for loop. This leads to confusing debug info.

Steps to Reproduce
https://godbolt.org/z/Pfe5zcPTb

Actual Behavior
%65 = OpExtInst %void %1 DebugLexicalBlock %42 %uint_11 %uint_1 %62
%66 = OpExtInst %void %1 DebugLexicalBlock %42 %uint_15 %uint_33 %65
Both 'i' variables have the same lexical block.

An examination of LLVM reveals that this can be solved by considering the for-loop controls to be a DebugLexicalScope.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with SpirvEmitter and reproduce the issue using the linked Godbolt example. Compare the emitted NS100 debug information with LLVM's treatment of for-loop controls as a DebugLexicalScope. Done means the two variables receive distinct lexical blocks and the confusing debug output is corrected.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.