Skip to content

Commit

Permalink
Parameterize OptimizerLattice like InferenceLattice (#47287)
Browse files Browse the repository at this point in the history
External AbstractInterpreters that do optimization while
retaining lattice elements in their custom lattice will
need to have this for the same reason that InferenceLattice
is needed, so there isn't really a good reason to not
parameterize this.
  • Loading branch information
Keno authored Oct 24, 2022
1 parent c34347a commit fa37bcb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions base/compiler/abstractlattice.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ is_valid_lattice(lattice::InferenceLattice, @nospecialize(elem)) =
The lattice used by the optimizer. Extends
`BaseInferenceLattice` with `MaybeUndef`.
"""
struct OptimizerLattice <: AbstractLattice; end
widenlattice(L::OptimizerLattice) = BaseInferenceLattice.instance
struct OptimizerLattice{L} <: AbstractLattice
parent::L
end
OptimizerLattice() = OptimizerLattice(BaseInferenceLattice.instance)
widenlattice(L::OptimizerLattice) = L.parent
is_valid_lattice(lattice::OptimizerLattice, @nospecialize(elem)) =
is_valid_lattice(widenlattice(lattice), elem) || isa(elem, MaybeUndef)

Expand Down
2 changes: 1 addition & 1 deletion base/compiler/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ infer_compilation_signature(::NativeInterpreter) = true

typeinf_lattice(::AbstractInterpreter) = InferenceLattice(BaseInferenceLattice.instance)
ipo_lattice(::AbstractInterpreter) = InferenceLattice(IPOResultLattice.instance)
optimizer_lattice(::AbstractInterpreter) = OptimizerLattice()
optimizer_lattice(::AbstractInterpreter) = OptimizerLattice(BaseInferenceLattice.instance)

abstract type CallInfo end

Expand Down

0 comments on commit fa37bcb

Please sign in to comment.