Skip to content

Commit

Permalink
[SYCL][Driver] Fix suggested target triple in the warning message (#4475
Browse files Browse the repository at this point in the history
)

The warning message emitted for deprecated target triple includes
suggested target triple to be used instead of deprecated one. Currently
it prints only architecture component of the target triple, which works
only for SPIR target architecture. Non-SPIR targets may support multiple
vendor/OS components, so users are expected to specify the full triple.
This patch fixes the warning message and suggests all components set
before deprecated `sycldevice` environment component if they are not
"unknown" (which is default and can be omitted).
  • Loading branch information
bader authored Sep 7, 2021
1 parent 26184e2 commit 7cc89fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,8 +925,17 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,

// Warn about deprecated `sycldevice` environment component.
if (TT.getEnvironmentName() == "sycldevice") {
// Build a string with suggested target triple.
std::string SuggestedTriple = TT.getArchName().str();
if (TT.getOS() != llvm::Triple::UnknownOS) {
SuggestedTriple += '-';
if (TT.getVendor() != llvm::Triple::UnknownVendor)
SuggestedTriple += TT.getVendorName();
SuggestedTriple += Twine("-" + TT.getOSName()).str();
} else if (TT.getVendor() != llvm::Triple::UnknownVendor)
SuggestedTriple += Twine("-" + TT.getVendorName()).str();
Diag(clang::diag::warn_drv_deprecated_arg)
<< TT.str() << TT.getArchName();
<< TT.str() << SuggestedTriple;
// Drop environment component.
std::string EffectiveTriple =
Twine(TT.getArchName() + "-" + TT.getVendorName() + "-" +
Expand Down
3 changes: 2 additions & 1 deletion clang/test/Driver/sycl.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
// DISABLED-NOT: "-sycl-std={{.*}}"
// DISABLED-NOT: "-fsycl-std-layout-kernel-params"

// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice -c %s 2>&1 | FileCheck %s --check-prefix=CHECK_WARNING
// RUN: %clangxx -fsycl -fsycl-targets=spir64-unknown-unknown-sycldevice,nvptx64-nvidia-cuda-sycldevice -fno-sycl-libspirv -nocudalib -c %s 2>&1 | FileCheck %s --check-prefix=CHECK_WARNING
// CHECK_WARNING: argument 'spir64-unknown-unknown-sycldevice' is deprecated, use 'spir64' instead
// CHECK_WARNING: argument 'nvptx64-nvidia-cuda-sycldevice' is deprecated, use 'nvptx64-nvidia-cuda' instead

// RUN: %clang -### -fsycl-device-only -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
// RUN: %clang -### -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
Expand Down

0 comments on commit 7cc89fa

Please sign in to comment.