Skip to content

Commit 2e6387c

Browse files
committed
rename device-lib-spv-dir to device-lib-dir
Signed-off-by: jinge90 <[email protected]>
1 parent 3543b2d commit 2e6387c

File tree

8 files changed

+33
-37
lines changed

8 files changed

+33
-37
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10947,15 +10947,15 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1094710947
if (TC.getTriple().isSPIROrSPIRV() && !TC.getTriple().isSPIRAOT() &&
1094810948
!DeviceLibDisable) {
1094910949
SYCLInstallationDetector SYCLInstall(TC.getDriver());
10950-
SmallVector<SmallString<128>, 4> SpvLocCandidates;
10951-
SmallString<128> FallbackAssertName("libsycl-fallback-cassert.spv");
10952-
SYCLInstall.getSYCLDeviceLibPath(SpvLocCandidates, true);
10953-
for (const auto &SpvLoc : SpvLocCandidates) {
10954-
SmallString<128> FullLibName(SpvLoc);
10950+
SmallVector<SmallString<128>, 4> DeviceLibLocCandidates;
10951+
SmallString<128> FallbackAssertName("libsycl-fallback-cassert.bc");
10952+
SYCLInstall.getSYCLDeviceLibPath(DeviceLibLocCandidates);
10953+
for (const auto &DeviceLibLoc : DeviceLibLocCandidates) {
10954+
SmallString<128> FullLibName(DeviceLibLoc);
1095510955
llvm::sys::path::append(FullLibName, FallbackAssertName);
1095610956
if (llvm::sys::fs::exists(FullLibName)) {
10957-
SmallString<128> SYCLDeviceLibDir("--device-lib-spv-dir=");
10958-
SYCLDeviceLibDir += SpvLoc.str();
10957+
SmallString<128> SYCLDeviceLibDir("--device-lib-dir=");
10958+
SYCLDeviceLibDir += DeviceLibLoc.str();
1095910959
addArgs(PostLinkArgs, TCArgs, {SYCLDeviceLibDir.str()});
1096010960
break;
1096110961
}

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
8-
98
#include "SYCL.h"
109
#include "CommonArgs.h"
1110
#include "clang/Driver/Action.h"
@@ -153,20 +152,14 @@ SYCLInstallationDetector::SYCLInstallationDetector(const Driver &D)
153152
}
154153

155154
void SYCLInstallationDetector::getSYCLDeviceLibPath(
156-
llvm::SmallVector<llvm::SmallString<128>, 4> &DeviceLibPaths,
157-
bool GetSPV) const {
158-
auto TargetTriple = llvm::Triple(D.getTargetTriple());
155+
llvm::SmallVector<llvm::SmallString<128>, 4> &DeviceLibPaths) const {
159156
for (const auto &IC : InstallationCandidates) {
160157
llvm::SmallString<128> InstallLibPath(IC.str());
161-
if (GetSPV && TargetTriple.isOSWindows())
162-
InstallLibPath.append("/bin");
163-
else
164-
InstallLibPath.append("/lib");
158+
InstallLibPath.append("/lib");
165159
DeviceLibPaths.emplace_back(InstallLibPath);
166160
}
167161

168-
if (!GetSPV || !TargetTriple.isOSWindows())
169-
DeviceLibPaths.emplace_back(D.SysRoot + "/lib");
162+
DeviceLibPaths.emplace_back(D.SysRoot + "/lib");
170163
}
171164

172165
void SYCLInstallationDetector::AddSYCLIncludeArgs(

clang/lib/Driver/ToolChains/SYCL.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,7 @@ class SYCLInstallationDetector {
129129
public:
130130
SYCLInstallationDetector(const Driver &D);
131131
void getSYCLDeviceLibPath(
132-
llvm::SmallVector<llvm::SmallString<128>, 4> &DeviceLibPaths,
133-
bool GetSPV = false) const;
132+
llvm::SmallVector<llvm::SmallString<128>, 4> &DeviceLibPaths) const;
134133
void AddSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs,
135134
llvm::opt::ArgStringList &CC1Args) const;
136135
void print(llvm::raw_ostream &OS) const;

clang/test/Driver/sycl-linker-wrapper-image.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,21 @@ int main() {
4444
// CHECK-DAG: @.sycl_offloading.target.0 = internal unnamed_addr constant [7 x i8] c"spir64\00"
4545
// CHECK-DAG: @.sycl_offloading.opts.compile.0 = internal unnamed_addr constant [1 x i8] zeroinitializer
4646
// CHECK-DAG: @.sycl_offloading.opts.link.0 = internal unnamed_addr constant [1 x i8] zeroinitializer
47-
// CHECK-DAG: @prop = internal unnamed_addr constant [8 x i8] c"aspects\00"
47+
// CHECK-DAG: @prop = internal unnamed_addr constant [17 x i8] c"DeviceLibReqMask\00"
48+
// CHECK-DAG: @__sycl_offload_prop_sets_arr = internal constant [1 x %_pi_device_binary_property_struct] [%_pi_device_binary_property_struct { ptr @prop, ptr null, i32 1, i64 0 }]
49+
// CHECK-DAG: @SYCL_PropSetName = internal unnamed_addr constant [24 x i8] c"SYCL/devicelib req mask\00"
50+
// CHECK-DAG: @prop.1 = internal unnamed_addr constant [8 x i8] c"aspects\00"
4851
// CHECK-DAG: @prop_val = internal unnamed_addr constant [8 x i8] zeroinitializer
49-
// CHECK-DAG: @__sycl_offload_prop_sets_arr = internal constant [1 x %_pi_device_binary_property_struct] [%_pi_device_binary_property_struct { ptr @prop, ptr @prop_val, i32 2, i64 8 }]
50-
// CHECK-DAG: @SYCL_PropSetName = internal unnamed_addr constant [25 x i8] c"SYCL/device requirements\00"
51-
// CHECK-DAG: @SYCL_PropSetName.1 = internal unnamed_addr constant [22 x i8] c"SYCL/kernel param opt\00"
52-
// CHECK-DAG: @__sycl_offload_prop_sets_arr.2 = internal constant [2 x %_pi_device_binary_property_set_struct] [%_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName, ptr @__sycl_offload_prop_sets_arr, ptr getelementptr ([1 x %_pi_device_binary_property_struct], ptr @__sycl_offload_prop_sets_arr, i64 0, i64 1) }, %_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName.1, ptr null, ptr null }]
52+
// CHECK-DAG: @__sycl_offload_prop_sets_arr.2 = internal constant [1 x %_pi_device_binary_property_struct] [%_pi_device_binary_property_struct { ptr @prop.1, ptr @prop_val, i32 2, i64 8 }]
53+
// CHECK-DAG: @SYCL_PropSetName.3 = internal unnamed_addr constant [25 x i8] c"SYCL/device requirements\00"
54+
// CHECK-DAG: @SYCL_PropSetName.4 = internal unnamed_addr constant [22 x i8] c"SYCL/kernel param opt\00"
55+
// CHECK-DAG: @__sycl_offload_prop_sets_arr.5 = internal constant [3 x %_pi_device_binary_property_set_struct] [%_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName, ptr @__sycl_offload_prop_sets_arr, ptr getelementptr ([1 x %_pi_device_binary_property_struct], ptr @__sycl_offload_prop_sets_arr, i64 0, i64 1) }, %_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName.3, ptr @__sycl_offload_prop_sets_arr.2, ptr getelementptr ([1 x %_pi_device_binary_property_struct], ptr @__sycl_offload_prop_sets_arr.2, i64 0, i64 1) }, %_pi_device_binary_property_set_struct { ptr @SYCL_PropSetName.4, ptr null, ptr null }]
5356
// CHECK-DAG: @.sycl_offloading.0.data = internal unnamed_addr constant [772 x i8]
5457
// CHECK-DAG: @__sycl_offload_entry_name = internal unnamed_addr constant [25 x i8] c"_ZTSZ4mainE11fake_kernel\00"
5558
// CHECK-DAG: @__sycl_offload_entries_arr = internal constant [1 x %struct.__tgt_offload_entry] [%struct.__tgt_offload_entry { ptr null, ptr @__sycl_offload_entry_name, i64 0, i32 0, i32 0 }]
5659
// CHECK-DAG: @.sycl_offloading.0.info = internal local_unnamed_addr constant [2 x i64] [i64 ptrtoint (ptr @.sycl_offloading.0.data to i64), i64 772], section ".tgtimg", align 16
5760
// CHECK-DAG: @llvm.used = appending global [1 x ptr] [ptr @.sycl_offloading.0.info], section "llvm.metadata"
58-
// CHECK-DAG: @.sycl_offloading.device_images = internal unnamed_addr constant [1 x %__sycl.tgt_device_image] [%__sycl.tgt_device_image { i16 2, i8 4, i8 0, ptr @.sycl_offloading.target.0, ptr @.sycl_offloading.opts.compile.0, ptr @.sycl_offloading.opts.link.0, ptr null, ptr null, ptr @.sycl_offloading.0.data, ptr getelementptr ([772 x i8], ptr @.sycl_offloading.0.data, i64 0, i64 772), ptr @__sycl_offload_entries_arr, ptr getelementptr ([1 x %struct.__tgt_offload_entry], ptr @__sycl_offload_entries_arr, i64 0, i64 1), ptr @__sycl_offload_prop_sets_arr.2, ptr getelementptr ([2 x %_pi_device_binary_property_set_struct], ptr @__sycl_offload_prop_sets_arr.2, i64 0, i64 2) }]
61+
// CHECK-DAG: @.sycl_offloading.device_images = internal unnamed_addr constant [1 x %__sycl.tgt_device_image] [%__sycl.tgt_device_image { i16 2, i8 4, i8 0, ptr @.sycl_offloading.target.0, ptr @.sycl_offloading.opts.compile.0, ptr @.sycl_offloading.opts.link.0, ptr null, ptr null, ptr @.sycl_offloading.0.data, ptr getelementptr ([772 x i8], ptr @.sycl_offloading.0.data, i64 0, i64 772), ptr @__sycl_offload_entries_arr, ptr getelementptr ([1 x %struct.__tgt_offload_entry], ptr @__sycl_offload_entries_arr, i64 0, i64 1), ptr @__sycl_offload_prop_sets_arr.5, ptr getelementptr ([3 x %_pi_device_binary_property_set_struct], ptr @__sycl_offload_prop_sets_arr.5, i64 0, i64 3) }]
5962
// CHECK-DAG: @.sycl_offloading.descriptor = internal constant %__sycl.tgt_bin_desc { i16 1, i16 1, ptr @.sycl_offloading.device_images, ptr null, ptr null }
6063
// CHECK-DAG: @llvm.global_ctors = {{.*}} { i32 1, ptr @sycl.descriptor_reg, ptr null }]
6164
// CHECK-DAG: @llvm.global_dtors = {{.*}} { i32 1, ptr @sycl.descriptor_unreg, ptr null }]

clang/test/Driver/sycl-post-link-options-win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %clangxx -### --target=x86_64-pc-windows-msvc -fsycl \
44
// RUN: -Xdevice-post-link -O0 %s 2>&1 \
55
// RUN: | FileCheck -check-prefix OPTIONS_POSTLINK_JIT_OLD %s
6-
// OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "--device-lib-spv-dir={{.*}}" "-properties" "-spec-const=native" "-split=auto" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0"
6+
// OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "--device-lib-dir={{.*}}" "-properties" "-spec-const=native" "-split=auto" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0"
77
// -------
88
// Generate .o file as linker wrapper input.
99
//

clang/test/Driver/sycl-post-link-options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl -### \
44
// RUN: --no-offload-new-driver -Xdevice-post-link -O0 %s 2>&1 \
55
// RUN: | FileCheck -check-prefix OPTIONS_POSTLINK_JIT_OLD %s
6-
// OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "--device-lib-spv-dir={{.*}}" "-properties" "-spec-const=native" "-split=auto" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0"
6+
// OPTIONS_POSTLINK_JIT_OLD: sycl-post-link{{.*}} "-O2" "-device-globals" "--device-lib-dir={{.*}}" "-properties" "-spec-const=native" "-split=auto" "-emit-only-kernels-as-entry-points" "-emit-param-info" "-symbols" "-emit-exported-symbols" "-emit-imported-symbols" "-split-esimd" "-lower-esimd" "-O0"
77
//
88
// Generate .o file as linker wrapper input.
99
//

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -730,16 +730,12 @@ runSYCLPostLinkTool(ArrayRef<StringRef> InputFiles, const ArgList &Args) {
730730
const llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ));
731731
Arg *SYCLDeviceLibLoc = Args.getLastArg(OPT_sycl_device_library_location_EQ);
732732
if (SYCLDeviceLibLoc && !Triple.isSPIRAOT()) {
733-
std::string SYCLDeviceLibSPVLoc = SYCLDeviceLibLoc->getValue();
734-
llvm::Triple HostTriple(Args.getLastArgValue(OPT_host_triple_EQ));
735-
if (HostTriple.isOSWindows())
736-
SYCLDeviceLibSPVLoc += "../bin";
737-
738-
std::string AssertSPVLoc =
739-
SYCLDeviceLibSPVLoc + "/libsycl-fallback-cassert.spv";
740-
if (llvm::sys::fs::exists(AssertSPVLoc)) {
741-
SYCLDeviceLibSPVLoc = "--device-lib-spv-dir=" + SYCLDeviceLibSPVLoc;
742-
CmdArgs.push_back(Args.MakeArgString(StringRef(SYCLDeviceLibSPVLoc)));
733+
std::string SYCLDeviceLibLocParam = SYCLDeviceLibLoc->getValue();
734+
std::string AssertDeviceLibLoc =
735+
SYCLDeviceLibLocParam + "/libsycl-fallback-cassert.bc";
736+
if (llvm::sys::fs::exists(AssertDeviceLibLoc)) {
737+
SYCLDeviceLibLocParam = "--device-lib-dir=" + SYCLDeviceLibLocParam;
738+
CmdArgs.push_back(Args.MakeArgString(StringRef(SYCLDeviceLibLocParam)));
743739
}
744740
}
745741
getTripleBasedSYCLPostLinkOpts(Args, CmdArgs, Triple);

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ cl::opt<std::string> OutputDir{
104104
"Directory where files listed in the result file table will be output"),
105105
cl::value_desc("dirname"), cl::cat(PostLinkCat)};
106106

107+
cl::opt<std::string> DeviceLibDir{
108+
"device-lib-dir",
109+
cl::desc("Directory where sycl fallback device libraries reside"),
110+
cl::value_desc("dirname"), cl::cat(PostLinkCat)};
111+
107112
struct TargetFilenamePair {
108113
std::string Target;
109114
std::string Filename;

0 commit comments

Comments
 (0)