Skip to content

Commit 4463200

Browse files
authored
[Driver][SYCL] Deprecate -fsycl-fp32-prec-sqrt (#17257)
We have introduced a new set of options -foffload-fp32-prec-div and -foffload-fp32-prec-sqrt. The -foffload-fp32-prec-sqrt option provides the same functionality as -fsycl-fp32-prec-sqrt. Deprecate -fsycl-fp32-prec-sqrt, making it an alias for -foffload-fp32-prec-sqrt. Use of -fsycl-fp32-prec-sqrt will also emit a deprecation message: option '-fsycl-fp32-prec-sqrt' is deprecated and will be removed in a future release, use '-foffload-fp32-prec-sqrt' instead Upon updating this behavior, an existing deprecated option -fsycl-use-bitcode is also impacted and will emit the new diagnostic. Update the UserManual to reflect the replacement option for both -fsycl-fp32-prec-sqrt and -fsycl-use-bitcode.
1 parent 588205a commit 4463200

File tree

11 files changed

+50
-44
lines changed

11 files changed

+50
-44
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ CODEGENOPT(OpenCLCorrectlyRoundedDivSqrt, 1, 0) ///< -cl-fp32-correctly-rounded-
197197
CODEGENOPT(HIPCorrectlyRoundedDivSqrt, 1, 1) ///< -fno-hip-fp32-correctly-rounded-divide-sqrt
198198
CODEGENOPT(DisableBlockSignatureString, 1, 0) ///< Set when -fdisable-block-signature-string is enabled.
199199
CODEGENOPT(HIPSaveKernelArgName, 1, 0) ///< Set when -fhip-kernel-arg-name is enabled.
200-
CODEGENOPT(SYCLFp32PrecSqrt, 1, 0) ///< -fsycl-fp32-prec-sqrt
201200
CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get unique names.
202201
CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using profile information.
203202
CODEGENOPT(PPCUseFullRegisterNames, 1, 0) ///< Print full register names in assembly

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def warn_drv_object_size_disabled_O0 : Warning<
566566
def warn_drv_deprecated_option : Warning<
567567
"option '%0' is deprecated, use '%1' directly instead">, InGroup<Deprecated>;
568568
def warn_drv_deprecated_option_release : Warning<
569-
"option '%0' is deprecated and will be removed in a future release">,
569+
"option '%0' is deprecated and will be removed in a future release%select{|, use '%2' instead}1">,
570570
InGroup<Deprecated>;
571571
def warn_drv_deprecated_argument_option_release : Warning<
572572
"argument '%0' for option '%1' is deprecated and will be removed in a "

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6943,9 +6943,9 @@ def fsycl_device_lib_jit_link : Flag<["-"], "fsycl-device-lib-jit-link">,
69436943
def fno_sycl_device_lib_jit_link : Flag<["-"], "fno-sycl-device-lib-jit-link">,
69446944
HelpText<"Disables sycl device library jit link (experimental)">;
69456945
def fsycl_fp32_prec_sqrt : Flag<["-"], "fsycl-fp32-prec-sqrt">,
6946+
Alias<foffload_fp32_prec_sqrt>, Flags<[Deprecated]>,
69466947
Visibility<[ClangOption, CC1Option]>, HelpText<"SYCL only. Specify that "
6947-
"single precision floating-point sqrt is correctly rounded.">,
6948-
MarshallingInfoFlag<CodeGenOpts<"SYCLFp32PrecSqrt">>;
6948+
"single precision floating-point sqrt is correctly rounded. (deprecated)">;
69496949
def fsycl_default_sub_group_size
69506950
: Separate<["-"], "fsycl-default-sub-group-size">,
69516951
HelpText<"Set the default sub group size for SYCL kernels">,

clang/lib/Driver/Driver.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,16 @@ InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
360360
while (Used->getAlias())
361361
Used = Used->getAlias();
362362
if (Used->getOption().hasFlag(options::Deprecated)) {
363-
Diag(diag::warn_drv_deprecated_option_release) << Used->getAsString(Args);
363+
// Some deprecated options have a replacement option. In these cases,
364+
// add the replacement option string to the diagnostic.
365+
SmallString<128> AliasOpt;
366+
if (Used != A) {
367+
AliasOpt = A->getSpelling();
368+
if (A->getNumValues())
369+
AliasOpt += A->getValue();
370+
}
371+
Diag(diag::warn_drv_deprecated_option_release)
372+
<< Used->getAsString(Args) << !AliasOpt.empty() << AliasOpt;
364373
ContainsError |= Diags.getDiagnosticLevel(
365374
diag::warn_drv_deprecated_option_release,
366375
SourceLocation()) > DiagnosticsEngine::Warning;

clang/lib/Driver/ToolChains/AMDGPU.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,11 +1079,10 @@ ROCMToolChain::getCommonDeviceLibNames(
10791079
bool FastRelaxedMath = DriverArgs.hasFlag(options::OPT_ffast_math,
10801080
options::OPT_fno_fast_math, false);
10811081
bool CorrectSqrt = false;
1082-
if (DeviceOffloadingKind == Action::OFK_SYCL) {
1082+
if (DeviceOffloadingKind == Action::OFK_SYCL)
10831083
// When using SYCL, sqrt is only correctly rounded if the flag is specified
1084-
CorrectSqrt = DriverArgs.hasArg(options::OPT_fsycl_fp32_prec_sqrt) ||
1085-
DriverArgs.hasArg(options::OPT_foffload_fp32_prec_sqrt);
1086-
} else
1084+
CorrectSqrt = DriverArgs.hasArg(options::OPT_foffload_fp32_prec_sqrt);
1085+
else
10871086
CorrectSqrt = DriverArgs.hasFlag(
10881087
options::OPT_fhip_fp32_correctly_rounded_divide_sqrt,
10891088
options::OPT_fno_hip_fp32_correctly_rounded_divide_sqrt, true);

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,17 +3144,18 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31443144
CmdArgs.push_back(A->getValue());
31453145
}
31463146

3147-
auto addSPIRVArgs = [&](StringRef SPIRVArg) {
3147+
auto addSPIRVArgs = [&](const Arg *PrecArg) {
31483148
if (IsFp32PrecDivSqrtAllowed) {
3149+
OptSpecifier Opt(PrecArg->getOption().getID());
31493150
if (!FPAccuracy.empty())
3150-
EmitAccuracyDiag(D, JA, FPAccuracy, SPIRVArg);
3151-
if (SPIRVArg == "-fno-offload-fp32-prec-div")
3151+
EmitAccuracyDiag(D, JA, FPAccuracy, PrecArg->getSpelling());
3152+
if (Opt == options::OPT_fno_offload_fp32_prec_div)
31523153
NoOffloadFP32PrecDiv = true;
3153-
else if (SPIRVArg == "-fno-offload-fp32-prec-sqrt")
3154+
else if (Opt == options::OPT_fno_offload_fp32_prec_sqrt)
31543155
NoOffloadFP32PrecSqrt = true;
3155-
else if (SPIRVArg == "-foffload-fp32-prec-sqrt")
3156+
else if (Opt == options::OPT_foffload_fp32_prec_sqrt)
31563157
NoOffloadFP32PrecSqrt = false;
3157-
else if (SPIRVArg == "-foffload-fp32-prec-div")
3158+
else if (Opt == options::OPT_foffload_fp32_prec_div)
31583159
NoOffloadFP32PrecDiv = false;
31593160
}
31603161
};
@@ -3181,17 +3182,15 @@ static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
31813182
default: continue;
31823183

31833184
case options::OPT_foffload_fp32_prec_div:
3184-
addSPIRVArgs("-foffload-fp32-prec-div");
3185-
break;
31863185
case options::OPT_foffload_fp32_prec_sqrt:
3187-
addSPIRVArgs("-foffload-fp32-prec-sqrt");
3188-
break;
31893186
case options::OPT_fno_offload_fp32_prec_div:
3190-
addSPIRVArgs("-fno-offload-fp32-prec-div");
3191-
break;
31923187
case options::OPT_fno_offload_fp32_prec_sqrt:
3193-
addSPIRVArgs("-fno-offload-fp32-prec-sqrt");
3194-
break;
3188+
if (IsFp32PrecDivSqrtAllowed) {
3189+
addSPIRVArgs(A);
3190+
break;
3191+
}
3192+
// Skip claim, as we didn't use the option.
3193+
continue;
31953194
case options::OPT_fcx_limited_range:
31963195
if (GccRangeComplexOption.empty()) {
31973196
if (Range != LangOptions::ComplexRangeKind::CX_Basic)

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,7 @@ void CudaToolChain::addClangTargetOptions(
965965
if (DeviceOffloadingKind == Action::OFK_SYCL) {
966966
SYCLInstallation.addSYCLIncludeArgs(DriverArgs, CC1Args);
967967

968-
if (DriverArgs.hasArg(options::OPT_fsycl_fp32_prec_sqrt) ||
969-
DriverArgs.hasArg(options::OPT_foffload_fp32_prec_sqrt))
968+
if (DriverArgs.hasArg(options::OPT_foffload_fp32_prec_sqrt))
970969
CC1Args.push_back("-fcuda-prec-sqrt");
971970

972971
bool FastRelaxedMath = DriverArgs.hasFlag(

clang/test/Driver/sycl-deprecated.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
/// Test for any deprecated options
22
// RUN: %clangxx -fsycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-explicit-simd
33
// RUN: %clangxx -fno-sycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-explicit-simd
4-
// RUN: %clangxx -fsycl -fsycl-use-bitcode %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-use-bitcode
5-
// RUN: %clangxx -fsycl -fno-sycl-use-bitcode %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-use-bitcode
64
// RUN: %clangxx -fsycl -fsycl-allow-device-dependencies %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-allow-device-dependencies
75
// RUN: %clangxx -fsycl -fno-sycl-allow-device-dependencies %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-allow-device-dependencies
86
// CHECK: option '[[OPTION]]' is deprecated and will be removed in a future release
7+
8+
// RUN: %clangxx -fsycl -fsycl-use-bitcode %s -### 2>&1 \
9+
// RUN: | FileCheck %s --check-prefix=CHECK_REPLACE -DOPTION=-fsycl-use-bitcode -DOPTION_REPLACE=-fsycl-device-obj=llvmir
10+
// RUN: %clangxx -fsycl -fno-sycl-use-bitcode %s -### 2>&1 \
11+
// RUN: | FileCheck %s --check-prefix=CHECK_REPLACE -DOPTION=-fno-sycl-use-bitcode -DOPTION_REPLACE=-fsycl-device-obj=spirv
12+
// 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
13+
// CHECK_REPLACE: option '[[OPTION]]' is deprecated and will be removed in a future release, use '[[OPTION_REPLACE]]' instead

clang/test/Driver/sycl-no-prec-sqrt.cpp

Lines changed: 0 additions & 12 deletions
This file was deleted.

clang/test/Driver/sycl-specific-args-diagnostics.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,17 @@
8181
// RUN: %clang_cl -### -fsycl-force-inline-kernel-lambda %s 2>&1 \
8282
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-fsycl-force-inline-kernel-lambda %s
8383

84-
// Warning should be emitted when using -fsycl-fp32-prec-sqrt without -fsycl
85-
// RUN: %clang -### -fsycl-fp32-prec-sqrt %s 2>&1 \
86-
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-fsycl-fp32-prec-sqrt %s
87-
// RUN: %clang_cl -### -fsycl-fp32-prec-sqrt %s 2>&1 \
88-
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-fsycl-fp32-prec-sqrt %s
84+
// Warning should be emitted when using -foffload-fp32-prec-sqrt without -fsycl
85+
// RUN: %clang -### -foffload-fp32-prec-sqrt %s 2>&1 \
86+
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-foffload-fp32-prec-sqrt %s
87+
// RUN: %clang_cl -### -foffload-fp32-prec-sqrt %s 2>&1 \
88+
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-foffload-fp32-prec-sqrt %s
89+
90+
// Warning should be emitted when using -foffload-fp32-prec-div without -fsycl
91+
// RUN: %clang -### -foffload-fp32-prec-div %s 2>&1 \
92+
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-foffload-fp32-prec-div %s
93+
// RUN: %clang_cl -### -foffload-fp32-prec-div %s 2>&1 \
94+
// RUN: | FileCheck -check-prefix=WARNING-UNUSED-ARG -DOPT=-foffload-fp32-prec-div %s
8995

9096
// Warning should be emitted when using -fsycl-id-queries-fit-in-int without -fsycl
9197
// RUN: %clang -### -fsycl-id-queries-fit-in-int %s 2>&1 \

sycl/doc/UsersManual.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ and not recommended to use in production environment.
343343
Emit SYCL device code in LLVM-IR bitcode format. When disabled, SPIR-V is
344344
emitted.
345345
Enabled by default.
346+
This option is replaced with -fsycl-device-obj=<arg>.
346347

347348
**`-fsycl-device-obj=<arg>`** [EXPERIMENTAL]
348349

@@ -382,6 +383,7 @@ and not recommended to use in production environment.
382383
Enable use of correctly rounded `sycl::sqrt` function as defined by IEE754.
383384
Without this flag, the default precision requirement for `sycl::sqrt` is 3
384385
ULP.
386+
This option is replaced with -foffload-fp32-prec-sqrt.
385387

386388
NOTE: This flag is currently only supported with the CUDA and HIP targets.
387389

0 commit comments

Comments
 (0)