[IR Container] Phase 2.3 Basic shared ptr#5960
[IR Container] Phase 2.3 Basic shared ptr#5960mdavis36 wants to merge 2 commits intomd/fusion-stmt-regfrom
Conversation
|
!test |
|
Review updated until commit c965408 Description
|
| Relevant files | |||||||||
|---|---|---|---|---|---|---|---|---|---|
| Enhancement |
| ||||||||
| Configuration changes |
|
PR Reviewer Guide
Here are some key observations to aid the review process:
| 🧪 No relevant tests |
| ⚡ Recommended focus areas for review |
Missing error handling
ir_container_->removeFusion(this) but no null check. While the constructor initializes ir_container_ with std::make_shared, there could be scenarios where the container becomes null during the fusion lifetime. Consider adding a null check for defensive programming. |
3a199c8 to
53e5045
Compare
Change Fusion::ir_container_ from unique_ptr to shared_ptr to enable future container sharing between Fusions. Add Fusion tracking API to IrContainer (addFusion/removeFusion/transferFusion/sharingCount). Remove IrContainer::parent_ since the 1:1 relationship no longer holds. Disable parallel compilation during the shared_ptr transition.
074c814 to
54cd0fe
Compare
53e5045 to
f8ff364
Compare
|
!test |
Greptile SummaryThis PR transitions Key Changes:
Implementation Quality:
Future Work: Confidence Score: 5/5
Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
class Fusion {
-shared_ptr~IrContainer~ ir_container_
+Fusion()
+~Fusion()
+swap(Fusion& a, Fusion& b)
+copy(Fusion* from, Fusion* to)
}
class IrContainer {
-unordered_set~Fusion*~ sharing_fusions_
+addFusion(Fusion* fusion)
+removeFusion(Fusion* fusion)
+transferFusion(Fusion* from, Fusion* to)
+sharingCount() size_t
+hasMultipleFusions() bool
+swap(IrContainer& a, IrContainer& b)
}
class Statement {
+Fusion* ir_container_
+container() Fusion*
}
Fusion "1" --> "1" IrContainer : owns (shared_ptr)
IrContainer "1" --> "*" Fusion : tracks (sharing_fusions_)
Statement "*" --> "1" Fusion : belongs to
note for IrContainer "Phase 2: Replaced parent_ pointer with sharing_fusions_ set to support multi-Fusion containers"
note for Fusion "Phase 2: Changed from unique_ptr to shared_ptr for future container sharing"
Last reviewed commit: c965408 |
Additional Comments (1)
These comments reference "parent backpointers" and say "each Fusion owns a different IrContainer", both of which are artifacts of the old |
Summary
Replace
unique_ptr<IrContainer>withshared_ptr<IrContainer>in Fusion and add the container-side registration API that tracks which Fusions share a given container.This is the foundational change of Phase 2. The pointer type change alone has no behavioral impact — single-Fusion containers behave identically under
shared_ptr. The tracking infrastructure (sharing_fusions_,addFusion/removeFusion) lays the groundwork for all subsequent tasks.Parallel compilation is disabled in-code via
kPhase2DisableParallelCompile = trueas a precaution during the transition. This ensures CI runs serial compilation for later PRs without requiring environment variables. Parallel compilation is restored in #5971 .Relationship to Phase 2
This is the core type change that enables the shared container model:
Without this change, no subsequent Phase 2 work (per-Fusion tracking, shared-container copy/move, thread safety) is possible. The tracking API is the mechanism that makes container sharing safe — it allows the container to know its consumers, enabling correct cleanup when Fusions are destroyed.
CI Risk
Low. For single-Fusion containers (all existing usage),
shared_ptris behaviorally identical tounique_ptr. No accessor paths change. Parallel compilation is serialized by the in-code constant.