Skip to content

Commit f8c34d1

Browse files
committed
[clang][Driver][HIP] Change OffloadingActionBuilder to respect the --no-gpu-bundle-output flag
1 parent 66feafd commit f8c34d1

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3844,6 +3844,9 @@ class OffloadingActionBuilder final {
38443844
/// Flag set to true if all valid builders allow file bundling/unbundling.
38453845
bool CanUseBundler;
38463846

3847+
/// Flag set to false if an argument turns off bundling.
3848+
bool ShouldUseBundler;
3849+
38473850
public:
38483851
OffloadingActionBuilder(Compilation &C, DerivedArgList &Args,
38493852
const Driver::InputList &Inputs)
@@ -3878,6 +3881,9 @@ class OffloadingActionBuilder final {
38783881
}
38793882
CanUseBundler =
38803883
ValidBuilders && ValidBuilders == ValidBuildersSupportingBundling;
3884+
3885+
ShouldUseBundler = Args.hasFlag(options::OPT_gpu_bundle_output,
3886+
options::OPT_no_gpu_bundle_output, true);
38813887
}
38823888

38833889
~OffloadingActionBuilder() {
@@ -4029,11 +4035,11 @@ class OffloadingActionBuilder final {
40294035
SB->appendTopLevelActions(OffloadAL);
40304036
}
40314037

4032-
// If we can use the bundler, replace the host action by the bundling one in
4033-
// the resulting list. Otherwise, just append the device actions. For
4034-
// device only compilation, HostAction is a null pointer, therefore only do
4035-
// this when HostAction is not a null pointer.
4036-
if (CanUseBundler && HostAction &&
4038+
// If we can and should use the bundler, replace the host action by the
4039+
// bundling one in the resulting list. Otherwise, just append the device
4040+
// actions. For device only compilation, HostAction is a null pointer,
4041+
// therefore only do this when HostAction is not a null pointer.
4042+
if (CanUseBundler && ShouldUseBundler && HostAction &&
40374043
HostAction->getType() != types::TY_Nothing && !OffloadAL.empty()) {
40384044
// Add the host action to the list in order to create the bundling action.
40394045
OffloadAL.push_back(HostAction);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang -ccc-print-phases -c -emit-llvm \
2+
// RUN: --offload-arch=gfx900,gfx1030 -O3 -x hip %s \
3+
// RUN: 2>&1 | FileCheck %s --check-prefix=OFFLOAD
4+
5+
// RUN: %clang -ccc-print-phases -c -emit-llvm \
6+
// RUN: --gpu-bundle-output --offload-arch=gfx900,gfx1030 -O3 -x hip %s \
7+
// RUN: 2>&1 | FileCheck %s --check-prefix=OFFLOAD
8+
9+
// RUN: %clang -ccc-print-phases -c -emit-llvm \
10+
// RUN: --no-gpu-bundle-output --offload-arch=gfx900,gfx1030 -O3 -x hip %s \
11+
// RUN: 2>&1 | FileCheck %s --check-prefix=OFFLOAD2
12+
13+
// OFFLOAD: clang-offload-bundler
14+
// OFFLOAD2-NOT: clang-offload-bundler
15+
16+
int square(int num) {
17+
return num * num;
18+
}

0 commit comments

Comments
 (0)