The current chunking strategy is very bad for sorting, and we don't really know how to chunk in general. This fixes the performance problem for sorting.
Reviewed By: ldionne, #libc
Spies: libcxx-commits, krytarowski
Differential Revision: https://reviews.llvm.org/D155531
Use header_information to generate the __std_clang_module header. Instead of using lit_header_restrictions like the manually written header did, make a new header_include_requirements to codify what can be included rather than what can be fully tested.
Reviewed By: Mordante, #libc
Differential Revision: https://reviews.llvm.org/D157364
Top level modules don't need `requires` because they're only built when their headers are included.
Reviewed By: ldionne, Mordante, #libc
Differential Revision: https://reviews.llvm.org/D157363
In the event the internal function __init is called with an empty string the code will take unnecessary extra steps, in addition, the code generated might be overall greater because, to my understanding, when initializing a string with an empty `const char*` "" (like in this case), the compiler might be unable to deduce the string is indeed empty at compile time and more code is generated.
The goal of this patch is to make a new internal function that will accept just an error code skipping the empty string argument. It should skip the unnecessary steps and in the event `if (ec)` is `false`, it will return an empty string using the correct ctor, avoiding any extra code generation issues.
After the conversation about this patch matured in the libcxx channel on the LLVM Discord server, the patch was analyzed quickly with "Compiler Explorer" and other tools and it was discovered that it does indeed reduce the amount of code generated when using the latest stable clang version (16) which in turn produces faster code.
This patch targets LLVM 18 as it will break the ABI by addressing https://github.com/llvm/llvm-project/issues/63985
Benchmark tests run on other machines as well show in the best case, that the new version without the extra string as an argument performs 10 times faster.
On the buildkite CI run it shows the new code takes less CPU time as well.
In conclusion, the new code should also just appear cleaner because there are fewer checks to do when there is no message.
Reviewed By: #libc, philnik
Spies: emaste, nemanjai, philnik, libcxx-commits
Differential Revision: https://reviews.llvm.org/D155820
I need to use header_information.py in a generator script that isn't for tests in an upcoming change. Move it up a level so that it's in utils/libcxx instead of utils/libcxx/tests.
Differential Revision: https://reviews.llvm.org/D157639
experimental/algorithm and experimental/functional no longer exist, but header_information.py still has references.
Differential Revision: https://reviews.llvm.org/D157639
We don't actually use these headers, so we might as well remove them.
Reviewed By: ldionne, #libc
Spies: arichardson, EricWF, sstefan1, jplehr, wangpc, mgrang, libcxx-commits, miyuki
Differential Revision: https://reviews.llvm.org/D157558
With ABI version 2 and big endian Arm, the full_size test matches the
current behaviour. It's possible that this would also be the case for
other big endian architectures but I don't have data on that.
Differential Revision: https://reviews.llvm.org/D157699
We were defining the function in locale.cpp, and we actually had two
overloads for it. This is pretty confusing given that one was static
and not exported from the dylib, and the other one was. Instead, use
the vanilla __throw_runtime_error function everywhere even though that
adds a tiny bit of code duplication.
Differential Revision: https://reviews.llvm.org/D155008
This has been deprecated and should be removed now.
Reviewed By: #libc, Mordante
Spies: Mordante, libcxx-commits
Differential Revision: https://reviews.llvm.org/D157058
This patch is based on the suggestion by @ChuanqiXu on discourse
(https://discourse.llvm.org/t/alternatives-to-the-implementation-of-std-modules/71958)
Instead of making a module partition per header every header gets an inc
file which contains the exports per header. The std module then includes
all public headers and these inc files. The one file per header is
useful for testing purposes. The CI tests whether the exports of a
header's module partition matches the "public" named declarations in the
header. With one file per header this can still be done.
The patch improves compilation time of files using "import std;" and the
size of the std module.
A comparision of the compilation speed using a libc++ test
build/bin/llvm-lit -a -Dstd=c++23 -Denable_modules=std libcxx/test/std/modules/std.pass.cpp
Which boils down to
import std;
int main(int, char**) {
std::println("Hello modular world");
return 0;
}
and has -ftime-report enabled
Before
===-------------------------------------------------------------------------===
Clang front-end time report
===-------------------------------------------------------------------------===
Total Execution Time: 8.6585 seconds (8.6619 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
4.5041 ( 57.2%) 0.4264 ( 54.4%) 4.9305 ( 56.9%) 4.9331 ( 57.0%) Clang front-end timer
3.2037 ( 40.7%) 0.2408 ( 30.7%) 3.4445 ( 39.8%) 3.4452 ( 39.8%) Reading modules
0.1665 ( 2.1%) 0.1170 ( 14.9%) 0.2835 ( 3.3%) 0.2837 ( 3.3%) Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm
7.8744 (100.0%) 0.7842 (100.0%) 8.6585 (100.0%) 8.6619 (100.0%) Total
After
===-------------------------------------------------------------------------===
Clang front-end time report
===-------------------------------------------------------------------------===
Total Execution Time: 1.2420 seconds (1.2423 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
0.8892 ( 84.6%) 0.1698 ( 88.8%) 1.0590 ( 85.3%) 1.0590 ( 85.2%) Clang front-end timer
0.1533 ( 14.6%) 0.0168 ( 8.8%) 0.1701 ( 13.7%) 0.1704 ( 13.7%) Reading modules
0.0082 ( 0.8%) 0.0047 ( 2.5%) 0.0129 ( 1.0%) 0.0129 ( 1.0%) Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm
1.0507 (100.0%) 0.1913 (100.0%) 1.2420 (100.0%) 1.2423 (100.0%) Total
Using "include <print>" instead of "import module;"
===-------------------------------------------------------------------------===
Clang front-end time report
===-------------------------------------------------------------------------===
Total Execution Time: 2.1507 seconds (2.1517 wall clock)
---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name ---
1.9714 (100.0%) 0.1793 (100.0%) 2.1507 (100.0%) 2.1517 (100.0%) Clang front-end timer
1.9714 (100.0%) 0.1793 (100.0%) 2.1507 (100.0%) 2.1517 (100.0%) Total
It's possible to use the std module in external projects
(https://libcxx.llvm.org/Modules.html#using-in-external-projects)
Tested this with a private project to validate the size of the generated files:
Before
$ du -sch std-*
448M std-build
508K std-src
120K std-subbuild
449M total
After
$ du -sch std-*
29M std-build
1004K std-src
132K std-subbuild
30M total
Reviewed By: ldionne, #libc
Differential Revision: https://reviews.llvm.org/D156907
The builders are in a broken state, which causes all the CI builds
to appear as red. Make them soft fail until we've managed to reach
the build bot owners.
Differential Revision: https://reviews.llvm.org/D157421
P2408 requires this for C++23, but implementing it in C++20 is safe
because the only code impacted would be code that violated a
precondition of the parallel algorithm. It was P2408 intent to
enable implementations to backport this to C++20.
Closes#63447 .
Reviewed By: philnik, #libc
Differential Revision: https://reviews.llvm.org/D154305
PSTL contains many pragmas that request loop vectorization, which would
produce a warning when the compiler is unable to fulfill the request (if
`-Wpass-failed` is enabled). This is normal and expected in some cases,
and we don't want `-Werror` to turn that into a compilation failure.
Differential Revision: https://reviews.llvm.org/D157145
If CMAKE_MSVC_RUNTIME_LIBRARY isn't set, then CMake defaults to
the debug CRT, if CMAKE_BUILD_TYPE is set to Debug. If
CMAKE_MSVC_RUNTIME_LIBRARY is set though, that overrides any
implicit defaults.
Match this in libcxx's own manual linking logic. This allows
decoupling the debug CRT from the CMAKE_BUILD_TYPE and allows users
to configure their builds exactly how they want.
Differential Revision: https://reviews.llvm.org/D155561
`print` functions require `FILE` and `stdout` to be available and cause
compilation errors on platforms that don't support the file system.
Differential Revision: https://reviews.llvm.org/D156585
Make it a multichoice string to closer mirror the CMake variable. This
allows writing `UNSUPPORTED: libcpp-hardening-mode=unchecked` rather
than `UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode`.
Differential Revision: https://reviews.llvm.org/D155906
Some places in the format library were identified to benefit from
basic_string's from_range constructor. At that time that constructor was
not implemented. It's implemented now so adjust the code to use this new
constructor.
Reviewed By: #libc, var-const
Differential Revision: https://reviews.llvm.org/D156022