[clang] [HLSL] Use HLSLToolChain for Vulkan (PR #110306)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 27 11:04:58 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Steven Perron (s-perron)
<details>
<summary>Changes</summary>
The options are not translated correctly when targeting Vulkan using the dxc
driver mode. Resuing the translator used for HLSL.
Fixes problem 2 in https://github.com/llvm/llvm-project/issues/108567.
---
Full diff: https://github.com/llvm/llvm-project/pull/110306.diff
3 Files Affected:
- (modified) clang/lib/Driver/Driver.cpp (+1)
- (modified) clang/test/CodeGenHLSL/entry.hlsl (+4)
- (modified) clang/test/Driver/dxc_E.hlsl (+1)
``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d0c8bdba0ede95..fba6a8853c3960 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6481,6 +6481,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::ZOS:
TC = std::make_unique<toolchains::ZOS>(*this, Target, Args);
break;
+ case llvm::Triple::Vulkan:
case llvm::Triple::ShaderModel:
TC = std::make_unique<toolchains::HLSLToolChain>(*this, Target, Args);
break;
diff --git a/clang/test/CodeGenHLSL/entry.hlsl b/clang/test/CodeGenHLSL/entry.hlsl
index ec4254e76fb66b..cd3bf948df48c4 100644
--- a/clang/test/CodeGenHLSL/entry.hlsl
+++ b/clang/test/CodeGenHLSL/entry.hlsl
@@ -2,6 +2,10 @@
// RUN: dxil-pc-shadermodel6.3-compute %s -hlsl-entry foo \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN: spirv-unknown-vulkan-compute %s -hlsl-entry foo \
+// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
// Make sure not mangle entry.
// CHECK:define void @foo()
// Make sure add function attribute and numthreads attribute.
diff --git a/clang/test/Driver/dxc_E.hlsl b/clang/test/Driver/dxc_E.hlsl
index 05cfca685c9a65..07715a2e2259af 100644
--- a/clang/test/Driver/dxc_E.hlsl
+++ b/clang/test/Driver/dxc_E.hlsl
@@ -1,4 +1,5 @@
// RUN: not %clang_dxc -Efoo -Tlib_6_7 foo.hlsl -### %s 2>&1 | FileCheck %s
+// RUN: not %clang_dxc -Efoo -Tlib_6_7 -spirv foo.hlsl -### %s 2>&1 | FileCheck %s
// Make sure E option flag which translated into "-hlsl-entry".
// CHECK:"-hlsl-entry" "foo"
``````````
</details>
https://github.com/llvm/llvm-project/pull/110306
More information about the cfe-commits
mailing list