[compiler-rt] [tsan][go] use __builtin_memcpy for 128-bit Go atomic args buffer access (PR #213123)

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 16 13:51:20 PDT 2026


https://github.com/vitalybuka approved this pull request.

LGTM with internal_memcpy

it probably less effcient but less likely hit interceptorps

Maybe this one:
```
ALIGNED(8) typedef a128 a128_u64;
SANITIZER_INTERFACE_ATTRIBUTE
void __tsan_go_atomic128_load(ThreadState* thr, uptr cpc, uptr pc, u8* a) {
  *(a128_u64*)(a + 8) =
      AtomicGoRet<OpLoad>(thr, cpc, pc, mo_acquire, *(a128**)a);
}
```

can we have test,

go/test.c?

```
#if defined(__SIZEOF_INT128__) && !defined(__mips64) && !defined(__s390x__)
  {
    // Align `a` to 16 bytes so `a + 8` and `a + 24` are 8-byte aligned (8 mod 16).
    __attribute__((aligned(16))) char a[64];
    *(void **)(a + 0) = buf;
    __builtin_memset(a + 8, 0x11, 16);
    __tsan_go_atomic128_store(thr0, (char *)&barfoo + 1, (char *)&barfoo + 1, a);
    __builtin_memset(a + 8, 0, 16);
    __tsan_go_atomic128_load(thr0, (char *)&barfoo + 1, (char *)&barfoo + 1, a);
    __builtin_memset(a + 24, 0x22, 16);
    __tsan_go_atomic128_compare_exchange(thr0, (char *)&barfoo + 1, (char *)&barfoo + 1, a);
  }
```

https://github.com/llvm/llvm-project/pull/213123


More information about the llvm-commits mailing list