[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
https://github.com/bharadwajy closed https://github.com/llvm/llvm-project/pull/91407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
https://github.com/bogner approved this pull request. https://github.com/llvm/llvm-project/pull/91407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
bogner wrote: > > It would be nice to mention in the description what the sanitizer fix was > > compared to the original PR. > > Thanks! The fix to address ASAN failure is in commit > [8522e36](https://github.com/llvm/llvm-project/commit/8522e3609869d72b7b457a4752149a802be4662d) > of this PR. Updated the description as well. Since we squash commits when we merge it doesn't really make sense to refer to the hash of the PR in the description - this won't point at anything meaningful once the change is merged and the PR commits get garbage collected. https://github.com/llvm/llvm-project/pull/91407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
bharadwajy wrote: > It would be nice to mention in the description what the sanitizer fix was > compared to the original PR. Thanks! The fix to address ASAN failure is in commit 8522e3609869d72b7b457a4752149a802be4662d of this PR. Updated the description as well. https://github.com/llvm/llvm-project/pull/91407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
https://github.com/bharadwajy edited https://github.com/llvm/llvm-project/pull/91407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
https://github.com/dmpots approved this pull request. It would be nice to mention in the description what the sanitizer fix was compared to the original PR. https://github.com/llvm/llvm-project/pull/91407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
https://github.com/python3kgae approved this pull request. https://github.com/llvm/llvm-project/pull/91407 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
llvmbot wrote: @llvm/pr-subscribers-clang-driver Author: S. Bharadwaj Yadavalli (bharadwajy) Changes This change set restores the PR #90809 that was reverted to address ASAN failures and includes a fix for the ASAN failures. Following is the description of the change: An earlier commit provided a way to decouple DXIL version from Shader Model version by representing the DXIL version as `SubArch` in the DXIL Target Triple and adding corresponding valid DXIL Arch types. This change constructs DXIL target triple with DXIL version that is deduced from Shader Model version specified in the following scenarios: 1. When compilation target profile is specified: For e.g., DXIL target triple `dxilv1.8-unknown-shader6.8-library` is constructed when `-T lib_6_8` is specified. 2. When DXIL target triple without DXIL version is specified: For e.g., DXIL target triple `dxilv1.8-pc-shadermodel6.8-library` is constructed when `-mtriple=dxil-pc-shadermodel6.8-library` is specified. Note that this is an alternate / expanded implementation to that proposed in PR #89823. PR #89823 implements functionality (1) above. However, it requires any DXIL target triple to explicitly include DXIL version anywhere DXIL target triple is expected (e.g., `dxilv1.8-pc-shadermodel6.8-library`) while a triple without DXIL version (e.g., `dxil-pc-shadermodel6.8-library`) is considered invalid. This functionality is implemented as a change to `tryParseProfile()` and is included in this PR. This PR adds the functionality (2) to eliminate the above requirement to explicitly specify DXIL version in the target triple thereby considering a triple without DXIL version ( e.g., `dxil-pc-shadermodel6.8-library`) to be valid. A triple with DXIL version is inferred based on the shader mode version specified. If no shader model version is specified, DXIL version is defaulted to 1.0. This functionality is implemented in the "Special case logic ..." section of `Triple::normalize()`. Updated relevant HLSL tests that check for target triple. Validated that Clang (`check-clang`), LLVM (`check-llvm`) regression tests and `TargetParserTests` built with sanitizer, pass. --- Full diff: https://github.com/llvm/llvm-project/pull/91407.diff 10 Files Affected: - (modified) clang/lib/Basic/Targets.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/HLSL.cpp (+42-2) - (modified) clang/test/CodeGenHLSL/basic-target.c (+1-1) - (modified) clang/test/Driver/dxc_dxv_path.hlsl (+3-3) - (modified) clang/test/Options/enable_16bit_types_validation.hlsl (+2-2) - (modified) clang/unittests/Driver/DXCModeTest.cpp (+12-10) - (modified) llvm/include/llvm/TargetParser/Triple.h (+1) - (modified) llvm/lib/IR/Verifier.cpp (+2-2) - (modified) llvm/lib/TargetParser/Triple.cpp (+86) - (modified) llvm/unittests/TargetParser/TripleTest.cpp (+16) ``diff diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index e3283510c6aa..dc1792b3471e 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -760,7 +760,7 @@ using namespace clang::targets; TargetInfo * TargetInfo::CreateTargetInfo(DiagnosticsEngine , const std::shared_ptr ) { - llvm::Triple Triple(Opts->Triple); + llvm::Triple Triple(llvm::Triple::normalize(Opts->Triple)); // Construct the target std::unique_ptr Target = AllocateTarget(Triple, *Opts); diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp index 558e4db46f81..8286e3be2180 100644 --- a/clang/lib/Driver/ToolChains/HLSL.cpp +++ b/clang/lib/Driver/ToolChains/HLSL.cpp @@ -98,9 +98,49 @@ std::optional tryParseProfile(StringRef Profile) { else if (llvm::getAsUnsignedInteger(Parts[2], 0, Minor)) return std::nullopt; - // dxil-unknown-shadermodel-hull + // Determine DXIL version using the minor version number of Shader + // Model version specified in target profile. Prior to decoupling DXIL version + // numbering from that of Shader Model DXIL version 1.Y corresponds to SM 6.Y. + // E.g., dxilv1.Y-unknown-shadermodelX.Y-hull llvm::Triple T; - T.setArch(Triple::ArchType::dxil); + Triple::SubArchType SubArch = llvm::Triple::NoSubArch; + switch (Minor) { + case 0: +SubArch = llvm::Triple::DXILSubArch_v1_0; +break; + case 1: +SubArch = llvm::Triple::DXILSubArch_v1_1; +break; + case 2: +SubArch = llvm::Triple::DXILSubArch_v1_2; +break; + case 3: +SubArch = llvm::Triple::DXILSubArch_v1_3; +break; + case 4: +SubArch = llvm::Triple::DXILSubArch_v1_4; +break; + case 5: +SubArch = llvm::Triple::DXILSubArch_v1_5; +break; + case 6: +SubArch = llvm::Triple::DXILSubArch_v1_6; +break; + case 7: +SubArch = llvm::Triple::DXILSubArch_v1_7; +break; + case 8: +SubArch = llvm::Triple::DXILSubArch_v1_8; +break; + case OfflineLibMinor: +// Always consider minor version x as the latest supported DXIL
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
llvmbot wrote: @llvm/pr-subscribers-clang Author: S. Bharadwaj Yadavalli (bharadwajy) Changes This change set restores the PR #90809 that was reverted to address ASAN failures and includes a fix for the ASAN failures. Following is the description of the change: An earlier commit provided a way to decouple DXIL version from Shader Model version by representing the DXIL version as `SubArch` in the DXIL Target Triple and adding corresponding valid DXIL Arch types. This change constructs DXIL target triple with DXIL version that is deduced from Shader Model version specified in the following scenarios: 1. When compilation target profile is specified: For e.g., DXIL target triple `dxilv1.8-unknown-shader6.8-library` is constructed when `-T lib_6_8` is specified. 2. When DXIL target triple without DXIL version is specified: For e.g., DXIL target triple `dxilv1.8-pc-shadermodel6.8-library` is constructed when `-mtriple=dxil-pc-shadermodel6.8-library` is specified. Note that this is an alternate / expanded implementation to that proposed in PR #89823. PR #89823 implements functionality (1) above. However, it requires any DXIL target triple to explicitly include DXIL version anywhere DXIL target triple is expected (e.g., `dxilv1.8-pc-shadermodel6.8-library`) while a triple without DXIL version (e.g., `dxil-pc-shadermodel6.8-library`) is considered invalid. This functionality is implemented as a change to `tryParseProfile()` and is included in this PR. This PR adds the functionality (2) to eliminate the above requirement to explicitly specify DXIL version in the target triple thereby considering a triple without DXIL version ( e.g., `dxil-pc-shadermodel6.8-library`) to be valid. A triple with DXIL version is inferred based on the shader mode version specified. If no shader model version is specified, DXIL version is defaulted to 1.0. This functionality is implemented in the "Special case logic ..." section of `Triple::normalize()`. Updated relevant HLSL tests that check for target triple. Validated that Clang (`check-clang`), LLVM (`check-llvm`) regression tests and `TargetParserTests` built with sanitizer, pass. --- Full diff: https://github.com/llvm/llvm-project/pull/91407.diff 10 Files Affected: - (modified) clang/lib/Basic/Targets.cpp (+1-1) - (modified) clang/lib/Driver/ToolChains/HLSL.cpp (+42-2) - (modified) clang/test/CodeGenHLSL/basic-target.c (+1-1) - (modified) clang/test/Driver/dxc_dxv_path.hlsl (+3-3) - (modified) clang/test/Options/enable_16bit_types_validation.hlsl (+2-2) - (modified) clang/unittests/Driver/DXCModeTest.cpp (+12-10) - (modified) llvm/include/llvm/TargetParser/Triple.h (+1) - (modified) llvm/lib/IR/Verifier.cpp (+2-2) - (modified) llvm/lib/TargetParser/Triple.cpp (+86) - (modified) llvm/unittests/TargetParser/TripleTest.cpp (+16) ``diff diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index e3283510c6aa..dc1792b3471e 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -760,7 +760,7 @@ using namespace clang::targets; TargetInfo * TargetInfo::CreateTargetInfo(DiagnosticsEngine , const std::shared_ptr ) { - llvm::Triple Triple(Opts->Triple); + llvm::Triple Triple(llvm::Triple::normalize(Opts->Triple)); // Construct the target std::unique_ptr Target = AllocateTarget(Triple, *Opts); diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp index 558e4db46f81..8286e3be2180 100644 --- a/clang/lib/Driver/ToolChains/HLSL.cpp +++ b/clang/lib/Driver/ToolChains/HLSL.cpp @@ -98,9 +98,49 @@ std::optional tryParseProfile(StringRef Profile) { else if (llvm::getAsUnsignedInteger(Parts[2], 0, Minor)) return std::nullopt; - // dxil-unknown-shadermodel-hull + // Determine DXIL version using the minor version number of Shader + // Model version specified in target profile. Prior to decoupling DXIL version + // numbering from that of Shader Model DXIL version 1.Y corresponds to SM 6.Y. + // E.g., dxilv1.Y-unknown-shadermodelX.Y-hull llvm::Triple T; - T.setArch(Triple::ArchType::dxil); + Triple::SubArchType SubArch = llvm::Triple::NoSubArch; + switch (Minor) { + case 0: +SubArch = llvm::Triple::DXILSubArch_v1_0; +break; + case 1: +SubArch = llvm::Triple::DXILSubArch_v1_1; +break; + case 2: +SubArch = llvm::Triple::DXILSubArch_v1_2; +break; + case 3: +SubArch = llvm::Triple::DXILSubArch_v1_3; +break; + case 4: +SubArch = llvm::Triple::DXILSubArch_v1_4; +break; + case 5: +SubArch = llvm::Triple::DXILSubArch_v1_5; +break; + case 6: +SubArch = llvm::Triple::DXILSubArch_v1_6; +break; + case 7: +SubArch = llvm::Triple::DXILSubArch_v1_7; +break; + case 8: +SubArch = llvm::Triple::DXILSubArch_v1_8; +break; + case OfflineLibMinor: +// Always consider minor version x as the latest supported DXIL version
[clang] [llvm] [DXIL] Set DXIL Version in DXIL target triple based on shader model version (PR #91407)
https://github.com/bharadwajy created https://github.com/llvm/llvm-project/pull/91407 This change set restores the PR #90809 that was reverted to address ASAN failures and includes a fix for the ASAN failures. Following is the description of the change: An earlier commit provided a way to decouple DXIL version from Shader Model version by representing the DXIL version as `SubArch` in the DXIL Target Triple and adding corresponding valid DXIL Arch types. This change constructs DXIL target triple with DXIL version that is deduced from Shader Model version specified in the following scenarios: 1. When compilation target profile is specified: For e.g., DXIL target triple `dxilv1.8-unknown-shader6.8-library` is constructed when `-T lib_6_8` is specified. 2. When DXIL target triple without DXIL version is specified: For e.g., DXIL target triple `dxilv1.8-pc-shadermodel6.8-library` is constructed when `-mtriple=dxil-pc-shadermodel6.8-library` is specified. Note that this is an alternate / expanded implementation to that proposed in PR #89823. PR #89823 implements functionality (1) above. However, it requires any DXIL target triple to explicitly include DXIL version anywhere DXIL target triple is expected (e.g., `dxilv1.8-pc-shadermodel6.8-library`) while a triple without DXIL version (e.g., `dxil-pc-shadermodel6.8-library`) is considered invalid. This functionality is implemented as a change to `tryParseProfile()` and is included in this PR. This PR adds the functionality (2) to eliminate the above requirement to explicitly specify DXIL version in the target triple thereby considering a triple without DXIL version ( e.g., `dxil-pc-shadermodel6.8-library`) to be valid. A triple with DXIL version is inferred based on the shader mode version specified. If no shader model version is specified, DXIL version is defaulted to 1.0. This functionality is implemented in the "Special case logic ..." section of `Triple::normalize()`. Updated relevant HLSL tests that check for target triple. Validated that Clang (`check-clang`), LLVM (`check-llvm`) regression tests and `TargetParserTests` built with sanitizer, pass. >From 78f9aa5849b30ee480221f09f2257faa6d6e6eed Mon Sep 17 00:00:00 2001 From: Bharadwaj Yadavalli Date: Tue, 7 May 2024 18:32:44 + Subject: [PATCH 1/2] Restore "[DirectX][DXIL] Set DXIL Version in DXIL target triple based on shader model version" (#91290)" This restores commit 178ff395006f204265b4f6fe72a3dbb2b9a79b47. An earlier commit provided a way to decouple DXIL version from Shader Model version by representing the DXIL version as `SubArch` in the DXIL Target Triple and adding corresponding valid DXIL Arch types. This change constructs DXIL target triple with DXIL version that is deduced from Shader Model version specified in the following scenarios: 1. When compilation target profile is specified: For e.g., DXIL target triple `dxilv1.8-unknown-shader6.8-library` is constructed when `-T lib_6_8` is specified. 2. When DXIL target triple without DXIL version is specified: For e.g., DXIL target triple `dxilv1.8-pc-shadermodel6.8-library` is constructed when `-mtriple=dxil-pc-shadermodel6.8-library` is specified. Updated relevant HLSL tests that check for target triple. --- clang/lib/Basic/Targets.cpp | 2 +- clang/lib/Driver/ToolChains/HLSL.cpp | 44 +++- clang/test/CodeGenHLSL/basic-target.c | 2 +- clang/test/Driver/dxc_dxv_path.hlsl | 6 +- .../enable_16bit_types_validation.hlsl| 4 +- clang/unittests/Driver/DXCModeTest.cpp| 22 +++--- llvm/include/llvm/TargetParser/Triple.h | 1 + llvm/lib/IR/Verifier.cpp | 4 +- llvm/lib/TargetParser/Triple.cpp | 68 +++ llvm/unittests/TargetParser/TripleTest.cpp| 16 + 10 files changed, 148 insertions(+), 21 deletions(-) diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index e3283510c6aac..dc1792b3471e6 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -760,7 +760,7 @@ using namespace clang::targets; TargetInfo * TargetInfo::CreateTargetInfo(DiagnosticsEngine , const std::shared_ptr ) { - llvm::Triple Triple(Opts->Triple); + llvm::Triple Triple(llvm::Triple::normalize(Opts->Triple)); // Construct the target std::unique_ptr Target = AllocateTarget(Triple, *Opts); diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp index 558e4db46f818..8286e3be21803 100644 --- a/clang/lib/Driver/ToolChains/HLSL.cpp +++ b/clang/lib/Driver/ToolChains/HLSL.cpp @@ -98,9 +98,49 @@ std::optional tryParseProfile(StringRef Profile) { else if (llvm::getAsUnsignedInteger(Parts[2], 0, Minor)) return std::nullopt; - // dxil-unknown-shadermodel-hull + // Determine DXIL version using the minor version number of Shader + // Model