Documentation

Strata.Transform.DeadDefElim

Erasing unread definitions of an obligation program #

deadDefElim live ss removes from the statement list ss every init x : T := e (or init x : T := *) whose variable no later statement mentions, whatever T and e. "Later" is the rest of the statement's list after erasure, and, for a statement of a branch or block body, also everything after the enclosing statement (live, the identifiers mentioned after the list); for a statement of the then branch of an ite, it also includes the else branch after erasure. The rest of a list is processed before its head, a branch or block body after the rest of its enclosing list, and the else branch of an ite before its then branch, so one pass reaches the fixpoint: no remaining init has an unmentioned variable. No other statement is removed or changed.

Erasing an unread init never removes a failure (DeadDefElimCorrect).

deadDefElim recomputes the identifiers of the rest of a list at each statement. deadDefElimH computes the same list (deadDefElimH_eq in DeadDefElimProps) in one backward pass that carries the identifiers mentioned later in one hash set.

For Core, Core.DeadDefElim.deadDefElimProgram runs deadDefElimH on every structured procedure body, and Core.deadDefElimPipelinePhase is the pipeline phase that runs it (DeadDefElimCoreCorrect).

Key definitions: erasable, deadDefElim, deadDefElimS, deadDefElimH, Core.DeadDefElim.deadDefElimProgram, Core.deadDefElimPipelinePhase.

Is s an init whose variable is not in live?

Equations
Instances For

    The statement list without its unread inits, live being the identifiers mentioned after the list.

    Equations
    Instances For

      The statement with the unread inits of its branches or body removed, live being the identifiers mentioned after it; the then branch of an ite is processed with the identifiers of the processed else branch added.

      Equations
      Instances For

        Insert the free variables of an expression.

        Equations
        Instances For

          Insert the identifiers of a call argument: the free variables of an input expression, the variable of an input-output or output argument.

          Equations
          Instances For
            @[irreducible]

            deadDefElim in one backward pass: h holds the identifiers mentioned after the list; the result is the processed list and h with the identifiers of the processed list added. The rest of a list is processed before its head, the else branch of an ite before its then branch; each kept statement adds its own identifiers once.

            Equations
            Instances For

              deadDefElim in one backward pass with one hash set (deadDefElimHL).

              Equations
              Instances For

                The Core phase #

                The declaration with the unread inits of its structured procedure body removed, and whether that body changed.

                Equations
                Instances For

                  The dead-definition transform. Every procedure of the program with the unread inits of its structured body removed, every other declaration unchanged, and whether some procedure body changed. It transforms each body once and leaves the transform state, cached analyses included, as it is.

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

                    The dead-definition elimination pipeline phase: removes from each procedure body the inits whose variable no later statement mentions (Core.DeadDefElim.deadDefElimProgram). It requires a program

                    • without calls (noCalls) and loops (noLoops): its correctness is established for call-free, loop-free procedure bodies only;
                    • whose function preconditions are already checked (noPrecondsFromFuncs): an erased init takes its unchecked preconditions with it;
                    • that is type-checked (typeAnnotated, which only typeCheck establishes): an erased init takes its type errors with it. It only deletes inits, so it keeps every fact of its input. No default pipeline runs it; a pipeline names it (Core.nameablePhases).
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For