https://github.com/dnovillo updated 
https://github.com/llvm/llvm-project/pull/239374

>From 8a38e21d36b050de325eede18c62e9d453394e08 Mon Sep 17 00:00:00 2001
From: Diego Novillo <[email protected]>
Date: Thu, 5 Nov 2026 15:51:51 -0500
Subject: [PATCH 1/2] [HLSL][Driver][SPIRV] Default -fspv-extension to the DXC
 extension set

---
 clang/docs/ReleaseNotes.md                |  4 ++++
 clang/include/clang/Options/Options.td    | 11 +++++++----
 clang/lib/Driver/ToolChains/HLSL.cpp      | 10 ++++++----
 clang/test/Driver/dxc_fspv_extension.hlsl | 12 ++++++++++--
 4 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 14382a06db34c..b67826e1bb637 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -442,6 +442,10 @@ documentation](CIR/index.md) for more information 
regarding ClangIR's status and
   separated from surrounding arguments by whitespace. Quoted arguments can no
   longer be split across multiple lines using a backslash.
 
+- `clang-dxc -spirv` without `-fspv-extension` now enables the SPIR-V
+  extensions that DXC implements, as `-fspv-extension=DXC` does, instead of all
+  extensions. `-fspv-extension=all` restores the previous behavior.
+
 ### Removed Compiler Flags
 
 ### Attribute Changes in Clang
diff --git a/clang/include/clang/Options/Options.td 
b/clang/include/clang/Options/Options.td
index 4fc924f848507..c137f99856242 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -10197,10 +10197,13 @@ def fspv_extension_EQ
       Group<dxc_Group>,
       HelpText<
           "Specify the available SPIR-V extensions. If this option is not "
-          "specified, then all extensions are available. If KHR is specified, "
-          "then all KHR extensions will be available. If DXC is specifided, "
-          "then all extensions implemented by the DirectX Shader compiler will 
"
-          "be available. This option is useful for moving from DXC to Clang.">;
+          "specified, then all extensions implemented by the DirectX Shader "
+          "compiler are available. If KHR is specified, then all KHR "
+          "extensions will be available. If DXC is specified, then all "
+          "extensions implemented by the DirectX Shader compiler will be "
+          "available. If all is specified, then all extensions the SPIR-V "
+          "backend supports will be available. This option is useful for "
+          "moving from DXC to Clang.">;
 def fvk_use_dx_layout
     : DXCFlag<"fvk-use-dx-layout">,
       HelpText<"Use DirectX memory layout for Vulkan resources.">;
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp 
b/clang/lib/Driver/ToolChains/HLSL.cpp
index 38635d3899691..ed2d1cbcc35dc 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -246,9 +246,11 @@ void getSpirvExtOperand(StringRef SpvExtensionArg, 
raw_ostream &out) {
 }
 
 SmallString<1024> getSpirvExtArg(ArrayRef<std::string> SpvExtensionArgs) {
-  if (SpvExtensionArgs.empty()) {
-    return StringRef("-spirv-ext=all");
-  }
+  // The backend uses any enabled extension it can, so `all` makes modules
+  // declare extensions that a Vulkan application may not have enabled.
+  const std::string DefaultExtension = "DXC";
+  if (SpvExtensionArgs.empty())
+    SpvExtensionArgs = ArrayRef<std::string>(DefaultExtension);
 
   llvm::SmallString<1024> LlvmOption;
   raw_svector_ostream out(LlvmOption);
@@ -265,7 +267,7 @@ SmallString<1024> getSpirvExtArg(ArrayRef<std::string> 
SpvExtensionArgs) {
 }
 
 bool isValidSPIRVExtensionName(const std::string &str) {
-  std::regex pattern("dxc|DXC|khr|KHR|SPV_[a-zA-Z0-9_]+");
+  std::regex pattern("dxc|DXC|khr|KHR|all|SPV_[a-zA-Z0-9_]+");
   return std::regex_match(str, pattern);
 }
 
diff --git a/clang/test/Driver/dxc_fspv_extension.hlsl 
b/clang/test/Driver/dxc_fspv_extension.hlsl
index aeba9f56463f8..06025856dd51f 100644
--- a/clang/test/Driver/dxc_fspv_extension.hlsl
+++ b/clang/test/Driver/dxc_fspv_extension.hlsl
@@ -1,7 +1,15 @@
-// If there is no `-fspv-extension`, enable all extensions.
-// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s 2>&1 | FileCheck %s 
-check-prefix=ALL
+// If there is no `-fspv-extension`, enable the extensions DXC implements, and
+// not SPV_KHR_fma, SPV_KHR_float_controls2 or SPV_EXT_long_vector.
+// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s 2>&1 | FileCheck %s 
-check-prefix=DEFAULT --implicit-check-not=SPV_KHR_fma 
--implicit-check-not=SPV_KHR_float_controls2 
--implicit-check-not=SPV_EXT_long_vector --implicit-check-not=-spirv-ext=all
+// DEFAULT: "-spirv-ext={{(\+SPV_[a-zA-Z0-9_]+,?)+}}"
+
+// `-fspv-extension=all` enables every extension the backend supports.
+// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=all 2>&1 | 
FileCheck %s -check-prefix=ALL
 // ALL: "-spirv-ext=all"
 
+// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=all 
-fspv-extension=SPV_TEST1 2>&1 | FileCheck %s -check-prefix=ALL2
+// ALL2: "-spirv-ext=all,+SPV_TEST1"
+
 // Convert the `-fspv-extension` into `spirv-ext`.
 // RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 2>&1 | 
FileCheck %s -check-prefix=TEST1
 // TEST1: "-spirv-ext=+SPV_TEST1"

>From f8dc25017ae2ee8b85ce848e295c4c68b9973836 Mon Sep 17 00:00:00 2001
From: Diego Novillo <[email protected]>
Date: Fri, 13 Nov 2026 15:46:16 -0500
Subject: [PATCH 2/2] Update help text for -fspv-extension.

---
 clang/include/clang/Options/Options.td | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/clang/include/clang/Options/Options.td 
b/clang/include/clang/Options/Options.td
index c137f99856242..a2b6a7920313a 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -10196,14 +10196,11 @@ def fspv_extension_EQ
     : Joined<["-"], "fspv-extension=">,
       Group<dxc_Group>,
       HelpText<
-          "Specify the available SPIR-V extensions. If this option is not "
-          "specified, then all extensions implemented by the DirectX Shader "
-          "compiler are available. If KHR is specified, then all KHR "
-          "extensions will be available. If DXC is specified, then all "
+          "Specify the available SPIR-V extensions. If KHR is specified, then "
+          "all KHR extensions will be available. If DXC is specified, then all 
"
           "extensions implemented by the DirectX Shader compiler will be "
           "available. If all is specified, then all extensions the SPIR-V "
-          "backend supports will be available. This option is useful for "
-          "moving from DXC to Clang.">;
+          "backend supports will be available. The default behavior is DXC.">;
 def fvk_use_dx_layout
     : DXCFlag<"fvk-use-dx-layout">,
       HelpText<"Use DirectX memory layout for Vulkan resources.">;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to