Skip to content

Commit 8d49f7e

Browse files
committed
Remove unnecessary string copy
Signed-off-by: jinge90 <[email protected]>
1 parent 9c0ce3f commit 8d49f7e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,9 @@ addSYCLDeviceSanitizerLibs(const Compilation &C, bool IsSpirvAOT,
561561
}
562562
#endif
563563

564+
// Get the list of SYCL device libraries to link with user's device image if
565+
// some deprecated options are used including: -f[no-]sycl-device-lib=xxx,
566+
// -f[no-]sycl-device-lib-jit-link.
564567
// TODO: remove getDeviceLibrariesLegacy when we remove deprecated options
565568
// related to sycl device library link.
566569
static SmallVector<std::string, 8>
@@ -742,6 +745,7 @@ getDeviceLibrariesLegacy(const Compilation &C, const llvm::Triple &TargetTriple,
742745
return LibraryList;
743746
}
744747

748+
// Get the list of SYCL device libraries to link with user's device image.
745749
SmallVector<std::string, 8>
746750
SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
747751
bool IsSpirvAOT) {
@@ -776,7 +780,7 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
776780
return LibraryList;
777781
}
778782

779-
using SYCLDeviceLibsList = SmallVector<StringRef, 8>;
783+
using SYCLDeviceLibsList = SmallVector<StringRef>;
780784
const SYCLDeviceLibsList SYCLDeviceLibs = {"libsycl-crt",
781785
"libsycl-complex",
782786
"libsycl-complex-fp64",
@@ -806,9 +810,7 @@ SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
806810
LibSuffix = IsWindowsMSVCEnv ? ".new.obj" : ".new.o";
807811
auto addLibraries = [&](const SYCLDeviceLibsList &LibsList) {
808812
for (const StringRef &Lib : LibsList) {
809-
SmallString<128> LibName(Lib);
810-
llvm::sys::path::replace_extension(LibName, LibSuffix);
811-
LibraryList.push_back(Args.MakeArgString(LibName));
813+
LibraryList.push_back(Args.MakeArgString(Twine(Lib) + LibSuffix));
812814
}
813815
};
814816

0 commit comments

Comments
 (0)