-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Do not optimize IR without optimized outputs #15162
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --ir-optimized --optimize --debug-info none |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
| pragma solidity *; | ||
|
|
||
| contract C {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| Optimized IR: | ||
| /// @use-src 0:"ir_optimized_with_optimize/input.sol" | ||
| object "C_2" { | ||
| code { | ||
| { | ||
| let _1 := memoryguard(0x80) | ||
| mstore(64, _1) | ||
| if callvalue() { revert(0, 0) } | ||
| let _2 := datasize("C_2_deployed") | ||
| codecopy(_1, dataoffset("C_2_deployed"), _2) | ||
| return(_1, _2) | ||
| } | ||
| } | ||
| /// @use-src 0:"ir_optimized_with_optimize/input.sol" | ||
| object "C_2_deployed" { | ||
| code { { revert(0, 0) } } | ||
| data ".metadata" hex"<BYTECODE REMOVED>" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --ir --optimize --debug-info none | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I have another one with
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. Only for this case though because I don't think such a test is overly useful. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
| pragma solidity *; | ||
|
|
||
| contract C {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| IR: | ||
|
|
||
| /// @use-src 0:"ir_unoptimized_with_optimize/input.sol" | ||
| object "C_2" { | ||
| code { | ||
|
|
||
| mstore(64, memoryguard(128)) | ||
| if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } | ||
|
|
||
| constructor_C_2() | ||
|
|
||
| let _1 := allocate_unbounded() | ||
| codecopy(_1, dataoffset("C_2_deployed"), datasize("C_2_deployed")) | ||
|
|
||
| return(_1, datasize("C_2_deployed")) | ||
|
|
||
| function allocate_unbounded() -> memPtr { | ||
| memPtr := mload(64) | ||
| } | ||
|
|
||
| function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { | ||
| revert(0, 0) | ||
| } | ||
|
|
||
| function constructor_C_2() { | ||
|
|
||
| } | ||
|
|
||
| } | ||
| /// @use-src 0:"ir_unoptimized_with_optimize/input.sol" | ||
| object "C_2_deployed" { | ||
| code { | ||
|
|
||
| mstore(64, memoryguard(128)) | ||
|
|
||
| revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() | ||
|
|
||
| function shift_right_224_unsigned(value) -> newValue { | ||
| newValue := | ||
|
|
||
| shr(224, value) | ||
|
|
||
| } | ||
|
|
||
| function allocate_unbounded() -> memPtr { | ||
| memPtr := mload(64) | ||
| } | ||
|
|
||
| function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { | ||
| revert(0, 0) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| data ".metadata" hex"<BYTECODE REMOVED>" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| --ir --optimize --via-ir --debug-info none |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| // SPDX-License-Identifier: GPL-3.0 | ||
| pragma solidity *; | ||
|
|
||
| contract C {} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| IR: | ||
|
|
||
| /// @use-src 0:"ir_unoptimized_with_optimize_via_ir/input.sol" | ||
| object "C_2" { | ||
| code { | ||
|
|
||
| mstore(64, memoryguard(128)) | ||
| if callvalue() { revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() } | ||
|
|
||
| constructor_C_2() | ||
|
|
||
| let _1 := allocate_unbounded() | ||
| codecopy(_1, dataoffset("C_2_deployed"), datasize("C_2_deployed")) | ||
|
|
||
| return(_1, datasize("C_2_deployed")) | ||
|
|
||
| function allocate_unbounded() -> memPtr { | ||
| memPtr := mload(64) | ||
| } | ||
|
|
||
| function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { | ||
| revert(0, 0) | ||
| } | ||
|
|
||
| function constructor_C_2() { | ||
|
|
||
| } | ||
|
|
||
| } | ||
| /// @use-src 0:"ir_unoptimized_with_optimize_via_ir/input.sol" | ||
| object "C_2_deployed" { | ||
| code { | ||
|
|
||
| mstore(64, memoryguard(128)) | ||
|
|
||
| revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() | ||
|
|
||
| function shift_right_224_unsigned(value) -> newValue { | ||
| newValue := | ||
|
|
||
| shr(224, value) | ||
|
|
||
| } | ||
|
|
||
| function allocate_unbounded() -> memPtr { | ||
| memPtr := mload(64) | ||
| } | ||
|
|
||
| function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { | ||
| revert(0, 0) | ||
| } | ||
|
|
||
| } | ||
|
|
||
| data ".metadata" hex"<BYTECODE REMOVED>" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "language": "Solidity", | ||
| "sources": { | ||
| "C.sol": {"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity *; contract C {}"} | ||
| }, | ||
| "settings": { | ||
| "outputSelection": {"*": {"*": ["ir"]}}, | ||
| "optimizer": {"enabled": true}, | ||
| "debug": {"debugInfo": []} | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
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.
Note that these tests do not really test much. I added them so that this unintuitive option combination at least gets used, but the change is not really visible in compiler output. We won't detect anything unless it just crashes.
The difference is only visible in execution time. Both of these should now finish almost instantly:
time solc test/benchmarks/chains.sol --ir --optimizetime solc test/benchmarks/chains.sol --ir --optimize --via-ir