Skip to content

Commit 9a64792

Browse files
committed
fix sycl-host-access
1 parent e9df350 commit 9a64792

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ static void ExtendSpirKernelArgs(Module &M, FunctionAnalysisManager &FAM,
13581358
AsanSpirKernelMetadata->addAttribute(
13591359
"sycl-device-global-size", std::to_string(DL.getTypeAllocSize(ArrayTy)));
13601360
AsanSpirKernelMetadata->addAttribute("sycl-device-image-scope");
1361-
AsanSpirKernelMetadata->addAttribute("sycl-host-access", "2");
1361+
AsanSpirKernelMetadata->addAttribute("sycl-host-access", "0"); // read only
13621362
AsanSpirKernelMetadata->addAttribute("sycl-unique-id",
13631363
"_Z20__AsanKernelMetadata");
13641364
AsanSpirKernelMetadata->setDSOLocal(true);

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
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+
; CHECK: @__AsanKernelMetadata = appending dso_local local_unnamed_addr addrspace(1) global
67
; CHECK: @__AsanLaunchInfo = external addrspace(3) global ptr addrspace(1)
78

89
define spir_kernel void @sycl_kernel1() #0 {
@@ -22,3 +23,6 @@ entry:
2223
}
2324

2425
attributes #0 = { sanitize_address }
26+
;; sycl-device-global-size = 16 * 2
27+
;; sycl-host-access = 0 read-only
28+
; CHECK: attributes #{{.*}} = { "sycl-device-global-size"="32" "sycl-device-image-scope" "sycl-host-access"="0" "sycl-unique-id"="_Z20__AsanKernelMetadata" }

llvm/test/tools/sycl-post-link/device-sanitizer/asan.ll

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
; This test checks that the post-link tool properly generates "asanUsed=1"
2-
; in [SYCL/misc properties]
2+
; in prop file, and fixes the attributes and metadata of @__AsanKernelMetadata
33

44
; RUN: sycl-post-link -properties -split=kernel -symbols -S < %s -o %t.table
5-
; RUN: FileCheck %s -input-file=%t_0.prop
6-
; CHECK: [SYCL/misc properties]
7-
; CHECK: asanUsed=1
5+
6+
; RUN: FileCheck %s -input-file=%t_0.prop --check-prefix CHECK-PROP
7+
; CHECK-PROP: [SYCL/misc properties]
8+
; CHECK-PROP: asanUsed=1
9+
10+
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefix CHECK-IR
811

912
; ModuleID = 'parallel_for_int.cpp'
1013
source_filename = "parallel_for_int.cpp"
@@ -15,6 +18,7 @@ $_ZTSZZ4mainENKUlRN4sycl3_V17handlerEE_clES2_E8MyKernel = comdat any
1518

1619
@__asan_kernel = internal addrspace(1) constant [55 x i8] c"_ZTSZZ4mainENKUlRN4sycl3_V17handlerEE_clES2_E8MyKernel\00"
1720
@__AsanKernelMetadata = appending dso_local local_unnamed_addr addrspace(1) global [1 x { i64, i64 }] [{ i64, i64 } { i64 ptrtoint (ptr addrspace(1) @__asan_kernel to i64), i64 54 }] #2
21+
; CHECK-IR: @__AsanKernelMetadata {{.*}} !spirv.Decorations
1822
@__spirv_BuiltInGlobalInvocationId = external dso_local local_unnamed_addr addrspace(1) constant <3 x i64>, align 32
1923
@__asan_func = internal addrspace(2) constant [106 x i8] c"typeinfo name for main::'lambda'(sycl::_V1::handler&)::operator()(sycl::_V1::handler&) const::MyKernelR_4\00"
2024

@@ -48,7 +52,7 @@ declare spir_func void @__itt_offload_wi_finish_wrapper()
4852

4953
attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
5054
attributes #1 = { mustprogress norecurse nounwind sanitize_address uwtable "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="parallel_for_int.cpp" "sycl-optlevel"="2" "uniform-work-group-size"="true" }
51-
attributes #2 = { "sycl-device-global-size"="16" "sycl-device-image-scope" "sycl-host-access"="2" "sycl-unique-id"="_Z20__AsanKernelMetadata" }
55+
attributes #2 = { "sycl-device-global-size"="16" "sycl-device-image-scope" "sycl-host-access"="0" "sycl-unique-id"="_Z20__AsanKernelMetadata" }
5256

5357
!llvm.module.flags = !{!0, !1, !2}
5458
!opencl.spir.version = !{!3}

0 commit comments

Comments
 (0)