[libcxx-commits] [PATCH] D85420: [libcxx/variant] Introduce `switch`-based mechanism for `std::visit`.

Michael Park via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 6 03:31:12 PDT 2020


mpark created this revision.
mpark added reviewers: ldionne, EricWF, mclow.lists.
Herald added subscribers: libcxx-commits, dexonsmith.
Herald added a project: libc++.
Herald added a reviewer: libc++.
mpark requested review of this revision.

This patch introduces mechanism for `std::visit` backed by `switch`.
The dispatching mechansim itself is fully general, and the manual vtable
approach is left in-tact. The benchmarks added shows that for <= 2 variants,
the `switch` approach can be much faster due to better inlining. For 3 variants
and above, it seems to start to perform at par and starts to get worse.

The proposed solution here is to use the `switch`-based mechanism for <= 2
variants and to keep the existing mechanism for 3 variants and above.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85420

Files:
  libcxx/include/variant

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85420.283560.patch
Type: text/x-patch
Size: 14719 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200806/2dd11f09/attachment.bin>


More information about the libcxx-commits mailing list