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
feat: add parametrized labels to LLL #2598
feat: add parametrized labels to LLL #2598
Conversation
387eb4d
to
0680464
Compare
ec3ccaa
to
cc635a5
Compare
This pull request introduces 1 alert when merging 2ea434d into 0004e0c - view on LGTM.com new alerts:
|
get_comb_opcodes originally stood for "get combined [pseudo- and evm-] opcodes". what it really meant is get all LLL opcodes.
this commit forces stack items passed to labels to be explicitly named. this will help liveness analysis of stack items. note that it changes the structure of labels - instead of allowing labels to occur arbitrarily in code, they turn into blocks, enforcing scope of the named stack items.
2ea434d
to
cdbb155
Compare
This pull request introduces 1 alert when merging 5d177b2 into e480e91 - view on LGTM.com new alerts:
|
5d177b2
to
685696a
Compare
This pull request introduces 1 alert when merging 685696a into e480e91 - view on LGTM.com new alerts:
|
685696a
to
902b791
Compare
902b791
to
0db966b
Compare
Codecov Report
@@ Coverage Diff @@
## master #2598 +/- ##
==========================================
+ Coverage 86.26% 86.29% +0.02%
==========================================
Files 91 91
Lines 9646 9739 +93
Branches 2437 2466 +29
==========================================
+ Hits 8321 8404 +83
- Misses 828 833 +5
- Partials 497 502 +5
Continue to review full report at Codecov.
|
This pull request introduces 1 alert when merging 93fe033 into 14cbedb - view on LGTM.com new alerts:
|
93fe033
to
86220cf
Compare
86220cf
to
af3ceb0
Compare
cases: - internal void - internal with return - external void - external with return
Change labels in LLL to be parameterized. Previously, stack items were implicitly consumed from jumpdests using `pass`, which made liveness analysis for stack items impossible in general. Since labels now take parameters, they are very similar to subroutines so we could use that terminology interchangeably. This change also enables translation to other architectures such as LLVM backends since implicit stack items cannot be handled in translation to a register machine. Lastly, this commit also added an `exit_to` instruction for LLL. This compiles the same as `goto` -- to a JUMP instruction -- but has different scoping semantics. `exit_to` terminates a subroutine while `goto` expects control flow to be returned. This is an important hint for liveness analysis. If you hit an `exit_to`, all stack items in scope must be consumed, whereas if you hit a `goto` the same requirement does not hold. In order to accomodate the semantic change, this commit changes the codegen everywhere that stack items are consumed implicitly. In practice, this happens in private functions, and in function common cleanup blocks. Note: the assembly output for all contracts I looked at were byte-for-byte the same with the exception of those which returned straight out of a loop (using the LLL `cleanup_repeat` instruction), so this commit adds a couple more tests to test returns out of loops (in the void return and external cases)
What I did
change labels in LLL to be parameterized. previously, stack items were implicitly consumed from jumpdests using
pass
, liveness analysis for stack items is impossible in the general case. now, labels in LLL are very similar to subroutines since they take parameters and are properly terminated. fixes #2511.this also enables translation to certain LLVM backends since implicit stack items cannot be handled in translation to a register machine.
I also added an
exit_to
instruction for LLL. This compiles the same asgoto
-- to a JUMP instruction -- but has different scoping semantics.exit_to
terminates a subroutine whilegoto
expects control flow to be returned. this is an important hint for liveness analysis, if you hit anexit_to
, all stack items in scope must be consumed, whereas if you hit agoto
the same requirement does not hold.How I did it
change the codegen everywhere that stack items are consumed implicitly. in practice, this happens in private functions, and in function common cleanup blocks.
How to verify it
see that tests pass. the assembly output for all contracts i looked at were byte-for-byte the same except for those which return straight out of a loop (using the LLL
cleanup_repeat
instruction), so i added a couple more tests to test returns out of loops (in the void return and external cases)Commit message
Description for the changelog
Cute Animal Picture