Skip to content
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

[DirectX] Set DXIL Version using shader model version in compilation target profile #89823

Closed

Conversation

bharadwajy
Copy link
Contributor

@bharadwajy bharadwajy commented Apr 23, 2024

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 DXIL Arch types as valid.

This change constructs the DXIL target triple with DXIL version that is deduced
from the Shader Model version specified in the compilation target profile in a dxc
driver invocation flow.

Updates to tests necessitated by the above change are also included:

  • Arch string dxil in all HLSL and DirectX tests is updated to include appropriate
    version number string.
  • Normalization tests of triple strings with DXIL Arch that now has version number
    are separated in TripleTest.cpp.

PR #90809 adds the functionality that does not require explicit specification of DXIL version in
a target triple specified on command-line.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' backend:DirectX HLSL HLSL Language Support backend:SPIR-V labels Apr 23, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Apr 23, 2024

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-backend-spir-v
@llvm/pr-subscribers-backend-directx
@llvm/pr-subscribers-hlsl

@llvm/pr-subscribers-clang-driver

Author: S. Bharadwaj Yadavalli (bharadwajy)

Changes

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 DXIL Arch types as valid.

This change constructs the DXIL target triple with DXIL version that is deduced
from the Shader Model version specified in the compilation target profile in a dxc
driver invocation flow.

Updates to tests necessitated by the above change are also included:

  • Arch string dxil in all HLSL and DirectX tests is updated to include appropriate
    version number string.
  • Normalization tests of triple strings with DXIL Arch that now has version number
    are separated in TripleTest.cpp.

Patch is 168.73 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/89823.diff

182 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/HLSL.cpp (+42-2)
  • (modified) clang/test/AST/HLSL/RWBuffer-AST.hlsl (+2-2)
  • (modified) clang/test/AST/HLSL/ResourceStruct.hlsl (+1-1)
  • (modified) clang/test/AST/HLSL/ast-dump-comment-cbuffe-tbufferr.hlsl (+2-2)
  • (modified) clang/test/AST/HLSL/cbuffer_tbuffer.hlsl (+1-1)
  • (modified) clang/test/AST/HLSL/group_shared.hlsl (+1-1)
  • (modified) clang/test/AST/HLSL/pch.hlsl (+2-2)
  • (modified) clang/test/AST/HLSL/pch_hlsl_buffer.hlsl (+2-2)
  • (modified) clang/test/AST/HLSL/pch_with_buf.hlsl (+2-2)
  • (modified) clang/test/AST/HLSL/resource_binding_attr.hlsl (+1-1)
  • (modified) clang/test/AST/HLSL/this-reference-template.hlsl (+1-1)
  • (modified) clang/test/AST/HLSL/this-reference.hlsl (+1-1)
  • (modified) clang/test/AST/HLSL/vector-alias.hlsl (+1-1)
  • (modified) clang/test/AST/HLSL/vector-constructors.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/ArrayTemporary.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/GlobalConstructorLib.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/GlobalConstructors.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/GlobalDestructors.hlsl (+2-2)
  • (modified) clang/test/CodeGenHLSL/basic-target.c (+8-8)
  • (modified) clang/test/CodeGenHLSL/basic_types.hlsl (+2-2)
  • (modified) clang/test/CodeGenHLSL/buffer-array-operator.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/RWBuffer-subscript.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/RasterizerOrderedBuffer-annotations.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/ScalarSwizzles.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/abs.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/all.hlsl (+4-4)
  • (modified) clang/test/CodeGenHLSL/builtins/any.hlsl (+4-4)
  • (modified) clang/test/CodeGenHLSL/builtins/ceil.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/clamp-builtin.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/clamp.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/cos.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/create_handle.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/dot-builtin.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/dot.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/exp.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/exp2.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/floor.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/frac.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/isinf.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/lerp-builtin.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/lerp.hlsl (+4-4)
  • (modified) clang/test/CodeGenHLSL/builtins/log.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/log10.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/log2.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/mad.hlsl (+4-4)
  • (modified) clang/test/CodeGenHLSL/builtins/max.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/min.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/pow.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/rcp.hlsl (+9-9)
  • (modified) clang/test/CodeGenHLSL/builtins/reversebits.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/builtins/round.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/rsqrt.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/sin.hlsl (+2-2)
  • (modified) clang/test/CodeGenHLSL/builtins/sqrt.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/builtins/trunc.hlsl (+3-3)
  • (modified) clang/test/CodeGenHLSL/cbuf.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/cbuf_in_namespace.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/convergent-functions.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/disable_opt.hlsl (+2-2)
  • (modified) clang/test/CodeGenHLSL/entry.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/float3.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/group_shared.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/half.hlsl (+2-2)
  • (modified) clang/test/CodeGenHLSL/no_int_promotion.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/semantics/DispatchThreadID.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/semantics/GroupIndex-codegen.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/shader_type_attr.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/shift-mask.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/sret_output.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/static_global_and_function_in_cb.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/this-assignment-overload.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/this-assignment.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/this-reference.hlsl (+1-1)
  • (modified) clang/test/CodeGenHLSL/validator_version.hlsl (+1-1)
  • (modified) clang/test/Driver/dxc_dxv_path.hlsl (+3-3)
  • (modified) clang/test/Driver/hlsl-lang-targets-spirv.hlsl (+1-1)
  • (modified) clang/test/Driver/hlsl-lang-targets.hlsl (+21-18)
  • (modified) clang/test/Driver/hlsl_no_stdinc.hlsl (+3-3)
  • (modified) clang/test/Frontend/hlsl-entry.cpp (+1-1)
  • (modified) clang/test/Options/enable_16bit_types_validation.hlsl (+2-2)
  • (modified) clang/test/ParserHLSL/access_specifiers.hlsl (+2-2)
  • (modified) clang/test/ParserHLSL/cb_error.hlsl (+1-1)
  • (modified) clang/test/ParserHLSL/group_shared.hlsl (+1-1)
  • (modified) clang/test/ParserHLSL/group_shared_202x.hlsl (+1-1)
  • (modified) clang/test/ParserHLSL/invalid_inside_cb.hlsl (+1-1)
  • (modified) clang/test/ParserHLSL/semantic_parsing.hlsl (+1-1)
  • (modified) clang/test/Preprocessor/predefined-macros-hlsl.hlsl (+15-15)
  • (modified) clang/test/Preprocessor/predefined-macros-no-warnings.c (+1-1)
  • (modified) clang/test/SemaHLSL/ArrayParams.hlsl (+5-5)
  • (modified) clang/test/SemaHLSL/ArrayTemporary.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/AvailabilityMarkup.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BitInt128.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/any-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/clamp-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/exp-errors.hlsl (+2-2)
  • (modified) clang/test/SemaHLSL/BuiltIns/frac-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/half-float-only-errors.hlsl (+12-12)
  • (modified) clang/test/SemaHLSL/BuiltIns/isinf-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/lerp-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/mad-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/pow-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/rcp-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/reversebits-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/round-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/rsqrt-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/vector-constructors-erros.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/BuiltIns/vector-errors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/GlobalConstructors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/OverloadResolutionBugs.hlsl (+2-2)
  • (modified) clang/test/SemaHLSL/Semantics/entry_parameter.hlsl (+2-2)
  • (modified) clang/test/SemaHLSL/Semantics/groupindex.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/Semantics/invalid_entry_parameter.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/Semantics/missing_entry_annotation.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/Semantics/valid_entry_parameter.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzleErrors.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/Types/BuiltinVector/ScalarSwizzles.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/VectorOverloadResolution.hlsl (+2-2)
  • (modified) clang/test/SemaHLSL/Wave.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/cb_error.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/entry.hlsl (+2-2)
  • (modified) clang/test/SemaHLSL/entry_shader.hlsl (+2-2)
  • (modified) clang/test/SemaHLSL/entry_shader_redecl.hlsl (+4-4)
  • (modified) clang/test/SemaHLSL/group_shared.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/group_shared_202x.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/literal_suffixes.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/literal_suffixes_no_16bit.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/num_threads.hlsl (+11-11)
  • (modified) clang/test/SemaHLSL/parameter_modifiers.hlsl (+2-2)
  • (modified) clang/test/SemaHLSL/parameter_modifiers_ast.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/prohibit_pointer.hlsl (+4-4)
  • (modified) clang/test/SemaHLSL/prohibit_reference.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/resource_binding_attr_error.hlsl (+1-1)
  • (modified) clang/test/SemaHLSL/shader_type_attr.hlsl (+2-2)
  • (modified) clang/test/SemaHLSL/standard_conversion_sequences.hlsl (+4-4)
  • (modified) clang/test/SemaHLSL/valid-shader-stages.hlsl (+1-1)
  • (modified) clang/unittests/Driver/DXCModeTest.cpp (+10-10)
  • (modified) llvm/lib/TargetParser/Triple.cpp (+30-7)
  • (modified) llvm/test/CodeGen/DirectX/ContainerData/DebugShaderHash.ll (+2-2)
  • (modified) llvm/test/CodeGen/DirectX/ContainerData/ShaderHash.ll (+2-2)
  • (modified) llvm/test/CodeGen/DirectX/Metadata/shaderModel-as.ll (+2-2)
  • (modified) llvm/test/CodeGen/DirectX/Metadata/shaderModel-cs.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/Metadata/shaderModel-gs.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/Metadata/shaderModel-hs.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/Metadata/shaderModel-lib.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/Metadata/shaderModel-ms.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/Metadata/shaderModel-ps.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/Metadata/shaderModel-vs.ll (+2-2)
  • (modified) llvm/test/CodeGen/DirectX/ShaderFlags/double-extensions.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/ShaderFlags/doubles.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/ShaderFlags/no_flags.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/UAVMetadata.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/cbuf.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/comput_ids.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/conflicting-bitcast-insert.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/dxil_ver.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/embed-dxil.ll (+2-2)
  • (modified) llvm/test/CodeGen/DirectX/exp2.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/fmad.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/fneg-conversion.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/frac.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/imad.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/legacy_cb_layout_0.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/legacy_cb_layout_1.ll (+2-2)
  • (modified) llvm/test/CodeGen/DirectX/legacy_cb_layout_2.ll (+3-3)
  • (modified) llvm/test/CodeGen/DirectX/legacy_cb_layout_3.ll (+6-6)
  • (modified) llvm/test/CodeGen/DirectX/lib_entry.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/min_vec_size.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/omit-bitcast-insert.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/strip-call-attrs.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/strip-fn-attrs.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/typed_ptr.ll (+1-1)
  • (modified) llvm/test/CodeGen/DirectX/umad.ll (+1-1)
  • (modified) llvm/test/Frontend/HLSL/empty_cs_entry.ll (+1-1)
  • (modified) llvm/unittests/TargetParser/TripleTest.cpp (+70-50)
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp
index 1169b5d8c92dd6..51f2680b491c60 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -12,7 +12,9 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Job.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/TargetParser/Triple.h"
+#include <string>
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -98,9 +100,47 @@ std::optional<std::string> tryParseProfile(StringRef Profile) {
   else if (llvm::getAsUnsignedInteger(Parts[2], 0, Minor))
     return std::nullopt;
 
-  // dxil-unknown-shadermodel-hull
+  // Determine DXIL version number 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;
+  }
+  if (SubArch == llvm::Triple::NoSubArch) {
+    report_fatal_error(
+        "No DXIL version found for specified Shader Model version",
+        /*gen_crash_diag*/ false);
+  }
+  T.setArch(Triple::ArchType::dxil, SubArch);
   T.setOSName(Triple::getOSTypeName(Triple::OSType::ShaderModel).str() +
               VersionTuple(Major, Minor).getAsString());
   T.setEnvironment(Kind);
diff --git a/clang/test/AST/HLSL/RWBuffer-AST.hlsl b/clang/test/AST/HLSL/RWBuffer-AST.hlsl
index c1613520a146c8..ca2fd5b8375810 100644
--- a/clang/test/AST/HLSL/RWBuffer-AST.hlsl
+++ b/clang/test/AST/HLSL/RWBuffer-AST.hlsl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -fsyntax-only -ast-dump -DEMPTY %s | FileCheck -check-prefix=EMPTY %s 
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -fsyntax-only -ast-dump %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-library -x hlsl -fsyntax-only -ast-dump -DEMPTY %s | FileCheck -check-prefix=EMPTY %s
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-library -x hlsl -fsyntax-only -ast-dump %s | FileCheck %s
 
 
 // This test tests two different AST generations. The "EMPTY" test mode verifies
diff --git a/clang/test/AST/HLSL/ResourceStruct.hlsl b/clang/test/AST/HLSL/ResourceStruct.hlsl
index 34f1419180d84a..4f9f0d9fc62385 100644
--- a/clang/test/AST/HLSL/ResourceStruct.hlsl
+++ b/clang/test/AST/HLSL/ResourceStruct.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -fsyntax-only -ast-dump %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl -fsyntax-only -ast-dump %s | FileCheck %s
 
 // CHECK: NamespaceDecl {{.*}} implicit hlsl
 // CHECK: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class Resource definition
diff --git a/clang/test/AST/HLSL/ast-dump-comment-cbuffe-tbufferr.hlsl b/clang/test/AST/HLSL/ast-dump-comment-cbuffe-tbufferr.hlsl
index a98dc0f4ce4312..566f054e788e55 100644
--- a/clang/test/AST/HLSL/ast-dump-comment-cbuffe-tbufferr.hlsl
+++ b/clang/test/AST/HLSL/ast-dump-comment-cbuffe-tbufferr.hlsl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -Wdocumentation -ast-dump=json -x hlsl -triple dxil-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=JSON
-// RUN: %clang_cc1 -Wdocumentation -ast-dump -x hlsl -triple dxil-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=AST
+// RUN: %clang_cc1 -Wdocumentation -ast-dump=json -x hlsl -triple dxilv1.3-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=JSON
+// RUN: %clang_cc1 -Wdocumentation -ast-dump -x hlsl -triple dxilv1.3-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=AST
 
 // JSON:"kind": "HLSLBufferDecl",
 // JSON:"name": "A",
diff --git a/clang/test/AST/HLSL/cbuffer_tbuffer.hlsl b/clang/test/AST/HLSL/cbuffer_tbuffer.hlsl
index 7204dcd16e0a92..4700b3b946a559 100644
--- a/clang/test/AST/HLSL/cbuffer_tbuffer.hlsl
+++ b/clang/test/AST/HLSL/cbuffer_tbuffer.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.6-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
 
 // CHECK:HLSLBufferDecl 0x[[CB:[0-9a-f]+]] {{.*}} line:5:9 cbuffer CB
 // CHECK-NEXT:VarDecl 0x[[A:[0-9a-f]+]] {{.*}} col:9 used a 'float'
diff --git a/clang/test/AST/HLSL/group_shared.hlsl b/clang/test/AST/HLSL/group_shared.hlsl
index fb8a07626c66f2..b3b957f09dcf19 100644
--- a/clang/test/AST/HLSL/group_shared.hlsl
+++ b/clang/test/AST/HLSL/group_shared.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
 
 //CHECK:VarDecl 0x[[A:[0-9a-f]+]] <{{.*}} col:24> col:20 used a 'groupshared float[10]'
  groupshared float a[10];
diff --git a/clang/test/AST/HLSL/pch.hlsl b/clang/test/AST/HLSL/pch.hlsl
index 27fae8f499daac..84641bea66cbc3 100644
--- a/clang/test/AST/HLSL/pch.hlsl
+++ b/clang/test/AST/HLSL/pch.hlsl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl \
 // RUN:  -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl \
 // RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s \
 // RUN: | FileCheck  %s
 
