Skip to content

[Driver][SYCL] Improve deprecation messaging #6282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,9 @@ def warn_drv_object_size_disabled_O0 : Warning<
InGroup<InvalidCommandLineArgument>, DefaultWarnNoWerror;
def warn_drv_deprecated_option : Warning<
"option '%0' is deprecated, use '%1' directly instead">, InGroup<Deprecated>;
def warn_drv_deprecated_option_release : Warning<
"option '%0' is deprecated and will be removed in a future release">,
InGroup<Deprecated>;
def warn_ignoring_verify_debuginfo_preserve_export : Warning<
"ignoring -fverify-debuginfo-preserve-export=%0 because "
"-fverify-debuginfo-preserve wasn't enabled">,
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Driver/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum ClangFlags {
FlangOnlyOption = (1 << 16),
DXCOption = (1 << 17),
Ignored = (1 << 18),
Deprecated = (1 << 19),
};

enum ID {
Expand Down
24 changes: 18 additions & 6 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ def FlangOnlyOption : OptionFlag;
// FC1Option - This option should be accepted by flang -fc1.
def FC1Option : OptionFlag;

// Deprecated - The option is deprecated, but still supported. A
// diagnostic is emitted about the potential for the option to be removed
// in an upcoming release.
def Deprecated : OptionFlag;

// A short name to show in documentation. The name will be interpreted as rST.
class DocName<string name> { string DocName = name; }

Expand Down Expand Up @@ -2783,10 +2788,14 @@ def fsycl_device_only : Flag<["-"], "fsycl-device-only">, Flags<[CoreOption]>,
HelpText<"Compile SYCL kernels for device">;
def fsycl_targets_EQ : CommaJoined<["-"], "fsycl-targets=">, Flags<[NoXarchOption, CC1Option, CoreOption]>,
HelpText<"Specify comma-separated list of triples SYCL offloading targets to be supported">;
def fsycl_add_targets_EQ : CommaJoined<["-"], "fsycl-add-targets=">, Flags<[NoXarchOption, CoreOption]>,
HelpText<"Specify comma-separated list of triple and device binary image pairs to add to the final SYCL binary">;
def fsycl_link_targets_EQ : CommaJoined<["-"], "fsycl-link-targets=">, Flags<[NoXarchOption, CC1Option, CoreOption]>,
HelpText<"Specify comma-separated list of triples SYCL offloading targets to produce linked device images">;
def fsycl_add_targets_EQ : CommaJoined<["-"], "fsycl-add-targets=">,
Flags<[NoXarchOption, CoreOption, Deprecated]>,
HelpText<"Specify comma-separated list of triple and device binary image "
"pairs to add to the final SYCL binary (deprecated)">;
def fsycl_link_targets_EQ : CommaJoined<["-"], "fsycl-link-targets=">,
Flags<[NoXarchOption, CC1Option, CoreOption, Deprecated]>,
HelpText<"Specify comma-separated list of triples SYCL offloading targets "
"to produce linked device images (deprecated)">;
def fsycl_device_code_split_EQ : Joined<["-"], "fsycl-device-code-split=">,
Flags<[CC1Option, CoreOption]>, HelpText<"Perform SYCL device code split: per_kernel (device code module is "
"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). "
Expand Down Expand Up @@ -4894,9 +4903,12 @@ def fsycl : Flag<["-"], "fsycl">, Flags<[NoXarchOption, CoreOption]>, Group<sycl
def fno_sycl : Flag<["-"], "fno-sycl">, Flags<[NoXarchOption, CoreOption]>, Group<sycl_Group>,
HelpText<"Disables SYCL kernels compilation for device">;
// FIXME: -fsycl-explicit-simd is deprecated. remove it when support is dropped.
def : Flag<["-"], "fsycl-explicit-simd">, Flags<[CoreOption]>, Group<clang_ignored_legacy_options_Group>,
def : Flag<["-"], "fsycl-explicit-simd">, Flags<[CoreOption, Deprecated]>,
Group<clang_ignored_legacy_options_Group>,
HelpText<"Enable SYCL explicit SIMD extension. (deprecated)">;
def : Flag<["-"], "fno-sycl-explicit-simd">, Flags<[CoreOption]>, Group<clang_ignored_legacy_options_Group>,
def : Flag<["-"], "fno-sycl-explicit-simd">,
Flags<[CoreOption, Deprecated]>,
Group<clang_ignored_legacy_options_Group>,
HelpText<"Disable SYCL explicit SIMD extension. (deprecated)">;
defm sycl_early_optimizations : OptOutCC1FFlag<"sycl-early-optimizations", "Enable", "Disable", " standard optimization pipeline for SYCL device compiler", [CoreOption]>;
def fsycl_dead_args_optimization : Flag<["-"], "fsycl-dead-args-optimization">,
Expand Down
9 changes: 9 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,15 @@ InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
continue;
}

// Deprecated options emit a diagnostic about deprecation, but are still
// supported until removed.
if (A->getOption().hasFlag(options::Deprecated)) {
Diag(diag::warn_drv_deprecated_option_release) << A->getAsString(Args);
ContainsError |= Diags.getDiagnosticLevel(
diag::warn_drv_deprecated_option_release,
SourceLocation()) > DiagnosticsEngine::Warning;
}

// Warn about -mcpu= without an argument.
if (A->getOption().matches(options::OPT_mcpu_EQ) && A->containsValue("")) {
Diag(diag::warn_drv_empty_joined_argument) << A->getAsString(Args);
Expand Down
4 changes: 4 additions & 0 deletions clang/test/Driver/sycl-deprecated.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// Test for any deprecated options
// RUN: %clangxx -fsycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fsycl-explicit-simd
// RUN: %clangxx -fno-sycl-explicit-simd %s -### 2>&1 | FileCheck %s -DOPTION=-fno-sycl-explicit-simd
// CHECK: option '[[OPTION]]' is deprecated and will be removed in a future release