Skip to content

Commit c64e7d6

Browse files
committed
Update tests.
1 parent 785e16f commit c64e7d6

File tree

4 files changed

+61
-13
lines changed

4 files changed

+61
-13
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
switch calldataload(0)
3+
case 0 {
4+
recursive()
5+
sstore(0, 1)
6+
}
7+
case 1 {
8+
terminating()
9+
sstore(0, 7)
10+
}
11+
case 2 {
12+
reverting()
13+
sstore(0, 7)
14+
}
15+
16+
17+
function recursive()
18+
{
19+
recursive()
20+
}
21+
function terminating()
22+
{
23+
return(0, 0)
24+
}
25+
function reverting()
26+
{
27+
revert(0, 0)
28+
}
29+
}
30+
// ----
31+
// step: deadCodeEliminator
32+
//
33+
// {
34+
// switch calldataload(0)
35+
// case 0 { recursive() }
36+
// case 1 { terminating() }
37+
// case 2 { reverting() }
38+
// function recursive()
39+
// { recursive() }
40+
// function terminating()
41+
// { return(0, 0) }
42+
// function reverting()
43+
// { revert(0, 0) }
44+
// }

test/libyul/yulOptimizerTests/deadCodeEliminator/function_after_revert.yul

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
function fun()
77
{
8-
return(1, 1)
9-
10-
pop(sub(10, 5))
8+
sstore(0, 1)
119
}
1210

1311
pop(add(1, 1))
@@ -19,5 +17,5 @@
1917
// fun()
2018
// revert(0, 0)
2119
// function fun()
22-
// { return(1, 1) }
20+
// { sstore(0, 1) }
2321
// }

test/libyul/yulOptimizerTests/fullSuite/name_cleaner_reserved.yul

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
// This function name can be shortened, the other cannot.
33
function nonmstore_(x) {
4-
nonmstore_(x)
4+
if calldataload(0) { nonmstore_(x) }
55
sstore(10, calldataload(2))
66
}
77
function mstore_(x) -> y {
8-
let t3_3_ := mstore_(x)
8+
if calldataload(0) { let t3_3_ := mstore_(x) }
99
y := 8
1010
sstore(y, calldataload(y))
1111
}
@@ -22,12 +22,12 @@
2222
// }
2323
// function nonmstore(x)
2424
// {
25-
// nonmstore(x)
25+
// if calldataload(0) { nonmstore(x) }
2626
// sstore(10, calldataload(2))
2727
// }
2828
// function mstore_(x) -> y
2929
// {
30-
// pop(mstore_(x))
30+
// if calldataload(0) { pop(mstore_(x)) }
3131
// y := 8
3232
// sstore(y, calldataload(y))
3333
// }

test/libyul/yulOptimizerTests/fullSuite/unusedFunctionParameterPruner_recursion.yul

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
sstore(1, l)
66
function f(a, b, c) -> x, y, z
77
{
8-
x, y, z := f(1, 2, 3)
8+
if calldataload(0) {
9+
x, y, z := f(1, 2, 3)
10+
}
911
x := add(x, 1)
1012
}
1113
}
@@ -21,9 +23,13 @@
2123
// }
2224
// function f() -> x, y, z
2325
// {
24-
// let x_1, y_1, z_1 := f()
25-
// y := y_1
26-
// z := z_1
27-
// x := add(x_1, 1)
26+
// if calldataload(0)
27+
// {
28+
// let x_1, y_1, z_1 := f()
29+
// x := x_1
30+
// y := y_1
31+
// z := z_1
32+
// }
33+
// x := add(x, 1)
2834
// }
2935
// }

0 commit comments

Comments
 (0)