-
Notifications
You must be signed in to change notification settings - Fork 84
[IR Container] Phase 2.3 Basic shared ptr #5960
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
Open
+64
−29
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -112,13 +112,10 @@ void Fusion::swap(Fusion& a, Fusion& b) noexcept { | |
| // will only swap the ptrs NOT the contents. | ||
| IrContainer::swap(*(a.ir_container()), *(b.ir_container())); | ||
|
|
||
| // Fix parent pointers after swapping containers | ||
| // After swap, each Fusion owns a different IrContainer, so we must | ||
| // update the parent backpointers in those containers to point to their new | ||
| // owners | ||
| // After swapping container contents, update Statement::ir_container_ | ||
| // pointers so each Statement points to the Fusion whose container now | ||
| // holds it. | ||
| if (a.ir_container_) { | ||
| // Also update all Statement ir_container_ pointers to point to new owner | ||
| a.ir_container()->parent_ = &a; | ||
| for (auto val : a.vals()) { | ||
| val->ir_container_ = &a; | ||
| } | ||
|
|
@@ -127,8 +124,6 @@ void Fusion::swap(Fusion& a, Fusion& b) noexcept { | |
| } | ||
| } | ||
| if (b.ir_container_) { | ||
| // Also update all Statement ir_container_ pointers to point to new owner | ||
| b.ir_container()->parent_ = &b; | ||
| for (auto val : b.vals()) { | ||
| val->ir_container_ = &b; | ||
| } | ||
|
|
@@ -162,7 +157,8 @@ std::unique_ptr<SegmentedFusion> Fusion::segment( | |
| IrCloner Fusion::copy(const Fusion* from, Fusion* to) { | ||
| to->clear(); | ||
|
|
||
| auto ir_cloner = IrContainer::copy(from->ir_container(), to->ir_container()); | ||
| auto ir_cloner = | ||
| IrContainer::copy(from->ir_container(), to->ir_container(), to); | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This additional argument is only temporary while IrContainer::copy is a valid call from Fusion. |
||
|
|
||
| // Remap cached special val pointers through the cloner | ||
| if (from->zero_val_) { | ||
|
|
@@ -255,8 +251,8 @@ IrCloner Fusion::copy(const Fusion* from, Fusion* to) { | |
| } | ||
|
|
||
| // Default constructor | ||
| Fusion::Fusion() : ir_container_(std::make_unique<IrContainer>()) { | ||
| ir_container_->parent_ = this; | ||
| Fusion::Fusion() : ir_container_(std::make_shared<IrContainer>()) { | ||
| ir_container_->addFusion(this); | ||
| } | ||
|
|
||
| // Copy constructor | ||
|
|
@@ -288,6 +284,9 @@ Fusion& Fusion::operator=(Fusion&& other) noexcept { | |
|
|
||
| Fusion::~Fusion() { | ||
| clear(); | ||
| if (ir_container_) { | ||
| ir_container_->removeFusion(this); | ||
| } | ||
| } | ||
|
|
||
| void Fusion::clear() noexcept { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.