[all-commits] [llvm/llvm-project] 29be7c: [libcxxabi] Re-organized inheritance structure to ...

DanielMcIntosh via All-commits all-commits at lists.llvm.org
Wed Jan 12 14:31:22 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 29be7c9c4f5d03be21ac80dc178a730aa10452f9
      https://github.com/llvm/llvm-project/commit/29be7c9c4f5d03be21ac80dc178a730aa10452f9
  Author: Daniel McIntosh <Daniel.McIntosh at ibm.com>
  Date:   2022-01-12 (Wed, 12 Jan 2022)

  Changed paths:
    M libcxxabi/src/cxa_guard_impl.h
    M libcxxabi/test/guard_test_basic.pass.cpp

  Log Message:
  -----------
  [libcxxabi] Re-organized inheritance structure to remove CRTP in cxa_guard

Currently, the `InitByte...` classes inherit from `GuardObject` so they can
access the `base_address`, `init_byte_address` and `thread_id_address`. Then,
since `GuardObject` needs to call `acquire`/`release`/`abort_init_byte`, it uses
the curiously recurring template pattern (CRTP). This is rather messy.

Instead, we'll have `GuardObject` contain an instance of `InitByte`, and pass it
the addresses it needs in the constructor. `GuardObject` doesn't need the
addresses anyways, so it makes more sense for `InitByte` to keep them instead of
`GuardObject`. Then, `GuardObject` can call `acquire`/`release`/`abort` as one
of `InitByte`'s member functions.

Organizing things this way not only gets rid of the use of the CRTP, but also
improves separation of concerns a bit since the `InitByte` classes are no longer
indirectly responsible for things because of their inheritance from
`GuardObject`. This means we no longer have strange things like calling
`InitByteFutex.cxa_guard_acquire`, instead we call
`GuardObject<InitByteFutex>.cxa_guard_acquire`.

This is the 4th of 5 changes to overhaul cxa_guard.
See D108343 for what the final result will be.

Depends on D115367

Reviewed By: ldionne, #libc_abi

Differential Revision: https://reviews.llvm.org/D115368




More information about the All-commits mailing list