Skip to content

Conversation

vladimirradosavljevic
Copy link
Contributor

@vladimirradosavljevic vladimirradosavljevic commented Jul 29, 2025

For EVM, to return from the contract we are using different instructions (e.g. return, revert) which are followed by unreachable. In the Inliner heuristic, if BB is unreachable-terminated threshold is set to 0 and these callsites are unlikely to be inlined. Instead, add small threshold and continue to calculate cost model, since in some cases we benefit from inlining.

@vladimirradosavljevic vladimirradosavljevic force-pushed the evm_allow_size_growth_in_inlinecost branch from dc11487 to 4d393ff Compare July 29, 2025 08:29
Copy link

github-actions bot commented Jul 29, 2025

Results for: evm ir-llvm EVMInterpreter
╔═╡ Size (-%) ╞═══════════════════════╡ All E +M3B3 ╞═╗
║ Best                                         28.605 ║
║ Worst                                       -19.512 ║
║ Total                                         0.086 ║
╠═╡ Cycles (-%) ╞═════════════════════╡ All E +M3B3 ╞═╣
║ Best                                         77.201 ║
║ Worst                                        -3.651 ║
║ Total                                         0.003 ║
╠═╡ Ergs (-%) ╞═══════════════════════╡ All E +M3B3 ╞═╣
║ Best                                         34.849 ║
║ Worst                                        -5.634 ║
║ Total                                         0.005 ║
╠══╡ Gas (-%) ╞═══════════════════════╡ All E +M3B3 ╞═╣
║ Best                                         77.799 ║
║ Worst                                       -20.472 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═══════════════════════╡ All E +MzB3 ╞═╗
║ Best                                         28.125 ║
║ Worst                                         0.000 ║
║ Total                                         0.033 ║
╠═╡ Cycles (-%) ╞═════════════════════╡ All E +MzB3 ╞═╣
║ Best                                         29.714 ║
║ Worst                                        -0.213 ║
║ Total                                         0.001 ║
╠═╡ Ergs (-%) ╞═══════════════════════╡ All E +MzB3 ╞═╣
║ Best                                         12.752 ║
║ Worst                                        -0.026 ║
║ Total                                         0.002 ║
╠══╡ Gas (-%) ╞═══════════════════════╡ All E +MzB3 ╞═╣
║ Best                                         30.637 ║
║ Worst                                        -2.439 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═══════════════════════╡ All Y +M3B3 ╞═╗
║ Best                                         51.675 ║
║ Worst                                       -18.367 ║
║ Total                                         1.295 ║
╠═╡ Cycles (-%) ╞═════════════════════╡ All Y +M3B3 ╞═╣
║ Best                                         79.019 ║
║ Worst                                        -3.517 ║
║ Total                                         0.037 ║
╠═╡ Ergs (-%) ╞═══════════════════════╡ All Y +M3B3 ╞═╣
║ Best                                         36.835 ║
║ Worst                                        -5.614 ║
║ Total                                         0.053 ║
╠══╡ Gas (-%) ╞═══════════════════════╡ All Y +M3B3 ╞═╣
║ Best                                         80.935 ║
║ Worst                                       -21.105 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═══════════════════════╡ All Y +MzB3 ╞═╗
║ Best                                         46.483 ║
║ Worst                                        -7.643 ║
║ Total                                         0.606 ║
╠═╡ Cycles (-%) ╞═════════════════════╡ All Y +MzB3 ╞═╣
║ Best                                         58.470 ║
║ Worst                                       -13.327 ║
║ Total                                         0.017 ║
╠═╡ Ergs (-%) ╞═══════════════════════╡ All Y +MzB3 ╞═╣
║ Best                                         21.035 ║
║ Worst                                       -11.974 ║
║ Total                                         0.019 ║
╠══╡ Gas (-%) ╞═══════════════════════╡ All Y +MzB3 ╞═╣
║ Best                                         67.955 ║
║ Worst                                       -12.282 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════════════════╡ Real life E +M3B3 ╞═╗
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠═╡ Cycles (-%) ╞═══════════════╡ Real life E +M3B3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠═╡ Ergs (-%) ╞═════════════════╡ Real life E +M3B3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠══╡ Gas (-%) ╞═════════════════╡ Real life E +M3B3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════════════════╡ Real life E +MzB3 ╞═╗
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠═╡ Cycles (-%) ╞═══════════════╡ Real life E +MzB3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠═╡ Ergs (-%) ╞═════════════════╡ Real life E +MzB3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╠══╡ Gas (-%) ╞═════════════════╡ Real life E +MzB3 ╞═╣
║ Best                                          0.000 ║
║ Worst                                         0.000 ║
║ Total                                         0.000 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════════════════╡ Real life Y +M3B3 ╞═╗
║ Best                                          1.187 ║
║ Worst                                         0.000 ║
║ Total                                         0.540 ║
╠═╡ Cycles (-%) ╞═══════════════╡ Real life Y +M3B3 ╞═╣
║ Best                                          1.518 ║
║ Worst                                         0.000 ║
║ Total                                         0.260 ║
╠═╡ Ergs (-%) ╞═════════════════╡ Real life Y +M3B3 ╞═╣
║ Best                                          0.742 ║
║ Worst                                         0.000 ║
║ Total                                         0.104 ║
╠══╡ Gas (-%) ╞═════════════════╡ Real life Y +M3B3 ╞═╣
║ Best                                          0.636 ║
║ Worst                                         0.000 ║
║ Total                                         0.148 ║
╚═════════════════════════════════════════════════════╝

╔═╡ Size (-%) ╞═════════════════╡ Real life Y +MzB3 ╞═╗
║ Best                                          0.119 ║
║ Worst                                         0.000 ║
║ Total                                         0.035 ║
╠═╡ Cycles (-%) ╞═══════════════╡ Real life Y +MzB3 ╞═╣
║ Best                                          0.535 ║
║ Worst                                        -0.003 ║
║ Total                                         0.040 ║
╠═╡ Ergs (-%) ╞═════════════════╡ Real life Y +MzB3 ╞═╣
║ Best                                          0.315 ║
║ Worst                                         0.000 ║
║ Total                                         0.012 ║
╠══╡ Gas (-%) ╞═════════════════╡ Real life Y +MzB3 ╞═╣
║ Best                                          0.139 ║
║ Worst                                         0.000 ║
║ Total                                         0.041 ║
╚═════════════════════════════════════════════════════╝

Copy link

github-actions bot commented Jul 29, 2025

Target Mode Toolchain Environment Link
eravm E+M3B3_0.4 ir-llvm zk_evm Results
eravm E+M3B3_0.5 ir-llvm zk_evm Results
eravm E+M3B3_0.6 ir-llvm zk_evm Results
eravm E+M3B3_0.7 ir-llvm zk_evm Results
eravm E+M3B3_0.8 ir-llvm zk_evm Results
eravm E+MzB3_0.4 ir-llvm zk_evm Results
eravm E+MzB3_0.5 ir-llvm zk_evm Results
eravm E+MzB3_0.6 ir-llvm zk_evm Results
eravm E+MzB3_0.7 ir-llvm zk_evm Results
eravm E+MzB3_0.8 ir-llvm zk_evm Results
eravm Y+M3B3 ir-llvm zk_evm Results
eravm Y+MzB3 ir-llvm zk_evm Results
evm E+M3B3 ir-llvm EVMInterpreter Results
evm E+MzB3 ir-llvm EVMInterpreter Results
evm Y+M3B3 ir-llvm EVMInterpreter Results
evm Y+MzB3 ir-llvm EVMInterpreter Results
evm E+_0.8 solc EVMInterpreter Results
evm Y+ solc EVMInterpreter Results

Copy link

github-actions bot commented Jul 29, 2025

📊 Excel Report Available

Benchmarks measured for:

  • solx candidate version: solx, LLVM-based Solidity compiler for the EVM v0.1.1, LLVM revision: v1.0.2, LLVM build: eff88dbb32d919ece3a73c7ae64d7ab825a1cf52
  • solx ToT version: solx, LLVM-based Solidity compiler for the EVM v0.1.1, LLVM revision: v1.0.2, LLVM build: 19eef9120651351733dc64cb737bb6eacc9debce
  • solx latest release version: solx, LLVM-based Solidity compiler for the EVM v0.1.1, LLVM revision: v1.0.2, LLVM build: b32c5ccab280fd4219e26aceb3f60f425e907498
  • solc version: 0.8.30

➡️ Download Excel Report

@vladimirradosavljevic vladimirradosavljevic force-pushed the evm_allow_size_growth_in_inlinecost branch 11 times, most recently from d9d33cb to 9dbc203 Compare July 30, 2025 13:30
@vladimirradosavljevic vladimirradosavljevic changed the title [EVM] Allow size growth in InlineCost when BB is unreachable-terminated [EVM][InlineCost] Set threshold to a small value when BB is unreachable-terminated Jul 30, 2025
@akiramenai akiramenai force-pushed the evm_allow_size_growth_in_inlinecost branch from 9dbc203 to 78a86b0 Compare August 11, 2025 22:46
@akiramenai akiramenai force-pushed the evm_allow_size_growth_in_inlinecost branch 2 times, most recently from ea56e72 to d317fe0 Compare August 31, 2025 09:01
Copy link

codecov bot commented Aug 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 30.08%. Comparing base (19eef91) to head (eff88db).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #867      +/-   ##
==========================================
+ Coverage   30.07%   30.08%   +0.01%     
==========================================
  Files        2442     2442              
  Lines      807946   807951       +5     
  Branches   176475   176476       +1     
==========================================
+ Hits       242985   243088     +103     
+ Misses     522792   522694      -98     
  Partials    42169    42169              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vladimirradosavljevic vladimirradosavljevic force-pushed the evm_allow_size_growth_in_inlinecost branch from d317fe0 to 6af3496 Compare September 8, 2025 08:19
@akiramenai akiramenai force-pushed the evm_allow_size_growth_in_inlinecost branch from 6af3496 to 0f1095d Compare September 8, 2025 18:41
Copy link
Collaborator

@akiramenai akiramenai left a comment

Choose a reason for hiding this comment

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

Could we add a positive and a negative test case for inlining with unreachable?

…alue when BB is unreachable-terminated

Add positive and negative tests to show why in some
cases is preferable to inline when BB is
unreachable-terminated. Functions callee_inline is
taken from real world example where inlining this
function reduces one SLOAD after optimizations (we have
the same load from the callers and in the callee).

Signed-off-by: Vladimir Radosavljevic <[email protected]>
…le-terminated

For EVM, to return from the contract we are using
different instructions (e.g. return, revert) which
are followed by unreachable. In the Inliner heuristic,
if BB is unreachable-terminated threshold is set to 0
and these callsites are unlikely to be inlined. Instead,
add small threshold and continue to calculate cost model,
since in some cases we benefit from inlining.

Signed-off-by: Vladimir Radosavljevic <[email protected]>
@vladimirradosavljevic vladimirradosavljevic force-pushed the evm_allow_size_growth_in_inlinecost branch from 0f1095d to eff88db Compare September 9, 2025 11:40
@akiramenai akiramenai merged commit 5fc524e into main Sep 13, 2025
30 checks passed
@akiramenai akiramenai deleted the evm_allow_size_growth_in_inlinecost branch September 13, 2025 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants