[libcxx-commits] [libcxx] Speed up compilation of common uses of std::visit() by ~8x (PR #164196)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Nov 28 03:13:26 PST 2025


higher-performance wrote:

> IIUC this basically fixes #62648. I'm not sure how to proceed here. Previously there were problems with this approach generating a lot of code, which is why it was reverted. This patch is a lot more conservative at least. I guess I'd really like if we had reflection here, since that would allow us to generate the perfect switch/case for any variant. I think I'd be fine with this as a temporary solution. I'd really like you to check compile time and code generation overhead of this though, since, as mentioned, this was a big problem previously. Please run the variant benchmarks as well and share the results.

Sounds good, thanks.  
Re: #62648, note that this is only special-casing the (common) case of `std::visit`ing 1 `variant`. Invocations for 2+ `variant`s will still retain whatever problems or other characteristics they may have had before.

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


More information about the libcxx-commits mailing list