From fa37bcbb0d9133cbb5bb4016fb3df0e10c6d20d4 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Mon, 24 Oct 2022 00:15:35 -0400 Subject: [PATCH] Parameterize OptimizerLattice like InferenceLattice (#47287) 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. --- base/compiler/abstractlattice.jl | 7 +++++-- base/compiler/types.jl | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/base/compiler/abstractlattice.jl b/base/compiler/abstractlattice.jl index 83e64cd4a042f..03f93e88b81d8 100644 --- a/base/compiler/abstractlattice.jl +++ b/base/compiler/abstractlattice.jl @@ -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) diff --git a/base/compiler/types.jl b/base/compiler/types.jl index fc7714523b2f9..37f8b5a23bbf6 100644 --- a/base/compiler/types.jl +++ b/base/compiler/types.jl @@ -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