[libcxx-commits] [libcxx] [libc++] Add build flags to optimize <format> and <charconv> for code size. (PR #98003)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 9 14:23:04 PDT 2024


================
@@ -274,6 +274,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI int __to_chars_integral_widt
 template <typename _Tp>
 inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result
 __to_chars_integral(char* __first, char* __last, _Tp __value, int __base, false_type) {
+# ifndef _LIBCPP_CHARCONV_OPTIMIZE_SIZE
----------------
ldionne wrote:

Yes, ideally we'd do something like automatically switch to this implementation under `-Os` (we have precedent for that in a few algorithms where we use vectorization). However, it becomes impossible to break ABI if we do that, since we *must* have a compatible ABI regardless of the optimization level.

How much of a code size benefit are we talking about here? If the code size benefits are extremely large, it might make sense to think about whether this can be made the default implementation (breaking the ABI would still be an issue but we can still entertain that idea).

https://github.com/llvm/llvm-project/pull/98003


More information about the libcxx-commits mailing list