From 438f412e7ea7939bd3b632a5c7828b79aefcfa94 Mon Sep 17 00:00:00 2001 From: "Zhao, Yang2" Date: Mon, 4 Nov 2024 11:10:38 +0800 Subject: [PATCH 1/2] skip asan completely if one module has esimd --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 8 +++++++- .../Instrumentation/AddressSanitizer/SPIRV/sycl_esimd.ll | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index fa8ec000f61ca..b4bd2c9ea968a 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( 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 } From e3e64f09428d121b71657d1ecddc0d17078ead54 Mon Sep 17 00:00:00 2001 From: "Zhao, Yang2" Date: Mon, 4 Nov 2024 11:25:03 +0800 Subject: [PATCH 2/2] clean code --- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index b4bd2c9ea968a..7ade5db5046a6 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -3503,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;