Skip to content

Dominance Analysis#133

Open
axelcool1234 wants to merge 3 commits intoopencompl:mainfrom
axelcool1234:dominance
Open

Dominance Analysis#133
axelcool1234 wants to merge 3 commits intoopencompl:mainfrom
axelcool1234:dominance

Conversation

@axelcool1234
Copy link
Copy Markdown
Contributor

@axelcool1234 axelcool1234 commented Jan 21, 2026

This implements CFG dominance analysis on top of the dataflow framework: #264

This is based off of the Cooper-Harvey-Kennedy algorithm.

@axelcool1234 axelcool1234 marked this pull request as draft January 21, 2026 21:28
@axelcool1234
Copy link
Copy Markdown
Contributor Author

I am currently working on implementing a dominance tree data structure that closely mirrors with the one defined in LLVM: https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/Support/GenericDomTree.h

@axelcool1234 axelcool1234 force-pushed the dominance branch 2 times, most recently from 85e953d to 156344b Compare February 3, 2026 23:13
@axelcool1234 axelcool1234 changed the title Draft: Dominance Tree Draft: Dominance Tree and Dataflow Framework Feb 18, 2026
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Copy link
Copy Markdown
Collaborator

@ineol ineol left a comment

Choose a reason for hiding this comment

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

Thank you!

Maybe we should consider splitting the dominance tree off of the PR to keep it manageable?

@axelcool1234
Copy link
Copy Markdown
Contributor Author

axelcool1234 commented Feb 26, 2026

Thank you!

Maybe we should consider splitting the dominance tree off of the PR to keep it manageable?

I definitely will. I also intend on cleaning up all of these commits because they're a mess. I've been under the weather lately - I was planning on splitting up the PR a couple days ago. I'll get to it soon.

Also, thanks for the comments. This'll help me write better Lean code :)

@axelcool1234 axelcool1234 changed the title Draft: Dominance Tree and Dataflow Framework Draft: Dominance Tree Mar 3, 2026
@axelcool1234
Copy link
Copy Markdown
Contributor Author

Thank you!

Maybe we should consider splitting the dominance tree off of the PR to keep it manageable?

I just split my work into two PRs. This one now only contains the Dominance Tree. #264 contains the Dataflow Analysis Framework now.

@ineol
Copy link
Copy Markdown
Collaborator

ineol commented Mar 25, 2026

Hi @axelcool1234, can you rebase this PR on main? We'd like to start merging it soon :)

@axelcool1234
Copy link
Copy Markdown
Contributor Author

Hi @axelcool1234, can you rebase this PR on main? We'd like to start merging it soon :)

Ah shoot, sorry about that! I'll get on that

@axelcool1234 axelcool1234 marked this pull request as ready for review March 25, 2026 11:17
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
def DomTreeNodePtr.getSibling! (ptr : DomTreeNodePtr) (ctx : DomContext) : Option DomTreeNodePtr :=
(ptr.get! ctx).sibling

def DomTreeNodePtr.getLastChildSibling! (ptr : DomTreeNodePtr) (ctx : DomContext) : Option DomTreeNodePtr :=
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm confused. According to the invariant it should always return none?

Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
Comment thread Veir/IR/Dominance.lean Outdated
finger2 := (finger2.getIDom! domCtx).get!
return (finger1.getBlock! domCtx)

-- Postorder traversal of blocks, insert into DomTree (which is just an array!)
Copy link
Copy Markdown
Collaborator

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 split this into a function and document what it does? this function is really large

@axelcool1234 axelcool1234 force-pushed the dominance branch 4 times, most recently from 898562b to d9ad389 Compare April 18, 2026 02:43
@axelcool1234 axelcool1234 changed the title Draft: Dominance Tree Dominance Analysis Apr 22, 2026
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.

3 participants