@@ -67,7 +67,7 @@ inline void ConvertGenericPointer(uptr &addr, uint32_t &as) {
6767 // FIXME: I'm not sure if we need to check ADDRESS_SPACE_CONSTANT,
6868 // but this can really simplify the generic pointer conversion logic
6969 as = ADDRESS_SPACE_GLOBAL;
70- addr = old;
70+ addr = (uptr) ToGlobal (( void *) old) ;
7171 }
7272 TSAN_DEBUG (__spirv_ocl_printf (__tsan_print_generic_to, old, addr, as));
7373}
@@ -317,10 +317,10 @@ inline bool ContainsSameAccess(__SYCL_GLOBAL__ RawShadow *s, Shadow cur,
317317
318318} // namespace
319319
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) { \
324324 __SYCL_GLOBAL__ RawShadow *shadow_mem = MemToShadow (addr, as); \
325325 if (!shadow_mem) \
326326 return ; \
@@ -341,6 +341,11 @@ inline bool ContainsSameAccess(__SYCL_GLOBAL__ RawShadow *s, Shadow cur,
341341 CheckRace (shadow_mem, cur, type, addr, size, as, file, line, func); \
342342 }
343343
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+
344349TSAN_CHECK(read, false , 1 )
345350TSAN_CHECK(read, false , 2 )
346351TSAN_CHECK(read, false , 4 )
@@ -350,24 +355,26 @@ TSAN_CHECK(write, true, 2)
350355TSAN_CHECK(write, true , 4 )
351356TSAN_CHECK(write, true , 8 )
352357
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+ }
359365
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 )
366370
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) { \
371378 __SYCL_GLOBAL__ RawShadow *shadow_mem = MemToShadow (addr, as); \
372379 if (!shadow_mem) \
373380 return ; \
@@ -410,6 +417,11 @@ __tsan_read16(uptr addr, uint32_t as, const char __SYCL_CONSTANT__ *file,
410417 } \
411418 }
412419
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+
413425TSAN_UNALIGNED_CHECK(read, false , 1 )
414426TSAN_UNALIGNED_CHECK(read, false , 2 )
415427TSAN_UNALIGNED_CHECK(read, false , 4 )
@@ -419,21 +431,21 @@ TSAN_UNALIGNED_CHECK(write, true, 2)
419431TSAN_UNALIGNED_CHECK(write, true , 4 )
420432TSAN_UNALIGNED_CHECK(write, true , 8 )
421433
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+ }
429441
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)
437449
438450static inline void __tsan_cleanup_private_cpu_impl(uptr addr, uint32_t size) {
439451 if (size) {
0 commit comments