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

inference: refine PartialStruct lattice tmerge #44404

Merged
merged 2 commits into from
Mar 13, 2022
Merged

inference: refine PartialStruct lattice tmerge #44404

merged 2 commits into from
Mar 13, 2022

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Mar 2, 2022

Be more aggressive about merging fields to greatly accelerate
convergence, but also compute anyrefine more correctly as we do now
elsewhere (since #42831, a121721)

Move the tmeet algorithm, without changes, since it is a precise lattice
operation, not a heuristic limit like tmerge.

Close #43784

@vtjnash vtjnash added compiler:inference Type inference backport 1.8 Change should be backported to release-1.8 labels Mar 2, 2022
@vtjnash vtjnash requested a review from aviatesk March 2, 2022 03:50
base/compiler/typelattice.jl Show resolved Hide resolved
test/compiler/inference.jl Show resolved Hide resolved
test/compiler/inference.jl Show resolved Hide resolved
test/compiler/inference.jl Show resolved Hide resolved
base/compiler/typelimits.jl Show resolved Hide resolved
base/compiler/typelimits.jl Show resolved Hide resolved
base/compiler/typelimits.jl Outdated Show resolved Hide resolved
@KristofferC KristofferC mentioned this pull request Mar 3, 2022
47 tasks
@vtjnash vtjnash added the merge me PR is reviewed. Merge when all tests are passing label Mar 10, 2022
vtjnash added 2 commits March 11, 2022 12:11
Previously we assumed only union type could have complexity that
violated the tmerge lattice requirements, but other types can have that
too. This lets us fix an issue with the PartialStruct comparison failing
for undefined fields, mentioned in #43784.
Be more aggressive about merging fields to greatly accelerate
convergence, but also compute anyrefine more correctly as we do now
elsewhere (since #42831, a121721)

Move the tmeet algorithm, without changes, since it is a precise lattice
operation, not a heuristic limit like tmerge.

Close #43784
@DilumAluthge DilumAluthge merged commit ff88fa4 into master Mar 13, 2022
@DilumAluthge DilumAluthge deleted the jn/43784 branch March 13, 2022 00:09
@DilumAluthge DilumAluthge removed the merge me PR is reviewed. Merge when all tests are passing label Mar 13, 2022
@aviatesk
Copy link
Member

These commits shouldn't be squashed.

Comment on lines +473 to +476
# compute typeintersect over the extended inference lattice,
# as precisely as we can,
# where v is in the extended lattice, and t is a Type.
function tmeet(@nospecialize(v), @nospecialize(t))
Copy link
Member

Choose a reason for hiding this comment

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

Duplicated with the definition at L295.

KristofferC pushed a commit that referenced this pull request Mar 13, 2022
* inference: fix tmerge lattice over issimpleenoughtype

Previously we assumed only union type could have complexity that
violated the tmerge lattice requirements, but other types can have that
too. This lets us fix an issue with the PartialStruct comparison failing
for undefined fields, mentioned in #43784.

* inference: refine PartialStruct lattice tmerge

Be more aggressive about merging fields to greatly accelerate
convergence, but also compute anyrefine more correctly as we do now
elsewhere (since #42831, a121721)

Move the tmeet algorithm, without changes, since it is a precise lattice
operation, not a heuristic limit like tmerge.

Close #43784

(cherry picked from commit ff88fa4)
aviatesk added a commit that referenced this pull request Mar 15, 2022
aviatesk added a commit that referenced this pull request Mar 15, 2022
@KristofferC KristofferC removed the backport 1.8 Change should be backported to release-1.8 label Mar 15, 2022
aviatesk added a commit that referenced this pull request Dec 20, 2022
…47910)

When merging `PartialStruct`, we are currently merging their fields a
bit aggressively (#44404) in order to accelerate (or rather, guarantee) convergence.
However, when `PartialStruct` wraps external lattice elements, this can
be too aggressive since it does not use `tmerge(𝕃, fields...)` recursively
and thus the external lattice elements are not merged as expected.

This commit adds an additional lattice hook, `tmerge_field`, inside
`tmerge(::PartialsLattice)` so that external lattice implementation
can provide its own field-merge strategies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PartialStruct tmerge fails to converge
4 participants