Skip to content

Commit 8d6239b

Browse files
committed
[Driver] Let all offload builders add inputs to host link job action
This patch fixes a problem with loosing OpenMP device binary when program uses both OpenMP and SYCL offloading models. Signed-off-by: Sergey Dmitriev <[email protected]>
1 parent d44aa3f commit 8d6239b

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4780,7 +4780,7 @@ class OffloadingActionBuilder final {
47804780
return false;
47814781
}
47824782

4783-
Action* makeHostLinkAction() {
4783+
void makeHostLinkAction(ActionList &LinkerInputs) {
47844784
// Build a list of device linking actions.
47854785
ActionList DeviceAL;
47864786
for (DeviceActionBuilder *SB : SpecializedBuilders) {
@@ -4790,16 +4790,15 @@ class OffloadingActionBuilder final {
47904790
}
47914791

47924792
if (DeviceAL.empty())
4793-
return nullptr;
4793+
return;
47944794

47954795
// Let builders add host linking actions.
4796-
Action* HA;
47974796
for (DeviceActionBuilder *SB : SpecializedBuilders) {
47984797
if (!SB->isValid())
47994798
continue;
4800-
HA = SB->appendLinkHostActions(DeviceAL);
4799+
if (Action *HA = SB->appendLinkHostActions(DeviceAL))
4800+
LinkerInputs.push_back(HA);
48014801
}
4802-
return HA;
48034802
}
48044803

48054804
/// Processes the host linker action. This currently consists of replacing it
@@ -5184,8 +5183,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
51845183

51855184
// Add a link action if necessary.
51865185
if (!LinkerInputs.empty()) {
5187-
if (Action *Wrapper = OffloadBuilder.makeHostLinkAction())
5188-
LinkerInputs.push_back(Wrapper);
5186+
OffloadBuilder.makeHostLinkAction(LinkerInputs);
51895187
types::ID LinkType(types::TY_Image);
51905188
if (Args.hasArg(options::OPT_fsycl_link_EQ))
51915189
LinkType = types::TY_Archive;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// Check that OpenMP and SYCL device binaries are wrapped and linked to the host
2+
/// image when program uses both OpenMP and SYCL offloading models.
3+
4+
// REQUIRES: clang-driver
5+
// REQUIRES: x86-registered-target
6+
7+
// RUN: touch %t.o
8+
// RUN: %clang --target=x86_64-host-linux-gnu -fsycl -fopenmp -fopenmp-targets=x86_64-device-linux-gnu -### %t.o 2>&1 \
9+
// RUN: | FileCheck %s
10+
// CHECK: clang-offload-wrapper{{(.exe)?}}" {{.*}} "-target=spir64" "-kind=sycl"
11+
// CHECK: clang-offload-wrapper{{(.exe)?}}" {{.*}} "-kind=openmp" "-target=x86_64-device-linux-gnu"

0 commit comments

Comments
 (0)