[SM6.10][NFC] Refactor LinAlg Validations with helpers - #8778
Merged
Ashley Coleman (V-FEXrt) merged 2 commits intoAug 14, 2026
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Refactors DXIL LinAlg validation to reduce repetition by introducing helper utilities for extracting constant operands and for fetching LinAlgTargetType metadata.
Changes:
- Added
ValidateConstantIntGetValue(...)to centralize immediate-constant validation and extraction. - Added
GetCheckedLATT(...)to centralizeLinAlgTargetTypeMaplookup withstd::optionalresults. - Updated multiple LinAlg validators to use these helpers instead of repeated
dyn_cast/map-lookup sequences.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
lib/DxilValidation/DxilValidation.cpp:1097
- The new helper name
GetCheckedLATTis hard to decode for readers unfamiliar with theLATTabbreviation. Consider renaming to a more explicit name (e.g.,GetCheckedLinAlgTargetTypeorGetLinAlgTargetTypeIfPresent) to improve readability/maintainability.
static std::optional<LinAlgTargetType>
GetCheckedLATT(Type *Ty, ValidationContext &ValCtx) {
lib/DxilValidation/DxilValidation.cpp:989
ValidateConstantIntGetValueboth emits a diagnostic (side effect) and returns an optional value, which makes it easy for future call sites to ignorestd::nulloptand accidentally continue validation with default/placeholder values. Consider renaming this helper to make the side effect explicit (e.g.,GetConstantIntValueOrEmitError) and/or documenting the expected usage pattern (treatnulloptas 'validation already failed for this operand').
static std::optional<uint64_t>
ValidateConstantIntGetValue(CallInst *CI, Value *V, ValidationContext &ValCtx,
StringRef ValueName, StringRef OpName) {
if (!isa<ConstantInt>(V)) {
ValCtx.EmitInstrFormatError(CI, ValidationRule::InstrOpConst,
{ValueName, OpName});
return std::nullopt;
}
return cast<ConstantInt>(V)->getLimitedValue();
}
Damyan Pepper (damyanp)
approved these changes
Aug 14, 2026
Alex Sepkowski (alsepkow)
approved these changes
Aug 14, 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.
NFC
Pulls two common boiler plate operations into helper functions then uses them across all the validation rules
Operations are
LinAlgTargetTypefor a given matrix without raising a diag if its missing (as those diags are already raised)Value*that is expected to be an immediateConstantIntand raise a diag if it isn't