Skip to content

Draft: Dominance Tree#133

Draft
axelcool1234 wants to merge 2 commits intoopencompl:mainfrom
axelcool1234:dominance
Draft

Draft: Dominance Tree#133
axelcool1234 wants to merge 2 commits intoopencompl:mainfrom
axelcool1234:dominance

Conversation

@axelcool1234
Copy link
Contributor

@axelcool1234 axelcool1234 commented Jan 21, 2026

The following draft implements a dominance tree. The dominance tree currently uses the Cooper-Harvey-Kennedy algorithm.

@axelcool1234 axelcool1234 marked this pull request as draft January 21, 2026 21:28
@axelcool1234
Copy link
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
deriving Inhabited, Repr, DecidableEq, Hashable

structure DomTreeNode where
-- The block in question
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can use /-- -/ to write doc comments.

let parentNode := (parent.get! ctx)

if (child.getSibling! ctx).isSome then
panic! "cannot add child that already has siblings"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be better to return none. @math-fehr do you have an opinion?

panic! "parent's last child is not the same as the last sibling"

-- Special case: child being removed is first child in sibling list
if parentFirst == child then
Copy link
Collaborator

Choose a reason for hiding this comment

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

Usually, it's more canonical to use = instead of == in Lean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. What are some of the benefits of giving if ... then ... else ... a Prop instead of a Bool?

Copy link
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
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
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.

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