1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! Dead-code elimination — engine + ProgramPass registration colocated.
//!
//! Audit cleanup A7 (2026-04-30): hoisted from `transform/optimize/dce/`
//! mirroring the A6 CSE consolidation. Engine + ProgramPass registration share one home.
//!
//! ## Layout
//!
//! - `engine` — the `dce(program)` entry point (runs
//! `eliminate_dead_lets` → `eliminate_unreachable` → `eliminate_dead_lets`
//! again to catch bindings that became dead after unreachable code was
//! stripped).
//! - `eliminate_dead_lets.rs` — backward liveness pass that strips dead
//! `let` bindings. Drops a `let` when its name is not live AND its value
//! is pure (effectful nodes always preserved).
//! - `eliminate_unreachable.rs` — forward pass folding constant branches +
//! truncating after `Return`.
//! - `collect_expr_refs.rs` — iterative visitor accumulating every
//! `Expr::Var` name (conservative liveness over-approximation).
//! - `const_truth.rs` — partial constant evaluator for boolean expressions.
//! - `const_loop_empty.rs` — detects statically empty loops.
//! - `live_result.rs` — result bundle returned by liveness pruning.
//! - `reachable_prefix.rs` — slice the node list up to first unconditional
//! `Return`.
//! - `program_pass.rs` — the registered `DcePass` (ProgramPass impl).
//!
//! `expr_has_effect` is shared with CSE — single source of truth in
//! `super::cse::expr_has_effect`.
// `expr_has_effect` is shared with CSE — single source of truth in
// `super::cse::expr_has_effect`. Re-exported here so the DCE engine can
// say `super::expr_has_effect` without learning about the cse path.
pub use expr_has_effect;
/// Collect variable references from an expression tree.
pub use collect_expr_refs;
/// Evaluate whether loop bounds make a loop statically empty.
pub use const_loop_empty;
/// Evaluate an expression as a static boolean when possible.
pub use const_truth;
/// Remove let-bindings whose values are neither live nor effectful.
pub use eliminate_dead_lets;
/// Trim unreachable control-flow nodes after static terminators.
pub use eliminate_unreachable;
/// Result bundle returned by liveness pruning.
pub use LiveResult;
/// Return the node prefix reachable before an unconditional return.
pub use reachable_prefix;
/// Iterative `Expr::Var` collector.
/// Detect statically empty loops.
/// Partial constant evaluator for boolean expressions.
/// Backward liveness pass that strips dead `let` bindings.
/// Forward pass folding constant branches and truncating after `Return`.
/// Entry point for the dead-code elimination pass.
/// Result bundle returned by `eliminate_dead_lets`.
/// Registered `DcePass` (ProgramPass impl) for the engine.
/// Slice the node list up to the first unconditional `Return`.
pub use dce;
pub use DcePass;
/// DCE adversarial test suite.