Local function usage information used to decide whether it should be inlined or not.
The information is an approximation, but it is on the "safe" side. That is, if we tagged
a function with .once
, then it is applied only once. A local function may be marked as
.many
, but after simplifications the number of applications may reduce to 1. This is not
a big problem in practice because we run the simplifier multiple times, and this information
is recomputed from scratch at the beginning of each simplification step.
- once: Lean.Compiler.LCNF.Simp.FunDeclInfo
Local function is applied once, and must be inlined.
- many: Lean.Compiler.LCNF.Simp.FunDeclInfo
Local function is applied many times or occur as an argument of another function, and will only be inlined if it is small.
- mustInline: Lean.Compiler.LCNF.Simp.FunDeclInfo
Function must be inlined.
Instances For
Local function declaration statistics.
Mapping from local function name to inlining information.
Instances For
Equations
- Lean.Compiler.LCNF.Simp.instInhabitedFunDeclInfoMap = { default := { map := default } }
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add new occurrence for the local function with binder name key
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add new occurrence for the local function occurring as an argument for another function.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Add new occurrence for the local function with binder name key
.
Equations
- { map := map }.addMustInline fvarId = { map := map.insert fvarId Lean.Compiler.LCNF.Simp.FunDeclInfo.mustInline }
Instances For
Equations
Instances For
Traverse code
and update function occurrence map.
This map is used to decide whether we inline local functions or not.
If mustInline := true
, then all local function declarations occurring in
code
are tagged as .mustInline
.
Recall that we use .mustInline
for local function declarations occurring in type class instances.
Equations
- s.update code mustInline = do let __discr ← (Lean.Compiler.LCNF.Simp.FunDeclInfoMap.update.go mustInline code).run s match __discr with | (fst, s) => pure s
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.Simp.FunDeclInfoMap.update.addArgOcc Lean.Compiler.LCNF.Arg.erased = pure ()
- Lean.Compiler.LCNF.Simp.FunDeclInfoMap.update.addArgOcc (Lean.Compiler.LCNF.Arg.type expr) = pure ()
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Lean.Compiler.LCNF.Simp.FunDeclInfoMap.update.addLetValueOccs Lean.Compiler.LCNF.LetValue.erased = pure ()
- Lean.Compiler.LCNF.Simp.FunDeclInfoMap.update.addLetValueOccs (Lean.Compiler.LCNF.LetValue.value value) = pure ()
- Lean.Compiler.LCNF.Simp.FunDeclInfoMap.update.addLetValueOccs (Lean.Compiler.LCNF.LetValue.proj typeName idx struct) = pure ()
- Lean.Compiler.LCNF.Simp.FunDeclInfoMap.update.addLetValueOccs (Lean.Compiler.LCNF.LetValue.const declName us args) = Array.forM Lean.Compiler.LCNF.Simp.FunDeclInfoMap.update.addArgOcc args