Skip to content

[SPIRV] Emit DebugLexicalScope for forloop controls (#8514)#8515

Open
SteveUrquhart wants to merge 2 commits into
microsoft:mainfrom
SteveUrquhart:emit-forloop-debugscope
Open

[SPIRV] Emit DebugLexicalScope for forloop controls (#8514)#8515
SteveUrquhart wants to merge 2 commits into
microsoft:mainfrom
SteveUrquhart:emit-forloop-debugscope

Conversation

@SteveUrquhart

Copy link
Copy Markdown
Contributor

Adds missing DebugLexicalScope to for-loops, fixes #8514

@damyanp

damyanp commented Jun 3, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the SPIR-V emitter’s rich debug info generation to introduce an additional lexical scope for for loop controls (the for (<init>; <cond>; <inc>) region), addressing missing scope nesting reported in #8514 and updating FileCheck expectations accordingly.

Changes:

  • Emit an extra DebugLexicalBlock for for loop controls and push/pop it during ForStmt emission.
  • Update rich debug scope expectations so %for_check, %for_continue, and %for_merge use the new controls lexical scope.
  • Refresh DebugLexicalBlock expectations in related SPIR-V debug-info tests (line/column and parent-scope relationships).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
tools/clang/test/CodeGenSPIRV/shader.debug.debuglexicalblock.hlsl Updates NS100 debug lexical block expectations to include a separate for controls lexical scope.
tools/clang/test/CodeGenSPIRV/rich.debug.debugscope.hlsl Updates rich debug scope expectations for for blocks/labels to reference the new controls scope.
tools/clang/test/CodeGenSPIRV/rich.debug.debuglexicalblock.hlsl Updates rich debug lexical block expectations to include the new for controls lexical scope.
tools/clang/lib/SPIRV/SpirvEmitter.cpp Adds push/pop of a new debug lexical scope around for loop emission when rich debug info is enabled.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp
Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp
@SteveUrquhart SteveUrquhart force-pushed the emit-forloop-debugscope branch from 2d38cb6 to ae0dab8 Compare June 5, 2026 15:13
@SteveUrquhart

Copy link
Copy Markdown
Contributor Author

I addressed the points raised by CoPilot.

Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp Outdated
@SteveUrquhart SteveUrquhart force-pushed the emit-forloop-debugscope branch from ae0dab8 to 900d18d Compare June 25, 2026 20:07
@github-actions

github-actions Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

✅ With the latest revision this PR passed the C/C++ code formatter.

@SteveUrquhart SteveUrquhart force-pushed the emit-forloop-debugscope branch from 900d18d to ce1b650 Compare June 25, 2026 20:14
Comment thread tools/clang/lib/SPIRV/SpirvEmitter.cpp Outdated
Co-authored-by: Chris B <beanz@abolishcrlf.org>
@SteveUrquhart

Copy link
Copy Markdown
Contributor Author

I accepted the nit, requiring reapproval. Sorry about the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

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

4 participants