Skip to content

Fix 8601 check for RayQuery user type - #8610

Open
brendan-duncan wants to merge 4 commits into
microsoft:mainfrom
brendan-duncan:fix-8601-rayquery-shadow
Open

Fix 8601 check for RayQuery user type#8610
brendan-duncan wants to merge 4 commits into
microsoft:mainfrom
brendan-duncan:fix-8601-rayquery-shadow

Conversation

@brendan-duncan

@brendan-duncan brendan-duncan commented Jul 9, 2026

Copy link
Copy Markdown

Fixes #8601

Compiling to SPIR-V crashes when a user-defined struct or class is named
RayQuery (a reserved intrinsic name), e.g. a ray-tracing abstraction that
declares its own RayQuery type inside a namespace.

HLSL has no rule forbidding this; the local declaration should shadow the
reserved name, and the struct should compile like any other.

Added tools/clang/test/CodeGenSPIRV/type.rayquery.user-defined-shadow.hlsl,
which reproduces the issue and checks that the shadowing struct lowers to a
normal OpTypeStruct and that no OpTypeRayQueryKHR is emitted.

Verified that the intrinsic RayQuery still lowers to OpTypeRayQueryKHR
and that existing rayquery CodeGenSPIRV tests continue to pass.

@azure-pipelines

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

@brendan-duncan

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@llvm-beanz llvm-beanz 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.

Thank you for this contribution!

I'm happy with this PR as-is, but I do (oddly) recommend removing the comments. I realize the comments do explain well the code and why it differs from the code around it, but all the code around it is also a mess of bugs that should change because string-matching type names is bad.

Comment thread tools/clang/lib/SPIRV/AstTypeProbe.cpp Outdated
Comment thread tools/clang/lib/SPIRV/LowerTypeVisitor.cpp Outdated
brendan-duncan and others added 2 commits July 9, 2026 09:54
Co-authored-by: Chris B <beanz@abolishcrlf.org>
Co-authored-by: Chris B <beanz@abolishcrlf.org>
@brendan-duncan

Copy link
Copy Markdown
Author

Agreed with the comment removal. I was debating that myself.

@brendan-duncan

Copy link
Copy Markdown
Author

@llvm-beanz Just checking that I'm not missing something from my side for this PR. Not sure what the pending check is "waiting for status to be reported". I looked around for buttons or TODOs I should be doing.

@brendan-duncan

Copy link
Copy Markdown
Author

@llvm-beanz sorry for the poke--do you think you can run the azp tests command so this PR can move forward, before I forget about it again?

@brendan-duncan

Copy link
Copy Markdown
Author

I just saw that since the change was made I needed to request a re-review, so I did that.

@bob80905

bob80905 commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

/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

Fixes SPIR-V handling of user-defined types named RayQuery.

Changes:

  • Uses semantic RayQuery detection instead of name matching.
  • Adds a regression test for struct shadowing.

Reviewed changes

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

File Description
AstTypeProbe.cpp Refines opaque-type detection.
LowerTypeVisitor.cpp Refines RayQuery lowering.
type.rayquery.user-defined-shadow.hlsl Adds shadowing coverage.

Comment thread tools/clang/test/CodeGenSPIRV/type.rayquery.user-defined-shadow.hlsl Outdated
Comment thread tools/clang/lib/SPIRV/LowerTypeVisitor.cpp
Comment thread tools/clang/lib/SPIRV/AstTypeProbe.cpp
Copilot AI review requested due to automatic review settings August 4, 2026 17:57
@brendan-duncan

Copy link
Copy Markdown
Author

@bob80905 I pushed some updates addressing copilot's notes.

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@bob80905 bob80905 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.

Cool, didn't know you could do implicit check nots on invocation!

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][Crash] structs called RayQuery are treated as ray query types in compute shaders

4 participants