Skip to content

Commit

Permalink
[SYCL][ASAN] apply only-needed when link asan libdevice (#12849)
Browse files Browse the repository at this point in the history
This patch removes some unused code in sanitizer libdevice and also
appied 'only-needed' option when linking libsycl-santizer libdevice.

---------

Signed-off-by: jinge90 <ge.jin@intel.com>
  • Loading branch information
jinge90 committed Mar 5, 2024
1 parent d518aa5 commit 7a21f07
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 2 additions & 0 deletions clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ static llvm::SmallVector<StringRef, 16> SYCLDeviceLibList {
"bfloat16", "crt", "cmath", "cmath-fp64", "complex", "complex-fp64",
#if defined(_WIN32)
"msvc-math",
#else
"sanitizer",
#endif
"imf", "imf-fp64", "itt-compiler-wrappers", "itt-stubs",
"itt-user-wrappers", "fallback-cassert", "fallback-cstring",
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/sycl-device-lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown" "-input={{.*}}libsycl-fallback-imf.o" "-output={{.*}}libsycl-fallback-imf-{{.*}}.o" "-unbundle"
// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown" "-input={{.*}}libsycl-fallback-imf-fp64.o" "-output={{.*}}libsycl-fallback-imf-fp64-{{.*}}.o" "-unbundle"
// SYCL_DEVICE_LIB_UNBUNDLE_DEFAULT-NEXT: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown" "-input={{.*}}libsycl-fallback-imf-bf16.o" "-output={{.*}}libsycl-fallback-imf-bf16-{{.*}}.o" "-unbundle"

/// ###########################################################################
/// test sycl fallback device libraries are not linked by default
// RUN: %clangxx -fsycl -fsycl-device-lib-jit-link %s --sysroot=%S/Inputs/SYCL -### 2>&1 \
Expand Down Expand Up @@ -251,3 +252,4 @@
// SYCL_DEVICE_ASAN_MACRO-SAME: "USE_SYCL_DEVICE_ASAN"
// SYCL_DEVICE_ASAN_MACRO-NEXT: llvm-link{{.*}}
// SYCL_DEVICE_ASAN_MACRO: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown" "-input={{.*}}libsycl-sanitizer.o" "-output={{.*}}libsycl-sanitizer-{{.*}}.o" "-unbundle"
// SYCL_DEVICE_ASAN_MACRO: llvm-link{{.*}} "-only-needed" "{{.*}}" "-o" "{{.*}}.bc" "--suppress-warnings"
9 changes: 0 additions & 9 deletions libdevice/include/spir_global_var.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
// Treat this header as system one to workaround frontend's restriction
#pragma clang system_header

#ifndef SPIR_GLOBAL_VAR
#ifdef __SYCL_DEVICE_ONLY__
#define SPIR_GLOBAL_VAR __attribute__((sycl_global_var))
#else
#warning "SPIR_GLOBAL_VAR not defined in host mode. Defining as empty macro."
#define SPIR_GLOBAL_VAR
#endif
#endif

#define __SYCL_GLOBAL__ __attribute__((opencl_global))
#define __SYCL_LOCAL__ __attribute__((opencl_local))
#define __SYCL_PRIVATE__ __attribute__((opencl_private))
Expand Down

0 comments on commit 7a21f07

Please sign in to comment.