Skip to content

[SPIRV] Generate debug info from original source - #9024

Open
Steve Urquhart (SteveUrquhart) wants to merge 2 commits into
microsoft:mainfrom
SteveUrquhart:spirv-debug-no-preprocess
Open

Steve Urquhart (SteveUrquhart) wants to merge 2 commits into
microsoft:mainfrom
SteveUrquhart:spirv-debug-no-preprocess

Conversation

@SteveUrquhart

Copy link
Copy Markdown
Contributor

Debug info should reflect the original source. The only reason for -P was that the line table tells us our included files. Obtain the included list from SourceManager instead, allowing use of original source.

Update rich.debug.cbuffer.hlsl, whose expected columns came from the preprocessed text, and add spirv.debug.columns.hlsl to cover columns after comments and macros.

Fixes 9022

Copilot AI balanced review requested due to automatic review settings October 9, 2026 18:22
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟡 Changes recommended

The user-visible compiler bug fix needs release-note coverage.

1 open finding
What changed in this PR

Updates SPIR-V debug generation to reference original HLSL source locations.

Changes:

  • Removes preprocessing before SPIR-V debug compilation.
  • Discovers included files through SourceManager.
  • Adds coverage for comments, macros, columns, and guarded includes.
File Description
tools/​clang/​tools/​dxcompiler/​dxcompilerobj.cpp Preserves original in-memory source without preprocessing.
tools/​clang/​lib/​SPIRV/​SpirvEmitter.cpp Collects unique source files from source-manager entries.
tools/​clang/​test/​CodeGenSPIRV/​spirv.debug.columns.hlsl Tests original-source columns and include deduplication.
tools/​clang/​test/​CodeGenSPIRV/​spirv.debug.columns.include.hlsli Supplies guarded macro definitions for testing.
tools/​clang/​test/​CodeGenSPIRV/​rich.debug.cbuffer.hlsl Updates expected original-source columns.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tools/clang/tools/dxcompiler/dxcompilerobj.cpp
Debug info should reflect the original source. The only reason for -P
was that the line table tells us our included files.  Obtains the
included list from SourceManager instead, allowing use of original
source.

Update rich.debug.cbuffer.hlsl, whose expected columns came from the
preprocessed text, and add spirv.debug.columns.hlsl to cover columns
after comments and macros and a guarded include with no code.

Fixes microsoft#9022
Copilot AI balanced review requested due to automatic review settings October 12, 2026 17:48

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.

🟢 Approval recommended

The implementation is focused, consistent with existing debug-source handling, and covered by targeted regression tests.

1 open finding

🧠 Review effort: Balanced

@dnovillo Diego Novillo (dnovillo) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for doing this! I think this also fixes #8543. I'd much rather have this than the column clamp in #9023. I'll close it after you merge this one.

Comment thread tools/clang/test/CodeGenSPIRV/spirv.debug.columns.hlsl
Comment thread tools/clang/test/CodeGenSPIRV/spirv.debug.columns.hlsl
@github-project-automation github-project-automation Bot moved this from New to In progress in HLSL Roadmap Oct 16, 2026
Copilot AI balanced review requested due to automatic review settings October 16, 2026 17:44

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.

🟢 Approval recommended

No blocking issues were identified, and focused regression coverage and release notes accompany the fix.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

@dnovillo Diego Novillo (dnovillo) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! LGTM.

This branch has not been deployed

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

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

[SPIR-V] Compile the original source with -fspv-debug instead of the -P output

3 participants