llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Steven Perron (s-perron) <details> <summary>Changes</summary> In DXC, there is an option to enable all KHR extension. This is added by passing the KHR option to the SPIR-V backend, which will enable all of the appropriate extensions. Part of https://github.com/llvm/llvm-project/issues/137650. --- Full diff: https://github.com/llvm/llvm-project/pull/145536.diff 2 Files Affected: - (modified) clang/lib/Driver/ToolChains/HLSL.cpp (+4-2) - (modified) clang/test/Driver/dxc_fspv_extension.hlsl (+6-1) ``````````diff diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp b/clang/lib/Driver/ToolChains/HLSL.cpp index dcc51e182924c..14bbd61c5178a 100644 --- a/clang/lib/Driver/ToolChains/HLSL.cpp +++ b/clang/lib/Driver/ToolChains/HLSL.cpp @@ -182,13 +182,15 @@ std::string getSpirvExtArg(ArrayRef<std::string> SpvExtensionArgs) { (Twine("-spirv-ext=+") + SpvExtensionArgs.front()).str(); SpvExtensionArgs = SpvExtensionArgs.slice(1); for (auto Extension : SpvExtensionArgs) { - LlvmOption = (Twine(LlvmOption) + ",+" + Extension).str(); + if (Extension != "KHR") + Extension = (Twine("+") + Extension).str(); + LlvmOption = (Twine(LlvmOption) + "," + Extension).str(); } return LlvmOption; } bool isValidSPIRVExtensionName(const std::string &str) { - std::regex pattern("SPV_[a-zA-Z0-9_]+"); + std::regex pattern("KHR|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 0a9d321b8d95e..7cb7990568d3e 100644 --- a/clang/test/Driver/dxc_fspv_extension.hlsl +++ b/clang/test/Driver/dxc_fspv_extension.hlsl @@ -10,8 +10,13 @@ // RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 -fspv-extension=SPV_TEST2 2>&1 | FileCheck %s -check-prefix=TEST2 // TEST2: "-spirv-ext=+SPV_TEST1,+SPV_TEST2" +// Merge KHR with other extensions. +// RUN: %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=SPV_TEST1 -fspv-extension=KHR -fspv-extension=SPV_TEST2 2>&1 | FileCheck %s -check-prefix=TEST3 +// TEST3: "-spirv-ext=+SPV_TEST1,KHR,+SPV_TEST2" + // Check for the error message if the extension name is not properly formed. -// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL +// RUN: not %clang_dxc -spirv -Tlib_6_7 -### %s -fspv-extension=KHR_BAD -fspv-extension=TEST1 -fspv-extension=SPV_GOOD -fspv-extension=TEST2 2>&1 | FileCheck %s -check-prefix=FAIL +// FAIL: invalid value 'KHR_BAD' in '-fspv_extension' // FAIL: invalid value 'TEST1' in '-fspv_extension' // FAIL: invalid value 'TEST2' in '-fspv_extension' `````````` </details> https://github.com/llvm/llvm-project/pull/145536 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits