Skip to content

Fix DXC assertion after a binding attribute and an inline method - #9072

Open
Arkadiusz Lachowicz (AnastaZIuk) wants to merge 3 commits into
microsoft:mainfrom
Devsh-Graphics-Programming:fix/lexed-method-odr-use-assert
Open

Arkadiusz Lachowicz (AnastaZIuk) wants to merge 3 commits into
microsoft:mainfrom
Devsh-Graphics-Programming:fix/lexed-method-odr-use-assert

Conversation

@AnastaZIuk

Copy link
Copy Markdown
Contributor

I think we talked past each other on #8324. The DXC bug I reported is an assertion in Debug and I can reproduce it on upstream main again at 1527671533a955c40a7e43a68f767fde734c4cb5 with LLVM_ENABLE_ASSERTIONS=ON. Release passing isn't the question here.

Here's the shader and command I ran.

static const uint Binding = 0;
[[vk::binding(Binding, 0)]] RWTexture2D<float> output;
struct Trigger { void f() {} };
[numthreads(1, 1, 1)] void main() { output[uint2(0, 0)] = 1.0; }
dxc -spirv -T cs_6_0 -E main minimal.hlsl -Fo output.spv

It hits MaybeODRUseExprs.empty(). The old #8324 patched build compiles the same shader with assertions on and spirv-val accepts its output.

I also built Clang 23.1.4 with assertions on and tried the same shader there. It passes because Clang parses the attribute argument in a ConstantEvaluated context and calls CleanupVarDeclMarking() when that context ends. DXC creates that context only for unevaluated arguments, so Binding is left pending and trips the assertion when the inline method starts. That's why #8324 calls CleanupVarDeclMarking() before that method starts.

Copilot AI balanced review requested due to automatic review settings October 23, 2026 23:25
@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.

🟢 Approval recommended

The targeted cleanup and regression test address the reported assertion, with only a non-blocking release-note question remaining.

1 open issue
What changed in this PR

Fixes an assertion-enabled DXC crash when a binding attribute referencing a constant is followed by an inline method.

Changes:

  • Clears pending ODR-use bookkeeping before parsing a deferred inline method body.
  • Adds a SPIR-V regression test for the reported trigger.
File Description
tools/​clang/​test/​CodeGenSPIRV/​lexed-inline-method-odr-use.hlsl Adds the minimal assertion-crash regression case.
tools/​clang/​lib/​Parse/​ParseCXXInlineMethods.cpp Cleans up variable-use state before starting the method definition.

Review effort: Balanced

Comment thread tools/clang/lib/Parse/ParseCXXInlineMethods.cpp
Copilot AI balanced review requested due to automatic review settings October 23, 2026 23:40

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 targeted fix includes regression coverage, and the only remaining feedback is a minor release-note convention correction.

2 open issues

Review effort: Balanced

Comment thread docs/ReleaseNotes.md Outdated
Copilot AI balanced review requested due to automatic review settings October 23, 2026 23:47

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 targeted cleanup addresses the reported assertion, includes a matching regression test and release note, and has no identified blocking issues.

1 open issue
1 resolved since last review

Review effort: Balanced

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: New

Development

Successfully merging this pull request may close these issues.

2 participants