-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Enable minimal yul optimizations by default. #13972
Comments
When we do this, we should replace the "unoptimized" preset and also the one with EVMASM optimizer only in external tests with one that uses this minimal optimization level. This will finally let us have all presets pass via IR. |
Some extra details on the implementation from @ekpyron:
Reconciling that with the existing options in a natural way (i.e. what happens when user explicitly sets |
@ekpyron I think that the simplest way to go about it is:
It's consistent with how currently Alternative solutionStill, I don't like the fact that options do not really mean what they sound like so here's an alternative way to do this:
This provides more fine grained control over the optimizer and makes the options actually mean what they sound like. I suspect that you'll say this is too complicated, so I'm going to go with the first variant anyway, but I wanted to put it out there in case you do think this is worthwhile. There's a possibility that we actually do want to have a way to disable the Yul optimizer and the first variant makes it impossible. |
We shouldn't care about CLI too much. We already can't e.g. disable the peephole optimizer in CLI - it's perfectly fine not to be able to disable minimal yul optimizations via CLI either. (And remember, we'll fix this with our CLI rewrite eventually ;-)). Also to help you with disliking that the options don't do what they say they do: With this change, you can actually consider the "minimal yul optimizations" as having the optimizer disabled. Those minimal optimizations just become parts of a Yul transformation for enabling code generation. That's really how we should think about this generally. So I'd go for the simplest solution here. Sounds good enough to me. |
Can someone summarize that this means for the next version? Specifically, what will be the behavior when you just have:
and when you have:
|
@fvictorio settings: {
viaIR: true,
optimizer: {
enabled: false,
details: {
yul: true,
yulDetails: {
stackAllocation: true,
optimizerSteps: "u",
}
}
}
} but only as long as your contract does not contain (or call internally) any code that uses This applies to pure Yul compilation (i.e. Behavior of |
Hi @cameel In Foundry we have a long standing issue foundry-rs/foundry#3357 with Thanks! |
@zerosnacks Unfortunately I can't offer any quick fix. The limitation ultimately lies in the current implementation of our Yul->EVM transform. It's sometimes unable to produce a viable stack layout and gives up. The minimum optimizations added here (i.e. unused pruner) reduce the stack pressure, making this happen less but there are still some hard cases where this happens even with the help of the stack-to-memory mover. This will be solved eventually, but it'll still be a while until any of the solutions land. On one hand we're working on a better Yul->EVM transform. On other the EVM is also moving towards EOF where the problem will no longer exist thanks to The prototype of the EOF backend will actually ship in the next release and relaxing stack constraints is the very next EOF feature that will be worked on after that. EOF support will be considered experimental until EOF hits mainnet and it would not be running the exact same bytecode, but the difference might not matter in practice, especially if the user is aware of the difference (i.e. has to explicitly enable it via a flag) so maybe it would be usable for coverage calculation. The biggest problem here will probably be that there will be syntax differences so the code may not run as is. We're still considering making it possible to write portable code though. Feedback welcome: [EOF] In-language construct to check for EOF. One thing we might do right now could be to make it a bit easier for users to find out what is triggering StackTooDeep and work around it (#12449). The problem usually does not sit in anything fundamental and is pretty ephemeral. Just restructuring code around it in various ways often makes it go away. The problem is just that finding the place to point at is mostly guesswork. The issue is non-local, so the point where it happened is sometimes not the place that's really causing it. But it still could be better than nothing and I think it should be provided at least as a hint.
Regarding source mappings - are they wrong or just incomplete? If it's the former, please report as a bug. |
This was mentioned in other issues, including #13721 and #12533.
The gist is that we want to enable a minimal set of optimizations for the via-IR pipeline, such that:
The text was updated successfully, but these errors were encountered: