Skip to content

cranelift: Remove redundant dominator-tree structure#7948

Merged
jameysharp merged 4 commits intobytecodealliance:mainfrom
jameysharp:domtree
Feb 16, 2024
Merged

cranelift: Remove redundant dominator-tree structure#7948
jameysharp merged 4 commits intobytecodealliance:mainfrom
jameysharp:domtree

Conversation

@jameysharp
Copy link
Contributor

The egraph work introduced a helper for walking over the dominator tree in pre-order, but it turns out that helper already existed in the dominator_tree module itself, and the older version also supports constant-time dominance checks using the same trick that @cfallin suggested in #7891. So let's just use that version.

cc: @elliottt @lpereira

We already know the entry block everywhere we use this.
These two types had nearly identical interfaces except that the latter
also supports constant-time dominance checks.
@jameysharp jameysharp requested a review from cfallin February 15, 2024 21:00
@jameysharp jameysharp requested a review from a team as a code owner February 15, 2024 21:00
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

Woah, nice find! I had no idea we already had this (which I guess is why we wrote it again).

While I hesitate to violate the law that "any sufficiently advanced compiler contains three domtree implementations" (regalloc2 has one too!), I think we can do some spring cleaning here :-)

@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Feb 15, 2024
It turns out this was the only thing the egraph pass used the original
dominator tree for, so we can stop passing that around.

We could also require that the caller of EgraphPass::new construct the
DominatorTreePreorder and avoid passing the original tree into the
egraph pass at all, but I've chosen to stop refactoring here.

We should review all uses of DominatorTree::dominates to see if it makes
sense to pass a DominatorTreePreorder around more places.
@lpereira
Copy link
Contributor

LGTM!

@jameysharp jameysharp added this pull request to the merge queue Feb 16, 2024
Merged via the queue into bytecodealliance:main with commit 757517f Feb 16, 2024
@jameysharp jameysharp deleted the domtree branch February 16, 2024 22:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants