Open
Description
Clang generates more than 2.5x the amount of assembly for the sample below when using std::format
, as opposed to an inline fmt::format
.
#include <string>
#ifdef USE_LIBFMT
#include <fmt/format-inl.h>
namespace format = fmt;
#else
#include <format>
namespace format = std;
#endif
std::string f(int const x)
{
return format::format("{}", x);
}
Architecture | Options | std::format codegen (lines) |
fmt::format codegen (lines) |
Binary size delta |
---|---|---|---|---|
x86_64 | 2726 | 1013 | std is 2.7x larger | |
x86_64 | -O3 | 3661 | 957 | std is 3.8x larger |
x86_64 | -Os | 2632 | 908 | std is 2.9x larger |
armv8-a | 2594 | 961 | std is 2.7x larger | |
armv8-a | -O3 | 2525 | 941 | std is 2.7x larger |
armv8-a | -Os | 2429 | 917 | std is 2.6x larger |
Is this something that we can improve upon, or is are the respective libraries designed differently enough that this additional codegen is unavoidable?
Metadata
Metadata
Assignees
Labels
C++20 std::format or std::print, and anything related to themC++20 std::format or std::print, and anything related to themlibc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.