Yul] RedundantAssignEliminator: Implements break/continue handling within ForLoop.

This commit is contained in:
Christian Parpart
2019-03-26 17:36:43 +01:00
committed by chriseth
parent d8c42a0270
commit a1ec49409d
6 changed files with 160 additions and 2 deletions
@@ -0,0 +1,32 @@
{
// Cannot be removed, because we might run the loop only once
let x := 1
for { } calldataload(0) { }
{
if callvalue() {
x := 2 // is preserved because of break stmt below.
break
}
x := 3
}
mstore(x, 0x42)
}
// ----
// redundantAssignEliminator
// {
// let x := 1
// for {
// }
// calldataload(0)
// {
// }
// {
// if callvalue()
// {
// x := 2
// break
// }
// x := 3
// }
// mstore(x, 0x42)
// }
@@ -0,0 +1,33 @@
{
// Cannot be removed, because we might run the loop only once
let x := 1
for { } calldataload(0) { }
{
x := 2 // Will not be removed as if-condition can be false.
if callvalue() {
x := 3
continue
}
mstore(x, 2)
}
x := 3
}
// ----
// redundantAssignEliminator
// {
// let x := 1
// for {
// }
// calldataload(0)
// {
// }
// {
// x := 2
// if callvalue()
// {
// x := 3
// continue
// }
// mstore(x, 2)
// }
// }
@@ -0,0 +1,32 @@
{
// Cannot be removed, because we might run the loop only once
let x := 1
for { } calldataload(0) { }
{
if callvalue() {
x := 2 // is preserved because of continue stmt below.
continue
}
x := 3
}
mstore(x, 0x42)
}
// ----
// redundantAssignEliminator
// {
// let x := 1
// for {
// }
// calldataload(0)
// {
// }
// {
// if callvalue()
// {
// x := 2
// continue
// }
// x := 3
// }
// mstore(x, 0x42)
// }
@@ -0,0 +1,31 @@
{
// Cannot be removed, because we might run the loop only once
let x := 1
for { } calldataload(0) { mstore(x, 0x42) }
{
if callvalue() {
x := 2 // is preserved because of continue stmt below.
continue
}
x := 3
}
}
// ----
// redundantAssignEliminator
// {
// let x := 1
// for {
// }
// calldataload(0)
// {
// mstore(x, 0x42)
// }
// {
// if callvalue()
// {
// x := 2
// continue
// }
// x := 3
// }
// }