Skip to content

Commit 7a21f07

Browse files
authored
[SYCL][ASAN] apply only-needed when link asan libdevice (#12849)
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>
1 parent d518aa5 commit 7a21f07

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ static llvm::SmallVector<StringRef, 16> SYCLDeviceLibList {
371371
"bfloat16", "crt", "cmath", "cmath-fp64", "complex", "complex-fp64",
372372
#if defined(_WIN32)
373373
"msvc-math",
374+
#else
375+
"sanitizer",
374376
#endif
375377
"imf", "imf-fp64", "itt-compiler-wrappers", "itt-stubs",
376378
"itt-user-wrappers", "fallback-cassert", "fallback-cstring",

clang/test/Driver/sycl-device-lib.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
// 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"
3737
// 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"
3838
// 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"
39+
3940
/// ###########################################################################
4041
/// test sycl fallback device libraries are not linked by default
4142
// RUN: %clangxx -fsycl -fsycl-device-lib-jit-link %s --sysroot=%S/Inputs/SYCL -### 2>&1 \
@@ -251,3 +252,4 @@
251252
// SYCL_DEVICE_ASAN_MACRO-SAME: "USE_SYCL_DEVICE_ASAN"
252253
// SYCL_DEVICE_ASAN_MACRO-NEXT: llvm-link{{.*}}
253254
// SYCL_DEVICE_ASAN_MACRO: clang-offload-bundler{{.*}} "-type=o" "-targets=sycl-spir64-unknown-unknown" "-input={{.*}}libsycl-sanitizer.o" "-output={{.*}}libsycl-sanitizer-{{.*}}.o" "-unbundle"
255+
// SYCL_DEVICE_ASAN_MACRO: llvm-link{{.*}} "-only-needed" "{{.*}}" "-o" "{{.*}}.bc" "--suppress-warnings"

libdevice/include/spir_global_var.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@
1111
// Treat this header as system one to workaround frontend's restriction
1212
#pragma clang system_header
1313

14-
#ifndef SPIR_GLOBAL_VAR
15-
#ifdef __SYCL_DEVICE_ONLY__
16-
#define SPIR_GLOBAL_VAR __attribute__((sycl_global_var))
17-
#else
18-
#warning "SPIR_GLOBAL_VAR not defined in host mode. Defining as empty macro."
19-
#define SPIR_GLOBAL_VAR
20-
#endif
21-
#endif
22-
2314
#define __SYCL_GLOBAL__ __attribute__((opencl_global))
2415
#define __SYCL_LOCAL__ __attribute__((opencl_local))
2516
#define __SYCL_PRIVATE__ __attribute__((opencl_private))

0 commit comments

Comments
 (0)