[Validation] Make validator reject unsupported llvm integer sizes#8207
Open
damyanp wants to merge 7 commits intomicrosoft:mainfrom
Open
[Validation] Make validator reject unsupported llvm integer sizes#8207damyanp wants to merge 7 commits intomicrosoft:mainfrom
damyanp wants to merge 7 commits intomicrosoft:mainfrom
Conversation
…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>
bob80905
reviewed
Feb 27, 2026
| // We always fail if we see i8 as operand type of a non-lifetime | ||
| // instruction. | ||
| ValCtx.EmitInstrError(&I, ValidationRule::TypesI8); | ||
| } else if (!IsValidIntBitWidth(BW)) { |
Collaborator
There was a problem hiding this comment.
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.
Member
Author
There was a problem hiding this comment.
Nice catch, I think that works out nicer!
bob80905
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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