Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements in the Yul-EVM Code transform #13721

Open
2 of 10 tasks
NunoFilipeSantos opened this issue Nov 17, 2022 · 3 comments
Open
2 of 10 tasks

Improvements in the Yul-EVM Code transform #13721

NunoFilipeSantos opened this issue Nov 17, 2022 · 3 comments

Comments

@NunoFilipeSantos
Copy link
Contributor

NunoFilipeSantos commented Nov 17, 2022

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
  • 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.
    • Create a Dominator tree from the CFG.
    • 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
@NunoFilipeSantos NunoFilipeSantos added the epic effort Multi-stage task that may require coordination between team members across multiple PRs. label Nov 17, 2022
@NunoFilipeSantos NunoFilipeSantos moved this from ❄️ Q4 2022 to 🌱 Q1 2023 in Solidity Roadmap Nov 17, 2022
@NunoFilipeSantos NunoFilipeSantos moved this from 🌱 Q1 2023 to 🍂 Q3 2023 in Solidity Roadmap Nov 17, 2022
@NunoFilipeSantos NunoFilipeSantos moved this from 🍂 Q3 2023 to ☀️ Q2 2023 in Solidity Roadmap Nov 17, 2022
@NunoFilipeSantos NunoFilipeSantos moved this from ☀️ Q2 2023 to 🌱 Q1 2023 in Solidity Roadmap Nov 17, 2022
@NunoFilipeSantos NunoFilipeSantos changed the title Remove Stack too Deep errors as blockers to via IR Remove Stack too Deep errors as blockers to via-IR Nov 22, 2022
@cameel cameel added roadmap epic and removed epic effort Multi-stage task that may require coordination between team members across multiple PRs. labels Dec 2, 2022
@cameel
Copy link
Member

cameel commented Dec 7, 2022

#12865 likely should also be considered a part of this. It does not cause "stack too deep" on its own but unnecessary unlinked references have similar impact on tools in terms of blocking via IR adoption.

@ekpyron
Copy link
Member

ekpyron commented Dec 7, 2022

#12865 likely should also be considered a part of this. It does not cause "stack too deep" on its own but unnecessary unlinked references have similar impact on tools in terms of blocking via IR adoption.

  1. We shouldn't cross-scope these things, so I categorically wouldn't consider this as a part here.
  2. We likely won't solve this issue here without optimizer anyways, and with optimizer the other one is a non-issue. So the main thing to consider here would be a minimal optimization sequence by default for via-IR, which we'll probably do, but yeah, this is off-topic here.

@NunoFilipeSantos
Copy link
Contributor Author

#12865 likely should also be considered a part of this. It does not cause "stack too deep" on its own but unnecessary unlinked references have similar impact on tools in terms of blocking via IR adoption.

  1. We shouldn't cross-scope these things, so I categorically wouldn't consider this as a part here.
  2. We likely won't solve this issue here without optimizer anyways, and with optimizer the other one is a non-issue. So the main thing to consider here would be a minimal optimization sequence by default for via-IR, which we'll probably do, but yeah, this is off-topic here.
  1. Absolutely. If it's tangent, it shouldn't belong here.
  2. I'm in favor of heavily scoping down initially and seeing where we land in Q1, rather than expanding immensely and missing such a large goalposts (a full quarter).

Remember that we don't plan for 100% of our time, meaning all the other day to day "sidequests" also take time.

@ekpyron ekpyron moved this from ☀️ Q2 2023 to 🍂 Q3 2023 in Solidity Roadmap Jun 6, 2023
@r0qs r0qs changed the title Remove Stack too Deep errors as blockers to via-IR Improvements in the Yul-EVM Code transform Jul 11, 2023
@r0qs r0qs moved this from To do to In Progress in Solidity Focus Board Jul 11, 2023
@ekpyron ekpyron moved this from 🍂 Q3 2023 to ❄️ Q4 2023 in Solidity Roadmap Oct 2, 2023
@ekpyron ekpyron moved this from ❄️ Q4 2023 to 🌱 Q1 2024 in Solidity Roadmap Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Archived in project
Development

No branches or pull requests

6 participants