This commit is contained in:
chriseth 2019-10-28 15:46:58 +01:00
parent 91a92a01d5
commit 499fe57d33
9 changed files with 188 additions and 0 deletions

View File

@ -0,0 +1,14 @@
contract C {
function f() public pure returns (uint w) {
assembly {
function f() -> t {
t := 2
leave
t := 9
}
w := f()
}
}
}
// ----
// f() -> 2

View File

@ -0,0 +1,10 @@
contract C {
function f() public pure {
assembly {
function f() {
leave
}
}
}
}
// ----

View File

@ -0,0 +1,9 @@
contract C {
function f() public pure {
assembly {
leave
}
}
}
// ----
// SyntaxError: (63-68): Keyword "leave" can only be used inside a function.

View File

@ -0,0 +1,20 @@
{
function f() -> x, y
{
for { x := 0 } lt(x, 10) { x := add(x, 1) } {
if eq(x, 5) { y := 1 leave }
}
x := 9
}
{
let a, b := f()
sstore(a, b)
}
}
// ====
// EVMVersion: >=constantinople
// ----
// Trace:
// Memory dump:
// Storage dump:
// 0000000000000000000000000000000000000000000000000000000000000005: 0000000000000000000000000000000000000000000000000000000000000001

View File

@ -0,0 +1,18 @@
{
function f() -> x
{
for { leave x := 2 } eq(x, 0) { } {
}
}
{
let a := f()
sstore(a, 7)
}
}
// ====
// EVMVersion: >=constantinople
// ----
// Trace:
// Memory dump:
// Storage dump:
// 0000000000000000000000000000000000000000000000000000000000000000: 0000000000000000000000000000000000000000000000000000000000000007

View File

@ -0,0 +1,19 @@
{
function f() -> x { x := 7 leave }
function g() -> x { leave x := 7 }
function h() -> x { if x { leave } }
}
// ====
// step: controlFlowSimplifier
// ----
// {
// function f() -> x
// { x := 7 }
// function g() -> x_1
// {
// leave
// x_1 := 7
// }
// function h() -> x_2
// { if x_2 { leave } }
// }

View File

@ -0,0 +1,36 @@
{
function f() -> x {
for {
let a := 20
}
lt(a, 40)
{
a := add(a, 2)
}
{
a := a
leave
mstore(0, a)
a := add(a, 10)
}
x := 9
}
pop(f())
}
// ====
// step: deadCodeEliminator
// ----
// {
// function f() -> x
// {
// let a := 20
// for { } lt(a, 40) { a := add(a, 2) }
// {
// a := a
// leave
// }
// x := 9
// }
// pop(f())
// }

View File

@ -0,0 +1,22 @@
{
function g() -> x { x := 8 leave }
function f(a) { a := g() }
let a1 := calldataload(0)
f(a1)
}
// ====
// step: fullInliner
// ----
// {
// {
// let a_2 := calldataload(0)
// a_2 := g()
// }
// function g() -> x
// {
// x := 8
// leave
// }
// function f(a)
// { a := g() }
// }

View File

@ -0,0 +1,40 @@
{
function f(a, b) -> x {
let t
a := 2
x := 2
t := 2
if b { leave }
a := 8
x := 8
t := 8
}
function g(a, b) -> x {
let t
a := 2
x := 2
t := 2
if b { }
a := 8
x := 8
t := 8
}
}
// ====
// step: redundantAssignEliminator
// ----
// {
// function f(a, b) -> x
// {
// let t
// x := 2
// if b { leave }
// x := 8
// }
// function g(a_1, b_2) -> x_3
// {
// let t_4
// if b_2 { }
// x_3 := 8
// }
// }