Skip to content

Commit f0b65a1

Browse files
authored
[Driver][SYCL] Improve deprecation messaging (#6282)
Certain options are deprecated and will be removed in a future release timeframe. Mark such options as deprecated so they emit a diagnostic stating as such. This was done by adding an additional option flag which can be applied to any option that is deprecated.
1 parent 8ae8bf2 commit f0b65a1

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ def warn_drv_object_size_disabled_O0 : Warning<
454454
InGroup<InvalidCommandLineArgument>, DefaultWarnNoWerror;
455455
def warn_drv_deprecated_option : Warning<
456456
"option '%0' is deprecated, use '%1' directly instead">, InGroup<Deprecated>;
457+
def warn_drv_deprecated_option_release : Warning<
458+
"option '%0' is deprecated and will be removed in a future release">,
459+
InGroup<Deprecated>;
457460
def warn_ignoring_verify_debuginfo_preserve_export : Warning<
458461
"ignoring -fverify-debuginfo-preserve-export=%0 because "
459462
"-fverify-debuginfo-preserve wasn't enabled">,

clang/include/clang/Driver/Options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ enum ClangFlags {
3737
FlangOnlyOption = (1 << 16),
3838
DXCOption = (1 << 17),
3939
Ignored = (1 << 18),
40+
Deprecated = (1 << 19),
4041
};
4142

4243
enum ID {

clang/include/clang/Driver/Options.td

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ def FlangOnlyOption : OptionFlag;
7171
// FC1Option - This option should be accepted by flang -fc1.
7272
def FC1Option : OptionFlag;
7373

74+
// Deprecated - The option is deprecated, but still supported. A
75+
// diagnostic is emitted about the potential for the option to be removed
76+
// in an upcoming release.
77+
def Deprecated : OptionFlag;
78+
7479
// A short name to show in documentation. The name will be interpreted as rST.
7580
class DocName<string name> { string DocName = name; }
7681

@@ -2783,10 +2788,14 @@ def fsycl_device_only : Flag<["-"], "fsycl-device-only">, Flags<[CoreOption]>,
27832788
HelpText<"Compile SYCL kernels for device">;
27842789
def fsycl_targets_EQ : CommaJoined<["-"], "fsycl-targets=">, Flags<[NoXarchOption, CC1Option, CoreOption]>,
27852790
HelpText<"Specify comma-separated list of triples SYCL offloading targets to be supported">;
2786-
def fsycl_add_targets_EQ : CommaJoined<["-"], "fsycl-add-targets=">, Flags<[NoXarchOption, CoreOption]>,
2787-
HelpText<"Specify comma-separated list of triple and device binary image pairs to add to the final SYCL binary">;
2788-
def fsycl_link_targets_EQ : CommaJoined<["-"], "fsycl-link-targets=">, Flags<[NoXarchOption, CC1Option, CoreOption]>,
2789-
HelpText<"Specify comma-separated list of triples SYCL offloading targets to produce linked device images">;
2791+
def fsycl_add_targets_EQ : CommaJoined<["-"], "fsycl-add-targets=">,
2792+
Flags<[NoXarchOption, CoreOption, Deprecated]>,
2793+
HelpText<"Specify comma-separated list of triple and device binary image "
2794+
"pairs to add to the final SYCL binary (deprecated)">;
2795+
def fsycl_link_targets_EQ : CommaJoined<["-"], "fsycl-link-targets=">,
2796+
Flags<[NoXarchOption, CC1Option, CoreOption, Deprecated]>,
2797+
HelpText<"Specify comma-separated list of triples SYCL offloading targets "
2798+
"to produce linked device images (deprecated)">;
27902799
def fsycl_device_code_split_EQ : Joined<["-"], "fsycl-device-code-split=">,
27912800
Flags<[CC1Option, CoreOption]>, HelpText<"Perform SYCL device code split: per_kernel (device code module is "
27922801
"created for each SYCL kernel) | per_source (device code module is created for each source (translation unit)) | off (no device code split). | auto (use heuristic to select the best way of splitting device code). "
@@ -4894,9 +4903,12 @@ def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, Group<sycl
48944903
def fno_sycl : Flag<["-"], "fno-sycl">, Flags<[NoXarchOption, CoreOption]>, Group<sycl_Group>,
48954904
HelpText<"Disables SYCL kernels compilation for device">;
48964905
// FIXME: -fsycl-explicit-simd is deprecated. remove it when support is dropped.
4897-
def : Flag<["-"], "fsycl-explicit-simd">, Flags<[CoreOption]>, Group<clang_ignored_legacy_options_Group>,
4906+
def : Flag<["-"], "fsycl-explicit-simd">, Flags<[CoreOption, Deprecated]>,
4907+
Group<clang_ignored_legacy_options_Group>,
48984908
HelpText<"Enable SYCL explicit SIMD extension. (deprecated)">;
4899-
def : Flag<["-"], "fno-sycl-explicit-simd">, Flags<[CoreOption]>, Group<clang_ignored_legacy_options_Group>,
4909+
def : Flag<["-"], "fno-sycl-explicit-simd">,
4910+
Flags<[CoreOption, Deprecated]>,
4911+
Group<clang_ignored_legacy_options_Group>,
49004912
HelpText<"Disable SYCL explicit SIMD extension. (deprecated)">;
49014913
defm sycl_early_optimizations : OptOutCC1FFlag<"sycl-early-optimizations", "Enable", "Disable", " standard optimization pipeline for SYCL device compiler", [CoreOption]>;
49024914
def fsycl_dead_args_optimization : Flag<["-"], "fsycl-dead-args-optimization">,

clang/lib/Driver/Driver.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,15 @@ InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
293293
continue;
294294
}
295295

296+
// Deprecated options emit a diagnostic about deprecation, but are still
297+
// supported until removed.
298+
if (A->getOption().hasFlag(options::Deprecated)) {
299+
Diag(diag::warn_drv_deprecated_option_release) << A->getAsString(Args);
300+
ContainsError |= Diags.getDiagnosticLevel(
301+
diag::warn_drv_deprecated_option_release,
302+
SourceLocation()) > DiagnosticsEngine::Warning;
303+
}
304+
296305
// Warn about -mcpu= without an argument.
297306
if (A->getOption().matches(options::OPT_mcpu_EQ) && A->containsValue("")) {
298307
Diag(diag::warn_drv_empty_joined_argument) << A->getAsString(Args);

clang/test/Driver/sycl-deprecated.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// Test for any deprecated options
2+
// RUN: %clangxx -fsycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-explicit-simd
3+
// RUN: %clangxx -fno-sycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-explicit-simd
4+
// CHECK: option '[[OPTION]]' is deprecated and will be removed in a future release

0 commit comments

Comments
 (0)