Skip to content

Commit 2368be3

Browse files
authored
[HIP] Always respect --gpu-bundle-output in the new driver (#150989)
Summary: This is a bit of an awkward transition point for the new and old drivers. Previously AMDGPU uses this to generate offloading bundles, but the new driver much prefers to output the file itself. This patch changes the behavior to always respect `--gpu-bundle-output` instead of having it be the default behavior. This means that we effectively get to override the default new driver behavior with this flag now. This should hoepfully fix some errors in the downstream comgr tests.
1 parent c03b0dd commit 2368be3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4919,13 +4919,14 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
49194919
}
49204920

49214921
// HIP code in device-only non-RDC mode will bundle the output if it invoked
4922-
// the linker.
4922+
// the linker or if the user explicitly requested it.
49234923
bool ShouldBundleHIP =
4924-
HIPNoRDC && offloadDeviceOnly() &&
49254924
Args.hasFlag(options::OPT_gpu_bundle_output,
4926-
options::OPT_no_gpu_bundle_output, true) &&
4927-
!llvm::any_of(OffloadActions,
4928-
[](Action *A) { return A->getType() != types::TY_Image; });
4925+
options::OPT_no_gpu_bundle_output, false) ||
4926+
(HIPNoRDC && offloadDeviceOnly() &&
4927+
llvm::none_of(OffloadActions, [](Action *A) {
4928+
return A->getType() != types::TY_Image;
4929+
}));
49294930

49304931
// All kinds exit now in device-only mode except for non-RDC mode HIP.
49314932
if (offloadDeviceOnly() && !ShouldBundleHIP)

clang/test/Driver/hip-binding.hip

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
// MULTI-D-ONLY-NEXT: # "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT]]"], output: "[[GFX90a:.+]]"
6262
// MULTI-D-ONLY-NEXT: # "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[GFX90a]]"], output: "[[GFX90a_OUT:.+]]"
6363
//
64-
// RUN: not %clang -### --target=x86_64-linux-gnu --offload-new-driver -ccc-print-bindings -nogpulib -nogpuinc \
64+
// RUN: not %clang -### --target=x86_64-linux-gnu --offload-new-driver -ccc-print-bindings -nogpulib -nogpuinc -emit-llvm \
6565
// RUN: --no-gpu-bundle-output --offload-arch=gfx90a --offload-arch=gfx908 --offload-device-only -c -o %t %s 2>&1 \
6666
// RUN: | FileCheck -check-prefix=MULTI-D-ONLY-NO-BUNDLE-O %s
6767
// MULTI-D-ONLY-NO-BUNDLE-O: error: cannot specify -o when generating multiple output files
@@ -75,6 +75,13 @@
7575
// MULTI-D-ONLY-O-NEXT: "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[GFX90A_OBJ]]"], output: "[[GFX90A:.+]]"
7676
// MULTI-D-ONLY-O-NEXT: "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[GFX908]]", "[[GFX90A]]"], output: "a.out"
7777

78+
// RUN: %clang -### --target=x86_64-linux-gnu --offload-new-driver -ccc-print-bindings -nogpulib -nogpuinc -emit-llvm \
79+
// RUN: --gpu-bundle-output --offload-arch=gfx90a --offload-arch=gfx908 --offload-device-only -c -o a.out %s 2>&1 \
80+
// RUN: | FileCheck -check-prefix=MULTI-D-ONLY-BC %s
81+
// MULTI-D-ONLY-BC: "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[GFX908_BC:.+]]"
82+
// MULTI-D-ONLY-BC-NEXT: "amdgcn-amd-amdhsa" - "clang", inputs: ["[[INPUT]]"], output: "[[GFX90A_BC:.+]]"
83+
// MULTI-D-ONLY-BC-NEXT: "amdgcn-amd-amdhsa" - "AMDGCN::Linker", inputs: ["[[GFX908_BC]]", "[[GFX90A_BC]]"], output: "a.out"
84+
7885
//
7986
// Check to ensure that we can use '-fsyntax-only' for HIP output with the new
8087
// driver.

0 commit comments

Comments
 (0)