[libcxx-commits] [libcxx] [libc++] Reduce std::conjunction overhead (PR #124259)

Ilya Biryukov via libcxx-commits libcxx-commits at lists.llvm.org
Fri Feb 7 05:24:55 PST 2025


ilya-biryukov wrote:

@philnik777 we have investigated further and found that this seems to boil down to Clang requiring more stack (likely deeper recursions) when instantiating `std::tuple` with long argument lists.

In our code, we end up crashing with stack overflow when instantiating `std::tuple<1000 x size_t>`. The upstream compiler takes a little longer (we seem to have more aggressive inlining when compiling Clang internally), but also seems to crash eventually. Here's a simple example with Clang from trunk and Clang 19 (they should be using the corresponding versions of libc++ that match the git commit). A tuple with 2k element either crashes it or times out, not sure about godbolt's output here:
https://gcc.godbolt.org/z/KTq98rfhr

If you play around with the tuple sizes, you'll see that smaller numbers that don't fail result in much higher compile times with the new approach.

The caveat is that there might've been more changes between Clang 19 and now, but we are pretty certain this commit is the root cause based on our rolling testing.

Could you please take a look if compiling `std::tuple` with long argument lists got slower / more crashy and investigate if that's expected? 

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


More information about the libcxx-commits mailing list