[all-commits] [llvm/llvm-project] abd5e4: [compiler-rt] Use __atomic builtins whenever possible

Alexander Richardson via All-commits all-commits at lists.llvm.org
Wed Apr 17 08:43:02 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: abd5e45a96954d80f6ffe6d8676c0059fae8573b
      https://github.com/llvm/llvm-project/commit/abd5e45a96954d80f6ffe6d8676c0059fae8573b
  Author: Alexander Richardson <alexrichardson at google.com>
  Date:   2024-04-17 (Wed, 17 Apr 2024)

  Changed paths:
    M compiler-rt/lib/sanitizer_common/CMakeLists.txt
    M compiler-rt/lib/sanitizer_common/sanitizer_atomic.h
    M compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang.h
    R compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_mips.h
    R compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_other.h
    R compiler-rt/lib/sanitizer_common/sanitizer_atomic_clang_x86.h
    M compiler-rt/lib/sanitizer_common/sanitizer_atomic_msvc.h
    M llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn

  Log Message:
  -----------
  [compiler-rt] Use __atomic builtins whenever possible

The code in this file dates back to 2012 when Clang's support for atomic
builtins was still quite limited. The bugs referenced in the comment
at the top of the file have long been fixed and using the compiler
builtins directly should now generate slightly better code.
Additionally, this allows using the atomic builtin header for platforms
where the __sync_builtins are lacking (e.g. Arm Morello).

This change does not introduce any code generation changes for
__tsan_read*/__tsan_write* or __tsan_func_{entry,exit} on x86, which
indicates the previously noted compiler issues have been fixed.

We also have to touch the non-clang codepaths here since the only way we
can make this work easily is by making the memory_order enum match the
compiler-provided macros, so we have to update the debug checks that
assumed the enum was always a bitflag.

The one downside of this change is that 32-bit MIPS now definitely
requires libatomic (but that may already have been needed for RMW ops).

Reviewed By: dvyukov

Pull Request: https://github.com/llvm/llvm-project/pull/84439



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