Skip to content

Commit d8370d4

Browse files
committed
fix: more stable eager lambda lifting heuristic
1 parent 2cfd980 commit d8370d4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Lean/Compiler/LCNF/LambdaLifting.lean

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,17 @@ def lambdaLifting : Pass where
169169
decls.foldlM (init := #[]) fun decls decl => return decls ++ (← decl.lambdaLifting false (suffix := `_lam))
170170

171171
/--
172-
During eager lambda lifting, we lift
173-
- All local function declarations from instances (motivation: make sure it is cheap to inline them later)
174-
- Local function declarations that take local instances as parameters (motivation: ensure they are specialized)
172+
During eager lambda lifting, we inspect declarations that are not inlineable or instances (doing it
173+
everywhere can accidentally introduce mutual recursion which the compiler cannot handle well at the
174+
moment). We then lift local function declarations that take local instances as parameters from
175+
their body to ensure they are specialized.
175176
-/
176177
def eagerLambdaLifting : Pass where
177178
phase := .base
178179
name := `eagerLambdaLifting
179180
run := fun decls => do
180181
decls.foldlM (init := #[]) fun decls decl => do
181-
if decl.inlineAttr || (← Meta.isInstance decl.name) then
182+
if decl.inlineable || (← Meta.isInstance decl.name) then
182183
return decls.push decl
183184
else
184185
return decls ++ (← decl.lambdaLifting (liftInstParamOnly := true) (suffix := `_elam))

0 commit comments

Comments
 (0)