================ @@ -78,23 +80,232 @@ public: __split_buffer, void>; - pointer __first_; - pointer __begin_; - pointer __end_; - _LIBCPP_COMPRESSED_PAIR(pointer, __cap_, allocator_type, __alloc_); + struct __data { + pointer __first_ = nullptr; + pointer __begin_ = nullptr; +#ifdef _LIBCPP_ABI_SIZE_BASED_CONTAINERS + size_type __size_ = 0; + size_type __cap_ = 0; + allocator_type __alloc_; +#else + pointer __end_ = nullptr; + _LIBCPP_COMPRESSED_PAIR(pointer, __cap_ = nullptr, allocator_type, __alloc_); +#endif + + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI __data() = default; + + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit __data(const allocator_type& __alloc) + : __alloc_(__alloc) + {} + + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer begin() _NOEXCEPT { + return __begin_; + } + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI const_pointer begin() const _NOEXCEPT { + return __begin_; + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer end() _NOEXCEPT { +#ifdef _LIBCPP_ABI_SIZE_BASED_CONTAINERS + return __begin_ + __size_; +#else + return __end_; +#endif + } + + _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer end() const _NOEXCEPT { +#ifdef _LIBCPP_ABI_SIZE_BASED_CONTAINERS + return __begin_ + __size_; +#else + return __end_; +#endif + } ---------------- cjdb wrote:
Here's what calling `end()` when [optimisations are disabled](https://godbolt.org/z/96Ph6sT1r) looks like with both implementations, across a handful of popular targets (or targets with increasing popularity). It looks like a fairly noticeable increase in code size, which risks pessimising debug performance. It's impossible to know if this is indeed a performance regression without benchmarks, and our load test infrastructure isn't set up to evaluate debug performance, which is why I wanted to keep the code consistent with what's currently there. There isn't a need to debate the trade-off any further though. IIUC your goal here was to reduce the `#ifdef` granularity, which the current implementation does in a different way. https://github.com/llvm/llvm-project/pull/139632 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits