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

Add ContiguousDisjointSet datastructure #15418

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

clonker
Copy link
Member

@clonker clonker commented Sep 9, 2024

needed for loop nesting forest construction in liveness analysis

@clonker clonker marked this pull request as ready for review September 9, 2024 07:31
@clonker clonker requested a review from nikola-matic September 9, 2024 07:33
Copy link
Collaborator

@nikola-matic nikola-matic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for SSA CFG?

libsolutil/DisjointSet.cpp Outdated Show resolved Hide resolved
@clonker
Copy link
Member Author

clonker commented Sep 9, 2024

Is this for SSA CFG?

Yeah, this is a data structure used in finding / construction of the loop nesting forest of a CFG

@clonker clonker force-pushed the liveness-disjoint-set branch from f54429f to a13a86f Compare September 9, 2024 09:42
@clonker clonker force-pushed the liveness-disjoint-set branch from a13a86f to 7f582e4 Compare September 9, 2024 09:45
@cameel cameel added the 🟡 PR review label label Sep 9, 2024
Copy link
Collaborator

@matheusaaguiar matheusaaguiar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the algorithm and can"t see anything wrong.

return rootElement;
}

void ContiguousDisjointSet::merge(value_type const _x, value_type const _y, bool const _mergeBySize)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we planning to add rank in the future? Or is there a situation where we would have this false?
just a nitpick...

ps: I see it set to false in the test, but realistically, should be better to always have it on (or switched to rank), right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question:) The place we need it for now (loop detection with Tarjan"s algorithm) relies on merging with "by size/rank" being switched off. That way a representative of a set can stay stable under merge operations. In particular this is used for loop headers (think a loop header as a vertex of a CFG represent a set of vertices that comprise the loop body). You can see this in PR 15419.

So generally I am inclined to agree that by rank is better - although potential problems with "by-size" are somewhat mitigated by path compression - but in our case it doesn"t really matter. For now. :D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and there is just one test that has mergeBySize disabled, to check exactly that stability property of the set representative... the rest does have it enabled..

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation @clonker !

@clonker clonker merged commit 9df0379 into develop Sep 11, 2024
72 checks passed
@clonker clonker deleted the liveness-disjoint-set branch September 11, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🟡 PR review label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants