Skip to content
30 changes: 17 additions & 13 deletions llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,13 +1333,27 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM,

if (!HasESIMD)
for (Function &F : M) {
if (F.getCallingConv() != CallingConv::SPIR_KERNEL)
continue;

if (!F.hasFnAttribute(Attribute::SanitizeAddress) ||
F.hasFnAttribute(Attribute::DisableSanitizerInstrumentation))
continue;

if (F.getName().contains("__sycl_service_kernel__")) {
F.addFnAttr(Attribute::DisableSanitizerInstrumentation);
continue;
}

// Skip referenced-indirectly function as we insert access to shared
// local memory (SLM) __AsanLaunchInfo and access to SLM in
// referenced-indirectly function isn't supported yet in
// intel-graphics-compiler.
if (F.hasFnAttribute("referenced-indirectly")) {
F.addFnAttr(Attribute::DisableSanitizerInstrumentation);
continue;
}

if (F.getCallingConv() != CallingConv::SPIR_KERNEL)
continue;

SpirFixupKernels.emplace_back(&F);

auto KernelName = F.getName();
Expand Down Expand Up @@ -3683,16 +3697,6 @@ bool AddressSanitizer::instrumentFunction(Function &F,
if (F.isPresplitCoroutine())
return false;

if (TargetTriple.isSPIROrSPIRV()) {
if (F.getName().contains("__sycl_service_kernel__"))
return false;
// Skip referenced-indirectly function as we insert access to shared local
// memory (SLM) __AsanLaunchInfo and access to SLM in referenced-indirectly
// function isn't supported yet in intel-graphics-compiler.
if (F.hasFnAttribute("referenced-indirectly"))
return false;
}

bool FunctionModified = false;

// Do not apply any instrumentation for naked functions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; RUN: opt < %s -passes=asan -asan-instrumentation-with-call-threshold=0 | FileCheck %s
; RUN: opt < %s -passes=asan -asan-instrumentation-with-call-threshold=0 -S | FileCheck %s

; Check referenced-indirectly function isn't instrumented.

Expand All @@ -9,6 +9,7 @@ target triple = "spir64-unknown-unknown"
@_ZTV8Derived1 = linkonce_odr addrspace(1) constant %structtype { [3 x ptr addrspace(4)] [ptr addrspace(4) null, ptr addrspace(4) null, ptr addrspace(4) addrspacecast (ptr @_ZN8Derived17displayEv to ptr addrspace(4))] }, align 8, !spirv.Decorations !0

define linkonce_odr spir_func i32 @_ZN8Derived17displayEv(ptr addrspace(4) align 8 %this) sanitize_address "referenced-indirectly" {
; CHECK: @_ZN8Derived17displayEv{{.*}}#1
entry:
; CHECK-NOT: call void @__asan_load

Expand All @@ -17,6 +18,8 @@ entry:
ret i32 %1
}

; CHECK: #1 {{.*}} disable_sanitizer_instrumentation

!0 = !{!1, !2, !3}
!1 = !{i32 22}
!2 = !{i32 41, !"_ZTV8Derived1", i32 2}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; RUN: opt < %s -passes=asan -asan-instrumentation-with-call-threshold=0 -S | FileCheck %s

; Check "sycl_service_kernel" function isn't instrumented.

target triple = "spir64-unknown-unknown"

%structtype = type { [3 x ptr addrspace(4)] }
%class.Base = type <{ ptr addrspace(4), i32, [4 x i8] }>

define linkonce_odr spir_func i32 @_ZTSN4sycl3_V16detail23__sycl_service_kernel__16AssertInfoCopierE(ptr addrspace(4) align 8 %this) sanitize_address "referenced-indirectly" {
; CHECK: @_ZTSN4sycl3_V16detail23__sycl_service_kernel__16AssertInfoCopierE{{.*}}#1
entry:
; CHECK-NOT: call void @__asan_load
%base_data = getelementptr inbounds %class.Base, ptr addrspace(4) %this, i64 0, i32 1
%1 = load i32, ptr addrspace(4) %base_data, align 8
ret i32 %1
}

; CHECK: #1 {{.*}} disable_sanitizer_instrumentation
2 changes: 1 addition & 1 deletion sycl/cmake/modules/FetchUnifiedRuntime.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if(SYCL_UR_USE_FETCH_CONTENT)
CACHE PATH "Path to external '${name}' adapter source dir" FORCE)
endfunction()

set(UNIFIED_RUNTIME_REPO "https://github.com/oneapi-src/unified-runtime.git")
set(UNIFIED_RUNTIME_REPO "https://github.com/AllanZyne/unified-runtime.git")
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UnifiedRuntimeTag.cmake)

set(UMF_BUILD_EXAMPLES OFF CACHE INTERNAL "EXAMPLES")
Expand Down
8 changes: 4 additions & 4 deletions sycl/cmake/modules/UnifiedRuntimeTag.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# commit 3ad235dee9588152a58980bb73c8827a3d03a9e8
# Merge: c7cd88de 6390f637
# Author: Kenneth Benzie (Benie) <[email protected]>
# Date: Wed Dec 4 18:17:07 2024 +0000
# Merge pull request #2389 from againull/indirect_fix
# [L0] Set exec info for all L0 kernels in UR kernel
set(UNIFIED_RUNTIME_TAG 3ad235dee9588152a58980bb73c8827a3d03a9e8)
# Date: Tue Dec 3 12:41:16 2024 +0000
# Merge pull request #2298 from Bensuo/ewan/cuda_update_local_size
# Improve CUDA/HIP local argument handling
set(UNIFIED_RUNTIME_TAG review/yang/fix_metadata_assert)
Loading