Merge remote-tracking branch 'origin/develop' into breaking

This commit is contained in:
chriseth
2020-07-06 15:25:25 +02:00
118 changed files with 1713 additions and 380 deletions
+1
View File
@@ -255,6 +255,7 @@ TestCase::TestResult YulOptimizerTest::run(ostream& _stream, string const& _line
else if (m_optimizerStep == "ssaTransform")
{
disambiguate();
ForLoopInitRewriter::run(*m_context, *m_ast);
SSATransform::run(*m_context, *m_ast);
}
else if (m_optimizerStep == "redundantAssignEliminator")
@@ -0,0 +1,13 @@
{
let x := calldataload(0)
let a := mload(x)
let b := mload(x)
sstore(a, b)
}
// ----
// step: loadResolver
//
// {
// let a := mload(calldataload(0))
// sstore(a, a)
// }
@@ -0,0 +1,16 @@
{
let x := calldataload(0)
let a := mload(x)
x := 7
let b := mload(x)
sstore(a, b)
}
// ----
// step: loadResolver
//
// {
// let x := calldataload(0)
// let a := mload(x)
// x := 7
// sstore(a, mload(x))
// }
@@ -0,0 +1,16 @@
{
let x := calldataload(0)
let a := mload(x)
a := 7
let b := mload(x)
sstore(a, b)
}
// ----
// step: loadResolver
//
// {
// let x := calldataload(0)
// let a := mload(x)
// a := 7
// sstore(a, mload(x))
// }
@@ -0,0 +1,19 @@
{
let x := mload(calldataload(0))
if calldataload(1) {
mstore(add(calldataload(0), 0x20), 1)
}
let t := mload(add(calldataload(0), 0x20))
let q := mload(calldataload(0))
sstore(t, q)
}
// ----
// step: loadResolver
//
// {
// let _2 := calldataload(0)
// let x := mload(_2)
// let _3 := 1
// if calldataload(_3) { mstore(add(_2, 0x20), _3) }
// sstore(mload(add(_2, 0x20)), x)
// }
@@ -0,0 +1,22 @@
{
let b := mload(2)
if calldataload(1) {
mstore(2, 7)
// Re-writing the old value, should allow to eliminate the load below.
mstore(2, b)
}
sstore(0, mload(2))
}
// ----
// step: loadResolver
//
// {
// let _1 := 2
// let b := mload(_1)
// if calldataload(1)
// {
// mstore(_1, 7)
// mstore(_1, b)
// }
// sstore(0, b)
// }
@@ -0,0 +1,19 @@
{
let b := mload(2)
sstore(0, b)
if calldataload(1) {
mstore(2, 7)
}
sstore(0, mload(2))
}
// ----
// step: loadResolver
//
// {
// let _1 := 2
// let b := mload(_1)
// let _2 := 0
// sstore(_2, b)
// if calldataload(1) { mstore(_1, 7) }
// sstore(_2, mload(_1))
// }
@@ -0,0 +1,15 @@
{
let x := calldataload(0)
x := mload(x)
let y := mload(x)
sstore(0, y)
}
// ----
// step: loadResolver
//
// {
// let _1 := 0
// let x := calldataload(_1)
// x := mload(x)
// sstore(_1, mload(x))
// }
@@ -0,0 +1,30 @@
{
let x := calldataload(0)
let len := sload(x)
let sum
for { let i := 0} lt(i, sload(x)) { i := add(i, 1) } {
let p := add(x, add(i, 1))
if gt(p, sload(x)) { revert(0, 0) }
sum := add(sum, sload(p))
}
mstore(0, sum)
return(0, 0x20)
}
// ----
// step: loadResolver
//
// {
// let _1 := 0
// let x := calldataload(_1)
// let len := sload(x)
// let sum
// let i := _1
// for { } lt(i, len) { i := add(i, 1) }
// {
// let p := add(add(x, i), 1)
// if gt(p, len) { revert(_1, _1) }
// sum := add(sum, sload(p))
// }
// mstore(_1, sum)
// return(_1, 0x20)
// }
@@ -0,0 +1,33 @@
{
for { let x := 0 } 1 { x := 2 } {
for { let y := 0 } 1 { y := 6 } {
}
}
}
// ----
// step: ssaTransform
//
// {
// let x_1 := 0
// let x := x_1
// for { }
// 1
// {
// let x_7 := x
// let x_2 := 2
// x := x_2
// }
// {
// let x_5 := x
// let y_3 := 0
// let y := y_3
// for { }
// 1
// {
// let y_6 := y
// let y_4 := 6
// y := y_4
// }
// { }
// }
// }
@@ -12,7 +12,8 @@
// {
// let a_1 := mload(0)
// let a := a_1
// for { mstore(0, a_1) }
// mstore(0, a_1)
// for { }
// a
// {
// let a_4 := a
@@ -12,19 +12,9 @@
// {
// let a_1 := mload(0)
// let a := a_1
// for {
// let a_2 := add(a_1, 3)
// a := a_2
// }
// a
// {
// let a_4 := a
// mstore(0, a_4)
// }
// {
// let a_3 := a
// mstore(0, a_3)
// }
// let a_5 := a
// mstore(0, a_5)
// let a_2 := add(a_1, 3)
// a := a_2
// for { } a_2 { mstore(0, a_2) }
// { mstore(0, a_2) }
// mstore(0, a_2)
// }
@@ -12,7 +12,8 @@
// {
// let a_1 := mload(0)
// let a := a_1
// for { mstore(0, a_1) }
// mstore(0, a_1)
// for { }
// a
// {
// let a_4 := a
@@ -32,10 +32,9 @@
// a := a_4
// }
// let a_10 := a
// for {
// let a_5 := add(a_10, 3)
// a := a_5
// }
// let a_5 := add(a_10, 3)
// a := a_5
// for { }
// a
// {
// let a_12 := a
@@ -0,0 +1,6 @@
{
function _...($..) {}
let a...
_...(a...)
}
// ----
@@ -0,0 +1,4 @@
{
function x..y() {}
}
// ----
@@ -0,0 +1,4 @@
{
function x(a..b) {}
}
// ----
@@ -0,0 +1,4 @@
{
function x() -> a..b {}
}
// ----
@@ -0,0 +1,4 @@
{
let a..b := 1
}
// ----
@@ -0,0 +1,4 @@
{
function x...y() {}
}
// ----
@@ -0,0 +1,4 @@
{
function x(a...b) {}
}
// ----
@@ -0,0 +1,4 @@
{
function x() -> a...b {}
}
// ----
@@ -0,0 +1,4 @@
{
let a...b := 1
}
// ----
@@ -0,0 +1,5 @@
{
function .x() {}
}
// ----
// ParserError 2314: (15-16): Expected identifier but got '.'
@@ -0,0 +1,5 @@
{
function x(.a) {}
}
// ----
// ParserError 2314: (17-18): Expected identifier but got '.'
@@ -0,0 +1,5 @@
{
function x() -> .a {}
}
// ----
// ParserError 2314: (22-23): Expected identifier but got '.'
@@ -0,0 +1,5 @@
{
let .a := 1
}
// ----
// ParserError 2314: (10-11): Expected identifier but got '.'
@@ -0,0 +1,4 @@
{
function x.y() {}
}
// ----
@@ -0,0 +1,4 @@
{
function x(a.b) {}
}
// ----
@@ -0,0 +1,4 @@
{
function x() -> a.b {}
}
// ----
@@ -0,0 +1,4 @@
{
let a.b := 1
}
// ----
@@ -0,0 +1,4 @@
{
function x.() {}
}
// ----
@@ -0,0 +1,4 @@
{
function x(a.) {}
}
// ----
@@ -0,0 +1,4 @@
{
function x() -> a. {}
}
// ----
@@ -0,0 +1,4 @@
{
let a. := 1
}
// ----