Skip to content

Commit e954fab

Browse files
committed
Add tests covering function parama variables
1 parent 5bf67dd commit e954fab

3 files changed

Lines changed: 148 additions & 0 deletions

File tree

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
function direct(arg, value)
3+
{
4+
sstore(arg, value)
5+
let v1 := add(value, 1)
6+
sstore(arg, v1)
7+
}
8+
9+
function indirect(arg, value)
10+
{
11+
let loc := arg
12+
sstore(loc, value)
13+
let value1 := add(value, 1)
14+
sstore(loc, value1)
15+
}
16+
}
17+
// ----
18+
// step: unusedStoreEliminatorNoSsaTransform
19+
//
20+
// {
21+
// { }
22+
// function direct(arg, value)
23+
// { sstore(arg, add(value, 1)) }
24+
// function indirect(arg_1, value_2)
25+
// {
26+
// let loc := arg_1
27+
// sstore(loc, add(value_2, 1))
28+
// }
29+
// }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
function direct(arg, value)
3+
{
4+
sstore(arg, value)
5+
pop(sload(arg))
6+
let value1 := add(value, 1)
7+
sstore(arg, value1)
8+
}
9+
10+
function indirect(arg, value)
11+
{
12+
let loc := arg
13+
sstore(loc, value)
14+
pop(sload(arg))
15+
let value1 := add(value, 1)
16+
sstore(loc, value1)
17+
}
18+
19+
function mix_elimination(arg, value)
20+
{
21+
let loc := add(arg, 1)
22+
sstore(arg, value)
23+
pop(sload(loc))
24+
let value1 := add(value, 1)
25+
sstore(arg, value1)
26+
}
27+
28+
function mix_no_elimination(arg, value)
29+
{
30+
let loc := arg
31+
sstore(arg, value)
32+
pop(sload(loc))
33+
let value1 := add(value, 1)
34+
sstore(arg, value1)
35+
}
36+
}
37+
// ----
38+
// step: unusedStoreEliminatorNoSsaTransform
39+
//
40+
// {
41+
// { }
42+
// function direct(arg, value)
43+
// {
44+
// sstore(arg, value)
45+
// pop(sload(arg))
46+
// sstore(arg, add(value, 1))
47+
// }
48+
// function indirect(arg_1, value_2)
49+
// {
50+
// let loc := arg_1
51+
// sstore(loc, value_2)
52+
// pop(sload(arg_1))
53+
// sstore(loc, add(value_2, 1))
54+
// }
55+
// function mix_elimination(arg_4, value_5)
56+
// {
57+
// pop(sload(add(arg_4, 1)))
58+
// sstore(arg_4, add(value_5, 1))
59+
// }
60+
// function mix_no_elimination(arg_8, value_9)
61+
// {
62+
// let loc_10 := arg_8
63+
// sstore(arg_8, value_9)
64+
// pop(sload(loc_10))
65+
// sstore(arg_8, add(value_9, 1))
66+
// }
67+
// }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
function direct(arg, value)
3+
{
4+
sstore(arg, value)
5+
arg := add(arg, 1)
6+
let value1 := add(value, 1)
7+
sstore(arg, value1)
8+
}
9+
10+
function indirect(arg, value)
11+
{
12+
let loc := arg
13+
sstore(loc, value)
14+
loc := add(loc, 1)
15+
let value1 := add(value, 1)
16+
sstore(loc, value1)
17+
}
18+
19+
function mix(arg, value)
20+
{
21+
let loc := arg
22+
// It should be eliminated, because the location is the same, but if we look at the result, second pass of the
23+
// optimizer will eliminate properly first `sstore`.
24+
sstore(loc, value)
25+
let value1 := add(value, 1)
26+
sstore(arg, value1)
27+
}
28+
}
29+
// ----
30+
// step: unusedStoreEliminatorNoSsaTransform
31+
//
32+
// {
33+
// { }
34+
// function direct(arg, value)
35+
// {
36+
// sstore(arg, value)
37+
// arg := add(arg, 1)
38+
// sstore(arg, add(value, 1))
39+
// }
40+
// function indirect(arg_1, value_2)
41+
// {
42+
// let loc := arg_1
43+
// sstore(loc, value_2)
44+
// loc := add(loc, 1)
45+
// sstore(loc, add(value_2, 1))
46+
// }
47+
// function mix(arg_4, value_5)
48+
// {
49+
// sstore(arg_4, value_5)
50+
// sstore(arg_4, add(value_5, 1))
51+
// }
52+
// }

0 commit comments

Comments
 (0)