Skip to content

Commit 1179477

Browse files
committed
Fix assertion with -flto
Missing offload linker wrapper job action to wrap device binary for -flto.
1 parent ff3a9dd commit 1179477

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4882,7 +4882,10 @@ Action *Driver::BuildOffloadingActions(Compilation &C,
48824882
// For HIP non-rdc non-device-only compilation, create a linker wrapper
48834883
// action for each host object to link, bundle and wrap device files in
48844884
// it.
4885-
if (isa<AssembleJobAction>(HostAction) && HIPNoRDC && !offloadDeviceOnly()) {
4885+
if ((isa<AssembleJobAction>(HostAction) ||
4886+
(isa<BackendJobAction>(HostAction) &&
4887+
HostAction->getType() == types::TY_LTO_BC)) &&
4888+
HIPNoRDC && !offloadDeviceOnly()) {
48864889
ActionList AL{HostAction};
48874890
HostAction = C.MakeAction<LinkerWrapperJobAction>(AL, types::TY_Object);
48884891
HostAction->propagateHostOffloadInfo(C.getActiveOffloadKinds(),

clang/test/Driver/hip-phases.hip

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
1313
// RUN: --offload-new-driver --cuda-gpu-arch=gfx803 %s 2>&1 \
1414
// RUN: | FileCheck -check-prefixes=BIN,NEW,NEWN %s
15+
// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
16+
// RUN: --offload-new-driver --cuda-gpu-arch=gfx803 -flto -c %s 2>&1 \
17+
// RUN: | FileCheck -check-prefixes=BIN,NEW,NEWLTO %s
1518
//
1619
// RUN: %clang -x hip --target=x86_64-unknown-linux-gnu -ccc-print-phases \
1720
// RUN: --no-offload-new-driver --cuda-gpu-arch=gfx803 -fgpu-rdc %s 2>&1 \
@@ -45,10 +48,14 @@
4548
// OLDR-DAG: [[P11:[0-9]+]]: offload, "device-[[T]] (amdgcn-amd-amdhsa)" {[[P10]]}, object
4649
// OLDN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]])
4750
// OLDN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]])
48-
// NEW-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]])
49-
// NEW-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]])
51+
// NEWN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]])
52+
// NEWN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]])
53+
// NEWLTO-DAG: [[P13:[0-9]+]]: backend, {[[P11]]}, lto-bc, (host-hip)
54+
// NEWR-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]])
55+
// NEWR-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]])
5056
// OLDN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]])
5157
// NEWN-DAG: [[P14:[0-9]+]]: clang-linker-wrapper, {[[P13]]}, object, (host-[[T]])
58+
// NEWLTO-DAG: [[P14:[0-9]+]]: clang-linker-wrapper, {[[P13]]}, object, (host-[[T]])
5259
// OLDR-DAG: [[P14:[0-9]+]]: linker, {[[P13]], [[P11]]}, image, (host-[[T]])
5360
// NEWR-DAG: [[P14:[0-9]+]]: clang-linker-wrapper, {[[P13]]}, image, (host-[[T]])
5461
// NEWN-DAG: [[P15:[0-9]+]]: linker, {[[P14]]}, image

0 commit comments

Comments
 (0)