mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Yul] RedundantAssignEliminator: Implements break/continue handling within ForLoop.
This commit is contained in:
committed by
chriseth
parent
d8c42a0270
commit
a1ec49409d
@@ -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
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user