Skip to content

Lack of proper heuristics in the Function Specializer can lead to large contract sizes #14893

Open
@kaber2

Description

@kaber2

Description

I have a smart contract where the majority of the functionality has one private function as entry point, and there are two external entry points. Solidity currently inlines the private function (including everything it calls) into both of the external entry points. I now wanted to add a third external entry point, and solidity inlines the entire private function yet again, making the contract blow up by almost 50% and exceeding the blockchain limit.

This happens with via-ir at any optimization run count, even when going down to zero. Turning off optimization is not an option for various reasons, but I also don't want to turn off inlining completely as I have many functions which are designed to be inlined. I would expect the compiler to pay some consideration to the size of the function being inlined and not blow up the contract to almost 3x the necessary size just to avoid a jump.

Is there anything I can do to make the compiler stop inlining this very large function, while still inlining small functions?

Environment

  • Compiler version: 0.8.24
  • Target EVM version (as per compiler settings): London
  • Operating system: Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions