Skip to main content

Module field_analysis

Module field_analysis 

Source
Expand description

Field-level definite assignment and liveness analysis on MIR.

Supplements the AST-level “optimistic hoisting” pre-pass (Phase 1) with a flow-sensitive MIR analysis (Phase 2) that uses the CFG with dominators. Phase 1 runs before compilation to collect fields; Phase 2 validates them per-function after MIR lowering, detecting conditionally-initialized and dead fields. Tracks which TypedObject fields are definitely initialized, conditionally initialized, live (have future reads), or dead (written but never read) at each program point.

The analysis has two phases:

  1. Forward: Definite initialization — which fields are guaranteed to be assigned on every path from the entry block to a given point.
  2. Backward: Field liveness — which (slot, field) pairs will be read on some path from the current point to function exit.

Structs§

FieldAnalysis
Results of field-level analysis for a single MIR function.
FieldAnalysisInput
Input bundle for field analysis.

Functions§

analyze_fields
Run field-level definite-assignment and liveness analysis.

Type Aliases§

FieldKey
A (slot, field) pair identifying a specific field on a specific local.