Skip to content

Commit 88ca2c1

Browse files
committed
[SYCL] Remove deprecated sycl device library driver options
Signed-off-by: jinge90 <[email protected]>
1 parent 0a6e6d1 commit 88ca2c1

35 files changed

+35
-836
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7268,23 +7268,6 @@ def fsycl_dead_args_optimization : Flag<["-"], "fsycl-dead-args-optimization">,
72687268
HelpText<"Enables elimination of DPC++ dead kernel arguments">;
72697269
def fno_sycl_dead_args_optimization : Flag<["-"], "fno-sycl-dead-args-optimization">,
72707270
HelpText<"Disables elimination of DPC++ dead kernel arguments">;
7271-
def fsycl_device_lib_EQ : CommaJoined<["-"], "fsycl-device-lib=">,
7272-
Flags<[Deprecated]>,
7273-
Values<"libc,libm-fp32,libm-fp64,libimf-fp32,libimf-fp64,libimf-bf16,all">,
7274-
HelpText<"Control inclusion of device libraries into device binary linkage. "
7275-
"Valid arguments are libc, libm-fp32, libm-fp64, libimf-fp32, "
7276-
"libimf-fp64, libimf-bf16, all. (deprecated)">;
7277-
def fno_sycl_device_lib_EQ : CommaJoined<["-"], "fno-sycl-device-lib=">,
7278-
Flags<[Deprecated]>,
7279-
Values<"libc, libm-fp32, libm-fp64, all">,
7280-
HelpText<"Control exclusion of device libraries from device binary linkage. "
7281-
"Valid arguments are libc, libm-fp32, libm-fp64, all. (deprecated)">;
7282-
def fsycl_device_lib_jit_link : Flag<["-"], "fsycl-device-lib-jit-link">,
7283-
Flags<[Deprecated]>,
7284-
HelpText<"Enables sycl device library jit link. (deprecated)">;
7285-
def fno_sycl_device_lib_jit_link : Flag<["-"], "fno-sycl-device-lib-jit-link">,
7286-
Flags<[Deprecated]>,
7287-
HelpText<"Disables sycl device library jit link. (deprecated)">;
72887271
def fsycl_fp32_prec_sqrt : Flag<["-"], "fsycl-fp32-prec-sqrt">,
72897272
Alias<foffload_fp32_prec_sqrt>, Flags<[Deprecated]>,
72907273
Visibility<[ClangOption, CC1Option]>, HelpText<"SYCL only. Specify that "

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5496,13 +5496,8 @@ class OffloadingActionBuilder final {
54965496
bool SYCLDeviceLibLinked = false;
54975497
Action *NativeCPULib = nullptr;
54985498
if (IsSPIR || IsNVPTX || IsAMDGCN || IsNativeCPU) {
5499-
bool UseJitLink =
5500-
IsSPIR &&
5501-
Args.hasFlag(options::OPT_fsycl_device_lib_jit_link,
5502-
options::OPT_fno_sycl_device_lib_jit_link, false);
5503-
bool UseAOTLink = IsSPIR && (IsSpirvAOT || !UseJitLink);
55045499
SYCLDeviceLibLinked = addSYCLDeviceLibs(
5505-
TC, SYCLDeviceLibs, UseAOTLink,
5500+
TC, SYCLDeviceLibs, IsSpirvAOT,
55065501
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment(),
55075502
IsNativeCPU, NativeCPULib, BoundArch);
55085503
}

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11282,14 +11282,8 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
1128211282
if (TC->getTriple().isSPIROrSPIRV() || TC->getTriple().isNVPTX()) {
1128311283
TargetTriple = TC->getTriple();
1128411284
SmallVector<std::string, 8> SYCLDeviceLibs;
11285-
bool IsSPIR = TargetTriple.isSPIROrSPIRV();
1128611285
bool IsSpirvAOT = TargetTriple.isSPIRAOT();
11287-
bool UseJitLink =
11288-
IsSPIR &&
11289-
Args.hasFlag(options::OPT_fsycl_device_lib_jit_link,
11290-
options::OPT_fno_sycl_device_lib_jit_link, false);
11291-
bool UseAOTLink = IsSPIR && (IsSpirvAOT || !UseJitLink);
11292-
SYCLDeviceLibs = SYCL::getDeviceLibraries(C, TargetTriple, UseAOTLink);
11286+
SYCLDeviceLibs = SYCL::getDeviceLibraries(C, TargetTriple, IsSpirvAOT);
1129311287
for (const auto &AddLib : SYCLDeviceLibs) {
1129411288
if (LibList.size() > 0)
1129511289
LibList += ",";

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 0 additions & 190 deletions
Original file line numberDiff line numberDiff line change
@@ -561,202 +561,12 @@ 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.
567-
// TODO: remove getDeviceLibrariesLegacy when we remove deprecated options
568-
// related to sycl device library link.
569-
static SmallVector<std::string, 8>
570-
getDeviceLibrariesLegacy(const Compilation &C, const llvm::Triple &TargetTriple,
571-
bool IsSpirvAOT) {
572-
SmallVector<std::string, 8> LibraryList;
573-
const llvm::opt::ArgList &Args = C.getArgs();
574-
575-
// For NVPTX and AMDGCN we only use one single bitcode library and ignore
576-
// manually specified SYCL device libraries.
577-
// For NativeCPU, only native_utils devicelib is used.
578-
bool UseSingleLib = TargetTriple.isNVPTX() || TargetTriple.isAMDGCN() ||
579-
TargetTriple.isNativeCPU();
580-
bool IgnoreSingleLib = false;
581-
582-
struct DeviceLibOptInfo {
583-
StringRef DeviceLibName;
584-
StringRef DeviceLibOption;
585-
};
586-
587-
enum { JIT = 0, AOT_CPU, AOT_DG2, AOT_PVC };
588-
589-
// Currently, all SYCL device libraries will be linked by default.
590-
llvm::StringMap<bool> DeviceLibLinkInfo = {
591-
{"libc", true}, {"libm-fp32", true}, {"libm-fp64", true},
592-
{"libimf-fp32", true}, {"libimf-fp64", true}, {"libimf-bf16", true},
593-
{"libm-bfloat16", true}, {"internal", true}};
594-
595-
// If -fno-sycl-device-lib is specified, its values will be used to exclude
596-
// linkage of libraries specified by DeviceLibLinkInfo. Linkage of "internal"
597-
// libraries cannot be affected via -fno-sycl-device-lib.
598-
bool ExcludeDeviceLibs = false;
599-
600-
if (Arg *A = Args.getLastArg(options::OPT_fsycl_device_lib_EQ,
601-
options::OPT_fno_sycl_device_lib_EQ)) {
602-
if (A->getValues().size() == 0)
603-
C.getDriver().Diag(diag::warn_drv_empty_joined_argument)
604-
<< A->getAsString(Args);
605-
else {
606-
if (A->getOption().matches(options::OPT_fno_sycl_device_lib_EQ))
607-
ExcludeDeviceLibs = true;
608-
609-
// When single libraries are ignored and a subset of library names
610-
// not containing the value "all" is specified by -fno-sycl-device-lib,
611-
// print an unused argument warning.
612-
bool PrintUnusedExcludeWarning = false;
613-
614-
for (StringRef Val : A->getValues()) {
615-
if (Val == "all") {
616-
PrintUnusedExcludeWarning = false;
617-
618-
// Make sure that internal libraries are still linked against
619-
// when -fno-sycl-device-lib contains "all" and single libraries
620-
// should be ignored. For NativeCPU, the native_cpu utils library
621-
// is always linked without '-only-needed' flag.
622-
IgnoreSingleLib =
623-
UseSingleLib && ExcludeDeviceLibs && !TargetTriple.isNativeCPU();
624-
625-
for (const auto &K : DeviceLibLinkInfo.keys())
626-
DeviceLibLinkInfo[K] = (K == "internal") || !ExcludeDeviceLibs;
627-
break;
628-
}
629-
auto LinkInfoIter = DeviceLibLinkInfo.find(Val);
630-
if (LinkInfoIter == DeviceLibLinkInfo.end() || Val == "internal") {
631-
// TODO: Move the diagnostic to the SYCL section of
632-
// Driver::CreateOffloadingDeviceToolChains() to minimize code
633-
// duplication.
634-
C.getDriver().Diag(diag::err_drv_unsupported_option_argument)
635-
<< A->getSpelling() << Val;
636-
}
637-
DeviceLibLinkInfo[Val] = !ExcludeDeviceLibs;
638-
PrintUnusedExcludeWarning = UseSingleLib && ExcludeDeviceLibs;
639-
}
640-
if (PrintUnusedExcludeWarning)
641-
C.getDriver().Diag(diag::warn_drv_unused_argument) << A->getSpelling();
642-
}
643-
}
644-
645-
if (TargetTriple.isNVPTX() && !IgnoreSingleLib)
646-
LibraryList.push_back(
647-
Args.MakeArgString("devicelib-nvptx64-nvidia-cuda.bc"));
648-
649-
if (TargetTriple.isAMDGCN() && !IgnoreSingleLib)
650-
LibraryList.push_back(Args.MakeArgString("devicelib-amdgcn-amd-amdhsa.bc"));
651-
652-
if (TargetTriple.isNativeCPU() && !IgnoreSingleLib)
653-
LibraryList.push_back(Args.MakeArgString("libsycl-nativecpu_utils.bc"));
654-
655-
if (UseSingleLib)
656-
return LibraryList;
657-
658-
using SYCLDeviceLibsList = SmallVector<DeviceLibOptInfo, 5>;
659-
660-
const SYCLDeviceLibsList SYCLDeviceWrapperLibs = {
661-
{"libsycl-crt", "libc"},
662-
{"libsycl-complex", "libm-fp32"},
663-
{"libsycl-complex-fp64", "libm-fp64"},
664-
{"libsycl-cmath", "libm-fp32"},
665-
{"libsycl-cmath-fp64", "libm-fp64"},
666-
#if defined(_WIN32)
667-
{"libsycl-msvc-math", "libm-fp32"},
668-
#endif
669-
{"libsycl-imf", "libimf-fp32"},
670-
{"libsycl-imf-fp64", "libimf-fp64"},
671-
{"libsycl-imf-bf16", "libimf-bf16"}};
672-
// For AOT compilation, we need to link sycl_device_fallback_libs as
673-
// default too.
674-
const SYCLDeviceLibsList SYCLDeviceFallbackLibs = {
675-
{"libsycl-fallback-cassert", "libc"},
676-
{"libsycl-fallback-cstring", "libc"},
677-
{"libsycl-fallback-complex", "libm-fp32"},
678-
{"libsycl-fallback-complex-fp64", "libm-fp64"},
679-
{"libsycl-fallback-cmath", "libm-fp32"},
680-
{"libsycl-fallback-cmath-fp64", "libm-fp64"},
681-
{"libsycl-fallback-imf", "libimf-fp32"},
682-
{"libsycl-fallback-imf-fp64", "libimf-fp64"},
683-
{"libsycl-fallback-imf-bf16", "libimf-bf16"}};
684-
const SYCLDeviceLibsList SYCLDeviceBfloat16FallbackLib = {
685-
{"libsycl-fallback-bfloat16", "libm-bfloat16"}};
686-
const SYCLDeviceLibsList SYCLDeviceBfloat16NativeLib = {
687-
{"libsycl-native-bfloat16", "libm-bfloat16"}};
688-
// ITT annotation libraries are linked in separately whenever the device
689-
// code instrumentation is enabled.
690-
const SYCLDeviceLibsList SYCLDeviceAnnotationLibs = {
691-
{"libsycl-itt-user-wrappers", "internal"},
692-
{"libsycl-itt-compiler-wrappers", "internal"},
693-
{"libsycl-itt-stubs", "internal"}};
694-
const SYCLDeviceLibsList SYCLNativeCpuDeviceLibs = {
695-
{"libsycl-nativecpu_utils", "internal"}};
696-
697-
bool IsWindowsMSVCEnv =
698-
C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment();
699-
bool IsNewOffload = C.getDriver().getUseNewOffloadingDriver();
700-
StringRef LibSuffix = ".bc";
701-
if (IsNewOffload)
702-
// For new offload model, we use packaged .bc files.
703-
LibSuffix = IsWindowsMSVCEnv ? ".new.obj" : ".new.o";
704-
auto addLibraries = [&](const SYCLDeviceLibsList &LibsList) {
705-
for (const DeviceLibOptInfo &Lib : LibsList) {
706-
if (!DeviceLibLinkInfo[Lib.DeviceLibOption])
707-
continue;
708-
SmallString<128> LibName(Lib.DeviceLibName);
709-
llvm::sys::path::replace_extension(LibName, LibSuffix);
710-
LibraryList.push_back(Args.MakeArgString(LibName));
711-
}
712-
};
713-
714-
addLibraries(SYCLDeviceWrapperLibs);
715-
if (IsSpirvAOT)
716-
addLibraries(SYCLDeviceFallbackLibs);
717-
718-
bool NativeBfloatLibs;
719-
bool NeedBfloatLibs = selectBfloatLibs(TargetTriple, C, NativeBfloatLibs);
720-
if (NeedBfloatLibs) {
721-
// Add native or fallback bfloat16 library.
722-
if (NativeBfloatLibs)
723-
addLibraries(SYCLDeviceBfloat16NativeLib);
724-
else
725-
addLibraries(SYCLDeviceBfloat16FallbackLib);
726-
}
727-
728-
// Link in ITT annotations library unless fsycl-no-instrument-device-code
729-
// is specified. This ensures that we are ABI-compatible with the
730-
// instrumented device code, which was the default not so long ago.
731-
if (Args.hasFlag(options::OPT_fsycl_instrument_device_code,
732-
options::OPT_fno_sycl_instrument_device_code, true))
733-
addLibraries(SYCLDeviceAnnotationLibs);
734-
735-
// Currently, device sanitizer support is required by some developers on
736-
// Linux platform only, so compiler only provides device sanitizer libraries
737-
// on Linux platform.
738-
#if !defined(_WIN32)
739-
addSYCLDeviceSanitizerLibs(C, IsSpirvAOT, LibSuffix, LibraryList);
740-
#endif
741-
742-
if (TargetTriple.isNativeCPU())
743-
addLibraries(SYCLNativeCpuDeviceLibs);
744-
745-
return LibraryList;
746-
}
747-
748564
// Get the list of SYCL device libraries to link with user's device image.
749565
SmallVector<std::string, 8>
750566
SYCL::getDeviceLibraries(const Compilation &C, const llvm::Triple &TargetTriple,
751567
bool IsSpirvAOT) {
752568
SmallVector<std::string, 8> LibraryList;
753569
const llvm::opt::ArgList &Args = C.getArgs();
754-
if (Args.getLastArg(options::OPT_fsycl_device_lib_EQ,
755-
options::OPT_fno_sycl_device_lib_EQ) ||
756-
Args.getLastArg(options::OPT_fsycl_device_lib_jit_link,
757-
options::OPT_fno_sycl_device_lib_jit_link))
758-
return getDeviceLibrariesLegacy(C, TargetTriple, IsSpirvAOT);
759-
760570
bool NoOffloadLib =
761571
!Args.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib, true);
762572
if (TargetTriple.isNVPTX()) {

clang/test/Driver/sycl-deprecated.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,3 @@
1212
// RUN: %clangxx -fsycl -fsycl-fp32-prec-sqrt %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_REPLACE -DOPTION=-fsycl-fp32-prec-sqrt -DOPTION_REPLACE=-foffload-fp32-prec-sqrt
1313
// RUN: %clangxx -fsycl -fsycl-dump-device-code=/path/to/spv/ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK_REPLACE -DOPTION=-fsycl-dump-device-code=/path/to/spv/ -DOPTION_REPLACE=-save-offload-code=/path/to/spv/
1414
// CHECK_REPLACE: option '[[OPTION]]' is deprecated and will be removed in a future release, use '[[OPTION_REPLACE]]' instead
15-
16-
// RUN: %clangxx -fsycl -fsycl-device-lib-jit-link %s -### 2>&1 \
17-
// RUN: | FileCheck %s --check-prefix=CHECK -DOPTION=-fsycl-device-lib-jit-link
18-
// RUN: %clangxx -fsycl -fsycl-device-lib=libc %s -### 2>&1 \
19-
// RUN: | FileCheck %s --check-prefix=CHECK -DOPTION=-fsycl-device-lib=libc
20-
// RUN: %clangxx -fsycl -fno-sycl-device-lib=libc %s -### 2>&1 \
21-
// RUN: | FileCheck %s --check-prefix=CHECK -DOPTION=-fno-sycl-device-lib=libc
22-

clang/test/Driver/sycl-device-lib-amdgcn.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@
44

55
// UNSUPPORTED: system-windows
66

7-
// Check that the -fsycl-device-lib flag has no effect when "all" is specified.
8-
// RUN: %clangxx -ccc-print-phases -std=c++11 -fsycl -fsycl-device-lib=all --sysroot=%S/Inputs/SYCL \
9-
// RUN: -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx906 %s 2>&1 \
10-
// RUN: | FileCheck -check-prefix=CHK-ALL %s
11-
12-
// Check that the -fsycl-device-lib flag has no effect when subsets of libs
13-
// are specified.
14-
// RUN: %clangxx -ccc-print-phases -std=c++11 --sysroot=%S/Inputs/SYCL \
15-
// RUN: -fsycl -fsycl-device-lib=libc,libm-fp32,libm-fp64,libimf-fp32,libimf-fp64,libimf-bf16,libm-bfloat16 \
16-
// RUN: -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=gfx906 %s 2>&1 \
17-
// RUN: | FileCheck -check-prefix=CHK-ALL %s
18-
197
// Check that -fno-sycl-device-lib is ignored when it does not contain "all".
208
// A warning should be printed that the flag got ignored.
219
// RUN: %clangxx -ccc-print-phases -std=c++11 -fsycl --sysroot=%S/Inputs/SYCL \

clang/test/Driver/sycl-device-lib-nvptx.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@
44

55
// UNSUPPORTED: system-windows
66

7-
// Check that the -fsycl-device-lib flag has no effect when "all" is specified.
8-
// RUN: %clangxx -ccc-print-phases -std=c++11 -fsycl -fsycl-device-lib=all --sysroot=%S/Inputs/SYCL \
9-
// RUN: -fsycl-targets=nvptx64-nvidia-cuda %s 2>&1 \
10-
// RUN: | FileCheck -check-prefix=CHK-ALL %s
11-
12-
// Check that the -fsycl-device-lib flag has no effect when subsets of libs
13-
// are specified.
14-
// RUN: %clangxx -ccc-print-phases -std=c++11 --sysroot=%S/Inputs/SYCL \
15-
// RUN: -fsycl -fsycl-device-lib=libc,libm-fp32,libm-fp64,libimf-fp32,libimf-fp64,libimf-bf16,libm-bfloat16 \
16-
// RUN: -fsycl-targets=nvptx64-nvidia-cuda %s 2>&1 \
17-
// RUN: | FileCheck -check-prefix=CHK-ALL %s
18-
197
// Check that -fno-sycl-device-lib is ignored when it does not contain "all".
208
// A warning should be printed that the flag got ignored.
219
// RUN: %clangxx -ccc-print-phases -std=c++11 -fsycl --sysroot=%S/Inputs/SYCL \

0 commit comments

Comments
 (0)