Issue |
140108
|
Summary |
`std::format` generates substantially more code than inlined `fmt::format`
|
Labels |
libc++,
format
|
Assignees |
mordante
|
Reporter |
cjdb
|
[Clang generates more than 2.5x the amount of assembly](https://godbolt.org/z/sv56Y1sMz) for the sample below when using `std::format`, as opposed to an inline `fmt::format`.
```cpp
#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?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs