Skip to content

Commit 362063b

Browse files
authored
[DeviceASAN] Skip ASan on modules where ESIMD Kernel exists (#15972)
To prevent ESIMD kernels and their callers from being sanitized, especially when sycl and ESIMD kernels are in the same module, we completely stop instrumenting the current module.
1 parent 5dae72c commit 362063b

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,8 +1450,14 @@ PreservedAnalyses AddressSanitizerPass::run(Module &M,
14501450
const StackSafetyGlobalInfo *const SSGI =
14511451
ClUseStackSafety ? &MAM.getResult<StackSafetyGlobalAnalysis>(M) : nullptr;
14521452

1453-
if (Triple(M.getTargetTriple()).isSPIROrSPIRV())
1453+
if (Triple(M.getTargetTriple()).isSPIROrSPIRV()) {
14541454
ExtendSpirKernelArgs(M, FAM);
1455+
// FIXME: W/A skip instrumentation if this module has ESIMD
1456+
for (auto &F : M) {
1457+
if (F.hasMetadata("sycl_explicit_simd"))
1458+
return PreservedAnalyses::all();
1459+
}
1460+
}
14551461

14561462
for (Function &F : M) {
14571463
AddressSanitizer FunctionSanitizer(
@@ -3497,10 +3503,6 @@ bool AddressSanitizer::instrumentFunction(Function &F,
34973503
// function isn't supported yet in intel-graphics-compiler.
34983504
if (F.hasFnAttribute("referenced-indirectly"))
34993505
return false;
3500-
// FIXME: ESIMD kernel doesn't support noinline functions, so we can't
3501-
// support sanitizer for it
3502-
if (F.hasMetadata("sycl_explicit_simd"))
3503-
return false;
35043506
}
35053507

35063508
bool FunctionModified = false;

llvm/test/Instrumentation/AddressSanitizer/SPIRV/sycl_esimd.ll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
44
target triple = "spir64-unknown-unknown"
55

6+
;;
7+
;; W/A: We skip asan completely if one module has esimd
8+
;;
9+
610
define spir_kernel void @sycl_kernel(ptr addrspace(1) %p) #0 {
711
; CHECK-LABEL: define spir_kernel void @sycl_kernel(ptr addrspace(1) %p, ptr addrspace(1) %__asan_launch) #0
812
entry:
913
%0 = load i32, ptr addrspace(1) %p, align 4
10-
; CHECK: store ptr addrspace(1) %__asan_launch, ptr addrspace(3) @__AsanLaunchInfo, align 8
11-
; CHECK: call void @__asan_load4
14+
; CHECK-NOT: store ptr addrspace(1) %__asan_launch, ptr addrspace(3) @__AsanLaunchInfo, align 8
15+
; CHECK-NOT: call void @__asan_load4
1216
ret void
1317
}
1418

0 commit comments

Comments
 (0)