[clang] [HLSL] Use HLSLToolChain for Vulkan (PR #110306)
Steven Perron via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 30 05:56:15 PDT 2024
https://github.com/s-perron updated https://github.com/llvm/llvm-project/pull/110306
>From bbdbc42f10a2c4f4e265610f325177ccf764cb83 Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Fri, 27 Sep 2024 12:49:34 -0400
Subject: [PATCH] [HLSL] Use HLSLToolChain for Vulkan
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.
---
clang/lib/Driver/Driver.cpp | 1 +
clang/test/CodeGenHLSL/entry.hlsl | 4 ++++
clang/test/Driver/dxc_E.hlsl | 1 +
3 files changed, 6 insertions(+)
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"
More information about the cfe-commits
mailing list