Make yul a setting.

This commit is contained in:
chriseth 2019-04-01 16:33:46 +02:00
parent aeb260cde1
commit e3d7a34c2c
284 changed files with 623 additions and 318 deletions

View File

@ -34,7 +34,7 @@ using namespace solidity;
using namespace dev::solidity::test; using namespace dev::solidity::test;
using namespace std; using namespace std;
void TestCase::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool) const void TestCase::printUpdatedSettings(ostream& _stream, const string& _linePrefix, const bool)
{ {
if (m_validatedSettings.empty()) if (m_validatedSettings.empty())
return; return;

View File

@ -72,7 +72,7 @@ public:
/// 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 the updated settings.
virtual void printUpdatedSettings(std::ostream &_stream, std::string const &_linePrefix = "", bool const _formatted = false) const; virtual void printUpdatedSettings(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

@ -78,19 +78,23 @@ YulOptimizerTest::YulOptimizerTest(string const& _filename)
m_optimizerStep = std::prev(std::prev(path.end()))->string(); m_optimizerStep = std::prev(std::prev(path.end()))->string();
ifstream file(_filename); ifstream file(_filename);
if (!file) soltestAssert(file, "Cannot open test contract: \"" + _filename + "\".");
BOOST_THROW_EXCEPTION(runtime_error("Cannot open test case: \"" + _filename + "\"."));
file.exceptions(ios::badbit); file.exceptions(ios::badbit);
string line; m_source = parseSourceAndSettings(file);
while (getline(file, line)) if (m_settings.count("yul"))
{ {
if (boost::algorithm::starts_with(line, "// ----")) m_yul = true;
break; m_validatedSettings["yul"] = "true";
if (m_source.empty() && boost::algorithm::starts_with(line, "// yul")) m_settings.erase("yul");
m_yul = true;
m_source += line + "\n";
} }
if (m_settings.count("step"))
{
m_validatedSettings["step"] = m_settings["step"];
m_settings.erase("step");
}
string line;
while (getline(file, line)) while (getline(file, line))
if (boost::algorithm::starts_with(line, "// ")) if (boost::algorithm::starts_with(line, "// "))
m_expectation += line.substr(3) + "\n"; m_expectation += line.substr(3) + "\n";
@ -266,8 +270,22 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
return false; return false;
} }
m_obtainedResult = m_optimizerStep + "\n" + AsmPrinter{m_yul}(*m_ast) + "\n"; m_obtainedResult = AsmPrinter{m_yul}(*m_ast) + "\n";
bool success = true;
if (m_optimizerStep != m_validatedSettings["step"])
{
string nextIndentLevel = _linePrefix + " ";
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) <<
_linePrefix <<
"Invalid optimizer step. Given: \"" <<
m_validatedSettings["step"] <<
"\", should be: \"" <<
m_optimizerStep <<
"\"." <<
endl;
success = false;
}
if (m_expectation != m_obtainedResult) if (m_expectation != m_obtainedResult)
{ {
string nextIndentLevel = _linePrefix + " "; string nextIndentLevel = _linePrefix + " ";
@ -276,9 +294,9 @@ bool YulOptimizerTest::run(ostream& _stream, string const& _linePrefix, bool con
printIndented(_stream, m_expectation, nextIndentLevel); printIndented(_stream, m_expectation, nextIndentLevel);
AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Obtained result:" << endl; AnsiColorized(_stream, _formatted, {formatting::BOLD, formatting::CYAN}) << _linePrefix << "Obtained result:" << endl;
printIndented(_stream, m_obtainedResult, nextIndentLevel); printIndented(_stream, m_obtainedResult, nextIndentLevel);
return false; success = false;
} }
return true; return success;
} }
void YulOptimizerTest::printSource(ostream& _stream, string const& _linePrefix, bool const) const void YulOptimizerTest::printSource(ostream& _stream, string const& _linePrefix, bool const) const
@ -286,6 +304,12 @@ 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_validatedSettings["step"] = m_optimizerStep;
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

@ -51,6 +51,7 @@ public:
bool run(std::ostream& _stream, std::string const& _linePrefix = "", bool const _formatted = false) override; bool 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:

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,8 +11,9 @@
datacopy("abc", x, y) datacopy("abc", x, y)
mstore(a, x) mstore(a, x)
} }
// ====
// step: commonSubexpressionEliminator
// ---- // ----
// commonSubexpressionEliminator
// { // {
// let r := "abc" // let r := "abc"
// let a := datasize("abc") // let a := datasize("abc")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,8 +13,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// deadCodeEliminator
// { // {
// for { // for {
// let a := 20 // let a := 20

