Merge pull request #8508 from a3d4/again-refactor-testcase-classes

More refactoring of TestCase classes
This commit is contained in:
chriseth 2020-03-19 23:05:32 +01:00 committed by GitHub
commit d55bbd4aa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
420 changed files with 847 additions and 838 deletions

View File

@ -28,7 +28,7 @@ using namespace solidity;
using namespace solidity::frontend; using namespace solidity::frontend;
using namespace solidity::frontend::test; using namespace solidity::frontend::test;
void TestCase::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool) void TestCase::printSettings(ostream& _stream, const string& _linePrefix, const bool)
{ {
auto& settings = m_reader.settings(); auto& settings = m_reader.settings();
if (settings.empty()) if (settings.empty())
@ -63,11 +63,10 @@ void TestCase::expect(string::iterator& _it, string::iterator _end, string::valu
EVMVersionRestrictedTestCase::EVMVersionRestrictedTestCase(string const& _filename): EVMVersionRestrictedTestCase::EVMVersionRestrictedTestCase(string const& _filename):
TestCase(_filename) TestCase(_filename)
{ {
if (!m_reader.hasSetting("EVMVersion")) string versionString = m_reader.stringSetting("EVMVersion", "any");
if (versionString == "any")
return; return;
string versionString = m_reader.stringSetting("EVMVersion", "");
string comparator; string comparator;
size_t versionBegin = 0; size_t versionBegin = 0;
for (auto character: versionString) for (auto character: versionString)

View File

@ -57,8 +57,8 @@ public:
/// If @arg _formatted is true, color-coding may be used to indicate /// If @arg _formatted is true, color-coding may be used to indicate
/// error locations in the contract, if applicable. /// error locations in the contract, if applicable.
virtual void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) const = 0; virtual void printSource(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) const = 0;
/// Outputs the updated settings. /// Outputs settings.
virtual void printUpdatedSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false); virtual void printSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false);
/// Outputs test expectations to @arg _stream that match the actual results of the test. /// Outputs test expectations to @arg _stream that match the actual results of the test.
/// Each line of output is prefixed with @arg _linePrefix. /// Each line of output is prefixed with @arg _linePrefix.
virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const = 0; virtual void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const = 0;

View File

@ -49,14 +49,9 @@ string TestCaseReader::simpleExpectations()
return parseSimpleExpectations(m_file); return parseSimpleExpectations(m_file);
} }
bool TestCaseReader::hasSetting(std::string const& _name) const
{
return m_settings.count(_name) != 0;
}
bool TestCaseReader::boolSetting(std::string const& _name, bool _defaultValue) bool TestCaseReader::boolSetting(std::string const& _name, bool _defaultValue)
{ {
if (!hasSetting(_name)) if (m_settings.count(_name) == 0)
return _defaultValue; return _defaultValue;
m_unreadSettings.erase(_name); m_unreadSettings.erase(_name);
@ -71,7 +66,7 @@ bool TestCaseReader::boolSetting(std::string const& _name, bool _defaultValue)
size_t TestCaseReader::sizetSetting(std::string const& _name, size_t _defaultValue) size_t TestCaseReader::sizetSetting(std::string const& _name, size_t _defaultValue)
{ {
if (!hasSetting(_name)) if (m_settings.count(_name) == 0)
return _defaultValue; return _defaultValue;
m_unreadSettings.erase(_name); m_unreadSettings.erase(_name);
@ -82,18 +77,13 @@ size_t TestCaseReader::sizetSetting(std::string const& _name, size_t _defaultVal
string TestCaseReader::stringSetting(string const& _name, string const& _defaultValue) string TestCaseReader::stringSetting(string const& _name, string const& _defaultValue)
{ {
if (!hasSetting(_name)) if (m_settings.count(_name) == 0)
return _defaultValue; return _defaultValue;
m_unreadSettings.erase(_name); m_unreadSettings.erase(_name);
return m_settings.at(_name); return m_settings.at(_name);
} }
void TestCaseReader::setSetting(std::string const& _name, std::string const& _value)
{
m_settings[_name] = _value;
}
void TestCaseReader::ensureAllSettingsRead() const void TestCaseReader::ensureAllSettingsRead() const
{ {
if (!m_unreadSettings.empty()) if (!m_unreadSettings.empty())

View File

@ -40,11 +40,9 @@ public:
std::string simpleExpectations(); std::string simpleExpectations();
bool hasSetting(std::string const& _name) const;
bool boolSetting(std::string const& _name, bool _defaultValue); bool boolSetting(std::string const& _name, bool _defaultValue);
size_t sizetSetting(std::string const& _name, size_t _defaultValue); size_t sizetSetting(std::string const& _name, size_t _defaultValue);
std::string stringSetting(std::string const& _name, std::string const& _defaultValue); std::string stringSetting(std::string const& _name, std::string const& _defaultValue);
void setSetting(std::string const& _name, std::string const& _value);
void ensureAllSettingsRead() const; void ensureAllSettingsRead() const;

View File

@ -43,21 +43,24 @@ SemanticTest::SemanticTest(string const& _filename, langutil::EVMVersion _evmVer
m_source = m_reader.source(); m_source = m_reader.source();
m_lineOffset = m_reader.lineNumber(); m_lineOffset = m_reader.lineNumber();
if (m_reader.hasSetting("compileViaYul")) string choice = m_reader.stringSetting("compileViaYul", "false");
if (choice == "also")
{ {
string choice = m_reader.stringSetting("compileViaYul", ""); m_runWithYul = true;
if (choice == "also") m_runWithoutYul = true;
{
m_runWithYul = true;
m_runWithoutYul = true;
}
else
{
m_reader.setSetting("compileViaYul", "only");
m_runWithYul = true;
m_runWithoutYul = false;
}
} }
else if (choice == "true")
{
m_runWithYul = true;
m_runWithoutYul = false;
}
else if (choice == "false")
{
m_runWithYul = false;
m_runWithoutYul = true;
}
else
BOOST_THROW_EXCEPTION(runtime_error("Invalid compileViaYul value: " + choice + "."));
m_runWithABIEncoderV1Only = m_reader.boolSetting("ABIEncoderV1Only", false); m_runWithABIEncoderV1Only = m_reader.boolSetting("ABIEncoderV1Only", false);
if (m_runWithABIEncoderV1Only && solidity::test::CommonOptions::get().useABIEncoderV2) if (m_runWithABIEncoderV1Only && solidity::test::CommonOptions::get().useABIEncoderV2)

View File

@ -7,7 +7,7 @@ contract C {
} }
} }
// ==== // ====
// compileViaYul: only // compileViaYul: true
// ---- // ----
// f(uint256,uint256): 10, 3 -> 1 // f(uint256,uint256): 10, 3 -> 1
// f(uint256,uint256): 10, 2 -> 0 // f(uint256,uint256): 10, 2 -> 0

View File

@ -7,7 +7,7 @@ contract C {
} }
} }
// ==== // ====
// compileViaYul: only // compileViaYul: true
// ---- // ----
// f(int256,int256): 10, 3 -> 1 // f(int256,int256): 10, 3 -> 1
// f(int256,int256): 10, 2 -> 0 // f(int256,int256): 10, 2 -> 0

View File

@ -8,7 +8,7 @@ contract C {
} }
} }
// ==== // ====
// compileViaYul: only // compileViaYul: true
// ---- // ----
// keccak1() -> 0x64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107 // keccak1() -> 0x64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107
// keccak2() -> 0x64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107 // keccak2() -> 0x64e604787cbf194841e7b68d7cd28786f6c9a0a3ab9f8b0a0e87cb4387ab0107

View File

@ -5,7 +5,7 @@ contract C {
function h() external pure returns (bytes4) { return 0xcafecafe; } function h() external pure returns (bytes4) { return 0xcafecafe; }
} }
// ==== // ====
// compileViaYul: only // compileViaYul: true
// ---- // ----
// f1() -> 0x20, 6, left(0x616263616263) // f1() -> 0x20, 6, left(0x616263616263)
// f2() -> 32, 47, 44048183223289766195424279195050628400112610419087780792899004030957505095210, 18165586057823232067963737336409268114628061002662705707816940456850361417728 // f2() -> 32, 47, 44048183223289766195424279195050628400112610419087780792899004030957505095210, 18165586057823232067963737336409268114628061002662705707816940456850361417728

View File

@ -103,8 +103,6 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename):
auto dialectName = m_reader.stringSetting("dialect", "evm"); auto dialectName = m_reader.stringSetting("dialect", "evm");
m_dialect = &dialect(dialectName, solidity::test::CommonOptions::get().evmVersion()); m_dialect = &dialect(dialectName, solidity::test::CommonOptions::get().evmVersion());
m_step = m_reader.stringSetting("step", "");
m_expectation = m_reader.simpleExpectations(); m_expectation = m_reader.simpleExpectations();
} }
@ -352,21 +350,8 @@ TestCase::TestResult YulOptimizerTest::run(ostream& _stream, string const& _line
return TestResult::FatalError; return TestResult::FatalError;
} }
m_obtainedResult = AsmPrinter{*m_dialect}(*m_ast) + "\n"; m_obtainedResult = "step: " + m_optimizerStep + "\n\n" + AsmPrinter{ *m_dialect }(*m_ast) + "\n";
if (m_optimizerStep != m_step)
{
string nextIndentLevel = _linePrefix + " ";
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) <<
_linePrefix <<
"Invalid optimizer step. Given: \"" <<
m_step <<
"\", should be: \"" <<
m_optimizerStep <<
"\"." <<
endl;
return TestResult::FatalError;
}
if (m_expectation != m_obtainedResult) if (m_expectation != m_obtainedResult)
{ {
string nextIndentLevel = _linePrefix + " "; string nextIndentLevel = _linePrefix + " ";
@ -385,13 +370,6 @@ void YulOptimizerTest::printSource(ostream& _stream, string const& _linePrefix,
printIndented(_stream, m_source, _linePrefix); printIndented(_stream, m_source, _linePrefix);
} }
void YulOptimizerTest::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool _formatted)
{
m_step = m_optimizerStep;
m_reader.setSetting("step", m_step);
EVMVersionRestrictedTestCase::printUpdatedSettings(_stream, _linePrefix, _formatted);
}
void YulOptimizerTest::printUpdatedExpectations(ostream& _stream, string const& _linePrefix) const void YulOptimizerTest::printUpdatedExpectations(ostream& _stream, string const& _linePrefix) const
{ {
printIndented(_stream, m_obtainedResult, _linePrefix); printIndented(_stream, m_obtainedResult, _linePrefix);

View File

@ -57,7 +57,6 @@ public:
TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override; TestResult run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override;
void printSource(std::ostream& _stream, std::string const &_linePrefix = "", bool const _formatted = false) const override; void printSource(std::ostream& _stream, std::string const &_linePrefix = "", bool const _formatted = false) const override;
void printUpdatedSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) override;
void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override; void printUpdatedExpectations(std::ostream& _stream, std::string const& _linePrefix) const override;
private: private:
@ -73,7 +72,6 @@ private:
std::string m_expectation; std::string m_expectation;
Dialect const* m_dialect = nullptr; Dialect const* m_dialect = nullptr;
std::string m_step;
std::set<YulString> m_reservedIdentifiers; std::set<YulString> m_reservedIdentifiers;
std::unique_ptr<NameDispenser> m_nameDispenser; std::unique_ptr<NameDispenser> m_nameDispenser;
std::unique_ptr<OptimiserStepContext> m_context; std::unique_ptr<OptimiserStepContext> m_context;

View File

@ -8,9 +8,9 @@
} }
let z := mload(2) let z := mload(2)
} }
// ====
// step: blockFlattener
// ---- // ----
// step: blockFlattener
//
// { // {
// let _1 := mload(0) // let _1 := mload(0)
// let f_a := mload(1) // let f_a := mload(1)

