-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DXIL][Analysis] Add validator version to info collected by Module Metadata Analysis #104828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,14 @@ static ModuleMetadataInfo collectMetadataInfo(Module &M) { | |
MMDAI.DXILVersion = TT.getDXILVersion(); | ||
MMDAI.ShaderModelVersion = TT.getOSVersion(); | ||
MMDAI.ShaderStage = TT.getEnvironment(); | ||
NamedMDNode *ValidatorVerNode = M.getNamedMetadata("dx.valver"); | ||
if (ValidatorVerNode) { | ||
auto *ValVerMD = cast<MDNode>(ValidatorVerNode->getOperand(0)); | ||
auto *MajorMD = mdconst::extract<ConstantInt>(ValVerMD->getOperand(0)); | ||
auto *MinorMD = mdconst::extract<ConstantInt>(ValVerMD->getOperand(1)); | ||
MMDAI.ValidatorVersion = | ||
VersionTuple(MajorMD->getZExtValue(), MinorMD->getZExtValue()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we report error when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Since this is an analysis pass, the thought behind not reporting an error here but just retaining the default value of |
||
return MMDAI; | ||
} | ||
|
||
|
@@ -33,6 +41,7 @@ void ModuleMetadataInfo::print(raw_ostream &OS) const { | |
OS << "DXIL Version : " << DXILVersion.getAsString() << "\n"; | ||
OS << "Shader Stage : " << Triple::getEnvironmentTypeName(ShaderStage) | ||
<< "\n"; | ||
OS << "Validator Version : " << ValidatorVersion.getAsString() << "\n"; | ||
} | ||
|
||
//===----------------------------------------------------------------------===// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
; RUN: opt -S -passes="print<dxil-metadata>" -disable-output %s 2>&1 | FileCheck %s --check-prefix=ANALYSIS | ||
; Verify correctness of Shader Model version, DXIL version, Shader stage and Validator version | ||
; obtained by Module Metadata Analysis pass from the metadata specified in the source. | ||
|
||
; ANALYSIS: Shader Model Version : 6.6 | ||
; ANALYSIS-NEXT: DXIL Version : 1.6 | ||
; ANALYSIS-NEXT: Shader Stage : compute | ||
; ANALYSIS-NEXT: Validator Version : 1.8 | ||
; ANALYSIS-EMPTY: | ||
|
||
; Function Attrs: nounwind memory(none) | ||
define void @main() local_unnamed_addr #0 { | ||
entry: | ||
ret void | ||
} | ||
|
||
attributes #0 = { nounwind memory(none) } | ||
|
||
!dx.valver = !{!0} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all the other test cases stop after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Deleted unrelated metadata. |
||
!dx.shaderModel = !{!2} | ||
!dx.version = !{!3} | ||
|
||
!0 = !{i32 1, i32 8} | ||
!2 = !{!"cs", i32 6, i32 6} | ||
!3 = !{i32 1, i32 6} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be a check if the tuple isn't well formed, or is there a separate place that's already checked?
AFAIK, there's nothing that guarantees someone couldn't form a bad metadata header, which shouldn't be accidentally evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These checks are not included here as they are expected to be done during Module construction.