@@ -67,7 +67,7 @@ inline void ConvertGenericPointer(uptr &addr, uint32_t &as) {
67
67
// FIXME: I'm not sure if we need to check ADDRESS_SPACE_CONSTANT,
68
68
// but this can really simplify the generic pointer conversion logic
69
69
as = ADDRESS_SPACE_GLOBAL;
70
- addr = old;
70
+ addr = (uptr) ToGlobal (( void *) old) ;
71
71
}
72
72
TSAN_DEBUG (__spirv_ocl_printf (__tsan_print_generic_to, old, addr, as));
73
73
}
@@ -317,10 +317,10 @@ inline bool ContainsSameAccess(__SYCL_GLOBAL__ RawShadow *s, Shadow cur,
317
317
318
318
} // namespace
319
319
320
- #define TSAN_CHECK (type, is_write, size ) \
321
- DEVICE_EXTERN_C_NOINLINE void __tsan_##type##size( \
322
- uptr addr, uint32_t as, const char __SYCL_CONSTANT__ *file, \
323
- uint32_t line, const char __SYCL_CONSTANT__ *func) { \
320
+ #define TSAN_CHECK_BASE (type, is_write, size, as ) \
321
+ DEVICE_EXTERN_C_NOINLINE void __tsan_##type##size##_p##as( \
322
+ uptr addr, const char __SYCL_CONSTANT__ *file, uint32_t line, \
323
+ const char __SYCL_CONSTANT__ *func) { \
324
324
__SYCL_GLOBAL__ RawShadow *shadow_mem = MemToShadow (addr, as); \
325
325
if (!shadow_mem) \
326
326
return ; \
@@ -341,6 +341,11 @@ inline bool ContainsSameAccess(__SYCL_GLOBAL__ RawShadow *s, Shadow cur,
341
341
CheckRace (shadow_mem, cur, type, addr, size, as, file, line, func); \
342
342
}
343
343
344
+ #define TSAN_CHECK (type, is_write, size ) \
345
+ TSAN_CHECK_BASE (type, is_write, size, 1 ) \
346
+ TSAN_CHECK_BASE(type, is_write, size, 3 ) \
347
+ TSAN_CHECK_BASE(type, is_write, size, 4 )
348
+
344
349
TSAN_CHECK(read, false , 1 )
345
350
TSAN_CHECK(read, false , 2 )
346
351
TSAN_CHECK(read, false , 4 )
@@ -350,24 +355,26 @@ TSAN_CHECK(write, true, 2)
350
355
TSAN_CHECK(write, true , 4 )
351
356
TSAN_CHECK(write, true , 8 )
352
357
353
- DEVICE_EXTERN_C_NOINLINE void
354
- __tsan_write16(uptr addr, uint32_t as, const char __SYCL_CONSTANT__ *file,
355
- uint32_t line, const char __SYCL_CONSTANT__ *func) {
356
- __tsan_write8 (addr, as, file, line, func);
357
- __tsan_write8 (addr + 8 , as, file, line, func);
358
- }
358
+ #define TSAN_CHECK16_BASE (type, as ) \
359
+ DEVICE_EXTERN_C_NOINLINE void __tsan_##type##16_p##as( \
360
+ uptr addr, const char __SYCL_CONSTANT__ *file, uint32_t line, \
361
+ const char __SYCL_CONSTANT__ *func) { \
362
+ __tsan_##type##8_p##as (addr, file, line, func); \
363
+ __tsan_##type##8_p##as (addr + 8 , file, line, func); \
364
+ }
359
365
360
- DEVICE_EXTERN_C_NOINLINE void
361
- __tsan_read16 (uptr addr, uint32_t as, const char __SYCL_CONSTANT__ *file,
362
- uint32_t line, const char __SYCL_CONSTANT__ *func) {
363
- __tsan_read8 (addr, as, file, line, func);
364
- __tsan_read8 (addr + 8 , as, file, line, func);
365
- }
366
+ #define TSAN_CHECK16 (type ) \
367
+ TSAN_CHECK16_BASE (type, 1 ) \
368
+ TSAN_CHECK16_BASE(type, 3 ) \
369
+ TSAN_CHECK16_BASE(type, 4 )
366
370
367
- #define TSAN_UNALIGNED_CHECK (type, is_write, size ) \
368
- DEVICE_EXTERN_C_NOINLINE void __tsan_unaligned_##type##size( \
369
- uptr addr, uint32_t as, const char __SYCL_CONSTANT__ *file, \
370
- uint32_t line, const char __SYCL_CONSTANT__ *func) { \
371
+ TSAN_CHECK16(read)
372
+ TSAN_CHECK16(write)
373
+
374
+ #define TSAN_UNALIGNED_CHECK_BASE (type, is_write, size, as ) \
375
+ DEVICE_EXTERN_C_NOINLINE void __tsan_unaligned_##type##size##_p##as( \
376
+ uptr addr, const char __SYCL_CONSTANT__ *file, uint32_t line, \
377
+ const char __SYCL_CONSTANT__ *func) { \
371
378
__SYCL_GLOBAL__ RawShadow *shadow_mem = MemToShadow (addr, as); \
372
379
if (!shadow_mem) \
373
380
return ; \
@@ -410,6 +417,11 @@ __tsan_read16(uptr addr, uint32_t as, const char __SYCL_CONSTANT__ *file,
410
417
} \
411
418
}
412
419
420
+ #define TSAN_UNALIGNED_CHECK (type, is_write, size ) \
421
+ TSAN_UNALIGNED_CHECK_BASE (type, is_write, size, 1 ) \
422
+ TSAN_UNALIGNED_CHECK_BASE(type, is_write, size, 3 ) \
423
+ TSAN_UNALIGNED_CHECK_BASE(type, is_write, size, 4 )
424
+
413
425
TSAN_UNALIGNED_CHECK(read, false , 1 )
414
426
TSAN_UNALIGNED_CHECK(read, false , 2 )
415
427
TSAN_UNALIGNED_CHECK(read, false , 4 )
@@ -419,21 +431,21 @@ TSAN_UNALIGNED_CHECK(write, true, 2)
419
431
TSAN_UNALIGNED_CHECK(write, true , 4 )
420
432
TSAN_UNALIGNED_CHECK(write, true , 8 )
421
433
422
- DEVICE_EXTERN_C_NOINLINE void
423
- __tsan_unaligned_write16(uptr addr, uint32_t as,
424
- const char __SYCL_CONSTANT__ *file, uint32_t line,
425
- const char __SYCL_CONSTANT__ *func) {
426
- __tsan_unaligned_write8 (addr, as, file, line, func);
427
- __tsan_unaligned_write8 (addr + 8 , as, file, line, func);
428
- }
434
+ # define TSAN_UNALIGNED_CHECK16_BASE ( type, as ) \
435
+ DEVICE_EXTERN_C_NOINLINE void __tsan_unaligned_##type##16_p##as( \
436
+ uptr addr, const char __SYCL_CONSTANT__ *file, uint32_t line, \
437
+ const char __SYCL_CONSTANT__ *func) { \
438
+ __tsan_unaligned_##type##8_p## as (addr, file, line, func); \
439
+ __tsan_unaligned_##type##8_p## as (addr + 8 , file, line, func); \
440
+ }
429
441
430
- DEVICE_EXTERN_C_NOINLINE void
431
- __tsan_unaligned_read16 (uptr addr, uint32_t as,
432
- const char __SYCL_CONSTANT__ *file, uint32_t line,
433
- const char __SYCL_CONSTANT__ *func) {
434
- __tsan_unaligned_read8 (addr, as, file, line, func);
435
- __tsan_unaligned_read8 (addr + 8 , as, file, line, func);
436
- }
442
+ # define TSAN_UNALIGNED_CHECK16 ( type ) \
443
+ TSAN_UNALIGNED_CHECK16_BASE (type, 1 ) \
444
+ TSAN_UNALIGNED_CHECK16_BASE(type, 3 ) \
445
+ TSAN_UNALIGNED_CHECK16_BASE(type, 4 )
446
+
447
+ TSAN_UNALIGNED_CHECK16(read)
448
+ TSAN_UNALIGNED_CHECK16(write)
437
449
438
450
static inline void __tsan_cleanup_private_cpu_impl(uptr addr, uint32_t size) {
439
451
if (size) {
0 commit comments