View File

@ -3,9 +3,9 @@
a := add(a, 1) a := add(a, 1)
} }
} }
// ====
// step: blockFlattener
// ---- // ----
// step: blockFlattener
//
// { // {
// for { let a := 1 } iszero(eq(a, 10)) { a := add(a, 1) } // for { let a := 1 } iszero(eq(a, 10)) { a := add(a, 1) }
// { a := add(a, 1) } // { a := add(a, 1) }

View File

@ -8,9 +8,9 @@
} }
let t := add(3, 9) let t := add(3, 9)
} }
// ====
// step: blockFlattener
// ---- // ----
// step: blockFlattener
//
// { // {
// if add(mload(7), sload(mload(3))) // if add(mload(7), sload(mload(3)))
// { // {

View File

@ -14,9 +14,9 @@
a := add(a, c) a := add(a, c)
} }
} }
// ====
// step: blockFlattener
// ---- // ----
// step: blockFlattener
//
// { // {
// let a := 3 // let a := 3
// let b := 4 // let b := 4

View File

@ -5,9 +5,9 @@
default { a := 3 { a := 4 } } default { a := 3 { a := 4 } }
a := 5 a := 5
} }
// ====
// step: blockFlattener
// ---- // ----
// step: blockFlattener
//
// { // {
// let a := 1 // let a := 1
// switch calldataload(0) // switch calldataload(0)

View File

@ -5,9 +5,9 @@
function h() -> z { z := g() } function h() -> z { z := g() }
a := h() a := h()
} }
// ====
// step: circularReferencesPruner
// ---- // ----
// step: circularReferencesPruner
//
// { // {
// let a // let a
// a := h() // a := h()

View File

@ -8,7 +8,7 @@
function d() -> w { w := c() } function d() -> w { w := c() }
} }
} }
// ====
// step: circularReferencesPruner
// ---- // ----
// step: circularReferencesPruner
//
// { } // { }

View File

@ -8,7 +8,7 @@
function y() -> x { x := z() } function y() -> x { x := z() }
} }
} }
// ====
// step: circularReferencesPruner
// ---- // ----
// step: circularReferencesPruner
//
// { } // { }

View File

@ -2,7 +2,7 @@
function f() -> x { x := g() } function f() -> x { x := g() }
function g() -> x { x := f() } function g() -> x { x := f() }
} }
// ====
// step: circularReferencesPruner
// ---- // ----
// step: circularReferencesPruner
//
// { } // { }

View File

@ -6,9 +6,9 @@
} }
mstore(1, codesize()) mstore(1, codesize())
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let a := 1 // let a := 1
// let b := codesize() // let b := codesize()

View File

@ -3,9 +3,9 @@
if b { b := 1 } if b { b := 1 }
let c := 1 let c := 1
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let b := 1 // let b := 1
// if b { b := b } // if b { b := b }

View File

@ -23,9 +23,9 @@
p_1 := add(array, _22) p_1 := add(array, _22)
} }
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let _13 := 0x20 // let _13 := 0x20
// let _14 := allocate(_13) // let _14 := allocate(_13)

View File

@ -7,9 +7,9 @@
a := 9 a := 9
sstore(x, 3) sstore(x, 3)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let a := calldataload(0) // let a := calldataload(0)
// let x := calldataload(0x20) // let x := calldataload(0x20)

View File

@ -23,9 +23,9 @@
let _11 := array_index_access(x, _10) let _11 := array_index_access(x, _10)
mstore(_11, _9) mstore(_11, _9)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// function allocate(size) -> p // function allocate(size) -> p
// { // {

View File

@ -35,9 +35,9 @@
} }
sstore(_1, sum_50) sstore(_1, sum_50)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let _1 := 0 // let _1 := 0
// let _33 := calldataload(_1) // let _33 := calldataload(_1)

View File

@ -7,9 +7,9 @@
let c := double_with_se(i) let c := double_with_se(i)
let d := double_with_se(i) let d := double_with_se(i)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// function double(x) -> y // function double(x) -> y
// { y := add(x, x) } // { y := add(x, x) }

View File

@ -2,9 +2,9 @@
let a := mload(1) let a := mload(1)
let b := mload(1) let b := mload(1)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let a := mload(1) // let a := mload(1)
// let b := mload(1) // let b := mload(1)

View File

@ -2,9 +2,9 @@
let a := gas() let a := gas()
let b := gas() let b := gas()
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let a := gas() // let a := gas()
// let b := gas() // let b := gas()

View File

@ -14,9 +14,9 @@ object "main" {
} }
data "abc" "Hello, World!" data "abc" "Hello, World!"
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let r := "abc" // let r := "abc"
// let a := datasize("abc") // let a := datasize("abc")

View File

@ -10,9 +10,9 @@
mstore(0, calldataload(0)) mstore(0, calldataload(0))
mstore(0, x) mstore(0, x)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let a := 10 // let a := 10
// let x := 20 // let x := 20

View File

@ -1,5 +1,5 @@
{ } { }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { } // { }

View File

@ -2,9 +2,9 @@
let a := mul(1, codesize()) let a := mul(1, codesize())
let b := mul(1, codesize()) let b := mul(1, codesize())
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let a := mul(1, codesize()) // let a := mul(1, codesize())
// let b := a // let b := a

View File

@ -9,9 +9,9 @@
let b := 0 let b := 0
sstore(a, b) sstore(a, b)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// function f() -> x // function f() -> x
// { // {

View File

@ -5,9 +5,9 @@
let b let b
mstore(sub(a, b), 7) mstore(sub(a, b), 7)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let a // let a
// let b // let b

View File

@ -12,9 +12,9 @@
a := b a := b
mstore(2, a) mstore(2, a)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// step: commonSubexpressionEliminator
//
// { // {
// let a := mload(0) // let a := mload(0)
// let b := add(a, 7) // let b := add(a, 7)

View File

@ -6,8 +6,9 @@
} }
// ==== // ====
// dialect: yul // dialect: yul
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let y:bool := false // let y:bool := false
// for { } true { } // for { } true { }

View File

@ -6,8 +6,9 @@
} }
// ==== // ====
// dialect: ewasm // dialect: ewasm
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let y:i32 := 0:i32 // let y:i32 := 0:i32
// for { } true { } // for { } true { }

View File

@ -4,9 +4,9 @@
if y { break } if y { break }
} }
} }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let y := mload(0x20) // let y := mload(0x20)
// for { } and(y, 8) { pop(y) } // for { } and(y, 8) { pop(y) }

View File

@ -4,9 +4,9 @@
if y { continue } if y { continue }
} }
} }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let y := mload(0x20) // let y := mload(0x20)
// for { } and(y, 8) { pop(y) } // for { } and(y, 8) { pop(y) }

View File

@ -7,9 +7,9 @@
x := 2 x := 2
} }
} }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let x := mload(0) // let x := mload(0)
// let y := mload(0) // let y := mload(0)

View File

@ -8,9 +8,9 @@
} }
sstore(0, x) sstore(0, x)
} }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let x // let x
// for { } x { sstore(1, x) } // for { } x { sstore(1, x) }

View File

@ -7,9 +7,9 @@
sstore(10, x) sstore(10, x)
} }
} }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let x := mload(0) // let x := mload(0)
// for { } 1 { } // for { } 1 { }

View File

@ -3,9 +3,9 @@
if x { sstore(0, x) } if x { sstore(0, x) }
sstore(1, x) sstore(1, x)
} }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let x := mload(0) // let x := mload(0)
// if x { sstore(0, x) } // if x { sstore(0, x) }

View File

@ -3,9 +3,9 @@
if x { sstore(0, x) revert(0, 0) } if x { sstore(0, x) revert(0, 0) }
sstore(1, x) sstore(1, x)
} }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let x := mload(0) // let x := mload(0)
// if x // if x

View File

@ -7,9 +7,9 @@
pop(x) pop(x)
} }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { // {
// let x := calldataload(0) // let x := calldataload(0)
// switch x // switch x

View File

@ -1,5 +1,5 @@
{ } { }
// ====
// step: conditionalSimplifier
// ---- // ----
// step: conditionalSimplifier
//
// { } // { }

View File

@ -5,9 +5,9 @@
y := 0 y := 0
} }
} }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { // {
// let y := mload(0x20) // let y := mload(0x20)
// for { } and(y, 8) { pop(y) } // for { } and(y, 8) { pop(y) }

View File

@ -5,9 +5,9 @@
y := 0 y := 0
} }
} }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { // {
// let y := mload(0x20) // let y := mload(0x20)
// for { } and(y, 8) { pop(y) } // for { } and(y, 8) { pop(y) }

View File

@ -9,9 +9,9 @@
x := 2 x := 2
} }
} }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { // {
// let x := mload(0) // let x := mload(0)
// let y := mload(0) // let y := mload(0)

View File

@ -7,9 +7,9 @@
} }
sstore(0, x) sstore(0, x)
} }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { // {
// let x // let x
// for { } x { sstore(1, x) } // for { } x { sstore(1, x) }

View File

@ -9,9 +9,9 @@
sstore(10, x) sstore(10, x)
} }
} }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { // {
// let x := mload(0) // let x := mload(0)
// for { } 1 { } // for { } 1 { }

View File

@ -4,9 +4,9 @@
x := 0 x := 0
sstore(1, x) sstore(1, x)
} }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { // {
// let x := mload(0) // let x := mload(0)
// if x { sstore(0, x) } // if x { sstore(0, x) }

View File

@ -4,9 +4,9 @@
x := 0 x := 0
sstore(1, x) sstore(1, x)
} }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { // {
// let x := mload(0) // let x := mload(0)
// if x // if x

View File

@ -8,9 +8,9 @@
pop(x) pop(x)
} }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { // {
// let x := calldataload(0) // let x := calldataload(0)
// switch x // switch x

View File

@ -1,5 +1,5 @@
{ } { }
// ====
// step: conditionalUnsimplifier
// ---- // ----
// step: conditionalUnsimplifier
//
// { } // { }

View File

@ -4,9 +4,9 @@
let z := 0xffff0000ffff0000ffff0000ffff0000ff00ff00ffff0000ffff0000ffff0000 let z := 0xffff0000ffff0000ffff0000ffff0000ff00ff00ffff0000ffff0000ffff0000
let w := 0xffffffff000000ffffef000001feff000067ffefff0000ff230002ffee00fff7 let w := 0xffffffff000000ffffef000001feff000067ffefff0000ff230002ffee00fff7
} }
// ====
// step: constantOptimiser
// ---- // ----
// step: constantOptimiser
//
// { // {
// let x := 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00 // let x := 0xff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00ff00
// let y := 0x1100ff00ff00ff001100ff00ff001100ff00ff001100ff00ff001100ff001100 // let y := 0x1100ff00ff00ff001100ff00ff001100ff00ff001100ff00ff001100ff001100

View File

@ -7,8 +7,9 @@
} }
// ==== // ====
// EVMVersion: >=constantinople // EVMVersion: >=constantinople
// step: constantOptimiser
// ---- // ----
// step: constantOptimiser
//
// { // {
// let a := shl(172, 1) // let a := shl(172, 1)
// let x := add(shl(248, 17), 0xffffffffffffffffffffffff23) // let x := add(shl(248, 17), 0xffffffffffffffffffffffff23)

View File

@ -4,9 +4,9 @@
for { let i := 0xff00 } lt(i, 2) { i := add(i, 3) } { for { let i := 0xff00 } lt(i, 2) { i := add(i, 3) } {
} }
} }
// ====
// step: constantOptimiser
// ---- // ----
// step: constantOptimiser
//
// { // {
// let x := 8 // let x := 8
// let y := 0xffff // let y := 0xffff

View File

@ -1,7 +1,7 @@
{ let a := mload(0) if a {} } { let a := mload(0) if a {} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// let a := mload(0) // let a := mload(0)
// pop(a) // pop(a)

View File

@ -1,5 +1,5 @@
{ if mload(0) {} } { if mload(0) {} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { pop(mload(0)) } // { pop(mload(0)) }

View File

@ -3,9 +3,9 @@
function g() -> x { leave x := 7 } function g() -> x { leave x := 7 }
function h() -> x { if x { leave } } function h() -> x { if x { leave } }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// function f() -> x // function f() -> x
// { x := 7 } // { x := 7 }

View File

@ -1,9 +1,9 @@
{ {
switch mload(0) default { mstore(1, 2) } switch mload(0) default { mstore(1, 2) }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// pop(mload(0)) // pop(mload(0))
// { mstore(1, 2) } // { mstore(1, 2) }

View File

@ -10,9 +10,9 @@
case 1 { } case 1 { }
default { } default { }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// let y := 200 // let y := 200
// pop(add(y, 4)) // pop(add(y, 4))

View File

@ -5,9 +5,9 @@
case 1 { y := 9 } case 1 { y := 9 }
case 2 { y := 10 } case 2 { y := 10 }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// let y := 200 // let y := 200
// switch calldataload(0) // switch calldataload(0)

View File

@ -5,9 +5,9 @@
case 1 { y := 9 } case 1 { y := 9 }
default { } default { }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// let y := 200 // let y := 200
// if eq(1, calldataload(0)) { y := 9 } // if eq(1, calldataload(0)) { y := 9 }

View File

@ -5,9 +5,9 @@
case 2 { y := 10 } case 2 { y := 10 }
default { } default { }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// let y := 200 // let y := 200
// switch calldataload(0) // switch calldataload(0)

View File

@ -1,9 +1,9 @@
{ {
switch calldataload(0) case 2 { mstore(0, 0) } switch calldataload(0) case 2 { mstore(0, 0) }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// if eq(2, calldataload(0)) { mstore(0, 0) } // if eq(2, calldataload(0)) { mstore(0, 0) }
// } // }

View File

@ -4,9 +4,9 @@
break break
} }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// if calldatasize() { mstore(4, 5) } // if calldatasize() { mstore(4, 5) }
// } // }

View File

@ -8,9 +8,9 @@
break break
} }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// for { } calldatasize() { mstore(8, 9) } // for { } calldatasize() { mstore(8, 9) }
// { // {

View File

@ -7,9 +7,9 @@
break break
} }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// if calldatasize() // if calldatasize()
// { // {

View File

@ -5,9 +5,9 @@
revert(0, x) revert(0, x)
} }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// if calldatasize() // if calldatasize()
// { // {

View File

@ -6,9 +6,9 @@
revert(0, x) revert(0, x)
} }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// for { } calldatasize() { mstore(1, 2) } // for { } calldatasize() { mstore(1, 2) }
// { // {

View File

@ -5,9 +5,9 @@
break break
} }
} }
// ====
// step: controlFlowSimplifier
// ---- // ----
// step: controlFlowSimplifier
//
// { // {
// for { } calldatasize() { mstore(1, 2) } // for { } calldatasize() { mstore(1, 2) }
// { // {

View File

@ -13,9 +13,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let a := 20 // let a := 20
// for { } lt(a, 40) { a := add(a, 2) } // for { } lt(a, 40) { a := add(a, 2) }

View File

@ -14,9 +14,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let a := 20 // let a := 20
// for { } lt(a, 40) { a := add(a, 2) } // for { } lt(a, 40) { a := add(a, 2) }

View File

@ -14,9 +14,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let a := 20 // let a := 20
// for { } lt(a, 40) { a := add(a, 2) } // for { } lt(a, 40) { a := add(a, 2) }

View File

@ -18,9 +18,9 @@
pop(f()) pop(f())
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// function f() -> x // function f() -> x
// { // {

View File

@ -15,9 +15,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let b := 20 // let b := 20
// revert(0, 0) // revert(0, 0)

View File

@ -15,9 +15,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let b := 20 // let b := 20
// stop() // stop()

View File

@ -4,7 +4,7 @@
let i_1 := i_0 let i_1 := i_0
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { stop() } // { stop() }

View File

@ -12,9 +12,9 @@
pop(add(1, 1)) pop(add(1, 1))
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// fun() // fun()
// revert(0, 0) // revert(0, 0)

View File

@ -12,9 +12,9 @@
y := 10 } y := 10 }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let y := mload(0) // let y := mload(0)
// switch y // switch y

View File

@ -4,9 +4,9 @@
} }
mstore(0, 0) mstore(0, 0)
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// { revert(0, 0) } // { revert(0, 0) }
// mstore(0, 0) // mstore(0, 0)

View File

@ -12,9 +12,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let a := 20 // let a := 20
// for { } lt(a, 40) { a := add(a, 2) } // for { } lt(a, 40) { a := add(a, 2) }

View File

@ -12,9 +12,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let a := 20 // let a := 20
// for { } lt(a, 40) { a := add(a, 2) } // for { } lt(a, 40) { a := add(a, 2) }

View File

@ -15,9 +15,9 @@
stop() stop()
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// step: deadCodeEliminator
//
// { // {
// let b := 20 // let b := 20
// let a := 20 // let a := 20

View File

@ -9,8 +9,9 @@
} }
// ==== // ====
// dialect: yul // dialect: yul
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { // {
// { let a, b } // { let a, b }
// { // {

View File

@ -8,8 +8,9 @@
} }
// ==== // ====
// dialect: yul // dialect: yul
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { // {
// { let a, b, c, d, f } // { let a, b, c, d, f }
// { // {

View File

@ -7,8 +7,9 @@
} }
// ==== // ====
// dialect: yul // dialect: yul
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { // {
// { let a, b, c } // { let a, b, c }
// { // {

View File

@ -1,8 +1,9 @@
{ { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } } { { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } { let aanteuhdaoneudbrgkjiuaothduiathudaoeuh:u256 } }
// ==== // ====
// dialect: yul // dialect: yul
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { // {
// { // {
// let aanteuhdaoneudbrgkjiuaothduiathudaoeuh // let aanteuhdaoneudbrgkjiuaothduiathudaoeuh

View File

@ -1,5 +1,5 @@
{ } { }
// ====
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { } // { }

View File

@ -1,6 +1,7 @@
{ } { }
// ==== // ====
// step: disambiguator
// dialect: yul // dialect: yul
// ---- // ----
// step: disambiguator
//
// { } // { }

View File

@ -9,8 +9,9 @@
} }
// ==== // ====
// dialect: yul // dialect: yul
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { // {
// { let a, b, c } // { let a, b, c }
// { // {

View File

@ -1,8 +1,9 @@
{ { let a:u256 } { let a:u256 } } { { let a:u256 } { let a:u256 } }
// ==== // ====
// dialect: yul // dialect: yul
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { // {
// { let a } // { let a }
// { let a_1 } // { let a_1 }

View File

@ -1,8 +1,9 @@
{ { let a:u256 let a_1:u256 } { let a:u256 } } { { let a:u256 let a_1:u256 } { let a:u256 } }
// ==== // ====
// dialect: yul // dialect: yul
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { // {
// { // {
// let a // let a

View File

@ -7,8 +7,9 @@
} }
// ==== // ====
// dialect: yul // dialect: yul
// step: disambiguator
// ---- // ----
// step: disambiguator
//
// { // {
// { // {
// let c // let c

View File

@ -54,9 +54,9 @@
} }
} }
} }
// ====
// step: equivalentFunctionCombiner
// ---- // ----
// step: equivalentFunctionCombiner
//
// { // {
// pop(f(1, 2, 3)) // pop(f(1, 2, 3))
// pop(f(4, 5, 6)) // pop(f(4, 5, 6))

View File

@ -4,9 +4,9 @@
function f() { mstore(1, mload(0)) } function f() { mstore(1, mload(0)) }
function g() { mstore(1, mload(0)) } function g() { mstore(1, mload(0)) }
} }
// ====
// step: equivalentFunctionCombiner
// ---- // ----
// step: equivalentFunctionCombiner
//
// { // {
// f() // f()
// f() // f()

View File

@ -4,9 +4,9 @@
function f() -> b { let a := mload(0) b := a } function f() -> b { let a := mload(0) b := a }
function g() -> a { let b := mload(0) a := b } function g() -> a { let b := mload(0) a := b }
} }
// ====
// step: equivalentFunctionCombiner
// ---- // ----
// step: equivalentFunctionCombiner
//
// { // {
// pop(f()) // pop(f())
// pop(f()) // pop(f())

Some files were not shown because too many files have changed in this diff Show More