Skip to content

Commit 5a51c0a

Browse files
authored
[SYCL] Gracefully handle unknown device (#11254)
Don't throw ICE when an unknown device is specified explicitly via `-Xsycl-target-backend --offload-arch=`. We don't enable macros or other niceties from sycl_ext_oneapi_device_architecture, but at least the code compiles. Fixes #8112, #11203, #12010
1 parent 4c9c455 commit 5a51c0a

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5482,7 +5482,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
54825482
Triple.getSubArch() == llvm::Triple::SPIRSubArch_gen) ||
54835483
Triple.isNVPTX() || Triple.isAMDGCN()) {
54845484
StringRef Device = JA.getOffloadingArch();
5485-
if (!Device.empty()) {
5485+
if (!Device.empty() && !SYCL::gen::getGenDeviceMacro(Device).empty()) {
54865486
Macro = "-D";
54875487
Macro += SYCL::gen::getGenDeviceMacro(Device);
54885488
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/// Verify that compiler passes are correctly determined
2+
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx600 -nogpulib -c -ccc-print-phases %s 2>&1 | FileCheck %s --check-prefix=CHECK-PHASES
3+
// CHECK-PHASES: offload, "device-sycl (amdgcn-amd-amdhsa:gfx600)"
4+
5+
/// Verify that preprocessor works (#8112)
6+
// RUN: %clangxx -fsycl -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx600 -nogpulib -E %s 2>&1 | FileCheck %s --check-prefix=CHECK-PREPROCESSOR
7+
// CHECK-PREPROCESSOR: // __CLANG_OFFLOAD_BUNDLE____START__ sycl-amdgcn-amd-amdhsa-gfx600
8+

0 commit comments

Comments
 (0)