Repository navigation
Flatten WeakTopologicalOrdering into a single entry vector #9220
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
Merged
Changes from all commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
dad6624
Add a dominator-tree WTO utility for reducible CFGs
tlively eb5b060
Use WTOWorklist in ConstraintAnalysis and RedundantSetElimination
tlively d1eb897
Use BasicBlock::contents.index in DomTree
tlively 383c406
Collapse inner loops with union-find during WTO construction
tlively 48737e0
Fast-path loop-free CFGs in WTOWorklist
tlively 2ec3749
Flatten WeakTopologicalOrdering into a single entry vector
tlively 50f7064
Work around clang++-18 crash on defaulted WTOCycle::operator==
tlively 60f33d0
Merge branch 'domtree-wto2' into wto-passes
tlively 4850b4c
Merge branch 'wto-passes' into domtree-block-indices
tlively ec7e4ab
Merge branch 'domtree-block-indices' into wto-union-find
tlively d899204
Merge branch 'wto-union-find' into wto-fast-paths
tlively 5dfa650
Merge branch 'wto-fast-paths' into wto-flat
tlively 08750e7
tighten up definition
tlively 4aea7cd
Moar comments (I wrote them myself!)
tlively a469c96
mini CFG comment
tlively f4d0e76
recursion comments
tlively f1a4061
Work around GCC 11 ICE on local static constexpr in WTO
tlively bece156
Merge branch 'domtree-wto2' into wto-passes
tlively 865e017
Merge branch 'wto-passes' into domtree-block-indices
tlively 268e04d
Merge branch 'domtree-block-indices' into wto-union-find
tlively 1b7906b
Merge branch 'wto-union-find' into wto-fast-paths
tlively 51c3d33
Merge branch 'wto-fast-paths' into wto-flat
tlively 9fb7800
Merge branch 'main' into wto-passes
tlively 2f54272
Merge branch 'wto-passes' into domtree-block-indices
tlively 25ec057
Merge branch 'domtree-block-indices' into wto-union-find
tlively e4539b6
Merge branch 'wto-union-find' into wto-fast-paths
tlively 4009e59
Merge branch 'wto-fast-paths' into wto-flat
tlively 8964e96
"for domtree"
tlively 91d6872
setBlockIndices
tlively 5001f17
Merge branch 'main' into wto-passes
tlively 4b1947a
Merge branch 'wto-passes' into domtree-block-indices
tlively bc37c1f
Merge branch 'domtree-block-indices' into wto-union-find
tlively ae09421
Merge branch 'wto-union-find' into wto-fast-paths
tlively 5988797
Merge branch 'wto-fast-paths' into wto-flat
tlively db7d4fe
Merge branch 'main' into domtree-block-indices
tlively 939de33
Merge branch 'domtree-block-indices' into wto-union-find
tlively e5d29c5
Merge branch 'wto-union-find' into wto-fast-paths
tlively 857c917
Merge branch 'wto-fast-paths' into wto-flat
tlively 7b7eeb7
Have DomTree set block indices itself
tlively a2089ff
Merge branch 'domtree-block-indices' into wto-union-find
tlively 252add9
Merge branch 'wto-union-find' into wto-fast-paths
tlively c18519e
Check loopTops.empty() instead of hasBackEdge()
tlively 59bdbd4
Merge branch 'wto-fast-paths' into wto-flat
tlively a3bbfbc
more comments on ufParent
tlively 7513840
Merge branch 'wto-union-find' into wto-fast-paths
tlively 9f2a310
Merge branch 'wto-fast-paths' into wto-flat
tlively 5acacd3
Merge branch 'wto-union-find' into wto-fast-paths
tlively 8220e47
Merge branch 'wto-fast-paths' into wto-flat
tlively 3f4236a
Remove redundant loop-free WTOWorklist test
tlively 0ad28a3
Merge branch 'wto-fast-paths' into wto-flat
tlively a2f9bbb
expand comment on entry
tlively 73ffa92
Merge remote-tracking branch 'origin/main' into wto-fast-paths
tlively 8851991
Merge branch 'wto-fast-paths' into wto-flat
tlively 4d5d092
fix build
tlively 4411846
Merge remote-tracking branch 'origin/main' into wto-flat
tlively 6c85f9f
clarify what indices we are talking about
tlively 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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What marks the cycle's start? Maybe I'm not understanding this comment. Is
cycleTargetmeaningful in all cases?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing marks the cycle's start besides the fact that later
cycleTargets point back to it.cycleTargetdetermines whether this is a "normal" entry (when it isNoTarget) or a cycle end marker entry.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still not sure how to read this. So a particular block B will appear twice, once at the start and once at the end?
Some things that might be confusing me: the word "visits" on line 97, and the word "either".
Perhaps this can be explained as follows?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite. When
cycleTarget != NoTarget,blockis the header of the loop, which already appeared previously as a normal entry (see lines 247 and 249). Storing the loop header directly with the cycle end marker means line 332 has one less indirection.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, then how about this comment:
Where I still do not follow is the end of part 2. It seems like the block is already saying where the backedge goes to, so we just need a boolean "this is a cycle end"? What information is conveyed in cycleTarget?
(an example in the comment might help)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to add a comment explaining what the WTO index is? The large toplevel comment only mentions the RPO index, and I don't see anything else below.
Or are you saying this is all quite obvious? Sorry if that is the case. Reading the code I see
Index startPc = entries.size(); entries.push_back({block, NoIndex}); self(self, nodes[curr].firstChild); entries.push_back({block, startPc});That seems to be where the "WTO Index" is generated, but I don't see it called that, and it's not clear to me how it differs from the RPO index. That is, isn't there one entry per basic block? Or is the fact that a basic block can appear a second time (to close the loop) the reason for the discrepancy in indexing? If so, that is exactly the kind of explanation I am looking for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been using "WTO index" as shorthand for "index in the entries vector" to clarify its distinction from "RPO index." The term "WTO index" does not appear in the code, so I think it should not need explaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's right. I can clarify that in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also there's the whole part where we do the backward search in the domtree and build linked lists of blocks in each loop. It's not clear to me that the flattened block order that produces matches the original RPO order, but maybe it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that the order ensures it is the RPO order, so I didn't even consider there were two indexes here...