@@ -37,6 +37,12 @@ DeviceGlobal<DeviceType> __DeviceType;
37
37
#if defined(__SPIR__)
38
38
39
39
#ifdef __SYCL_DEVICE_ONLY__
40
+ #define __USE_SPIR_BUILTIN__ 1
41
+ #else
42
+ #define __USE_SPIR_BUILTIN__
43
+ #endif
44
+
45
+ #if __USE_SPIR_BUILTIN__
40
46
extern SYCL_EXTERNAL int
41
47
__spirv_ocl_printf (const __SYCL_CONSTANT__ char *Format, ...);
42
48
@@ -251,6 +257,12 @@ bool __asan_region_is_value(uptr addr, int32_t as, std::size_t size,
251
257
return true ;
252
258
}
253
259
260
+ #ifdef __SYCL_DEVICE_ONLY__
261
+ #define __DEVICE_SANITIZER_REPORT_ACCESSOR __DeviceSanitizerReportMem.get()
262
+ #else
263
+ #define __DEVICE_SANITIZER_REPORT_ACCESSOR
264
+ #endif
265
+
254
266
static void __asan_internal_report_save (
255
267
uptr ptr, int32_t as, const char __SYCL_CONSTANT__ *file, int32_t line,
256
268
const char __SYCL_CONSTANT__ *func, bool is_write, uint32_t access_size,
@@ -259,7 +271,7 @@ static void __asan_internal_report_save(
259
271
260
272
const int Expected = ASAN_REPORT_NONE;
261
273
int Desired = ASAN_REPORT_START;
262
- if (atomicCompareAndSet (&__DeviceSanitizerReportMem. get () .Flag , Desired,
274
+ if (atomicCompareAndSet (&__DEVICE_SANITIZER_REPORT_ACCESSOR .Flag , Desired,
263
275
Expected) == Expected) {
264
276
265
277
int FileLength = 0 ;
@@ -272,38 +284,38 @@ static void __asan_internal_report_save(
272
284
for (auto *C = func; *C != ' \0 ' ; ++C, ++FuncLength)
273
285
;
274
286
275
- int MaxFileIdx = sizeof (__DeviceSanitizerReportMem. get () .File ) - 1 ;
276
- int MaxFuncIdx = sizeof (__DeviceSanitizerReportMem. get () .Func ) - 1 ;
287
+ int MaxFileIdx = sizeof (__DEVICE_SANITIZER_REPORT_ACCESSOR .File ) - 1 ;
288
+ int MaxFuncIdx = sizeof (__DEVICE_SANITIZER_REPORT_ACCESSOR .Func ) - 1 ;
277
289
278
290
if (FileLength < MaxFileIdx)
279
291
MaxFileIdx = FileLength;
280
292
if (FuncLength < MaxFuncIdx)
281
293
MaxFuncIdx = FuncLength;
282
294
283
295
for (int Idx = 0 ; Idx < MaxFileIdx; ++Idx)
284
- __DeviceSanitizerReportMem. get () .File [Idx] = file[Idx];
285
- __DeviceSanitizerReportMem. get () .File [MaxFileIdx] = ' \0 ' ;
296
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .File [Idx] = file[Idx];
297
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .File [MaxFileIdx] = ' \0 ' ;
286
298
287
299
for (int Idx = 0 ; Idx < MaxFuncIdx; ++Idx)
288
- __DeviceSanitizerReportMem. get () .Func [Idx] = func[Idx];
289
- __DeviceSanitizerReportMem. get () .Func [MaxFuncIdx] = ' \0 ' ;
290
-
291
- __DeviceSanitizerReportMem. get () .Line = line;
292
- __DeviceSanitizerReportMem. get () .GID0 = __spirv_GlobalInvocationId_x ();
293
- __DeviceSanitizerReportMem. get () .GID1 = __spirv_GlobalInvocationId_y ();
294
- __DeviceSanitizerReportMem. get () .GID2 = __spirv_GlobalInvocationId_z ();
295
- __DeviceSanitizerReportMem. get () .LID0 = __spirv_LocalInvocationId_x ();
296
- __DeviceSanitizerReportMem. get () .LID1 = __spirv_LocalInvocationId_y ();
297
- __DeviceSanitizerReportMem. get () .LID2 = __spirv_LocalInvocationId_z ();
298
-
299
- __DeviceSanitizerReportMem. get () .IsWrite = is_write;
300
- __DeviceSanitizerReportMem. get () .AccessSize = access_size;
301
- __DeviceSanitizerReportMem. get () .ErrorType = error_type;
302
- __DeviceSanitizerReportMem. get () .MemoryType = memory_type;
303
- __DeviceSanitizerReportMem. get () .IsRecover = is_recover;
300
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .Func [Idx] = func[Idx];
301
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .Func [MaxFuncIdx] = ' \0 ' ;
302
+
303
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .Line = line;
304
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .GID0 = __spirv_GlobalInvocationId_x ();
305
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .GID1 = __spirv_GlobalInvocationId_y ();
306
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .GID2 = __spirv_GlobalInvocationId_z ();
307
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .LID0 = __spirv_LocalInvocationId_x ();
308
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .LID1 = __spirv_LocalInvocationId_y ();
309
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .LID2 = __spirv_LocalInvocationId_z ();
310
+
311
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .IsWrite = is_write;
312
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .AccessSize = access_size;
313
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .ErrorType = error_type;
314
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .MemoryType = memory_type;
315
+ __DEVICE_SANITIZER_REPORT_ACCESSOR .IsRecover = is_recover;
304
316
305
317
// Show we've done copying
306
- atomicStore (&__DeviceSanitizerReportMem. get () .Flag , ASAN_REPORT_FINISH);
318
+ atomicStore (&__DEVICE_SANITIZER_REPORT_ACCESSOR .Flag , ASAN_REPORT_FINISH);
307
319
}
308
320
}
309
321
0 commit comments