drc: make sanitizers happier
authornotaz <notasas@gmail.com>
Thu, 19 Feb 2026 02:05:27 +0000 (04:05 +0200)
committernotaz <notasas@gmail.com>
Thu, 19 Feb 2026 02:05:27 +0000 (04:05 +0200)
libpcsxcore/new_dynarec/new_dynarec.c
libpcsxcore/new_dynarec/pcsxmem.c

index b976b87..b004b68 100644 (file)
@@ -4357,8 +4357,10 @@ static void speculate_register_values(struct compile_state *st, int i)
     case SHIFT:
     case LOADLR:
     case MOV:
-      smrv_strong_next&=~(1<<dops[i].rt1);
-      smrv_weak_next&=~(1<<dops[i].rt1);
+      if (dops[i].rt1 < 32) {
+        smrv_strong_next &= ~(1 << dops[i].rt1);
+        smrv_weak_next &= ~(1 << dops[i].rt1);
+      }
       break;
     case COP0:
     case COP2:
index 804330b..e0520ea 100644 (file)
@@ -31,25 +31,22 @@ static uintptr_t mem_ffwtab[(1+2+4) * 0x1000 / 4];
 //static uintptr_t mem_unmrtab[(1+2+4) * 0x1000 / 4];
 static uintptr_t mem_unmwtab[(1+2+4) * 0x1000 / 4];
 
-static
-#ifdef __clang__
-// When this is called in a loop, and 'h' is a function pointer, clang will crash.
-__attribute__ ((noinline))
-#endif
-void map_item(uintptr_t *out, const void *h, uintptr_t flag)
+static void map_item_(uintptr_t *out, uintptr_t hv, uintptr_t flag)
 {
-       uintptr_t hv = (uintptr_t)h;
        if (hv & 1) {
-               SysPrintf("FATAL: %p has LSB set\n", h);
+               SysPrintf("FATAL: %zx has LSB set\n", hv);
                abort();
        }
        *out = (hv >> 1) | (flag << (sizeof(hv) * 8 - 1));
 }
 
+#define map_item(out_, h_, flag_) \
+       map_item_(out_, (uintptr_t)(h_), flag_)
+
 // size must be power of 2, at least 4k
 #define map_l1_mem(tab, i, addr, size, base) \
-       map_item(&tab[((u32)(addr) >> 12) + i], \
-                (u8 *)(base) - (u32)((addr) + ((i << 12) & ~(size - 1))), 0)
+       map_item_(&tab[((u32)(addr) >> 12) + i], \
+                (uintptr_t)(base) - (u32)((addr) + ((i << 12) & ~(size - 1))), 0)
 
 #define IOMEM32(a) (((a) & 0xfff) / 4)
 #define IOMEM16(a) (0x1000/4 + (((a) & 0xfff) / 2))