Skip to content

Refactor hardcoded reachable stack depth#16467

Merged
clonker merged 1 commit intoargotorg:developfrom
frangio:refactor-stack-limit
Mar 19, 2026
Merged

Refactor hardcoded reachable stack depth#16467
clonker merged 1 commit intoargotorg:developfrom
frangio:refactor-stack-limit

Conversation

@frangio
Copy link
Copy Markdown
Contributor

@frangio frangio commented Feb 12, 2026

Preparation for #16424

@github-actions
Copy link
Copy Markdown

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.

@frangio
Copy link
Copy Markdown
Contributor Author

frangio commented Feb 12, 2026

@r0qs How should this PR deal with this part you mentioned in #16424 (review):

static size_t constexpr reachableStackDepth = 16;

@clonker
Copy link
Copy Markdown
Member

clonker commented Feb 13, 2026

@r0qs How should this PR deal with this part you mentioned in #16424 (review):

static size_t constexpr reachableStackDepth = 16;

You can ignore that in this PR. Thanks for bringing it up!

@cameel cameel requested review from clonker and r0qs February 16, 2026 14:59
Copy link
Copy Markdown
Member

@r0qs r0qs left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR @frangio. I’ve taken a look and left a few comments.

I think we may also need to update a couple of additional files that are currently missing:

Comment thread libyul/backends/evm/EVMCodeTransform.cpp
Comment thread libyul/backends/evm/EVMCodeTransform.cpp
Comment thread libyul/backends/evm/ssa/StackShuffler.h Outdated
}

template<StackManipulationCallbackConcept Callback, std::size_t ReachableStackDepth=16>
template<StackManipulationCallbackConcept Callback, std::size_t ReachableStackDepth>
Copy link
Copy Markdown
Member

@r0qs r0qs Feb 17, 2026

Choose a reason for hiding this comment

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

As mentioned in #16467 (comment), I think it would be fine to ignore these changes in the ssa-cfg pipeline for now.

Although, on second thought, this refactor, unlike the one in #16424 could probably be applied to the ssa-cfg pipeline as well, no @clonker? I’m just not sure how much effort that would take, but it seems to be only the StackShuffler and its tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems a little safer and relatively harmless to remove this constant in this PR. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, it was not harmless because it was causing a bunch of compilation errors. 🙂 I've reverted this because I noticed it requires a larger refactor once the reachable stack depth is no longer a static value that can be passed by template parameter.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

since it's all experimental in that part of the code (the whole ssa subdirectory) i suggest we leave it as-is right now. i want to rethink bits of the shuffler, too, provided we have these new opcodes. should open up interesting moves.

@frangio frangio requested a review from r0qs February 28, 2026 00:11
Comment thread libevmasm/GasMeter.cpp Outdated
@frangio frangio requested a review from clonker March 11, 2026 18:57
Copy link
Copy Markdown
Member

@clonker clonker left a comment

Choose a reason for hiding this comment

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

some more comments, beyond that it looks good to me:)

Comment thread libevmasm/CommonSubexpressionEliminator.cpp
Comment thread libevmasm/CommonSubexpressionEliminator.cpp
AssemblyItem invalidTag(PushTag, u256(-0x10));
state->feedItem(invalidTag, true);
if (parametersSize > 0)
state->feedItem(swapInstruction(parametersSize));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This needs to be handled in #16424

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

My guess is we'll comb through every occurence of dupInstruction, swapInstruction, and reachableStackDepth.

Comment thread liblangutil/EVMVersion.h Outdated
Comment thread libsolidity/codegen/LValue.cpp Outdated
Comment thread libyul/backends/evm/EVMCodeTransform.cpp Outdated
Comment thread test/libyul/ssa/StackShufflerTest.cpp Outdated
@frangio frangio requested a review from clonker March 17, 2026 19:25
Copy link
Copy Markdown
Member

@clonker clonker left a comment

Choose a reason for hiding this comment

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

Looks good to me now, what's from my point of view is left to do for this PR is cleaning up the commit history a bit (squash, rebase against develop so we get rid of merge commits).

@frangio frangio force-pushed the refactor-stack-limit branch from 5c21af3 to fbc707e Compare March 18, 2026 15:58
@frangio frangio requested a review from clonker March 18, 2026 16:03
@frangio
Copy link
Copy Markdown
Contributor Author

frangio commented Mar 18, 2026

Squashed and rebased!

@clonker clonker force-pushed the refactor-stack-limit branch from fbc707e to 90eb849 Compare March 19, 2026 09:35
@clonker clonker enabled auto-merge March 19, 2026 10:07
@clonker clonker merged commit 81013e6 into argotorg:develop Mar 19, 2026
71 of 82 checks passed
@frangio frangio deleted the refactor-stack-limit branch March 19, 2026 13:49
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.

4 participants