Skip to content

[SPIR-V] Fix incorrect [branch] gen on return. - #7834

Merged
Nathan Gauër (Keenuts) merged 1 commit into
microsoft:mainfrom
Keenuts:fix-7832
Oct 27, 2025
Merged

Nathan Gauër (Keenuts) merged 1 commit into
microsoft:mainfrom
Keenuts:fix-7832

Conversation

@Keenuts

Copy link
Copy Markdown
Collaborator

PR #6756 tried to address an issue when variables were declared in a fallthrough, but contained a bug: the PR assumed return statements were leaves, and that no statement was associated with the node. This is not true if a value is returned as the return statements contains the expression describing the returned value.

Skipping this return statement means we'd generate invalid code when returning a value in a switch with the [branch] attribute. Moved the exit condition after recording the statement so early returns are still generated.

Fixes #7832

PR microsoft#6756 tried to address an issue when variables were
declared in a fallthrough, but contained a bug: the PR assumed
return statements were leaves, and that no statement was associated
with the node. This is not true if a value is returned as the return
statements contains the expression describing the returned value.

Skipping this return statement means we'd generate invalid code when
returning a value in a switch with the `[branch]` attribute.
Moved the exit condition after recording the statement so early returns
are still generated.

Fixes microsoft#7832
@Keenuts
Nathan Gauër (Keenuts) merged commit 324f184 into microsoft:main Oct 27, 2025
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Oct 27, 2025
@Keenuts
Nathan Gauër (Keenuts) deleted the fix-7832 branch October 27, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

[SPIR-V] regression. [branch] attribute incorrect code generation

2 participants