[all-commits] [llvm/llvm-project] 0cebae: [compiler-rt] Add 'csan' library for the concurren...

Joseph Huber via All-commits all-commits at lists.llvm.org
Thu Oct 1 18:01:36 PDT 2026


  Branch: refs/heads/users/jhuber6/csan
  Home:   https://github.com/llvm/llvm-project
  Commit: 0cebae0833ef35774ab4ff4880acbca543bc8a18
      https://github.com/llvm/llvm-project/commit/0cebae0833ef35774ab4ff4880acbca543bc8a18
  Author: Joseph Huber <huberjn at outlook.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M compiler-rt/cmake/caches/AMDGPU.cmake
    M compiler-rt/cmake/config-ix.cmake
    A compiler-rt/lib/csan/CMakeLists.txt
    A compiler-rt/lib/csan/csan.cpp
    A compiler-rt/lib/csan/csan.h
    A compiler-rt/lib/csan/csan_defs.h
    A compiler-rt/lib/csan/csan_flags.inc
    A compiler-rt/lib/csan/csan_gpu.cpp
    A compiler-rt/lib/csan/csan_offload_packet.h
    A compiler-rt/lib/csan/csan_report.cpp
    A compiler-rt/lib/csan/csan_watch.h
    A compiler-rt/lib/csan/offload/CMakeLists.txt
    A compiler-rt/lib/csan/offload/csan_offload.h
    A compiler-rt/lib/csan/offload/csan_offload_hsa_interceptors.cpp
    A compiler-rt/lib/csan/offload/csan_offload_report.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
    M compiler-rt/lib/sanitizer_common/sanitizer_offload.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_offload.h
    M compiler-rt/lib/sanitizer_common/sanitizer_offload_hsa.h
    M compiler-rt/lib/sanitizer_common/sanitizer_offload_image.cpp
    M compiler-rt/lib/sanitizer_common/sanitizer_offload_opcodes.h
    M compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
    M compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
    A compiler-rt/test/csan/AMDGPU/aba-race.hip
    A compiler-rt/test/csan/AMDGPU/array-race.hip
    A compiler-rt/test/csan/AMDGPU/atomic-nonatomic.hip
    A compiler-rt/test/csan/AMDGPU/atomic.hip
    A compiler-rt/test/csan/AMDGPU/disjoint.hip
    A compiler-rt/test/csan/AMDGPU/global-race.hip
    A compiler-rt/test/csan/AMDGPU/helper-race.hip
    A compiler-rt/test/csan/AMDGPU/lds-disjoint.hip
    A compiler-rt/test/csan/AMDGPU/lds-race.hip
    A compiler-rt/test/csan/AMDGPU/lit.local.cfg.py
    A compiler-rt/test/csan/AMDGPU/memcpy-large-race.hip
    A compiler-rt/test/csan/AMDGPU/memcpy-race.hip
    A compiler-rt/test/csan/AMDGPU/memmove-race.hip
    A compiler-rt/test/csan/AMDGPU/openmp-race.cpp
    A compiler-rt/test/csan/AMDGPU/race.h
    A compiler-rt/test/csan/AMDGPU/shared-watchpoints.hip
    A compiler-rt/test/csan/AMDGPU/single-thread.hip
    A compiler-rt/test/csan/AMDGPU/write-read-race.hip
    A compiler-rt/test/csan/CMakeLists.txt
    A compiler-rt/test/csan/access-sizes.cpp
    A compiler-rt/test/csan/atomic-nonatomic.cpp
    A compiler-rt/test/csan/atomic.cpp
    A compiler-rt/test/csan/halt-on-error.cpp
    A compiler-rt/test/csan/ignore-thread.cpp
    A compiler-rt/test/csan/large-access.cpp
    A compiler-rt/test/csan/large-range-race.cpp
    A compiler-rt/test/csan/lit.common.cfg.py
    A compiler-rt/test/csan/lit.site.cfg.py.in
    A compiler-rt/test/csan/race.cpp
    A compiler-rt/test/csan/read-read.cpp
    A compiler-rt/test/csan/single-thread.cpp
    A compiler-rt/test/csan/unknown-origin.cpp
    M compiler-rt/test/lit.common.cfg.py

  Log Message:
  -----------
  [compiler-rt] Add 'csan' library for the concurrency sanitizer

Summary:
Adds the runtime for the concurrency sanitizer, both CPU and GPU.
Fundamentally, this works using the following pseudocode:

```c
static u64 watchpoints[N]; // Hash-indexed, zero is empty.

// Emitted before the access, so we never trip on our own write.
void check_access(volatile void *addr, u32 size, u32 type) {
    // Every access probes. A read conflicts only with a watched write, a
    // write conflicts with either.
    if (u64 *wp = find_watchpoint(addr, size, type))
        consume(wp, this_pc()); // Hand our location to the owner.

    if (!should_sample()) // Wave-uniform, 1-in-N chance.
        return;

    u64 *wp = arm_watchpoint(addr, size, type);
    if (!wp) // Slot is already taken.
        return;

    auto old = read(addr, size);
    delay(ctx.rand()); // Randomized, bounded.

    if (void *peer = disarm(wp))
        report_race(addr, this_pc(), peer);
    else if (read(addr, size) != old)
        report_race(addr, this_pc(), UNKNOWN);
}
```

This implementation is kept intentionally minimal to simplify the review
process. Many options are planned for later. The intended use is for
users to pass `-fsanitize=concurrency` for supported compilations.


  Commit: 417d1ba94901a66b901c8eab188b9230024a6f99
      https://github.com/llvm/llvm-project/commit/417d1ba94901a66b901c8eab188b9230024a6f99
  Author: Joseph Huber <huberjn at outlook.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
    M compiler-rt/cmake/config-ix.cmake
    M compiler-rt/lib/csan/CMakeLists.txt
    M compiler-rt/lib/csan/csan_gpu.cpp
    M compiler-rt/lib/csan/offload/CMakeLists.txt
    M compiler-rt/test/csan/CMakeLists.txt

  Log Message:
  -----------
  comments


  Commit: ccb04f8460b2c74b6a13ce2e7a7c188be7e6f39b
      https://github.com/llvm/llvm-project/commit/ccb04f8460b2c74b6a13ce2e7a7c188be7e6f39b
  Author: Joseph Huber <huberjn at outlook.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M compiler-rt/lib/csan/CMakeLists.txt
    A compiler-rt/lib/csan/csan.syms.extra
    M compiler-rt/lib/csan/offload/CMakeLists.txt
    M compiler-rt/lib/csan/offload/csan_offload_hsa_interceptors.cpp
    A compiler-rt/lib/csan/offload/csan_offload_preinit.cpp
    M compiler-rt/test/csan/AMDGPU/global-race.hip
    M compiler-rt/test/csan/AMDGPU/openmp-race.cpp
    A compiler-rt/test/csan/hsa-load-order.cpp
    A compiler-rt/test/csan/hsa-missing.cpp
    M compiler-rt/test/csan/lit.common.cfg.py
    M compiler-rt/test/csan/race.cpp

  Log Message:
  -----------
  [compiler-rt] Remove dlsym interceptor and support `-shared-libsan` for CSan

Summary:
Follow the UBSan offload runtime. Offload now resolves HSA through the
global scope, so the `dlsym` interceptor is no longer needed. The real
HSA entry points are still taken from the loaded HSA library rather than
`RTLD_NEXT`, since every DSO with a static runtime exports the same
wrappers and they would otherwise chain back into each other.

Build `libclang_rt.csan.so` with the offload objects folded in. The
exported HSA wrappers report failure when HSA is absent and warn when HSA
was loaded ahead of the runtime. The preinit hook moves to a separate
`csan_offload-preinit` archive for executables.


  Commit: ac79d0d681dbfd661690956f195cbbc9ebc7e94c
      https://github.com/llvm/llvm-project/commit/ac79d0d681dbfd661690956f195cbbc9ebc7e94c
  Author: Joseph Huber <huberjn at outlook.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M compiler-rt/lib/csan/csan.cpp
    M compiler-rt/lib/csan/csan_gpu.cpp
    A compiler-rt/test/csan/AMDGPU/volatile.hip
    A compiler-rt/test/csan/volatile.cpp

  Log Message:
  -----------
  Remove separate volatile entry points


  Commit: 6917c68e505fe83eb59e76b85963f1bb1855fb78
      https://github.com/llvm/llvm-project/commit/6917c68e505fe83eb59e76b85963f1bb1855fb78
  Author: Joseph Huber <huberjn at outlook.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M compiler-rt/lib/csan/csan.cpp
    M compiler-rt/test/csan/access-sizes.cpp

  Log Message:
  -----------
  Use unaligned loads when snapshotting watched values


Compare: https://github.com/llvm/llvm-project/compare/a301d4e87d77...6917c68e505f

To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list