How to solve stack too deep errors: a Yul to EVM pipeline
summary
A Yul-to-EVM pipeline builds on SSA-CFG to compute top‑down stack layouts, emits a greedy code generator that inserts virtual get annotations when values exceed the accessible stack depth, and then repairs them by spilling to the Solidity free memory pointer region. The standalone Python tool handles all stack-too-deep cases in the Solidity benchmark suite, survives an artificial limit of depth 8, runs as linear passes over the CFG, and reports fewer instructions/bytes and estimated gas in the evaluated contracts.
AI-written summary · about
chapters (21)
- 0:00Stack too deep errors
- 1:48EVM stack-based design
- 3:57Memory as registers in Solidity
- 4:38Yul to EVM pipeline
- 6:25Dual CFG in SSA form
- 7:27Liveness analysis under SSA
- 8:32Stack layouts top-down
- 10:00Stack contents across blocks
- 12:10Greedy code generation
- 13:52Repairing unreachable stack accesses
- 14:54Φ-functions for spilling
- 16:41Spilled variables decision
- 18:08Virtual gets to memory loads
- 18:51Implementation setup
- 19:12Benchmark results and gas savings
- 20:39Restricted stack access depth
- 21:01Pipeline phase performance
- 21:46Pipeline vs Solidity compiler
- 22:27Dual CFG limitations
- 23:10Future improvements
- 24:12Q&A
related talks
23mGenerating EVM Bytecode from Yul in the new via IR Pipeline
18mSuperStack: Superoptimization of Stack-Bytecode via Greedy, Constraint-Based, and SAT(…)
13mBootstrapping a Compiler with Yul
01h 15mReliable Stack Traces, the Reality of Myth
35mStrongly-Typed Multi-View Stack-Based Computations
23mSynthesizing Efficient Super-Instruction Sets for Ethereum Virtual Machine
30mThe Solidity Optimizooooor
37mSolidity in 2022: Recent and Planned Features
