-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Stack layout generator stack compression oddity. #15877
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
Conversation
// /* "":566:582 */ | ||
// calldataload | ||
// /* "":591:605 */ | ||
// dup16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the change, this dup16
will instead be transported up and turn into a dup14
plus some swapping to compensate.
The actual stack-too-deep failure in elementfi is actually also a bit curious. First of all, it's weird that this change triggers it - the change should actually make stacks smaller - but it will keep additional copies of slots around further up in the code, which it appears to just happen to prevent the stack-too-deep in elementfi. In any case, I'd actually tend towards not messing with this, even though the current behaviour is odd here, but to instead focus on bringing the SSA-based code transforms up to speed, which should be much more well-behaved in general. |
ElementFi test seems to be missing a The particular StackTooDeep you get there also points at a specific location so even if In any case, if we decide not to fix it, we should at least add a comment explaining what's happening there. I'd even refactor the condition into |
This pull request is stale because it has been open for 14 days with no activity. |
This pull request was closed due to a lack of activity for 7 days after it was stale. |
Noticed in #15844
The thought behind the line changed here was to always minimize the propagated stack, if the required value can be dup'ed ad-hoc, but the counting was off (not even by just 1, but by 2 slots).
However, while this change improves gas cost on some tests, it triggers a stack-too-deep in an external test (this is likely due to a non-local effect of the change, which is hard to directly mitigate).
So I'd tend towards keeping the existing logic and towards fixing this with generally improved stack layout generation in the SSA codegen approach. I'm still pushing a draft PR for now to consider options.