Skip to content

Fix 8601 check for RayQuery user type#8610

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

Fix 8601 check for RayQuery user type#8610
brendan-duncan wants to merge 3 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.

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

2 participants