View File

@ -14,8 +14,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// deadCodeEliminator
// { // {
// for { // for {
// let a := 20 // let a := 20

View File

@ -14,8 +14,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// deadCodeEliminator
// { // {
// for { // for {
// let a := 20 // let a := 20

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,8 +12,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// deadCodeEliminator
// { // {
// for { // for {
// let a := 20 // let a := 20

View File

@ -12,8 +12,9 @@
} }
} }
// ====
// step: deadCodeEliminator
// ---- // ----
// deadCodeEliminator
// { // {
// for { // for {
// let a := 20 // let a := 20

View File

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

View File

@ -1,4 +1,3 @@
// yul
{ {
{ let a:u256, b:u256 } { let a:u256, b:u256 }
{ {
@ -7,8 +6,10 @@
} }
} }
} }
// ====
// step: disambiguator
// yul: true
// ---- // ----
// disambiguator
// { // {
// { // {
// let a:u256, b:u256 // let a:u256, b:u256

View File

@ -1,4 +1,3 @@
// yul
{ {
{ let a:u256, b:u256, c:u256, d:u256, f:u256 } { let a:u256, b:u256, c:u256, d:u256, f:u256 }
{ {
@ -7,8 +6,10 @@
} }
} }
} }
// ====
// step: disambiguator
// yul: true
// ---- // ----
// disambiguator
// { // {
// { // {
// let a:u256, b:u256, c:u256, d:u256, f:u256 // let a:u256, b:u256, c:u256, d:u256, f:u256

View File

@ -1,4 +1,3 @@
// yul
{ {
{ let a:u256, b:u256, c:u256 } { let a:u256, b:u256, c:u256 }
{ {
@ -6,8 +5,10 @@
if a { let b:bool := a } if a { let b:bool := a }
} }
} }
// ====
// step: disambiguator
// yul: true
// ---- // ----
// disambiguator
// { // {
// { // {
// let a:u256, b:u256, c:u256 // let a:u256, b:u256, c:u256

View File

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

View File

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

View File

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

View File

@ -1,4 +1,3 @@
// yul
{ {
{ let a:u256, b:u256, c:u256 } { let a:u256, b:u256, c:u256 }
{ {
@ -8,8 +7,10 @@
default { let c:u256 := a } default { let c:u256 := a }
} }
} }
// ====
// step: disambiguator
// yul: true
// ---- // ----
// disambiguator
// { // {
// { // {
// let a:u256, b:u256, c:u256 // let a:u256, b:u256, c:u256

View File

@ -1,7 +1,8 @@
// yul
{ { let a:u256 } { let a:u256 } } { { let a:u256 } { let a:u256 } }
// ====
// step: disambiguator
// yul: true
// ---- // ----
// disambiguator
// { // {
// { // {
// let a:u256 // let a:u256

View File

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

View File

@ -1,4 +1,3 @@
// yul
{ {
{ let c:u256 let b:u256 } { let c:u256 let b:u256 }
function f(a:u256, c:u256) -> b:u256 { let x:u256 } function f(a:u256, c:u256) -> b:u256 { let x:u256 }
@ -6,8 +5,10 @@
let a:u256 let x:u256 let a:u256 let x:u256
} }
} }
// ====
// step: disambiguator
// yul: true
// ---- // ----
// disambiguator
// { // {
// { // {
// let c:u256 // let c:u256

View File

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

View File

@ -4,8 +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
// ---- // ----
// equivalentFunctionCombiner
// { // {
// f() // f()
// f() // f()

View File

@ -4,8 +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
// ---- // ----
// equivalentFunctionCombiner
// { // {
// pop(f()) // pop(f())
// pop(f()) // pop(f())

View File

@ -4,8 +4,9 @@
function f(x) { switch x case 0 { mstore(0, 42) } case 1 { mstore(1, 42) } } function f(x) { switch x case 0 { mstore(0, 42) } case 1 { mstore(1, 42) } }
function g(x) { switch x case 1 { mstore(1, 42) } case 0 { mstore(0, 42) } } function g(x) { switch x case 1 { mstore(1, 42) } case 0 { mstore(0, 42) } }
} }
// ====
// step: equivalentFunctionCombiner
// ---- // ----
// equivalentFunctionCombiner
// { // {
// f(0) // f(0)
// f(1) // f(1)

View File

@ -2,8 +2,9 @@
function f(a) -> x { x := add(a, a) } function f(a) -> x { x := add(a, a) }
let y := f(calldatasize()) let y := f(calldatasize())
} }
// ====
// step: expressionInliner
// ---- // ----
// expressionInliner
// { // {
// function f(a) -> x // function f(a) -> x
// { // {

View File

@ -3,8 +3,9 @@
function g(b, c) -> y { y := mul(mload(c), f(b)) } function g(b, c) -> y { y := mul(mload(c), f(b)) }
let y := g(calldatasize(), 7) let y := g(calldatasize(), 7)
} }
// ====
// step: expressionInliner
// ---- // ----
// expressionInliner
// { // {
// function f(a) -> x // function f(a) -> x
// { // {

View File

@ -3,8 +3,9 @@
function g(b, s) -> y { y := f(b, f(s, s)) } function g(b, s) -> y { y := f(b, f(s, s)) }
let y := g(calldatasize(), 7) let y := g(calldatasize(), 7)
} }
// ====
// step: expressionInliner
// ---- // ----
// expressionInliner
// { // {
// function f(a, r) -> x // function f(a, r) -> x
// { // {

View File

@ -3,8 +3,9 @@
function f(a) -> x { x := a } function f(a) -> x { x := a }
let y := f(mload(2)) let y := f(mload(2))
} }
// ====
// step: expressionInliner
// ---- // ----
// expressionInliner
// { // {
// function f(a) -> x // function f(a) -> x
// { // {

View File

@ -6,8 +6,9 @@
function h() -> z { mstore(0, 4) z := mload(0) } function h() -> z { mstore(0, 4) z := mload(0) }
let r := f(g(), h()) let r := f(g(), h())
} }
// ====
// step: expressionInliner
// ---- // ----
// expressionInliner
// { // {
// function f(a, b) -> x // function f(a, b) -> x
// { // {

View File

@ -1,10 +1,11 @@
// yul
{ {
function f() -> x:u256 { x := 2:u256 } function f() -> x:u256 { x := 2:u256 }
let y:u256 := f() let y:u256 := f()
} }
// ====
// step: expressionInliner
// yul: true
// ---- // ----
// expressionInliner
// { // {
// function f() -> x:u256 // function f() -> x:u256
// { // {

View File

@ -1,10 +1,11 @@
// yul
{ {
function f(a:u256) -> x:u256 { x := a } function f(a:u256) -> x:u256 { x := a }
let y:u256 := f(7:u256) let y:u256 := f(7:u256)
} }
// ====
// step: expressionInliner
// yul: true
// ---- // ----
// expressionInliner
// { // {
// function f(a:u256) -> x:u256 // function f(a:u256) -> x:u256
// { // {

View File

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

View File

@ -4,8 +4,9 @@
let x := mul(add(b, a), mload(2)) let x := mul(add(b, a), mload(2))
sstore(x, 3) sstore(x, 3)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// let a := mload(3) // let a := mload(3)
// let b := mload(6) // let b := mload(6)

View File

@ -4,8 +4,9 @@
let x := mul(add(b, a), 2) let x := mul(add(b, a), 2)
sstore(x, 3) sstore(x, 3)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// sstore(mul(add(mload(6), mload(2)), 2), 3) // sstore(mul(add(mload(6), mload(2)), 2), 3)
// } // }

View File

@ -3,8 +3,9 @@
let a := mload(2) let a := mload(2)
let b := add(a, a) let b := add(a, a)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// let a := mload(2) // let a := mload(2)
// let b := add(a, a) // let b := add(a, a)

View File

@ -7,8 +7,9 @@
let x := mul(a, add(2, b)) let x := mul(a, add(2, b))
sstore(x, 3) sstore(x, 3)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// let a := mload(2) // let a := mload(2)
// sstore(mul(a, add(2, mload(6))), 3) // sstore(mul(a, add(2, mload(6))), 3)

View File

@ -4,8 +4,9 @@
let x := mul(add(a, b), 2) let x := mul(add(a, b), 2)
sstore(x, 3) sstore(x, 3)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// let a := mload(2) // let a := mload(2)
// sstore(mul(add(a, mload(6)), 2), 3) // sstore(mul(add(a, mload(6)), 2), 3)

View File

@ -11,8 +11,9 @@
} }
sstore(x, 3) sstore(x, 3)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// let x := calldataload(mload(2)) // let x := calldataload(mload(2))
// sstore(x, 3) // sstore(x, 3)

View File

@ -1,8 +1,9 @@
{ {
for { let b := mload(1) } b {} {} for { let b := mload(1) } b {} {}
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// for { // for {
// let b := mload(1) // let b := mload(1)

View File

@ -2,8 +2,9 @@
let a := mload(0) let a := mload(0)
for { } a {} {} for { } a {} {}
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// let a := mload(0) // let a := mload(0)
// for { // for {

View File

@ -5,8 +5,9 @@
x := add(a, 3) x := add(a, 3)
} }
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// function f(a) -> x // function f(a) -> x
// { // {

View File

@ -4,8 +4,9 @@
let b := mload(a) let b := mload(a)
a := 4 a := 4
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// let a := mload(2) // let a := mload(2)
// let b := mload(a) // let b := mload(a)

View File

@ -3,8 +3,9 @@
let x := calldataload(a) let x := calldataload(a)
sstore(x, 3) sstore(x, 3)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// sstore(calldataload(mload(2)), 3) // sstore(calldataload(mload(2)), 3)
// } // }

View File

@ -5,8 +5,9 @@
let d := add(b, c) let d := add(b, c)
sstore(d, 0) sstore(d, 0)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// let b := sload(mload(3)) // let b := sload(mload(3))
// sstore(add(b, mload(7)), 0) // sstore(add(b, mload(7)), 0)

View File

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

View File

@ -14,8 +14,9 @@
let z := 3 let z := 3
let t := add(z, 9) let t := add(z, 9)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// switch add(mload(7), sload(mload(3))) // switch add(mload(7), sload(mload(3)))
// case 3 { // case 3 {

View File

@ -5,8 +5,9 @@
let x := mul(add(c, b), a) let x := mul(add(c, b), a)
sstore(x, 3) sstore(x, 3)
} }
// ====
// step: expressionJoiner
// ---- // ----
// expressionJoiner
// { // {
// sstore(mul(add(mload(7), mload(6)), mload(2)), 3) // sstore(mul(add(mload(7), mload(6)), mload(2)), 3)
// } // }

View File

@ -3,8 +3,9 @@
let c, d := f() let c, d := f()
let y := add(d, add(c, 7)) let y := add(d, add(c, 7))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// function f() -> x, z // function f() -> x, z
// { // {

View File

@ -1,6 +1,7 @@
{ let a := add(7, sub(mload(0), 7)) } { let a := add(7, sub(mload(0), 7)) }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let a := mload(0) // let a := mload(0)
// } // }

View File

@ -1,6 +1,7 @@
{ let a := add(1, mul(3, 4)) } { let a := add(1, mul(3, 4)) }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let a := 13 // let a := 13
// } // }

View File

@ -1,6 +1,7 @@
{ let a := sub(calldataload(0), calldataload(0)) } { let a := sub(calldataload(0), calldataload(0)) }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let a := 0 // let a := 0
// } // }

View File

@ -1,6 +1,7 @@
{ let a := sub(calldataload(1), calldataload(0)) } { let a := sub(calldataload(1), calldataload(0)) }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let a := sub(calldataload(1), calldataload(0)) // let a := sub(calldataload(1), calldataload(0))
// } // }

View File

@ -2,8 +2,9 @@
let a := mload(0) let a := mload(0)
let b := sub(a, a) let b := sub(a, a)
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let a := mload(0) // let a := mload(0)
// let b := 0 // let b := 0

View File

@ -2,8 +2,9 @@
function f() -> a {} function f() -> a {}
let b := add(7, sub(f(), 7)) let b := add(7, sub(f(), 7))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// function f() -> a // function f() -> a
// { // {

View File

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

View File

@ -2,8 +2,9 @@
let a := mload(sub(7, 7)) let a := mload(sub(7, 7))
let b := sub(a, 0) let b := sub(a, 0)
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let a := mload(0) // let a := mload(0)
// let b := a // let b := a

View File

@ -1,8 +1,9 @@
{ {
mstore(0, mod(calldataload(0), exp(2, 8))) mstore(0, mod(calldataload(0), exp(2, 8)))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// mstore(0, and(calldataload(0), 255)) // mstore(0, and(calldataload(0), 255))
// } // }

View File

@ -1,8 +1,9 @@
{ {
mstore(0, mod(calldataload(0), exp(2, 255))) mstore(0, mod(calldataload(0), exp(2, 255)))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// mstore(0, and(calldataload(0), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)) // mstore(0, and(calldataload(0), 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff))
// } // }

View File

@ -2,8 +2,9 @@
function f(a) -> b { } function f(a) -> b { }
let c := sub(f(0), f(1)) let c := sub(f(0), f(1))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// function f(a) -> b // function f(a) -> b
// { // {

View File

@ -3,8 +3,9 @@
function f2() -> b { } function f2() -> b { }
let c := sub(f1(), f2()) let c := sub(f1(), f2())
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// function f1() -> a // function f1() -> a
// { // {

View File

@ -3,8 +3,9 @@
function f() -> a { } function f() -> a { }
let b := sub(f(), f()) let b := sub(f(), f())
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// function f() -> a // function f() -> a
// { // {

View File

@ -3,8 +3,9 @@
{ {
let a := div(keccak256(0, 0), 0) let a := div(keccak256(0, 0), 0)
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let a := div(keccak256(0, 0), 0) // let a := div(keccak256(0, 0), 0)
// } // }

View File

@ -3,8 +3,9 @@
x := 0 x := 0
mstore(0, add(7, x)) mstore(0, add(7, x))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let x := mload(0) // let x := mload(0)
// x := 0 // x := 0

View File

@ -4,8 +4,9 @@
let y := add(d, add(c, 7)) let y := add(d, add(c, 7))
} }
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// function f() -> c, d // function f() -> c, d
// { // {

View File

@ -1,8 +1,9 @@
{ {
let a := add(0, mload(0)) let a := add(0, mload(0))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let a := mload(0) // let a := mload(0)
// } // }

View File

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

View File

@ -3,8 +3,9 @@
let c, d let c, d
let y := add(d, add(c, 7)) let y := add(d, add(c, 7))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let c, d // let c, d
// let y := 7 // let y := 7

View File

@ -4,8 +4,9 @@
let d let d
let y := add(d, add(c, 7)) let y := add(d, add(c, 7))
} }
// ====
// step: expressionSimplifier
// ---- // ----
// expressionSimplifier
// { // {
// let c // let c
// let d // let d

View File

@ -7,8 +7,9 @@
} }
} }
} }
// ====
// step: expressionSplitter
// ---- // ----
// expressionSplitter
// { // {
// let _1 := 0 // let _1 := 0
// let x := calldataload(_1) // let x := calldataload(_1)

View File

@ -5,8 +5,9 @@
} }
sstore(x, f(mload(2), mload(2))) sstore(x, f(mload(2), mload(2)))
} }
// ====
// step: expressionSplitter
// ---- // ----
// expressionSplitter
// { // {
// let _1 := 3 // let _1 := 3
// let _2 := 7 // let _2 := 7

View File

@ -6,8 +6,9 @@
// datacopy is fine, though // datacopy is fine, though
datacopy(mload(0), mload(1), mload(2)) datacopy(mload(0), mload(1), mload(2))
} }
// ====
// step: expressionSplitter
// ---- // ----
// expressionSplitter
// { // {
// let x := dataoffset("abc") // let x := dataoffset("abc")
// let y := datasize("abc") // let y := datasize("abc")

View File

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

View File

@ -5,8 +5,9 @@
default { mstore(0, mload(3)) } default { mstore(0, mload(3)) }
x := add(mload(3), 4) x := add(mload(3), 4)
} }
// ====
// step: expressionSplitter
// ---- // ----
// expressionSplitter
// { // {
// let x := 8 // let x := 8
// let _1 := 0 // let _1 := 0

View File

@ -1,8 +1,9 @@
{ {
mstore(add(calldataload(2), mload(3)), 8) mstore(add(calldataload(2), mload(3)), 8)
} }
// ====
// step: expressionSplitter
// ---- // ----
// expressionSplitter
// { // {
// let _1 := 8 // let _1 := 8
// let _2 := 3 // let _2 := 3

View File

@ -5,8 +5,9 @@
a := add(a, 1) a := add(a, 1)
} }
} }
// ====
// step: forLoopInitRewriter
// ---- // ----
// forLoopInitRewriter
// { // {
// let random := 42 // let random := 42
// let a := 1 // let a := 1

View File

@ -4,8 +4,9 @@
a := add(a, 1) a := add(a, 1)
} }
} }
// ====
// step: forLoopInitRewriter
// ---- // ----
// forLoopInitRewriter
// { // {
// let a := 1 // let a := 1
// for { // for {

View File

@ -13,8 +13,9 @@
mstore(b,b) mstore(b,b)
} }
} }
// ====
// step: forLoopInitRewriter
// ---- // ----
// forLoopInitRewriter
// { // {
// let random := 42 // let random := 42
// let a := 1 // let a := 1

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