Skip to content

Commit

Permalink
Merge pull request #15639 from ethereum/yul_evm_current_version
Browse files Browse the repository at this point in the history
Add Yul EVM version "current"
  • Loading branch information
clonker authored Dec 16, 2024
2 parents 03e2739 + 2064442 commit 10fbfca
Show file tree
Hide file tree
Showing 48 changed files with 53 additions and 4 deletions.
6 changes: 5 additions & 1 deletion test/TestCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ void EVMVersionRestrictedTestCase::processEVMVersionSetting()
break;

versionString = versionString.substr(versionBegin);
std::optional<langutil::EVMVersion> version = langutil::EVMVersion::fromString(versionString);
std::optional<langutil::EVMVersion> version;
if (versionString == "current")
version = std::make_optional<langutil::EVMVersion>();
else
version = langutil::EVMVersion::fromString(versionString);
if (!version)
BOOST_THROW_EXCEPTION(std::runtime_error{"Invalid EVM version: \"" + versionString + "\""});

Expand Down
5 changes: 2 additions & 3 deletions test/libyul/EVMCodeTransformTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ EVMCodeTransformTest::EVMCodeTransformTest(std::string const& _filename):
m_source = m_reader.source();
m_stackOpt = m_reader.boolSetting("stackOptimization", false);
m_expectation = m_reader.simpleExpectations();
m_shouldRun = CommonOptions::get().evmDialect().evmVersion() == EVMVersion{};
}

TestCase::TestResult EVMCodeTransformTest::run(std::ostream& _stream, std::string const& _linePrefix, bool const _formatted)
Expand All @@ -57,8 +56,8 @@ TestCase::TestResult EVMCodeTransformTest::run(std::ostream& _stream, std::strin
// Restrict to a single EVM/EOF version combination (the default one) as code generation
// can be different from version to version.
YulStack stack(
EVMVersion{},
std::nullopt,
CommonOptions::get().evmVersion(),
CommonOptions::get().eofVersion(),
YulStack::Language::StrictAssembly,
settings,
DebugInfoSelection::All()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":17:18 */
// 0x02
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/early_push_on_deep_swap.yul
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":1027:1092 */
// 0x0100000000000000000000000000000000000000000000000000000000000001
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/literal_loop.yul
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ object "main" {
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":62:82 */
// dataSize(sub_0)
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/nonempty_initial_layout.yul
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":9:69 */
// 0x2000000000000000000000000000000000000000000000000000000000
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/pops_in_reverting_branch.yul
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object "main" {
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":51:52 */
// 0x00
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stackReuse/for_1.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ for { let z := 0 } 1 { } { let x := 3 } let t := 2 }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":17:18 */
// 0x00
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stackReuse/for_2.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ for { let z := 0 } 1 { } { z := 8 let x := 3 } let t := 2 }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":17:18 */
// 0x00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:88 */
// stop
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stackReuse/function_call.yul
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":15:22 */
// tag_2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:662 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:28 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":210:252 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:80 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:32 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:65 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:65 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:78 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:70 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:67 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:74 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:46 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:52 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:22 */
// stop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":15:16 */
// 0x03
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":74:81 */
// tag_3
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stackReuse/if.yul
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{ let z := mload(0) if z { let x := z } let t := 3 }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":72:73 */
// 0x00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let z := 0 { pop(z) } let x := 1 }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":11:12 */
// 0x00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let z := mload(0) { let x := 1 x := 6 z := x } { let x := 2 z := x x := 4 } }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":17:18 */
// 0x00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let x := 1 x := 6 let y := 2 y := 4 }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":11:12 */
// 0x01
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let x := 1 x := 6 { let y := 2 y := 4 } }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":11:12 */
// 0x01
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":15:16 */
// 0x05
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":15:16 */
// 0x05
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":37:38 */
// 0x02
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":15:16 */
// 0x05
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stackReuse/reuse_slots.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let a, b, c, d let x := 2 let y := 3 mstore(x, a) mstore(y, c) }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":2:16 */
// 0x00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":58:61 */
// tag_2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":106:107 */
// 0x05
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":15:16 */
// 0x07
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stackReuse/single_var.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let x }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":2:7 */
// 0x00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let x := 1 }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":11:12 */
// 0x01
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let x := 1 mstore(3, 4) }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":11:12 */
// 0x01
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let x := 1 mstore(3, 4) pop(mload(x)) }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":11:12 */
// 0x01
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stackReuse/smoke.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:2 */
// stop
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stackReuse/switch.yul
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{ let z := 0 switch z case 0 { let x := 2 let y := 3 } default { z := 3 } let t := 9 }
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":11:12 */
// 0x00
Expand Down
1 change: 1 addition & 0 deletions test/libyul/evmCodeTransform/stub.yul
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":14:21 */
// tag_2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
}
// ====
// stackOptimization: true
// EVMVersion: =current
// ----
// /* "":0:111 */
// stop
Expand Down

0 comments on commit 10fbfca

Please sign in to comment.