diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index fa8ec000f61ca..7ade5db5046a6 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1450,8 +1450,14 @@ PreservedAnalyses AddressSanitizerPass::run(Module &M, const StackSafetyGlobalInfo *const SSGI = ClUseStackSafety ? &MAM.getResult(M) : nullptr; - if (Triple(M.getTargetTriple()).isSPIROrSPIRV()) + if (Triple(M.getTargetTriple()).isSPIROrSPIRV()) { ExtendSpirKernelArgs(M, FAM); + // FIXME: W/A skip instrumentation if this module has ESIMD + for (auto &F : M) { + if (F.hasMetadata("sycl_explicit_simd")) + return PreservedAnalyses::all(); + } + } for (Function &F : M) { AddressSanitizer FunctionSanitizer( @@ -3497,10 +3503,6 @@ bool AddressSanitizer::instrumentFunction(Function &F, // function isn't supported yet in intel-graphics-compiler. if (F.hasFnAttribute("referenced-indirectly")) return false; - // FIXME: ESIMD kernel doesn't support noinline functions, so we can't - // support sanitizer for it - if (F.hasMetadata("sycl_explicit_simd")) - return false; } bool FunctionModified = false; diff --git a/llvm/test/Instrumentation/AddressSanitizer/SPIRV/sycl_esimd.ll b/llvm/test/Instrumentation/AddressSanitizer/SPIRV/sycl_esimd.ll index 71e4bf97aed5c..77b73fc5b67dd 100644 --- a/llvm/test/Instrumentation/AddressSanitizer/SPIRV/sycl_esimd.ll +++ b/llvm/test/Instrumentation/AddressSanitizer/SPIRV/sycl_esimd.ll @@ -3,12 +3,16 @@ 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" target triple = "spir64-unknown-unknown" +;; +;; W/A: We skip asan completely if one module has esimd +;; + define spir_kernel void @sycl_kernel(ptr addrspace(1) %p) #0 { ; CHECK-LABEL: define spir_kernel void @sycl_kernel(ptr addrspace(1) %p, ptr addrspace(1) %__asan_launch) #0 entry: %0 = load i32, ptr addrspace(1) %p, align 4 - ; CHECK: store ptr addrspace(1) %__asan_launch, ptr addrspace(3) @__AsanLaunchInfo, align 8 - ; CHECK: call void @__asan_load4 + ; CHECK-NOT: store ptr addrspace(1) %__asan_launch, ptr addrspace(3) @__AsanLaunchInfo, align 8 + ; CHECK-NOT: call void @__asan_load4 ret void }