diff --git a/clang/test/AST/HLSL/pch_hlsl_buffer.hlsl b/clang/test/AST/HLSL/pch_hlsl_buffer.hlsl
index 0277d4756db884..3bd4e92a4941e8 100644
--- a/clang/test/AST/HLSL/pch_hlsl_buffer.hlsl
+++ b/clang/test/AST/HLSL/pch_hlsl_buffer.hlsl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl \
 // RUN:   -emit-pch -o %t %s
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl \
 // RUN:   -include-pch %t -fsyntax-only -ast-dump-all %S/Inputs/empty.hlsl \
 // RUN: | FileCheck  %s
 
diff --git a/clang/test/AST/HLSL/pch_with_buf.hlsl b/clang/test/AST/HLSL/pch_with_buf.hlsl
index e8eae533af6294..514e1915bb25b7 100644
--- a/clang/test/AST/HLSL/pch_with_buf.hlsl
+++ b/clang/test/AST/HLSL/pch_with_buf.hlsl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -emit-pch -o %t %S/Inputs/pch_with_buf.hlsl
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl -finclude-default-header -emit-pch -o %t %S/Inputs/pch_with_buf.hlsl
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl \
 // RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s | FileCheck  %s
 
 // Make sure PCH works by using function declared in PCH header.
diff --git a/clang/test/AST/HLSL/resource_binding_attr.hlsl b/clang/test/AST/HLSL/resource_binding_attr.hlsl
index 71900f2dbda550..28de07c44d2826 100644
--- a/clang/test/AST/HLSL/resource_binding_attr.hlsl
+++ b/clang/test/AST/HLSL/resource_binding_attr.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s | FileCheck %s
 
 // CHECK:HLSLBufferDecl 0x[[CB:[0-9a-f]+]] {{.*}} line:6:9 cbuffer CB
 // CHECK-NEXT:HLSLResourceBindingAttr 0x{{[0-9a-f]+}} <col:14> "b3" "space2"
diff --git a/clang/test/AST/HLSL/this-reference-template.hlsl b/clang/test/AST/HLSL/this-reference-template.hlsl
index 60e057986ebf80..c1090df587f92e 100644
--- a/clang/test/AST/HLSL/this-reference-template.hlsl
+++ b/clang/test/AST/HLSL/this-reference-template.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -disable-llvm-passes -o - -hlsl-entry main %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-compute -x hlsl -ast-dump -disable-llvm-passes -o - -hlsl-entry main %s | FileCheck %s
 
 template<typename K, typename V>
 struct Pair {
diff --git a/clang/test/AST/HLSL/this-reference.hlsl b/clang/test/AST/HLSL/this-reference.hlsl
index 67d8e7b7b9119a..2e1feeb440fcfd 100644
--- a/clang/test/AST/HLSL/this-reference.hlsl
+++ b/clang/test/AST/HLSL/this-reference.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -disable-llvm-passes -o - -hlsl-entry main %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-compute -x hlsl -ast-dump -disable-llvm-passes -o - -hlsl-entry main %s | FileCheck %s
 
 class Pair {
   int First;
diff --git a/clang/test/AST/HLSL/vector-alias.hlsl b/clang/test/AST/HLSL/vector-alias.hlsl
index effa1aa53db49a..86c5117925a9ff 100644
--- a/clang/test/AST/HLSL/vector-alias.hlsl
+++ b/clang/test/AST/HLSL/vector-alias.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s
 
 // CHECK: NamespaceDecl 0x{{[0-9a-fA-F]+}} <<invalid sloc>> <invalid sloc> implicit hlsl
 // CHECK-NEXT: TypeAliasTemplateDecl 0x{{[0-9a-fA-F]+}} <<invalid sloc>> <invalid sloc> implicit vector
diff --git a/clang/test/AST/HLSL/vector-constructors.hlsl b/clang/test/AST/HLSL/vector-constructors.hlsl
index 7861d5209b5d3e..b4e9aac1357e66 100644
--- a/clang/test/AST/HLSL/vector-constructors.hlsl
+++ b/clang/test/AST/HLSL/vector-constructors.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s
 
 typedef float float2 __attribute__((ext_vector_type(2)));
 typedef float float3 __attribute__((ext_vector_type(3)));
diff --git a/clang/test/CodeGenHLSL/ArrayTemporary.hlsl b/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
index 63a30b61440eb5..6a15e80d2024ef 100644
--- a/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
+++ b/clang/test/CodeGenHLSL/ArrayTemporary.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
 
 void fn(float x[2]) { }
 
diff --git a/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl b/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
index 06e3cc5af87e1a..3ba3ae26385591 100644
--- a/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
+++ b/clang/test/CodeGenHLSL/BasicFeatures/standard_conversion_sequences.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
 
 // CHECK-LABEL: f3_to_d4
 // CHECK: [[f3:%.*]] = alloca <3 x float>
diff --git a/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl b/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
index d65dec4a1ddf43..351a704a25349e 100644
--- a/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalConstructorFunction.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-compute -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
 
 int i;
 
diff --git a/clang/test/CodeGenHLSL/GlobalConstructorLib.hlsl b/clang/test/CodeGenHLSL/GlobalConstructorLib.hlsl
index e7fe4e0c4caf7d..9528aa91989df0 100644
--- a/clang/test/CodeGenHLSL/GlobalConstructorLib.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalConstructorLib.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
 
 // Make sure global variable for ctors exist for lib profile.
 // CHECK:@llvm.global_ctors
diff --git a/clang/test/CodeGenHLSL/GlobalConstructors.hlsl b/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
index 332302e1a8bb05..31ca7f877babb9 100644
--- a/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalConstructors.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.0-compute -x hlsl -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
 
 RWBuffer<float> Buffer;
 
diff --git a/clang/test/CodeGenHLSL/GlobalDestructors.hlsl b/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
index b245af7c0f7b11..44c13c72b32b95 100644
--- a/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
+++ b/clang/test/CodeGenHLSL/GlobalDestructors.hlsl
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -std=hlsl202x -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s --check-prefixes=CS,CHECK
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -std=hlsl202x -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s --check-prefixes=LIB,CHECK
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-compute -std=hlsl202x -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s --check-prefixes=CS,CHECK
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.3-library -std=hlsl202x -S -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s --check-prefixes=LIB,CHECK
 
 // Make sure global variable for dtors exist for lib profile.
 // LIB:@llvm.global_dtors
diff --git a/clang/test/CodeGenHLSL/basic-target.c b/clang/test/CodeGenHLSL/basic-target.c
index 8db711c3f2a5b1..23188fcbcf0cbc 100644
--- a/clang/test/CodeGenHLSL/basic-target.c
+++ b/clang/test/CodeGenHLSL/basic-target.c
@@ -1,10 +1,10 @@
-// RUN: %clang -target dxil-pc-shadermodel6.0-pixel -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang -target dxil-pc-shadermodel6.0-vertex -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang -target dxil-pc-shadermodel6.0-compute -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang -target dxil-pc-shadermodel6.0-library -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang -target dxil-pc-shadermodel6.0-hull -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang -target dxil-pc-shadermodel6.0-domain -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang -target dxil-pc-shadermodel6.0-geometry -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxilv1.0-pc-shadermodel6.0-pixel -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxilv1.0-pc-shadermodel6.0-vertex -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxilv1.0-pc-shadermodel6.0-compute -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxilv1.0-pc-shadermodel6.0-library -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxilv1.0-pc-shadermodel6.0-hull -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxilv1.0-pc-shadermodel6.0-domain -S -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang -target dxilv1.0-pc-shadermodel6.0-geometry -S -emit-llvm -o - %s | FileCheck %s
 
 // CHECK: target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
-// CHECK: target triple = "dxil-pc-shadermodel6.0-{{[a-z]+}}"
+// CHECK: target triple = "dxilv1.0-pc-shadermodel6.0-{{[a-z]+}}"
diff --git a/clang/test/CodeGenHLSL/basic_types.hlsl b/clang/test/CodeGenHLSL/basic_types.hlsl
index 15c963dfa666f4..31cbc0fdebee66 100644
--- a/clang/test/CodeGenHLSL/basic_types.hlsl
+++ b/clang/test/CodeGenHLSL/basic_types.hlsl
@@ -1,8 +1,8 @@
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
-// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   dxilv1.3-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - | FileCheck %s
 // RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
-// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   dxilv1.3-pc-shadermodel6.3-library %s -fnative-half-type \
 // RUN:   -emit-llvm -disable-llvm-passes -o - -DNAMESPACED| FileCheck %s
 
 
diff --git a/clang/test/CodeGenHLSL/buffer-array-operator.hlsl b/clang/test/CodeGenHLSL/buffer-array-operator.hlsl
index 6bcb06106bf1cf..959100ec946860 100644
--- a/clang/test/CodeGenHLSL/buffer-array-operator.hlsl
+++ b/clang/test/CodeGenHLSL/buffer-array-operator.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
 
 const RWBuffer<float> In;
 RWBuffer<float> Out;
diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl b/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
index 7ca78e60fb9c59..90ff6d3003e123 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-annotations.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.0-pc-shadermodel6.0-compute -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
 
 RWBuffer<float> Buffer1;
 RWBuffer<vector<float, 4> > BufferArray[4];
diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
index 74b3f59bf7600f..508b91743ef28c 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-constructor.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple spirv-vulkan-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-SPIRV
 
 RWBuffer<float> Buf;
diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl b/clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl
index 036c9c28ef2779..846459c572e0bd 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-elementtype.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.2-compute -finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxilv1.3-pc-shadermodel6.2-compute -finclude-default-header -fnative-half-type -emit-llvm -o - %s | FileCheck %s
 
 RWBuffer<int16_t> BufI16;
 RWBuffer<uint16_t> BufU16;
diff --git a/clang/test/CodeGenHLSL/builtins/RWBuffer-subscript.hlsl b/clang/test/CodeGenHLSL/builtins/RWBuffer-subscript.hlsl
index da8a1e538ec5e7..be0d2f8cd955c1 100644
--- a/clang/test/CodeGenHLSL/builtins/RWBuffer-subscript.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/RWBuffer-subscript.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-llvm -o ...
[truncated]

clang/lib/Driver/ToolChains/HLSL.cpp Outdated Show resolved Hide resolved
clang/lib/Driver/ToolChains/HLSL.cpp Outdated Show resolved Hide resolved
clang/unittests/Driver/DXCModeTest.cpp Outdated Show resolved Hide resolved
clang/lib/Driver/ToolChains/HLSL.cpp Outdated Show resolved Hide resolved
clang/lib/Driver/ToolChains/HLSL.cpp Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Apr 24, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

… profile specified

Update dxil arch string in all HLSL and DirectX tests

Separate out normalization tests of triple strings with DXIL Arch
that now has version number.
 - Delete call to report_fatal_error and return std::nullopt. As a result
   appropriate unsupported SM version diagnostic is reported.
 - Add the requirement of SubArch to be set for a DXIL Triple to be deemed legal.
 - Add test to verify invalid profile error.
@bharadwajy bharadwajy force-pushed the dxil-version-target-triple-strict branch from 64a607c to 8ffa097 Compare April 26, 2024 00:13
Copy link
Contributor

@bogner bogner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of churn here so I'm not 100% sure I saw all of the real changes, but I think I got them all. It might be nice to move the NFC parts into their own commit (if we actually need them, see my other comments).

I don't think we should treat the DXIL architecture differently than all of the other architectures in LLVM like this. More on that in the comments.

// RUN: not %clang -target dxilv1.2--shadermodel6.2-msvc %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-ENV %s

// Invaliddxil target with no version number
// RUN: not %clang -target dxil--shadermodel6.2-msvc %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-BAD-TARGET %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is the dxil arch with no subarch just completely disallowed then? This is unusual compared to other targets, and also a bit inconvenient for testing. If I'm trying something locally and switching between SM6.2 and SM6.0 I now need to update two parts of the triple on my command line even though these shader models and DXIL versions have a 1-1 mapping.

I also worry that this error message will be pretty confusing. IIUC it will print "HLSL code generation is unsupported for target 'dxil--shadermodel6.2-msvc'". We should arguably have an error message specifically saying that the DXIL version is invalid for the shader model. This might be covered by my other comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is the dxil arch with no subarch just completely disallowed then?

Yes.

This is unusual compared to other targets, and also a bit inconvenient for testing. If I'm trying something locally and switching between SM6.2 and SM6.0 I now need to update two parts of the triple on my command line even though these shader models and DXIL versions have a 1-1 mapping.

The intent is to avoid implicit mapping of DXIL and SM versions. Allowing dxil to be valid would require an implicit assumption of the DXIL version for such a specification - and can be cause for confusion. Specifying the targeted DXIL and SM versions explicitly - particularly since they have been decoupled, seems appropriate.

Copy link
Contributor

@python3kgae python3kgae Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll vote for allowing implicit mapping since that is the common case.
Even though they're decoupled, allowing a default value would match what other targets do.
Like spirv, it is ok to just say spirv32 for their test instead of require spirv32_v1.0.

// RUN: not %clang -target dxil--shadermodel6.2 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-NO-ENV %s
// RUN: not %clang -target dxilv1.2-shadermodel6.2 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-NO-ENV %s
// RUN: not %clang -target dxilv1.2--shadermodel6.2 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-NO-ENV %s
// RUN: not %clang -target dxilv1.2--shadermodel6.2 %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-NO-ENV %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen if someone specifies dxilv1.0--shadermodel6.7 and then uses some SM6.7 feature that isn't representable in dxil 1.0? We should probably validate that the dxil version and shadermodel are compatible.

A 1-1 mapping for validating the shader model vs the dxil version is probably sufficient / matches DXC. It's also possible we could do better, but I don't know that it's worth the effort of cataloguing compatibility for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What should happen if someone specifies dxilv1.0--shadermodel6.7 and then uses some SM6.7 feature that isn't representable in dxil 1.0? We should probably validate that the dxil version and shadermodel are compatible.

I'd expect such validation to be done during analysis and/or codegen passes - potentially specified in DXIL.td where the properties of DXIL Operations are specified.

A 1-1 mapping for validating the shader model vs the dxil version is probably sufficient / matches DXC. It's also possible we could do better, but I don't know that it's worth the effort of cataloguing compatibility for that.

Such cataloguing would be part of DXIL.td.

return "dxilv1.8";
default:
report_fatal_error("Unknown DXIL Version",
/*gen_crash_diag=*/false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should crash if we have an architecture without a subarch. We don't for any of the other architectures.

// Exclude testing DXIL Arch since arch type name for Triple::dxil depends
// on SubArch and is no longer "dxil". Instead, normalization tests for
// Triple::dxil are added at an earlier location in this test function.
if (Arch != Triple::dxil) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more evidence that treating DXIL specially here is problematic.

case 8:
case OfflineLibMinor:
// Always consider minor version x as the latest supported minor version
SubArch = llvm::Triple::DXILSubArch_v1_8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make updates here less error prone if we added DXILSubArch_v1_x = DXILSubArch_v1_8 or LastDXILSubArch = DXILSubArch_v1_8 to the enum in Triple.h, depending on which of those makes more logical sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might make updates here less error prone if we added DXILSubArch_v1_x = DXILSubArch_v1_8 or LastDXILSubArch = DXILSubArch_v1_8 to the enum in Triple.h, depending on which of those makes more logical sense.

OK.

@damyanp
Copy link
Contributor

damyanp commented May 6, 2024

Now the #90809 has landed, is this PR still relevant?

@bharadwajy
Copy link
Contributor Author

Now the #90809 has landed, is this PR still relevant?

No. I was just about to close it. Thanks!

Closing as an expanded implementation has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:DirectX backend:SPIR-V clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category HLSL HLSL Language Support
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[DXIL] [Clang] Set DXIL version in target triple when translating target profile
7 participants