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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//! Stack-effect SSA construction from a CFG and instruction stream.
//!
//! This replaces the earlier PUSH-only skeleton with a genuine stack-machine
//! SSA: every opcode's `(pop, push)` effect is modelled (see the `effects`
//! module), the eval stack is tracked symbolically as `Vec<SsaVariable>`,
//! and φ nodes are placed at control-flow joins where predecessors disagree
//! on a stack slot.
//!
//! ### Algorithm
//!
//! 1. Compute dominance (Cooper-Harvey-Kennedy) — gives idom / dominator tree
//! / dominance frontiers (used by downstream analyses and exposed on
//! [`SsaForm`]).
//! 2. Fixpoint over blocks in program order:
//! - Compute each block's **entry symbolic stack** from its predecessors'
//! exit stacks. Where predecessors agree on a slot, the value flows
//! through unchanged; where they disagree, a φ node is placed (canonical
//! target per `(block, depth)`).
//! - **Execute** the block straight-line: each compute opcode pops N uses
//! and pushes a fresh SSA definition carrying a real [`SsaExpr`](crate::decompiler::cfg::ssa::SsaExpr)
//! (binary, unary, literal, or a `Call` placeholder); reorder opcodes
//! transform the symbolic stack directly.
//! - Repeat until exit stacks and φ sets stop changing.
//!
//! Convergence is guaranteed because each block's exit-slot *identity* is
//! canonical (`b{block}_v{ordinal}`) and thus deterministic, so the join
//! structure reaches a fixed point within a small number of passes.
//!
//! The result carries real def/use chains and φ nodes suitable for the
//! constant-propagation / DCE passes (Phase 3).
use ;
use crate;
use crateInstruction;
use ;
use ;
use SsaVariable;
/// `(blocks, definitions, uses)` — the assembled SSA pieces.
type SsaBuildResult = ;
/// Builder for stack-effect SSA form from a CFG and instructions.