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

Prune unreferenced functions from CFG #15592

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

rodiazet
Copy link
Contributor

@rodiazet rodiazet commented Nov 27, 2024

Motivation:
EOF does not allow unreferenced code sections in the container. Pruning them on Assembly level requires building a control flow graph and analyzing block exit type to discover non-returning functions. It's more convenient to do it already on CFG building step.

  • Remove unreferenced functions from CFG.
  • Disable adding all entry points from the outermost yul block as reachable.

Copy link

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

@rodiazet rodiazet force-pushed the prune-unused-functions branch 11 times, most recently from 6cc1dbc to ac7f083 Compare December 3, 2024 14:25
@rodiazet rodiazet force-pushed the prune-unused-functions branch 3 times, most recently from ff68922 to 46271a3 Compare December 12, 2024 15:06
// EVMVersion: >=shanghai
// bytecodeFormat: >=EOFv1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// EVMVersion: >=shanghai
// bytecodeFormat: >=EOFv1
// bytecodeFormat: >=EOFv1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have it also in prune_unreferenced_function.yul.

@rodiazet rodiazet force-pushed the prune-unused-functions branch 3 times, most recently from a9735cc to a511f6b Compare December 17, 2024 09:37
cameel
cameel previously approved these changes Dec 17, 2024
Copy link
Member

@cameel cameel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks generally ok, but needs small tweaks before we can merge.

@rodiazet rodiazet force-pushed the prune-unused-functions branch from 46111bc to 9752443 Compare December 17, 2024 16:21
@rodiazet rodiazet force-pushed the prune-unused-functions branch from 9752443 to bbb6a11 Compare December 17, 2024 19:01
@cameel cameel merged commit 3ef0a06 into ethereum:develop Dec 18, 2024
73 checks passed
@rodiazet rodiazet deleted the prune-unused-functions branch December 18, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants