Skip to content

Commit

Permalink
[DevMSAN] Only return clean shadow for device usm and ptr with global…
Browse files Browse the repository at this point in the history
… as (#16567)
  • Loading branch information
zhaomaosu authored Jan 9, 2025
1 parent 93de8f1 commit 4d3ffae
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions libdevice/sanitizer/msan_rtl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,12 @@ inline uptr __msan_get_shadow_cpu(uptr addr) {
inline uptr __msan_get_shadow_pvc(uptr addr, uint32_t as) {
if (as == ADDRESS_SPACE_GENERIC) {
ConvertGenericPointer(addr, as);
if (as != ADDRESS_SPACE_GLOBAL)
return (uptr)((__SYCL_GLOBAL__ MsanLaunchInfo *)__MsanLaunchInfo.get())
->CleanShadow;
}

if (as != ADDRESS_SPACE_GLOBAL || !(addr & 0xFF00000000000000))
return (uptr)((__SYCL_GLOBAL__ MsanLaunchInfo *)__MsanLaunchInfo.get())
->CleanShadow;

// Device USM only
auto shadow_begin = ((__SYCL_GLOBAL__ MsanLaunchInfo *)__MsanLaunchInfo.get())
->GlobalShadowOffset;
Expand Down Expand Up @@ -196,11 +197,6 @@ DEVICE_EXTERN_C_NOINLINE uptr __msan_get_shadow(uptr addr, uint32_t as) {
if (!__MsanLaunchInfo.get())
return shadow_ptr;

if (UNLIKELY(!__MsanLaunchInfo)) {
__spirv_ocl_printf(__msan_print_warning_nolaunchinfo);
return shadow_ptr;
}

auto launch_info = (__SYCL_GLOBAL__ MsanLaunchInfo *)__MsanLaunchInfo.get();
MSAN_DEBUG(__spirv_ocl_printf(__msan_print_launchinfo, (void *)launch_info,
launch_info->GlobalShadowOffset));
Expand Down

0 comments on commit 4d3ffae

Please sign in to comment.