Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update variant "all types same/convertible" metaprogramming #3070

Merged
merged 8 commits into from
Sep 3, 2022

Conversation

CaseyCarter
Copy link
Member

And a few other minor changes while we're here. I've separated changes out by commit for ease of review, but this should be squash merged. The most significant change here - others are self-explanatory - replaces the metaprogramming used to enforce the Standard's requirements that "For each valid pack m, e(m) is a valid expression. All such expressions are of the same type
and value category" ([variant.visit]/5).

here are different mechanisms to validate the requirement for visit<R> and for plain visit. Previously, we created a single typelist where each type represented one possible configuration of the set of argument variants to a visit call, and then folded over a single giant pack expansion of visitor evaluations ensuring they had the same type and value category (or are all convertible to R for visit<R>). This was enormously expensive for throughput when the number of possible states is large since the compilers burn a lot of memory maintaining long typelists. The new version uses tree evaluation, where each internal node of the tree ands together the result of evaluating its child nodes, which each correspond to a possible state of a single argument variant. Leaves correspond to potential calls and have a boolean value indicating whether that potential call has the same type and value category as the first valid configuration (has a type and value category convertible to the result type for visit<R>).

The resulting speedup for the long-pole /analyze configs of the visit tests in the "Update LLVM" PR is around 50%.

Fixes #2770.
Unblocks #2976.

@CaseyCarter CaseyCarter added the throughput Must compile faster label Sep 2, 2022
@CaseyCarter CaseyCarter requested a review from a team as a code owner September 2, 2022 00:53
@CaseyCarter CaseyCarter added this to Final Review in Code Reviews Sep 2, 2022
@CaseyCarter CaseyCarter mentioned this pull request Sep 2, 2022
stl/inc/variant Outdated Show resolved Hide resolved
stl/inc/variant Outdated Show resolved Hide resolved
stl/inc/variant Outdated Show resolved Hide resolved
Code Reviews automation moved this from Final Review to Work In Progress Sep 2, 2022
@CaseyCarter CaseyCarter moved this from Work In Progress to Final Review in Code Reviews Sep 2, 2022
@StephanTLavavej StephanTLavavej moved this from Final Review to Ready To Merge in Code Reviews Sep 2, 2022
@StephanTLavavej StephanTLavavej self-assigned this Sep 3, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit f70a608 into microsoft:main Sep 3, 2022
Code Reviews automation moved this from Ready To Merge to Done Sep 3, 2022
@StephanTLavavej
Copy link
Member

Thanks for making variant faster to compile! 🚀 🐆 🐇

@CaseyCarter CaseyCarter deleted the variant-variation branch October 10, 2022 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
throughput Must compile faster
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

<variant>: visit() combinatoric catastrophe
2 participants