package js_of_ocaml-compiler

  1. Overview
  2. Docs
Module type
Class type

Global deadcode elimination pass.

This module provides a global liveness analysis more powerful than that found in In particular, this analysis annotates blocks with the specific fields that are live. It also uses to determine the liveness of function return values. It first computes an initial liveness of each variable by traversing the program IR. Then it propagates this information to the dependencies of each variable using a flow analysis solver. Lastly it replaces dead variables with a sentinal zero variable (the JS value `undefined`).

Although this module does not perform any dead-code elimination itself, it is designed to be used to identify and substitute dead variables that are then removed by In particular it allows for the elimination of unused functions defined in functors, which the original deadcode elimination cannot.

val f : Code.program -> deadcode_sentinal:Code.Var.t -> -> Code.program