[all-commits] [llvm/llvm-project] b2574c: [clang] [libc++] fix _Atomic c11 compare exchange ...

Hui via All-commits all-commits at lists.llvm.org
Sun Oct 19 11:25:21 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b2574c9dad487be92605316efd929738a5f6d851
      https://github.com/llvm/llvm-project/commit/b2574c9dad487be92605316efd929738a5f6d851
  Author: Hui <hui.xie1990 at gmail.com>
  Date:   2025-10-19 (Sun, 19 Oct 2025)

  Changed paths:
    M clang/lib/CodeGen/CGAtomic.cpp
    M clang/test/CodeGen/c11atomics-ios.c
    A clang/test/CodeGenCXX/builtin-atomic-compare_exchange.cpp
    A libcxx/test/std/atomics/atomics.types.generic/cas_non_power_of_2.pass.cpp

  Log Message:
  -----------
  [clang] [libc++] fix _Atomic c11 compare exchange does not update expected results (#78707)

fixes #30023

The issue is that for compare exchange builtin, if the type's size is
not power of 2, it creates a temporary of size power of 2, then emit the
compare exchange operation. And later, the results of the compare
exchange operation has two components: 1. a boolean whether or not the
exchange happens. 2. the old value
we are supposed to write the old value into user's "expected" value.
However, in case the type is not power of 2, what we actually wrote to
is the temporary that was created.

The fix is to pass the "expected" address all the way down so it can
wrote to the correct address



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