Skip to content

[Validation] Make validator reject unsupported llvm integer sizes - #8207

Merged
Damyan Pepper (damyanp) merged 7 commits into
microsoft:mainfrom
damyanp:copilot/fix-test-failures-issue-6563
Mar 10, 2026
Merged

Damyan Pepper (damyanp) merged 7 commits into
microsoft:mainfrom
damyanp:copilot/fix-test-failures-issue-6563

Conversation

@damyanp

Copy link
Copy Markdown
Member

There are a limited number of supported integer sizes in DXIL. This change updates the validator to reject shaders that use unsupported integer sizes.

Fixes #6563

Copilot AI and others added 6 commits February 21, 2026 00:25
…ds and results

Extends the existing i8 check in the instruction validation loop to also
reject integer types with non-standard widths (anything other than
i1/i8/i16/i32/i64). This catches cases where optimizations produce
odd-sized types like i25 that are not valid DXIL types.

Adds a LIT test that verifies i25 types are rejected by the validator.

Fixes microsoft#6563

Co-authored-by: damyanp <[email protected]>
Address review feedback:
- Replace if/else chains with switch statements for both operand
  and result type integer width validation
- Simplify LIT test to minimal IR with a single i25 add instruction

Co-authored-by: damyanp <[email protected]>
Add a select instruction with [2 x i25] result type to exercise the
array unwrapping path in the result type integer width validation.

Co-authored-by: damyanp <[email protected]>
Consolidate three duplicate bit width checks into a single
IsValidIntBitWidth(unsigned) helper used by ValidateType and
both instruction-level checks.

Co-authored-by: damyanp <[email protected]>
@damyanp
Damyan Pepper (damyanp) marked this pull request as ready for review February 27, 2026 00:16

@tex3d Tex Riddell (tex3d) 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.

LGTM.

Comment thread lib/DxilValidation/DxilValidation.cpp Outdated
// We always fail if we see i8 as operand type of a non-lifetime
// instruction.
ValCtx.EmitInstrError(&I, ValidationRule::TypesI8);
} else if (!IsValidIntBitWidth(BW)) {

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.

ValidateFunctionBody will call ValidateType in certain scenarios. I wonder if your test will pass without these two else ifs?
If it is possible, it is better to designate one location for validating types, and that function and your changes to it seem like the perfect fix.
And if not, then maybe calling ValidateType instead of the else if would be better?
For example, I wonder if calling ValidateType once at 3377 will do the same as these two else ifs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nice catch, I think that works out nicer!

@damyanp
Damyan Pepper (damyanp) merged commit 90ae8d8 into microsoft:main Mar 10, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Mar 10, 2026
@damyanp
Damyan Pepper (damyanp) deleted the copilot/fix-test-failures-issue-6563 branch March 11, 2026 00:22
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.

DxilValidation should reject unsupported llvm integer sizes

4 participants