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

[analysis] Implement a Lift lattice #6040

Merged
merged 2 commits into from
Oct 25, 2023
Merged

[analysis] Implement a Lift lattice #6040

merged 2 commits into from
Oct 25, 2023

Conversation

tlively
Copy link
Member

@tlively tlively commented Oct 21, 2023

This lattice "lifts" another lattice by inserting a new bottom element
underneath it.


namespace wasm::analysis {

template<Lattice L> struct Lift {
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps a comment on what Lift means?

bool isBottom() const noexcept { return !this->has_value(); }
bool operator==(const Element& other) const noexcept {
return (isBottom() && other.isBottom()) ||
(!isBottom() && !other.isBottom() && **this == *other);
Copy link
Member

Choose a reason for hiding this comment

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

Why wouldn't **this == *other work if both are bottom?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can't evaluate **this if isBottom because that would be dereferencing an empty optional.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see, then the new bottom element is basically the "nothing" case of the optional? So the extra bit of the optional marks that new item, basically. That's what I was missing.

At the risk of seeming repetitive: comments 😃


template<Lattice L> struct Lift {
struct Element : std::optional<typename L::Element> {
bool isBottom() const noexcept { return !this->has_value(); }
Copy link
Member

Choose a reason for hiding this comment

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

How should I read this has_value? Do we use the empty optional as the bottom perhaps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, exactly. I'll add a comment.

@tlively
Copy link
Member Author

tlively commented Oct 24, 2023

I've now improved or added doc comments to every PR in this stack.

@tlively
Copy link
Member Author

tlively commented Oct 25, 2023

Merge activity

  • Oct 25, 1:00 PM: @tlively started a stack merge that includes this pull request via Graphite.
  • Oct 25, 4:05 PM: Graphite rebased this pull request as part of a merge.
  • Oct 25, 4:51 PM: @tlively merged this pull request with Graphite.

Base automatically changed from flat-lattice to main October 25, 2023 20:05
This lattice "lifts" another lattice by inserting a new bottom element
underneath it.
@tlively tlively merged commit 1dcc859 into main Oct 25, 2023
13 of 14 checks passed
@tlively tlively deleted the lift-lattice branch October 25, 2023 20:51
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
This lattice "lifts" another lattice by inserting a new bottom element
underneath it.
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