Skip to content

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

Open
damyanp wants to merge 7 commits intomicrosoft:mainfrom
damyanp:copilot/fix-test-failures-issue-6563
Open

[Validation] Make validator reject unsupported llvm integer sizes#8207
damyanp wants to merge 7 commits intomicrosoft:mainfrom
damyanp:copilot/fix-test-failures-issue-6563

Conversation

@damyanp
Copy link
Member

@damyanp damyanp commented Feb 26, 2026

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 <8118402+damyanp@users.noreply.github.com>
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 <8118402+damyanp@users.noreply.github.com>
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 <8118402+damyanp@users.noreply.github.com>
Consolidate three duplicate bit width checks into a single
IsValidIntBitWidth(unsigned) helper used by ValidateType and
both instruction-level checks.

Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
Co-authored-by: damyanp <8118402+damyanp@users.noreply.github.com>
@damyanp damyanp marked this pull request as ready for review February 27, 2026 00:16
Copy link
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

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

LGTM.

// 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
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
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 damyanp requested review from bob80905 and tex3d February 27, 2026 01:57
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.

DxilValidation should reject unsupported llvm integer sizes

4 participants