better heuristics for choosing variables to move to memory #14067
Labels
high impact
Changes are very prominent and affect users or the project in a major way.
medium effort
Default level of effort
selected for development
It's on our short-term development
viair
Projects
Description
I've been looking at bytecodes produced using the
--via-ir
pipeline and I noticed that in most cases, popular constants (0, 4, etc.) are pushed to the stack on the function selector code and shared between public functions. I stumbled upon a contract where the memory mover kicks in to resolve stack too deep errors. This behavior can be seen in the produced yul code, with0
being stored at memory offset0xa0
. After this point the constant is loaded 271 times (can be observed by searching "60a051" in the deployed bytecode).So in this case the sequence
60a051
is used instead of6000
, adding 271 extra bytes to the deployed bytecode. Thought to report it as it will probably be common in large programs.Environment
Steps to Reproduce
I got the contract's code concatenated to a single file from here and compiled using 0.8.19 (after removing imports, etc). The same behavior is present. I'm not posting it here because its too large.
The text was updated successfully, but these errors were encountered: