-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Bug][compiler-v2] Optimized stackless bytecode may not always yield optimized file format bytecode #12404
Comments
A detailed example of this issueConsider the following code (we will focus on the
With variable coalescing (and related optimizations) on, we produce the following stackless bytecode:
The above (optimized) stackless bytecode yields the following file format bytecode:
Now, consider the case where we do not use variable coalescing (and related optimizations). It produces the following stackless bytecode, which uses more variables than the optimized version above:
However, this unoptimized stackless bytecode produces better file format bytecode! See below:
|
Eliminating this pattern for each local that is dead after the next operation will solve this case:
|
A few more tests cases are provided by the move-cli tests when compiled with v2, they show marked increase in number of bytes:
|
🐛 Bug
Our stackless bytecode optimization pipeline is geared towards optimizing the stackless bytecode (i.e., create fewer stackless bytecode instructions and fewer locals used by the instructions). This may not always result in fewer file-format bytecode: we need to investigate whether this is inevitable, or whether we can get some assurances about the translation from stackless bytecode to file format bytecode.
To reproduce
Run
aptos-move/aptos-transactional-test-harness/tests/v2-tests/default_int_size.move
with and without the default optimization pipeline, observe the stackless bytecode and file format bytecode generated (usingMVC_LOG=debug
).With optimization, we produce fewer stackless bytecode instructions and fewer locals, but slightly increase the file format bytecode instructions (and decrease locals).
The text was updated successfully, but these errors were encountered: