Make hardcoded parts of the optimizer sequence configurable

This commit is contained in:
Nikola Matic
2022-09-12 10:57:36 +02:00
parent f808855329
commit f6f0d6a360
55 changed files with 461 additions and 6 deletions
@@ -0,0 +1 @@
--pretty-json --json-indent 4
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {
function f() public pure {}
}
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_invalid_nested_delimiter/in.sol"]}
},
"settings": {
"optimizer": {
"details": {
"yul": true,
"yulDetails": {
"optimizerSteps": "dhfoDgvulfnTUtnIf\n[ xar:rscLM\n]\njmuljuljul VcTOcul jmul"
}
}
}
}
}
@@ -0,0 +1,12 @@
{
"errors":
[
{
"component": "general",
"formattedMessage": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Cleanup delimiter may only be placed at nesting level zero",
"message": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Cleanup delimiter may only be placed at nesting level zero",
"severity": "error",
"type": "JSONError"
}
]
}
@@ -0,0 +1 @@
--pretty-json --json-indent 4
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {
function f() public pure {}
}
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_mutliple_delimiters/in.sol"]}
},
"settings": {
"optimizer": {
"details": {
"yul": true,
"yulDetails": {
"optimizerSteps": "dhfoDgvu:lfnTUtnIf\n[ xarrscLM\n]\njmuljulj:ul VcTOcul jmul"
}
}
}
}
}
@@ -0,0 +1,12 @@
{
"errors":
[
{
"component": "general",
"formattedMessage": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Too many colon delimiters",
"message": "Invalid optimizer step sequence in \"settings.optimizer.details.optimizerSteps\": Too many colon delimiters",
"severity": "error",
"type": "JSONError"
}
]
}
@@ -0,0 +1 @@
--pretty-json --json-indent 4
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {
function f() public pure {}
}
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_with_cleanup_sequence/in.sol"]}
},
"settings": {
"optimizer": {
"details": {
"yul": true,
"yulDetails": {
"optimizerSteps": "dhfoDgvulfnTUtnIf\n[ xarrscLM\n]\njmuljuljul VcTOcul jmul:fDnTOc"
}
}
}
}
}
@@ -0,0 +1,9 @@
{
"sources":
{
"A":
{
"id": 0
}
}
}
@@ -0,0 +1 @@
--pretty-json --json-indent 4
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {
function f() public pure {}
}
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_with_cleanup_sequence/in.sol"]}
},
"settings": {
"optimizer": {
"details": {
"yul": true,
"yulDetails": {
"optimizerSteps": "dhfoDgvulfnTUtnIf\n[ xarrscLM\n]\njmuljuljul VcTOcul jmul:"
}
}
}
}
}
@@ -0,0 +1,9 @@
{
"sources":
{
"A":
{
"id": 0
}
}
}
@@ -0,0 +1 @@
--pretty-json --json-indent 4
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {
function f() public pure {}
}
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_with_cleanup_sequence/in.sol"]}
},
"settings": {
"optimizer": {
"details": {
"yul": true,
"yulDetails": {
"optimizerSteps": ":dhfoDgvulfnTUtnIf\n[ xarrscLM\n]\njmuljuljul VcTOcul jmul"
}
}
}
}
}
@@ -0,0 +1,9 @@
{
"sources":
{
"A":
{
"id": 0
}
}
}
@@ -0,0 +1 @@
--pretty-json --json-indent 4
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C {
function f() public pure {}
}
@@ -0,0 +1,16 @@
{
"language": "Solidity",
"sources": {
"A": {"urls": ["standard_optimizer_yulDetails_optimiserSteps_with_cleanup_sequence/in.sol"]}
},
"settings": {
"optimizer": {
"details": {
"yul": true,
"yulDetails": {
"optimizerSteps": ":"
}
}
}
}
}
@@ -0,0 +1,9 @@
{
"sources":
{
"A":
{
"id": 0
}
}
}
@@ -0,0 +1 @@
--ir-optimized --optimize --yul-optimizations dhfo[Dg:vu]lfnTUtnIf
@@ -0,0 +1 @@
Invalid optimizer step sequence in --yul-optimizations: Cleanup delimiter may only be placed at nesting level zero
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C
{
function f() public pure {}
}
@@ -0,0 +1 @@
--ir-optimized --optimize --yul-optimizations dhfoDg:vulfn:TUtnIf
@@ -0,0 +1 @@
Invalid optimizer step sequence in --yul-optimizations: Too many colon delimiters
@@ -0,0 +1 @@
1
@@ -0,0 +1,7 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C
{
function f() public pure {}
}
@@ -0,0 +1 @@
--ir-optimized --optimize --yul-optimizations iDu
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
pragma abicoder v2;
contract C {
constructor() payable {
assembly ("memory-safe") {
let a := 0
revert(0, a)
}
}
}
@@ -0,0 +1,24 @@
Optimized IR:
/// @use-src 0:"yul_optimizer_steps_short_sequence/input.sol"
object "C_8" {
code {
{
/// @src 0:80:221 "contract C {..."
mstore(64, memoryguard(0x80))
/// @src 0:129:213 "assembly (\"memory-safe\") {..."
let usr$a := 0
revert(usr$a, usr$a)
}
}
/// @use-src 0:"yul_optimizer_steps_short_sequence/input.sol"
object "C_8_deployed" {
code {
{
/// @src 0:80:221 "contract C {..."
mstore(64, memoryguard(0x80))
revert(0, 0)
}
}
data ".metadata" hex"<BYTECODE REMOVED>"
}
}
@@ -0,0 +1 @@
--ir-optimized --optimize --yul-optimizations dhfoDgvulfnTUtnIf:fDnTOc
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
pragma abicoder v2;
contract C
{
constructor() {}
}
@@ -0,0 +1,34 @@
Optimized IR:
/// @use-src 0:"yul_optimizer_steps_with_cleanup_sequence/input.sol"
object "C_7" {
code {
{
/// @src 0:80:115 "contract C..."
mstore(64, memoryguard(0x80))
if callvalue()
{
revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb()
}
let _1 := allocate_unbounded()
codecopy(_1, dataoffset("C_7_deployed"), datasize("C_7_deployed"))
return(_1, datasize("C_7_deployed"))
}
function allocate_unbounded() -> memPtr
{ memPtr := mload(64) }
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb()
{ revert(0, 0) }
}
/// @use-src 0:"yul_optimizer_steps_with_cleanup_sequence/input.sol"
object "C_7_deployed" {
code {
{
/// @src 0:80:115 "contract C..."
mstore(64, memoryguard(0x80))
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
}
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
{ revert(0, 0) }
}
data ".metadata" hex"<BYTECODE REMOVED>"
}
}
@@ -0,0 +1 @@
--ir-optimized --optimize --yul-optimizations iDu:
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
pragma abicoder v2;
contract C {
constructor() payable {
assembly ("memory-safe") {
let a := 0
revert(0, a)
}
}
}
@@ -0,0 +1,24 @@
Optimized IR:
/// @use-src 0:"yul_optimizer_steps_with_empty_cleanup_sequence/input.sol"
object "C_8" {
code {
{
/// @src 0:80:221 "contract C {..."
mstore(64, memoryguard(0x80))
/// @src 0:129:213 "assembly (\"memory-safe\") {..."
let usr$a := 0
revert(0, usr$a)
}
}
/// @use-src 0:"yul_optimizer_steps_with_empty_cleanup_sequence/input.sol"
object "C_8_deployed" {
code {
{
/// @src 0:80:221 "contract C {..."
mstore(64, memoryguard(0x80))
revert(0, 0)
}
}
data ".metadata" hex"<BYTECODE REMOVED>"
}
}
@@ -0,0 +1 @@
--ir-optimized --optimize --yul-optimizations :iDu
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
pragma abicoder v2;
contract C {
constructor() payable {
assembly ("memory-safe") {
let a := 0
revert(0, a)
}
}
}
@@ -0,0 +1,24 @@
Optimized IR:
/// @use-src 0:"yul_optimizer_steps_with_empty_optimization_sequence/input.sol"
object "C_8" {
code {
{
/// @src 0:80:221 "contract C {..."
mstore(64, memoryguard(0x80))
/// @src 0:129:213 "assembly (\"memory-safe\") {..."
let usr$a := 0
revert(0, usr$a)
}
}
/// @use-src 0:"yul_optimizer_steps_with_empty_optimization_sequence/input.sol"
object "C_8_deployed" {
code {
{
/// @src 0:80:221 "contract C {..."
mstore(64, memoryguard(0x80))
revert(0, 0)
}
}
data ".metadata" hex"<BYTECODE REMOVED>"
}
}
@@ -0,0 +1 @@
--ir-optimized --optimize --yul-optimizations :
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
pragma abicoder v2;
contract C
{
constructor() {}
}
@@ -0,0 +1,42 @@
Optimized IR:
/// @use-src 0:"yul_optimizer_steps_with_empty_sequences/input.sol"
object "C_7" {
code {
{
/// @src 0:80:115 "contract C..."
mstore(64, memoryguard(0x80))
if callvalue()
{
revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb()
}
constructor_C()
let _1 := allocate_unbounded()
codecopy(_1, dataoffset("C_7_deployed"), datasize("C_7_deployed"))
return(_1, datasize("C_7_deployed"))
}
function allocate_unbounded() -> memPtr
{ memPtr := mload(64) }
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb()
{ revert(0, 0) }
/// @ast-id 6 @src 0:97:113 "constructor() {}"
function constructor_C()
{ }
}
/// @use-src 0:"yul_optimizer_steps_with_empty_sequences/input.sol"
object "C_7_deployed" {
code {
{
/// @src 0:80:115 "contract C..."
mstore(64, memoryguard(0x80))
revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
}
function shift_right_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>"
}
}
+1
View File
@@ -339,6 +339,7 @@ YulOptimizerTestCommon::YulOptimizerTestCommon(
*m_object,
true,
frontend::OptimiserSettings::DefaultYulOptimiserSteps,
frontend::OptimiserSettings::DefaultYulOptimiserCleanupSteps,
frontend::OptimiserSettings::standard().expectedExecutionsPerDeployment
);
}},