Skip to content

Commit 7ffbd65

Browse files
authored
[SYCL] Fix sycl-post-link action output type for non-SPIRV (#8394)
With HIP, we use the output of clang-offload-bundler directly in target linking. Usually this is fine, because it becomes an input action for linking all device inputs together, and the link action has IR output type. However, for -fno-sycl-rdc we don't link the device code together, so the clang-offload-bundler action is a direct input to sycl-post-link. Since sycl-post-link previously copied the output type of the input action, we would end up with Object output type, which caused '-x object' to be pased to the HIP compiler, which is wrong. Instead, mark sycl-post-link as always outputting IR for non-SPIRV. Closes: #8364 Signed-off-by: Sarnie, Nick <[email protected]>
1 parent c7bb4c1 commit 7ffbd65

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5672,7 +5672,7 @@ class OffloadingActionBuilder final {
56725672
// post link is not optional - even if not splitting, always need to
56735673
// process specialization constants
56745674
types::ID PostLinkOutType = isSPIR ? types::TY_Tempfiletable
5675-
: FullDeviceLinkAction->getType();
5675+
: types::TY_LLVM_BC;
56765676
auto createPostLinkAction = [&]() {
56775677
// For SPIR-V targets, force TY_Tempfiletable.
56785678
auto TypedPostLinkAction = C.MakeAction<SYCLPostLinkJobAction>(

clang/test/Driver/sycl-hip-no-rdc.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Test for -fno-sycl-rdc with HIP to make sure sycl-post-link is marked as outputting ir
2+
3+
// RUN: touch %t1.cpp
4+
// RUN: %clang -### -fsycl -fno-sycl-rdc -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=gfx1031 --sysroot=%S/Inputs/SYCL %t1.cpp 2>&1 -ccc-print-phases | FileCheck %s
5+
6+
// CHECK: sycl-post-link, {{{.*}}}, ir, (device-sycl, gfx1031)

0 commit comments

Comments
 (0)