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

Framework for copy-on-write visitors (WIP) #5010

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ChrisDodd
Copy link
Contributor

This is still very much a work in progress (doesn't even build at the moment due to order-of-declaration issues), but is complete enough to show my thinking.

The idea here is address #4418 (excessive cloning in Transform/Modifier visitors) by doing lazy clones -- nodes are only cloned when they are modified (true copy on write), by giving the preorder/postorder methods "smart" pointers that manage the cloning when fields are actually modified. This uses the ir generator to make special COWref reference objects for each IR class that understand the fields in the IR class and can be assigned to as if they were instances of the class, managing the cloning on demand.

Since we've been saying we're going to update to requiring C++20, this uses C++20 concepts in a number of places to simplify the overloading.

@ChrisDodd ChrisDodd requested a review from asl November 11, 2024 06:42
@fruffy fruffy added the core Topics concerning the core segments of the compiler (frontend, midend, parser) label Nov 11, 2024
@asl
Copy link
Contributor

asl commented Nov 11, 2024

@ChrisDodd Great! How does it handle children visiting? E.g. when a child is changed, how do we clone the parent? Especially when e.g. inside Vector or IndexedVector?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Topics concerning the core segments of the compiler (frontend, midend, parser)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants