-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[compiler-v2] Test cases reduced from the framework showcasing need f…
…or stack optimizations
- Loading branch information
Showing
23 changed files
with
1,790 additions
and
0 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
third_party/move/move-compiler-v2/tests/eager-pushes/eager_load_03.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
============ initial bytecode ================ | ||
|
||
[variant baseline] | ||
fun m::bar($t0: &mut u64) { | ||
0: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun m::baz($t0: u64, $t1: u64) { | ||
0: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
public fun m::foo($t0: u64) { | ||
var $t1: u64 | ||
var $t2: &mut u64 | ||
0: $t1 := m::one() | ||
1: $t2 := borrow_local($t0) | ||
2: m::bar($t2) | ||
3: m::baz($t0, $t1) | ||
4: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun m::one(): u64 { | ||
var $t0: u64 | ||
0: $t0 := 1 | ||
1: return $t0 | ||
} | ||
|
||
============ after LiveVarAnalysisProcessor: ================ | ||
|
||
[variant baseline] | ||
fun m::bar($t0: &mut u64) { | ||
# live vars: $t0 | ||
0: drop($t0) | ||
# live vars: | ||
1: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun m::baz($t0: u64, $t1: u64) { | ||
# live vars: $t0, $t1 | ||
0: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
public fun m::foo($t0: u64) { | ||
var $t1: u64 | ||
var $t2: &mut u64 | ||
# live vars: $t0 | ||
0: $t1 := m::one() | ||
# live vars: $t0, $t1 | ||
1: $t2 := borrow_local($t0) | ||
# live vars: $t0, $t1, $t2 | ||
2: m::bar($t2) | ||
# live vars: $t0, $t1 | ||
3: m::baz($t0, $t1) | ||
# live vars: | ||
4: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun m::one(): u64 { | ||
var $t0: u64 | ||
# live vars: | ||
0: $t0 := 1 | ||
# live vars: $t0 | ||
1: return $t0 | ||
} | ||
|
||
|
||
============ disassembled file-format ================== | ||
// Move bytecode v7 | ||
module c0ffee.m { | ||
|
||
|
||
bar(Arg0: &mut u64) /* def_idx: 0 */ { | ||
B0: | ||
0: MoveLoc[0](Arg0: &mut u64) | ||
1: Pop | ||
2: Ret | ||
} | ||
baz(Arg0: u64, Arg1: u64) /* def_idx: 1 */ { | ||
B0: | ||
0: Ret | ||
} | ||
public foo(Arg0: u64) /* def_idx: 2 */ { | ||
L1: loc0: u64 | ||
B0: | ||
0: Call one(): u64 | ||
1: MutBorrowLoc[0](Arg0: u64) | ||
2: Call bar(&mut u64) | ||
3: StLoc[1](loc0: u64) | ||
4: MoveLoc[0](Arg0: u64) | ||
5: MoveLoc[1](loc0: u64) | ||
6: Call baz(u64, u64) | ||
7: Ret | ||
} | ||
one(): u64 /* def_idx: 3 */ { | ||
B0: | ||
0: LdU64(1) | ||
1: Ret | ||
} | ||
} | ||
============ bytecode verification succeeded ======== |
15 changes: 15 additions & 0 deletions
15
third_party/move/move-compiler-v2/tests/eager-pushes/eager_load_03.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module 0xc0ffee::m { | ||
fun one(): u64 { | ||
1 | ||
} | ||
|
||
fun bar(_x: &mut u64) {} | ||
|
||
fun baz(_x: u64, _y: u64) {} | ||
|
||
public fun foo(x: u64) { | ||
let t = one(); | ||
bar(&mut x); | ||
baz(x, t); | ||
} | ||
} |
142 changes: 142 additions & 0 deletions
142
third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_01.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
============ initial bytecode ================ | ||
|
||
[variant baseline] | ||
fun m::foo() { | ||
0: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun m::one(): u64 { | ||
var $t0: u64 | ||
0: $t0 := 1 | ||
1: return $t0 | ||
} | ||
|
||
|
||
[variant baseline] | ||
public fun m::test($t0: u64) { | ||
var $t1: u64 | ||
var $t2: bool | ||
var $t3: u64 | ||
var $t4: u64 | ||
var $t5: u64 | ||
0: $t1 := m::two() | ||
1: $t4 := infer($t0) | ||
2: $t5 := m::one() | ||
3: $t3 := -($t4, $t5) | ||
4: $t2 := >($t3, $t1) | ||
5: if ($t2) goto 6 else goto 9 | ||
6: label L0 | ||
7: m::foo() | ||
8: goto 10 | ||
9: label L1 | ||
10: label L2 | ||
11: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun m::two(): u64 { | ||
var $t0: u64 | ||
0: $t0 := 2 | ||
1: return $t0 | ||
} | ||
|
||
============ after LiveVarAnalysisProcessor: ================ | ||
|
||
[variant baseline] | ||
fun m::foo() { | ||
# live vars: | ||
0: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun m::one(): u64 { | ||
var $t0: u64 | ||
# live vars: | ||
0: $t0 := 1 | ||
# live vars: $t0 | ||
1: return $t0 | ||
} | ||
|
||
|
||
[variant baseline] | ||
public fun m::test($t0: u64) { | ||
var $t1: u64 | ||
var $t2: bool | ||
var $t3: u64 [unused] | ||
var $t4: u64 [unused] | ||
var $t5: u64 | ||
# live vars: $t0 | ||
0: $t1 := m::two() | ||
# live vars: $t0, $t1 | ||
1: $t5 := m::one() | ||
# live vars: $t0, $t1, $t5 | ||
2: $t0 := -($t0, $t5) | ||
# live vars: $t0, $t1 | ||
3: $t2 := >($t0, $t1) | ||
# live vars: $t2 | ||
4: if ($t2) goto 5 else goto 7 | ||
# live vars: | ||
5: label L0 | ||
# live vars: | ||
6: m::foo() | ||
# live vars: | ||
7: label L2 | ||
# live vars: | ||
8: return () | ||
} | ||
|
||
|
||
[variant baseline] | ||
fun m::two(): u64 { | ||
var $t0: u64 | ||
# live vars: | ||
0: $t0 := 2 | ||
# live vars: $t0 | ||
1: return $t0 | ||
} | ||
|
||
|
||
============ disassembled file-format ================== | ||
// Move bytecode v7 | ||
module c0ffee.m { | ||
|
||
|
||
foo() /* def_idx: 0 */ { | ||
B0: | ||
0: Ret | ||
} | ||
one(): u64 /* def_idx: 1 */ { | ||
B0: | ||
0: LdU64(1) | ||
1: Ret | ||
} | ||
public test(Arg0: u64) /* def_idx: 2 */ { | ||
L1: loc0: u64 | ||
L2: loc1: u64 | ||
B0: | ||
0: Call two(): u64 | ||
1: StLoc[1](loc0: u64) | ||
2: Call one(): u64 | ||
3: StLoc[2](loc1: u64) | ||
4: MoveLoc[0](Arg0: u64) | ||
5: MoveLoc[2](loc1: u64) | ||
6: Sub | ||
7: MoveLoc[1](loc0: u64) | ||
8: Gt | ||
9: BrFalse(11) | ||
B1: | ||
10: Call foo() | ||
B2: | ||
11: Ret | ||
} | ||
two(): u64 /* def_idx: 3 */ { | ||
B0: | ||
0: LdU64(2) | ||
1: Ret | ||
} | ||
} | ||
============ bytecode verification succeeded ======== |
19 changes: 19 additions & 0 deletions
19
third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_01.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module 0xc0ffee::m { | ||
fun one(): u64 { | ||
1 | ||
} | ||
|
||
fun two(): u64 { | ||
2 | ||
} | ||
|
||
fun foo() {} | ||
|
||
public fun test(p: u64) { | ||
let e = two(); | ||
if (p - one() > e) { | ||
foo(); | ||
} | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_02.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
============ initial bytecode ================ | ||
|
||
[variant baseline] | ||
public fun m::make($t0: u64, $t1: u64, $t2: u64, $t3: &m::S, $t4: u64): m::Wrap { | ||
var $t5: m::Wrap | ||
var $t6: u64 | ||
var $t7: &u64 | ||
0: $t7 := borrow_field<m::S>.x($t3) | ||
1: $t6 := read_ref($t7) | ||
2: $t5 := pack m::Wrap($t0, $t1, $t2, $t6, $t4) | ||
3: return $t5 | ||
} | ||
|
||
============ after LiveVarAnalysisProcessor: ================ | ||
|
||
[variant baseline] | ||
public fun m::make($t0: u64, $t1: u64, $t2: u64, $t3: &m::S, $t4: u64): m::Wrap { | ||
var $t5: m::Wrap | ||
var $t6: u64 | ||
var $t7: &u64 | ||
# live vars: $t0, $t1, $t2, $t3, $t4 | ||
0: $t7 := borrow_field<m::S>.x($t3) | ||
# live vars: $t0, $t1, $t2, $t4, $t7 | ||
1: $t6 := read_ref($t7) | ||
# live vars: $t0, $t1, $t2, $t4, $t6 | ||
2: $t5 := pack m::Wrap($t0, $t1, $t2, $t6, $t4) | ||
# live vars: $t5 | ||
3: return $t5 | ||
} | ||
|
||
|
||
============ disassembled file-format ================== | ||
// Move bytecode v7 | ||
module c0ffee.m { | ||
struct S { | ||
x: u64 | ||
} | ||
struct Wrap { | ||
a: u64, | ||
b: u64, | ||
c: u64, | ||
d: u64, | ||
e: u64 | ||
} | ||
|
||
public make(Arg0: u64, Arg1: u64, Arg2: u64, Arg3: &S, Arg4: u64): Wrap /* def_idx: 0 */ { | ||
L5: loc0: u64 | ||
B0: | ||
0: MoveLoc[3](Arg3: &S) | ||
1: ImmBorrowField[0](S.x: u64) | ||
2: ReadRef | ||
3: StLoc[5](loc0: u64) | ||
4: MoveLoc[0](Arg0: u64) | ||
5: MoveLoc[1](Arg1: u64) | ||
6: MoveLoc[2](Arg2: u64) | ||
7: MoveLoc[5](loc0: u64) | ||
8: MoveLoc[4](Arg4: u64) | ||
9: Pack[1](Wrap) | ||
10: Ret | ||
} | ||
} | ||
============ bytecode verification succeeded ======== |
23 changes: 23 additions & 0 deletions
23
third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_02.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module 0xc0ffee::m { | ||
struct Wrap { | ||
a: u64, | ||
b: u64, | ||
c: u64, | ||
d: u64, | ||
e: u64, | ||
} | ||
|
||
struct S { | ||
x: u64, | ||
} | ||
|
||
public fun make(a: u64, b: u64, c: u64, d: &S, e: u64): Wrap { | ||
Wrap { | ||
a, | ||
b, | ||
c, | ||
d: d.x, | ||
e, | ||
} | ||
} | ||
} |
Oops, something went wrong.