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

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 8 10:14:27 PDT 2024


================
@@ -250,29 +250,79 @@ class __basic_format_arg_value {
     __handle __handle_;
   };
 
+  // Visiting a value for formatting is dispatched via a function pointer to prevent
+  // unused formatters from being instantiated. This can lead to significant code size 
+  // reductions on statically linked targets esp. at lower optimization levels.
+
+  void (__basic_format_arg_value::*__format_)(
+      basic_format_parse_context<_CharT>& __parse_ctx, _Context& __ctx, bool __parse) const;
----------------
mordante wrote:

This adds a new member to the class and changes its size. This affects the size of `basic_format_arg` and is an ABI break.

I have not started the GH CI, the Buildkite CI fails to use `std::format` with the current changes.

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


More information about the libcxx-commits mailing list