From 7ab730d410e31ba5015551a0b9e5b67fa89b48e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Tue, 16 May 2023 11:05:09 +0200 Subject: [PATCH] Update tests that would become ineffective with minimal optimizations applied --- .../standard_yul_debug_info_print_all/in.yul | 1 + .../standard_yul_debug_info_print_all/output.json | 1 + .../in.yul | 1 + .../output.json | 1 + .../standard_yul_debug_info_print_none/in.yul | 1 + .../standard_yul_debug_info_print_none/output.json | 1 + .../in.yul | 1 + .../strict_asm_debug_info_print_all/input.yul | 1 + .../strict_asm_debug_info_print_all/output | 5 +++-- .../input.yul | 1 + .../output | 5 +++-- .../strict_asm_debug_info_print_none/input.yul | 1 + .../strict_asm_debug_info_print_none/output | 5 +++-- .../input.yul | 1 + test/libyul/objectCompiler/function_series.yul | 14 +++++++++++--- test/libyul/objectCompiler/jump_tags.yul | 14 +++++++++++--- 16 files changed, 42 insertions(+), 12 deletions(-) diff --git a/test/cmdlineTests/standard_yul_debug_info_print_all/in.yul b/test/cmdlineTests/standard_yul_debug_info_print_all/in.yul index 6d1ebe21b..aa564d00c 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_all/in.yul +++ b/test/cmdlineTests/standard_yul_debug_info_print_all/in.yul @@ -9,6 +9,7 @@ object "C_6_deployed" { /// @src 0:77:99 "function f() public {}" function fun_f_5() { + sstore(0, 42) } /// @src 0:60:101 "contract C {..." } diff --git a/test/cmdlineTests/standard_yul_debug_info_print_all/output.json b/test/cmdlineTests/standard_yul_debug_info_print_all/output.json index 78f14c08d..0c78efb80 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_all/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_print_all/output.json @@ -16,6 +16,7 @@ tag_2: /* \"input.sol\":77:99 */ jump(tag_3) tag_1: + sstore(0x00, 0x2a) jump\t// out tag_3: " diff --git a/test/cmdlineTests/standard_yul_debug_info_print_location_only/in.yul b/test/cmdlineTests/standard_yul_debug_info_print_location_only/in.yul index 6d1ebe21b..aa564d00c 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_location_only/in.yul +++ b/test/cmdlineTests/standard_yul_debug_info_print_location_only/in.yul @@ -9,6 +9,7 @@ object "C_6_deployed" { /// @src 0:77:99 "function f() public {}" function fun_f_5() { + sstore(0, 42) } /// @src 0:60:101 "contract C {..." } diff --git a/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json b/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json index 526a6a5c6..53be3d073 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_print_location_only/output.json @@ -16,6 +16,7 @@ tag_2: /* \"input.sol\":77:99 */ jump(tag_3) tag_1: + sstore(0x00, 0x2a) jump\t// out tag_3: " diff --git a/test/cmdlineTests/standard_yul_debug_info_print_none/in.yul b/test/cmdlineTests/standard_yul_debug_info_print_none/in.yul index 6d1ebe21b..aa564d00c 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_none/in.yul +++ b/test/cmdlineTests/standard_yul_debug_info_print_none/in.yul @@ -9,6 +9,7 @@ object "C_6_deployed" { /// @src 0:77:99 "function f() public {}" function fun_f_5() { + sstore(0, 42) } /// @src 0:60:101 "contract C {..." } diff --git a/test/cmdlineTests/standard_yul_debug_info_print_none/output.json b/test/cmdlineTests/standard_yul_debug_info_print_none/output.json index f5b5c6364..ac2a93b0f 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_none/output.json +++ b/test/cmdlineTests/standard_yul_debug_info_print_none/output.json @@ -14,6 +14,7 @@ tag_2: jump(tag_3) tag_1: + sstore(0x00, 0x2a) jump\t// out tag_3: " diff --git a/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/in.yul b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/in.yul index 6d1ebe21b..aa564d00c 100644 --- a/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/in.yul +++ b/test/cmdlineTests/standard_yul_debug_info_print_snippet_only/in.yul @@ -9,6 +9,7 @@ object "C_6_deployed" { /// @src 0:77:99 "function f() public {}" function fun_f_5() { + sstore(0, 42) } /// @src 0:60:101 "contract C {..." } diff --git a/test/cmdlineTests/strict_asm_debug_info_print_all/input.yul b/test/cmdlineTests/strict_asm_debug_info_print_all/input.yul index 6d1ebe21b..aa564d00c 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_all/input.yul +++ b/test/cmdlineTests/strict_asm_debug_info_print_all/input.yul @@ -9,6 +9,7 @@ object "C_6_deployed" { /// @src 0:77:99 "function f() public {}" function fun_f_5() { + sstore(0, 42) } /// @src 0:60:101 "contract C {..." } diff --git a/test/cmdlineTests/strict_asm_debug_info_print_all/output b/test/cmdlineTests/strict_asm_debug_info_print_all/output index e83614b62..2242e6630 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_all/output +++ b/test/cmdlineTests/strict_asm_debug_info_print_all/output @@ -10,13 +10,13 @@ object "C_6_deployed" { fun_f_5() /// @src 0:77:99 function fun_f_5() - { } + { sstore(0, 42) } } } Binary representation: -6080604052600a600e565b6010565b565b +6080604052600a600e565b6014565b602a5f55565b Text representation: /* "input.sol":60:101 */ @@ -28,5 +28,6 @@ tag_2: /* "input.sol":77:99 */ jump(tag_3) tag_1: + sstore(0x00, 0x2a) jump // out tag_3: diff --git a/test/cmdlineTests/strict_asm_debug_info_print_location_only/input.yul b/test/cmdlineTests/strict_asm_debug_info_print_location_only/input.yul index 6d1ebe21b..aa564d00c 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_location_only/input.yul +++ b/test/cmdlineTests/strict_asm_debug_info_print_location_only/input.yul @@ -9,6 +9,7 @@ object "C_6_deployed" { /// @src 0:77:99 "function f() public {}" function fun_f_5() { + sstore(0, 42) } /// @src 0:60:101 "contract C {..." } diff --git a/test/cmdlineTests/strict_asm_debug_info_print_location_only/output b/test/cmdlineTests/strict_asm_debug_info_print_location_only/output index a4fd0e494..c5de7c439 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_location_only/output +++ b/test/cmdlineTests/strict_asm_debug_info_print_location_only/output @@ -10,13 +10,13 @@ object "C_6_deployed" { fun_f_5() /// @src 0:77:99 function fun_f_5() - { } + { sstore(0, 42) } } } Binary representation: -6080604052600a600e565b6010565b565b +6080604052600a600e565b6014565b602a5f55565b Text representation: /* "input.sol":60:101 */ @@ -28,5 +28,6 @@ tag_2: /* "input.sol":77:99 */ jump(tag_3) tag_1: + sstore(0x00, 0x2a) jump // out tag_3: diff --git a/test/cmdlineTests/strict_asm_debug_info_print_none/input.yul b/test/cmdlineTests/strict_asm_debug_info_print_none/input.yul index 6d1ebe21b..aa564d00c 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_none/input.yul +++ b/test/cmdlineTests/strict_asm_debug_info_print_none/input.yul @@ -9,6 +9,7 @@ object "C_6_deployed" { /// @src 0:77:99 "function f() public {}" function fun_f_5() { + sstore(0, 42) } /// @src 0:60:101 "contract C {..." } diff --git a/test/cmdlineTests/strict_asm_debug_info_print_none/output b/test/cmdlineTests/strict_asm_debug_info_print_none/output index fc8841c9a..3db44c1f5 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_none/output +++ b/test/cmdlineTests/strict_asm_debug_info_print_none/output @@ -8,13 +8,13 @@ object "C_6_deployed" { mstore(64, 128) fun_f_5() function fun_f_5() - { } + { sstore(0, 42) } } } Binary representation: -6080604052600a600e565b6010565b565b +6080604052600a600e565b6014565b602a5f55565b Text representation: mstore(0x40, 0x80) @@ -24,5 +24,6 @@ Text representation: tag_2: jump(tag_3) tag_1: + sstore(0x00, 0x2a) jump // out tag_3: diff --git a/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/input.yul b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/input.yul index 6d1ebe21b..aa564d00c 100644 --- a/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/input.yul +++ b/test/cmdlineTests/strict_asm_debug_info_print_snippet_only/input.yul @@ -9,6 +9,7 @@ object "C_6_deployed" { /// @src 0:77:99 "function f() public {}" function fun_f_5() { + sstore(0, 42) } /// @src 0:60:101 "contract C {..." } diff --git a/test/libyul/objectCompiler/function_series.yul b/test/libyul/objectCompiler/function_series.yul index 10a018160..7be2db96b 100644 --- a/test/libyul/objectCompiler/function_series.yul +++ b/test/libyul/objectCompiler/function_series.yul @@ -3,6 +3,10 @@ object "Contract" { function f() {} function g() {} sstore(0, 1) + + // NOTE: msize forces the compiler to completely disable the Yul optimizer. + // Otherwise the functions would get optimized out. + pop(msize()) } } @@ -26,6 +30,10 @@ object "Contract" { // 0x00 // /* "source":73:85 */ // sstore -// Bytecode: 6009565b5b565b5b565b60015f55 -// Opcodes: PUSH1 0x9 JUMP JUMPDEST JUMPDEST JUMP JUMPDEST JUMPDEST JUMP JUMPDEST PUSH1 0x1 PUSH0 SSTORE -// SourceMappings: 33:15:0:-:0;;;;:::o;53:::-;;:::o;:::-;83:1;80;73:12 +// /* "source":231:238 */ +// msize +// /* "source":227:239 */ +// pop +// Bytecode: 6009565b5b565b5b565b60015f555950 +// Opcodes: PUSH1 0x9 JUMP JUMPDEST JUMPDEST JUMP JUMPDEST JUMPDEST JUMP JUMPDEST PUSH1 0x1 PUSH0 SSTORE MSIZE POP +// SourceMappings: 33:15:0:-:0;;;;:::o;53:::-;;:::o;:::-;83:1;80;73:12;231:7;227:12 diff --git a/test/libyul/objectCompiler/jump_tags.yul b/test/libyul/objectCompiler/jump_tags.yul index ba0984b10..0d1f1ff79 100644 --- a/test/libyul/objectCompiler/jump_tags.yul +++ b/test/libyul/objectCompiler/jump_tags.yul @@ -3,6 +3,10 @@ object "Contract" { function f() { g(1) } function g(x) { if x { leave } g(add(x, 2)) } g(1) + + // NOTE: msize forces the compiler to completely disable the Yul optimizer. + // Otherwise f() would get optimized out. + pop(msize()) } } @@ -62,6 +66,10 @@ object "Contract" { // tag_2 // jump // in // tag_9: -// Bytecode: 6026565b600b6001600e565b5b565b8015601857506024565b602260028201600e565b505b565b602e6001600e565b -// Opcodes: PUSH1 0x26 JUMP JUMPDEST PUSH1 0xB PUSH1 0x1 PUSH1 0xE JUMP JUMPDEST JUMPDEST JUMP JUMPDEST DUP1 ISZERO PUSH1 0x18 JUMPI POP PUSH1 0x24 JUMP JUMPDEST PUSH1 0x22 PUSH1 0x2 DUP3 ADD PUSH1 0xE JUMP JUMPDEST POP JUMPDEST JUMP JUMPDEST PUSH1 0x2E PUSH1 0x1 PUSH1 0xE JUMP JUMPDEST -// SourceMappings: 33:21:0:-:0;;;48:4;50:1;48:4;:::i;:::-;33:21;:::o;59:45::-;78:1;75:14;;;82:5;;;75:14;90:12;99:1;96;92:9;90:12;:::i;:::-;59:45;;:::o;:::-;109:4;111:1;109:4;:::i;:::- +// /* "source":249:256 */ +// msize +// /* "source":245:257 */ +// pop +// Bytecode: 6026565b600b6001600e565b5b565b8015601857506024565b602260028201600e565b505b565b602e6001600e565b5950 +// Opcodes: PUSH1 0x26 JUMP JUMPDEST PUSH1 0xB PUSH1 0x1 PUSH1 0xE JUMP JUMPDEST JUMPDEST JUMP JUMPDEST DUP1 ISZERO PUSH1 0x18 JUMPI POP PUSH1 0x24 JUMP JUMPDEST PUSH1 0x22 PUSH1 0x2 DUP3 ADD PUSH1 0xE JUMP JUMPDEST POP JUMPDEST JUMP JUMPDEST PUSH1 0x2E PUSH1 0x1 PUSH1 0xE JUMP JUMPDEST MSIZE POP +// SourceMappings: 33:21:0:-:0;;;48:4;50:1;48:4;:::i;:::-;33:21;:::o;59:45::-;78:1;75:14;;;82:5;;;75:14;90:12;99:1;96;92:9;90:12;:::i;:::-;59:45;;:::o;:::-;109:4;111:1;109:4;:::i;:::-;249:7;245:12