Skip to content

Commit 28a39e5

Browse files
authored
[SYCL][thinLTO] Don't pass -properties and -ir-output-only to sycl-post-link (#14501)
This errors out anyway, so it was just wrong. --------- Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 20a088e commit 28a39e5

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10746,11 +10746,6 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1074610746
if (TCArgs.hasFlag(options::OPT_fno_sycl_esimd_force_stateless_mem,
1074710747
options::OPT_fsycl_esimd_force_stateless_mem, false))
1074810748
addArgs(PostLinkArgs, TCArgs, {"-lower-esimd-force-stateless-mem=false"});
10749-
10750-
bool IsUsingLTO = TC.getDriver().isUsingLTO(/*IsDeviceOffloadAction=*/true);
10751-
auto LTOMode = TC.getDriver().getLTOMode(/*IsDeviceOffloadAction=*/true);
10752-
if (!IsUsingLTO || LTOMode != LTOK_Thin)
10753-
addArgs(PostLinkArgs, TCArgs, {"-properties"});
1075410749
}
1075510750

1075610751
// Add any sycl-post-link options that rely on a specific Triple in addition
@@ -10765,11 +10760,18 @@ static void getTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
1076510760
llvm::Triple Triple,
1076610761
bool SpecConstsSupported,
1076710762
types::ID OutputType) {
10763+
10764+
bool IsUsingLTO = TC.getDriver().isUsingLTO(/*IsDeviceOffloadAction=*/true);
10765+
auto LTOMode = TC.getDriver().getLTOMode(/*IsDeviceOffloadAction=*/true);
1076810766
if (OutputType == types::TY_LLVM_BC) {
1076910767
// single file output requested - this means only perform necessary IR
1077010768
// transformations (like specialization constant intrinsic lowering) and
1077110769
// output LLVMIR
1077210770
addArgs(PostLinkArgs, TCArgs, {"-ir-output-only"});
10771+
} else if (!IsUsingLTO || LTOMode != LTOK_Thin) {
10772+
// Only create a properties file if we are not
10773+
// only outputting IR.
10774+
addArgs(PostLinkArgs, TCArgs, {"-properties"});
1077310775
}
1077410776
if (SpecConstsSupported)
1077510777
addArgs(PostLinkArgs, TCArgs, {"-spec-const=native"});

clang/test/Driver/sycl-offload-new-driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \
6161
// RUN: -Xdevice-post-link -post-link-opt -### %s 2>&1 \
6262
// RUN: | FileCheck -check-prefix WRAPPER_OPTIONS_POSTLINK %s
63-
// WRAPPER_OPTIONS_POSTLINK: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-O2 -device-globals -properties -post-link-opt"
63+
// WRAPPER_OPTIONS_POSTLINK: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-O2 -device-globals -post-link-opt"
6464

6565
// -fsycl-device-only behavior
6666
// RUN: %clangxx --target=x86_64-unknown-linux-gnu -fsycl --offload-new-driver \

clang/test/Driver/sycl-post-link-options-win.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
// RUN: -sycl-device-libraries=%t.devicelib.o \
2121
// RUN: --sycl-post-link-options="-O2 -device-globals -O0" \
2222
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck --check-prefix OPTIONS_POSTLINK_JIT_NEW %s
23-
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -O0
23+
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -properties -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -O0

clang/test/Driver/sycl-post-link-options.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
//
1919
// RUN: clang-linker-wrapper --dry-run --host-triple=x86_64-unknown-linux-gnu \
2020
// RUN: -sycl-device-libraries=%t.devicelib.o \
21-
// RUN: --sycl-post-link-options="-O2 -device-globals -properties -O0" \
21+
// RUN: --sycl-post-link-options="-O2 -device-globals -O0" \
2222
// RUN: --linker-path=/usr/bin/ld %t.o -o a.out 2>&1 | FileCheck --check-prefix OPTIONS_POSTLINK_JIT_NEW %s
23-
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -properties -O0
23+
// OPTIONS_POSTLINK_JIT_NEW: sycl-post-link{{.*}} -spec-const=native -properties -split=auto -emit-only-kernels-as-entry-points -emit-param-info -symbols -emit-exported-symbols -emit-imported-symbols -split-esimd -lower-esimd -O2 -device-globals -O0

clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,9 @@ getTripleBasedSYCLPostLinkOpts(const ArgList &Args,
545545
else
546546
PostLinkArgs.push_back("-spec-const=emulation");
547547

548+
if (Triple.isSPIROrSPIRV() || SYCLNativeCPU)
549+
PostLinkArgs.push_back("-properties");
550+
548551
// See if device code splitting is already requested. If not requested, then
549552
// set -split=auto for non-FPGA targets.
550553
bool NoSplit = true;

0 commit comments

Comments
 (0)