Skip to content

Commit 1f3f02b

Browse files
authored
[DeviceSanitizer] Don't instrument referenced-indirectly functions (#14298)
When we create SLM __AsanLaunchInfo and store newly added kernel arg __asan_launch into the SLM, the SLM is loaded in asan report function. If instructions in referenced-indirectly function are instrumented, the report function is called. However, access to SLM in referenced- indirectly function isn't supported in intel-graphics-compiler yet.
1 parent 2ac6184 commit 1f3f02b

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3360,8 +3360,16 @@ bool AddressSanitizer::instrumentFunction(Function &F,
33603360
if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage) return false;
33613361
if (!ClDebugFunc.empty() && ClDebugFunc == F.getName()) return false;
33623362
if (F.getName().starts_with("__asan_")) return false;
3363-
if (F.getName().contains("__sycl_service_kernel__"))
3364-
return false;
3363+
3364+
if (TargetTriple.isSPIR()) {
3365+
if (F.getName().contains("__sycl_service_kernel__"))
3366+
return false;
3367+
// Skip referenced-indirectly function as we insert access to shared local
3368+
// memory (SLM) __AsanLaunchInfo and access to SLM in referenced-indirectly
3369+
// function isn't supported yet in intel-graphics-compiler.
3370+
if (F.hasFnAttribute("referenced-indirectly"))
3371+
return false;
3372+
}
33653373

33663374
bool FunctionModified = false;
33673375

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; RUN: opt < %s -passes=asan -asan-instrumentation-with-call-threshold=0 | FileCheck %s
2+
3+
; Check referenced-indirectly function isn't instrumented.
4+
5+
target triple = "spir64-unknown-unknown"
6+
7+
%structtype = type { [3 x ptr addrspace(4)] }
8+
%class.Base = type <{ ptr addrspace(4), i32, [4 x i8] }>
9+
@_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
10+
11+
define linkonce_odr spir_func i32 @_ZN8Derived17displayEv(ptr addrspace(4) align 8 %this) sanitize_address "referenced-indirectly" {
12+
entry:
13+
; CHECK-NOT: call void @__asan_load
14+
15+
%base_data = getelementptr inbounds %class.Base, ptr addrspace(4) %this, i64 0, i32 1
16+
%1 = load i32, ptr addrspace(4) %base_data, align 8
17+
ret i32 %1
18+
}
19+
20+
!0 = !{!1, !2, !3}
21+
!1 = !{i32 22}
22+
!2 = !{i32 41, !"_ZTV8Derived1", i32 2}
23+
!3 = !{i32 44, i32 8}

0 commit comments

Comments
 (0)