Documentation

Lean.Compiler.LCNF.InferBorrow

This pass is responsible for inferring borrow annotations to the parameters of functions and join points. When a parameter is marked as borrowed, the caller can be sure that the function will not decrement the reference count of the parameter. Thus, if the value is still used after the call, the caller does not need to inc it before calling in order to ensure that it stays alive.

The inference is done with a data flow analysis which initially assumes all arguments are passed as borrowed and subsequently refines this by marking parameters as owned as required and propagating the information throughout the program. The analysis has two reasons for marking a parameter as owned. Some parameters need to be owned for correctness, while others are heuristically marked as owned to reduce reference counting pressure inside of the function.

The correctness ones are the following:

For performance we:

Equations
  • One or more equations did not get rendered due to their size.
Instances For