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

Irreducible loops cleanup #257

Merged
merged 8 commits into from
Dec 11, 2024
Merged

Irreducible loops cleanup #257

merged 8 commits into from
Dec 11, 2024

Conversation

ailrst
Copy link
Contributor

@ailrst ailrst commented Oct 10, 2024

Addresses #194 and #194

Refactors the analysis to be iterative rather than recursive, work over blocks rather than Commands, adds flow conditions and a cli flag to disable the analysis/transform.

It also factors out the algorithm's state from class members + mutable collections into an immutable case class, which I think makes the high level api a bit clearer, but the algorithm itself is probably more difficult to understand.

@ailrst ailrst force-pushed the irreducible-loops-cleanup branch 2 times, most recently from 1936f87 to db284b8 Compare October 11, 2024 01:43
}


private def processVisitedNodeOutgoingEdge(istate: State, edge: LoopEdge, DFSPpos: Int): State = {
Copy link
Contributor

Choose a reason for hiding this comment

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

DFSPpos is never used, is there a reason it exists?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I just missed it in the refactor, its been moved into State.

thisLoop.reducible = false
thisLoop.reentries += edge
}
private def traverse_loops_dfs(_istate: State, _b0: Block, _DFSPpos: Int): (State, Option[Block]) = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nothing actually uses the second output parameter, what is it for & what does it mean?

Copy link
Contributor Author

@ailrst ailrst Nov 27, 2024

Choose a reason for hiding this comment

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

Do you mean the Option[Block]? I believe this is the first loop header following _b0, this is a holdover from the recursive style of the algorithm which traverses all the successors and tags block that is returned as a header. This still occurs in the state machine through the retval variable. It is retained in the refactor so the type of the pseudo-return FinishProcessNode state in the explicit call stack form matches the return value of the whole function.

Copy link
Contributor

Choose a reason for hiding this comment

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

The only time traverse_loops_dfs gets called, it has the tuple access ._1 at the end which only returns the State. Do we need to have this second output parameter at all? If there is some reason we want to keep it, there should be a comment documenting what it means.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just removed it as it isn't really necessary.

@l-kent
Copy link
Contributor

l-kent commented Nov 15, 2024

This seems fine overall, I'll merge it in once those unused parameters are explained

@l-kent l-kent force-pushed the irreducible-loops-cleanup branch from 27b4c5e to db284b8 Compare November 18, 2024 23:40
@ailrst ailrst force-pushed the irreducible-loops-cleanup branch from db284b8 to 7aaca91 Compare November 28, 2024 00:25
l-kent added 2 commits December 11, 2024 11:11
# Conflicts:
#	src/main/scala/Main.scala
#	src/main/scala/util/BASILConfig.scala
@l-kent l-kent merged commit 4d3f703 into main Dec 11, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants