argotorg / argotorg/solidity

Improvements in the Yul-EVM Code transform

Open
#13,721 3 comments 4 reactions 1 assignee Assigned to @ekpyron View on GitHub
epic roadmap viair
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

### What

Improve Yul-EVM code transform and remove stack-too-deep errors as blockers to via IR.

### Why

Currently, the via-IR compilation pipeline is not viable as default compilation mode for two reasons:
- Without optimizer hardly any non-trivial project compiles due to stack-too-deep errors.
- Even with optimizer, some more complex projects suffer from stack-too-deep errors.
- The performance of the via-IR pipeline still significantly lower than the legacy pipeline.

### Tasks

- [ ] [Further improve stack shuffling performance](https://github.com/ethereum/solidity/issues/14343)
- [ ] The current stack layout generation algorithm attempts to find the best stack layout based on minimum gas cost by performing the shuffling of stack slots. We should be able to improve the performance of the stack layout generation if we are able to determine the minimum stack layout prefix before shuffling, reducing the number of permutations, or even replacing the current shuffling step completely.
- [x] Create a Dominator tree from the CFG.
- [ ] https://github.com/ethereum/solidity/pull/14460
- [x] ~Generate the stack layout prefix based on the dominator tree and perform the shuffling for the remaining slots if any.~
It turned out that this approach would not work as we initially thought and we decided to go for doing proper SSA form.
- [ ] Implement minimal or pruned-SSA form using dominators for control flow analysis.
- [ ] Evaluate performance of the approach in term of compilation time and gas usage.
- [ ] Improve stack to memory (we need to minimize stack to memory moves).
- [ ] Ensure all codegen tests pass :)
- [ ] Lift down stack-to-memory from code-transform-Yul-optimizer interplay to being handled in the code transform directly.

### Out of scope

- Avoiding stack too deep errors:
- under all circumstances: Like in recursive functions.
- in the presence of memory unsafe assembly

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.