Skip to content

Commit d2b0896

Browse files
jhuber6mahesh-attarde
authored andcommitted
[Clang] Fix new driver HIP SPIR-V compilation in device only mode (llvm#150309)
Summary: This should emit LLVM-IR. Add to the extremely ugly if statement so that this happens correctly.
1 parent e8b5928 commit d2b0896

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5099,13 +5099,16 @@ Action *Driver::ConstructPhaseAction(
50995099
if (Args.hasArg(options::OPT_emit_llvm) ||
51005100
TargetDeviceOffloadKind == Action::OFK_SYCL ||
51015101
(((Input->getOffloadingToolChain() &&
5102-
Input->getOffloadingToolChain()->getTriple().isAMDGPU()) ||
5102+
(Input->getOffloadingToolChain()->getTriple().isSPIRV() ||
5103+
Input->getOffloadingToolChain()->getTriple().isAMDGPU())) ||
51035104
TargetDeviceOffloadKind == Action::OFK_HIP) &&
51045105
((Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
51055106
false) ||
51065107
(Args.hasFlag(options::OPT_offload_new_driver,
51075108
options::OPT_no_offload_new_driver, false) &&
5108-
!offloadDeviceOnly())) ||
5109+
(!offloadDeviceOnly() ||
5110+
(Input->getOffloadingToolChain() &&
5111+
Input->getOffloadingToolChain()->getTriple().isSPIRV())))) ||
51095112
TargetDeviceOffloadKind == Action::OFK_OpenMP))) {
51105113
types::ID Output =
51115114
Args.hasArg(options::OPT_S) &&

clang/test/Driver/hip-phases.hip

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@
677677
// DEVICE-ONLY-NEXT: 4: offload, "device-hip (amdgcn-amd-amdhsa:gfx90a)" {3}, none
678678

679679
//
680-
// Test the new driver when not bundling
680+
// Test the new driver bundling SPIR-V targets.
681681
//
682682
// RUN: %clang -### --target=x86_64-linux-gnu --offload-new-driver -ccc-print-phases \
683683
// RUN: --offload-device-only --offload-arch=amdgcnspirv,gfx1030 %s 2>&1 \
@@ -692,9 +692,8 @@
692692
// SPIRV-ONLY-NEXT: 7: input, "[[INPUT]]", hip, (device-hip, amdgcnspirv)
693693
// SPIRV-ONLY-NEXT: 8: preprocessor, {7}, hip-cpp-output, (device-hip, amdgcnspirv)
694694
// SPIRV-ONLY-NEXT: 9: compiler, {8}, ir, (device-hip, amdgcnspirv)
695-
// SPIRV-ONLY-NEXT: 10: backend, {9}, assembler, (device-hip, amdgcnspirv)
696-
// SPIRV-ONLY-NEXT: 11: assembler, {10}, object, (device-hip, amdgcnspirv)
697-
// SPIRV-ONLY-NEXT: 12: linker, {11}, image, (device-hip, amdgcnspirv)
698-
// SPIRV-ONLY-NEXT: 13: offload, "device-hip (spirv64-amd-amdhsa:amdgcnspirv)" {12}, image
699-
// SPIRV-ONLY-NEXT: 14: linker, {6, 13}, hip-fatbin, (device-hip)
700-
// SPIRV-ONLY-NEXT: 15: offload, "device-hip (amdgcn-amd-amdhsa)" {14}, none
695+
// SPIRV-ONLY-NEXT: 10: backend, {9}, ir, (device-hip, amdgcnspirv)
696+
// SPIRV-ONLY-NEXT: 11: linker, {10}, image, (device-hip, amdgcnspirv)
697+
// SPIRV-ONLY-NEXT: 12: offload, "device-hip (spirv64-amd-amdhsa:amdgcnspirv)" {11}, image
698+
// SPIRV-ONLY-NEXT: 13: linker, {6, 12}, hip-fatbin, (device-hip)
699+
// SPIRV-ONLY-NEXT: 14: offload, "device-hip (amdgcn-amd-amdhsa)" {13}, none

0 commit comments

Comments
 (0)