Skip to content

Commit 9587467

Browse files
authored
[Driver][SYCL] Fix issue with using deprecated sycldevice triple (#6877)
The changes to introduce the intel_gpu_* target support inadvertently broke the steps that do a cleanout of any use of the sycldevice environment setting in a user provided triple. Fix this issue, and introduce a test which tests for this functionality.
1 parent 6c253a7 commit 9587467

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,14 +1108,13 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
11081108
UserTargetName = "spir64_gen";
11091109
}
11101110

1111-
llvm::Triple TT(MakeSYCLDeviceTriple(Val));
11121111
if (!isValidSYCLTriple(MakeSYCLDeviceTriple(UserTargetName))) {
11131112
Diag(clang::diag::err_drv_invalid_sycl_target) << Val;
11141113
continue;
11151114
}
1116-
std::string NormalizedName = TT.normalize();
11171115

11181116
// Make sure we don't have a duplicate triple.
1117+
std::string NormalizedName = MakeSYCLDeviceTriple(Val).normalize();
11191118
auto Duplicate = FoundNormalizedTriples.find(NormalizedName);
11201119
if (Duplicate != FoundNormalizedTriples.end()) {
11211120
Diag(clang::diag::warn_drv_sycl_offload_target_duplicate)
@@ -1124,6 +1123,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
11241123
}
11251124

11261125
// Warn about deprecated `sycldevice` environment component.
1126+
llvm::Triple TT(MakeSYCLDeviceTriple(UserTargetName));
11271127
if (TT.getEnvironmentName() == "sycldevice") {
11281128
// Build a string with suggested target triple.
11291129
std::string SuggestedTriple = TT.getArchName().str();
@@ -1147,7 +1147,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
11471147
// Store the current triple so that we can check for duplicates in
11481148
// the following iterations.
11491149
FoundNormalizedTriples[NormalizedName] = Val;
1150-
UniqueSYCLTriplesVec.push_back(MakeSYCLDeviceTriple(UserTargetName));
1150+
UniqueSYCLTriplesVec.push_back(TT);
11511151
}
11521152
addSYCLDefaultTriple(C, UniqueSYCLTriplesVec);
11531153
} else

clang/test/Driver/sycl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
// DISABLED-NOT: "-sycl-std={{.*}}"
2929
// DISABLED-NOT: "-fsycl-std-layout-kernel-params"
3030

31-
// RUN: %clangxx -target x86_64-unknown-linux-gnu -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
31+
// RUN: %clangxx -target x86_64-unknown-linux-gnu -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
3232
// CHECK_WARNING: argument 'spir64-unknown-unknown-sycldevice' is deprecated, use 'spir64' instead
3333
// CHECK_WARNING: argument 'nvptx64-nvidia-cuda-sycldevice' is deprecated, use 'nvptx64-nvidia-cuda' instead
34+
// CHECK_WARNING: clang{{.*}} "-triple" "spir64-unknown-unknown"
35+
// CHECK_WARNING: clang{{.*}} "-triple" "nvptx64-nvidia-cuda"
3436

3537
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl-device-only -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT -DSPIRARCH=spir64
3638
// RUN: %clang -### -target x86_64-unknown-linux-gnu -fsycl-device-only %s 2>&1 | FileCheck %s --check-prefix=DEFAULT -DSPIRARCH=spir64

0 commit comments

Comments
 (0)