Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3360,8 +3360,16 @@ bool AddressSanitizer::instrumentFunction(Function &F,
if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return false;
if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false;
if (F.getName().starts_with("__asan_")) return false;
if (F.getName().contains("__sycl_service_kernel__"))
return false;

if (TargetTriple.isSPIR()) {
if (F.getName().contains("__sycl_service_kernel__"))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AllanZyne the name check might not be accurate, what if there is a user function that is xx__sycl_service_kernel__xx?

Copy link
Contributor

@AllanZyne AllanZyne Jun 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think either way is okay.
As far as I know, currently this kernel naming style is only used for assert.
llvm/sycl/include/sycl/queue.hpp:2908

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;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; RUN: opt < %s -passes=asan -asan-instrumentation-with-call-threshold=0 | FileCheck %s

; Check referenced-indirectly 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] }>
@_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" {
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
}

!0 = !{!1, !2, !3}
!1 = !{i32 22}
!2 = !{i32 41, !"_ZTV8Derived1", i32 2}
!3 = !{i32 44, i32 8}