[llvm] 74f5ee4 - [DXIL][Analysis] Add validator version to info collected by Module Metadata Analysis (#104828)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 07:35:35 PDT 2024
Author: S. Bharadwaj Yadavalli
Date: 2024-08-20T10:35:30-04:00
New Revision: 74f5ee4ffe89da4a0e9c762c69f8a68536fbf754
URL: https://github.com/llvm/llvm-project/commit/74f5ee4ffe89da4a0e9c762c69f8a68536fbf754
DIFF: https://github.com/llvm/llvm-project/commit/74f5ee4ffe89da4a0e9c762c69f8a68536fbf754.diff
LOG: [DXIL][Analysis] Add validator version to info collected by Module Metadata Analysis (#104828)
Add Validator Version to information collected by Module Metadata
Analysis pass. An earlier change (#104040) added a default hardcoded
value for validator version to be associated with DXIL module created
during HLSL source compilation.
Add tests to verify validator version info collected
- Updated existing tests
- Added a test with validator version specified in DXIL metadata
Added:
llvm/test/CodeGen/DirectX/Metadata/empty-valver1.8.ll
Modified:
llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
llvm/lib/Analysis/DXILMetadataAnalysis.cpp
llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.0.ll
llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.8.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-as.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs-val-ver-0.0.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-gs.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-hs.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-lib.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-ms.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-ps.ll
llvm/test/CodeGen/DirectX/Metadata/shaderModel-vs.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
index f325828495458b..0515139c01aee6 100644
--- a/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
+++ b/llvm/include/llvm/Analysis/DXILMetadataAnalysis.h
@@ -23,6 +23,7 @@ struct ModuleMetadataInfo {
VersionTuple DXILVersion{};
VersionTuple ShaderModelVersion{};
Triple::EnvironmentType ShaderStage = Triple::UnknownEnvironment;
+ VersionTuple ValidatorVersion{};
void print(raw_ostream &OS) const;
};
diff --git a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
index 202beeea841c11..192e151565370d 100644
--- a/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
+++ b/llvm/lib/Analysis/DXILMetadataAnalysis.cpp
@@ -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());
+ }
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";
}
//===----------------------------------------------------------------------===//
diff --git a/llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.0.ll b/llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.0.ll
index 318d5a6210eeea..b5ec0692f7955e 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.0.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.0.ll
@@ -6,8 +6,10 @@ target triple = "dxil-pc-shadermodel6.0-vertex"
; CHECK: ![[DXVER]] = !{i32 1, i32 0}
; ANALYSIS: Shader Model Version : 6.0
-; ANALYSIS: DXIL Version : 1.0
-; ANALYSIS: Shader Stage : vertex
+; ANALYSIS-NEXT: DXIL Version : 1.0
+; ANALYSIS-NEXT: Shader Stage : vertex
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.8.ll b/llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.8.ll
index fb54fa916f33f9..310a57659d5a81 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.8.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/dxilVer-1.8.ll
@@ -6,8 +6,10 @@ target triple = "dxil-pc-shadermodel6.8-compute"
; CHECK: ![[DXVER]] = !{i32 1, i32 8}
; ANALYSIS: Shader Model Version : 6.8
-; ANALYSIS: DXIL Version : 1.8
-; ANALYSIS: Shader Stage : compute
+; ANALYSIS-NEXT: DXIL Version : 1.8
+; ANALYSIS-NEXT: Shader Stage : compute
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/empty-valver1.8.ll b/llvm/test/CodeGen/DirectX/Metadata/empty-valver1.8.ll
new file mode 100644
index 00000000000000..e1507100a32069
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/Metadata/empty-valver1.8.ll
@@ -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}
+!dx.shaderModel = !{!2}
+!dx.version = !{!3}
+
+!0 = !{i32 1, i32 8}
+!2 = !{!"cs", i32 6, i32 6}
+!3 = !{i32 1, i32 6}
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-as.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-as.ll
index 96d04f948c9b83..49c820e14e36b4 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-as.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-as.ll
@@ -6,8 +6,10 @@ target triple = "dxil-pc-shadermodel6-amplification"
; CHECK: ![[SM]] = !{!"as", i32 6, i32 0}
; ANALYSIS: Shader Model Version : 6
-; ANALYSIS: DXIL Version : 1.0
-; ANALYSIS: Shader Stage : amplification
+; ANALYSIS-NEXT: DXIL Version : 1.0
+; ANALYSIS-NEXT: Shader Stage : amplification
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs-val-ver-0.0.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs-val-ver-0.0.ll
index 8e8f9d77539eab..c9ea6c94e36519 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs-val-ver-0.0.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs-val-ver-0.0.ll
@@ -17,5 +17,7 @@ attributes #0 = { noinline nounwind "exp-shader"="cs" "hlsl.numthreads"="1,2,1"
!0 = !{i32 0, i32 0}
; ANALYSIS: Shader Model Version : 6.6
-; ANALYSIS: DXIL Version : 1.6
-; ANALYSIS: Shader Stage : compute
+; ANALYSIS-NEXT: DXIL Version : 1.6
+; ANALYSIS-NEXT: Shader Stage : compute
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs.ll
index 8cba445bcb01e8..f5e524562ac1e0 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs.ll
@@ -8,8 +8,10 @@ target triple = "dxil-pc-shadermodel6.6-compute"
; CHECK: ![[SM]] = !{!"cs", i32 6, i32 6}
; ANALYSIS: Shader Model Version : 6.6
-; ANALYSIS: DXIL Version : 1.6
-; ANALYSIS: Shader Stage : compute
+; ANALYSIS-NEXT: DXIL Version : 1.6
+; ANALYSIS-NEXT: Shader Stage : compute
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-gs.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-gs.ll
index 662620cf9f95cb..fb58312e2c9310 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-gs.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-gs.ll
@@ -6,8 +6,10 @@ target triple = "dxil-pc-shadermodel6.6-geometry"
; CHECK: ![[SM]] = !{!"gs", i32 6, i32 6}
; ANALYSIS: Shader Model Version : 6.6
-; ANALYSIS: DXIL Version : 1.6
-; ANALYSIS: Shader Stage : geometry
+; ANALYSIS-NEXT: DXIL Version : 1.6
+; ANALYSIS-NEXT: Shader Stage : geometry
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-hs.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-hs.ll
index b405f8e915a329..b12de400698fe1 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-hs.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-hs.ll
@@ -6,8 +6,10 @@ target triple = "dxil-pc-shadermodel6.6-hull"
; CHECK: ![[SM]] = !{!"hs", i32 6, i32 6}
; ANALYSIS: Shader Model Version : 6.6
-; ANALYSIS: DXIL Version : 1.6
-; ANALYSIS: Shader Stage : hull
+; ANALYSIS-NEXT: DXIL Version : 1.6
+; ANALYSIS-NEXT: Shader Stage : hull
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-lib.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-lib.ll
index 26f3d287242edd..d4aa4cfa0ce471 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-lib.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-lib.ll
@@ -6,5 +6,7 @@ target triple = "dxil-pc-shadermodel6.3-library"
; CHECK: ![[SM]] = !{!"lib", i32 6, i32 3}
; ANALYSIS: Shader Model Version : 6.3
-; ANALYSIS: DXIL Version : 1.3
-; ANALYSIS: Shader Stage : library
+; ANALYSIS-NEXT: DXIL Version : 1.3
+; ANALYSIS-NEXT: Shader Stage : library
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-ms.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-ms.ll
index 422d4add912f3f..e22dbbcebf5849 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-ms.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-ms.ll
@@ -6,8 +6,10 @@ target triple = "dxil-pc-shadermodel6.6-mesh"
; CHECK: ![[SM]] = !{!"ms", i32 6, i32 6}
; ANALYSIS: Shader Model Version : 6.6
-; ANALYSIS: DXIL Version : 1.6
-; ANALYSIS: Shader Stage : mesh
+; ANALYSIS-NEXT: DXIL Version : 1.6
+; ANALYSIS-NEXT: Shader Stage : mesh
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-ps.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-ps.ll
index cdb9a6f0f6a4f4..eb784d71517bba 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-ps.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-ps.ll
@@ -6,8 +6,10 @@ target triple = "dxil-pc-shadermodel5.0-pixel"
; CHECK: ![[SM]] = !{!"ps", i32 5, i32 0}
; ANALYSIS: Shader Model Version : 5.0
-; ANALYSIS: DXIL Version : 1.0
-; ANALYSIS: Shader Stage : pixel
+; ANALYSIS-NEXT: DXIL Version : 1.0
+; ANALYSIS-NEXT: Shader Stage : pixel
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
diff --git a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-vs.ll b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-vs.ll
index 6b3501cc1dbaf7..ac52b5004eb906 100644
--- a/llvm/test/CodeGen/DirectX/Metadata/shaderModel-vs.ll
+++ b/llvm/test/CodeGen/DirectX/Metadata/shaderModel-vs.ll
@@ -6,8 +6,10 @@ target triple = "dxil-pc-shadermodel-vertex"
; CHECK: ![[SM]] = !{!"vs", i32 0, i32 0}
; ANALYSIS: Shader Model Version : 0
-; ANALYSIS: DXIL Version : 1.0
-; ANALYSIS: Shader Stage : vertex
+; ANALYSIS-NEXT: DXIL Version : 1.0
+; ANALYSIS-NEXT: Shader Stage : vertex
+; ANALYSIS-NEXT: Validator Version : 0
+; ANALYSIS-EMPTY:
define void @entry() #0 {
entry:
More information about the llvm-commits
mailing list