From aa1195c40fcdec3a7c107726ef968f35e32b1248 Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Tue, 21 Jan 2025 20:56:07 -0500 Subject: [PATCH] [compiler-v2] Showcase fixes for several old issues --- .../file-format-generator/issue_12404.exp | 31 +++++++++++++++++++ .../file-format-generator/issue_12404.move | 14 +++++++++ .../file-format-generator/issue_12404.opt.exp | 31 +++++++++++++++++++ .../file-format-generator/issue_12540.exp | 31 +++++++++++++++++++ .../file-format-generator/issue_12540.move | 11 +++++++ .../file-format-generator/issue_12540.opt.exp | 28 +++++++++++++++++ .../file-format-generator/issue_14243.exp | 30 ++++++++++++++++++ .../file-format-generator/issue_14243.move | 13 ++++++++ .../file-format-generator/issue_14243.opt.exp | 30 ++++++++++++++++++ .../tests/misc/issue_11022.exp | 14 +++++++++ .../tests/misc/issue_11022.move | 16 ++++++++++ 11 files changed, 249 insertions(+) create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.exp create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.move create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.opt.exp create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.exp create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.move create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.opt.exp create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.exp create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.move create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.opt.exp create mode 100644 third_party/move/move-compiler-v2/transactional-tests/tests/misc/issue_11022.exp create mode 100644 third_party/move/move-compiler-v2/transactional-tests/tests/misc/issue_11022.move diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.exp new file mode 100644 index 0000000000000..2edfc3d8c68cf --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.exp @@ -0,0 +1,31 @@ + +============ disassembled file-format ================== +// Move bytecode v8 +module c0ffee.m { + + +public test(): u64 /* def_idx: 0 */ { +B0: + 0: LdU64(2) + 1: Call test1(u64): u64 + 2: LdU64(5) + 3: Call test2(u64): u64 + 4: Add + 5: Ret +} +test1(Arg0: u64): u64 /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: LdU64(1) + 2: Add + 3: Ret +} +test2(Arg0: u64): u64 /* def_idx: 2 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: LdU64(2) + 2: Add + 3: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.move b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.move new file mode 100644 index 0000000000000..ef48682000bf8 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.move @@ -0,0 +1,14 @@ +// Example taken from https://github.com/aptos-labs/aptos-core/issues/12404#issuecomment-2004040746 +module 0xc0ffee::m { + fun test1(x: u64): u64 { + x + 1 + } + + fun test2(x: u64): u64 { + x + 2 + } + + public fun test(): u64 { + test1(2) + test2(5) + } +} diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.opt.exp new file mode 100644 index 0000000000000..2edfc3d8c68cf --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12404.opt.exp @@ -0,0 +1,31 @@ + +============ disassembled file-format ================== +// Move bytecode v8 +module c0ffee.m { + + +public test(): u64 /* def_idx: 0 */ { +B0: + 0: LdU64(2) + 1: Call test1(u64): u64 + 2: LdU64(5) + 3: Call test2(u64): u64 + 4: Add + 5: Ret +} +test1(Arg0: u64): u64 /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: LdU64(1) + 2: Add + 3: Ret +} +test2(Arg0: u64): u64 /* def_idx: 2 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: LdU64(2) + 2: Add + 3: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.exp new file mode 100644 index 0000000000000..d238f9dfcd45d --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.exp @@ -0,0 +1,31 @@ + +============ disassembled file-format ================== +// Move bytecode v8 +module c0ffee.m { + + +public point_add_assign(Arg0: &mut u64, Arg1: &u64): &mut u64 /* def_idx: 0 */ { +L2: loc0: &mut u64 +B0: + 0: CopyLoc[0](Arg0: &mut u64) + 1: FreezeRef + 2: MoveLoc[1](Arg1: &u64) + 3: LdTrue + 4: Call point_add_internal(&u64, &u64, bool): u64 + 5: MoveLoc[0](Arg0: &mut u64) + 6: StLoc[2](loc0: &mut u64) + 7: Pop + 8: MoveLoc[2](loc0: &mut u64) + 9: Ret +} +point_add_internal(Arg0: &u64, Arg1: &u64, Arg2: bool): u64 /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: &u64) + 1: ReadRef + 2: MoveLoc[1](Arg1: &u64) + 3: ReadRef + 4: Add + 5: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.move b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.move new file mode 100644 index 0000000000000..c58f7ce8fbacd --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.move @@ -0,0 +1,11 @@ +// Code example taken from https://github.com/aptos-labs/aptos-core/issues/12540 +module 0xc0ffee::m { + fun point_add_internal(a: &u64, b: &u64, _in_place: bool): u64 { + *a + *b + } + + public fun point_add_assign(a: &mut u64, b: &u64): &mut u64 { + point_add_internal(a, b, true); + a + } +} diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.opt.exp new file mode 100644 index 0000000000000..1adc7d764d872 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_12540.opt.exp @@ -0,0 +1,28 @@ + +============ disassembled file-format ================== +// Move bytecode v8 +module c0ffee.m { + + +public point_add_assign(Arg0: &mut u64, Arg1: &u64): &mut u64 /* def_idx: 0 */ { +B0: + 0: CopyLoc[0](Arg0: &mut u64) + 1: FreezeRef + 2: MoveLoc[1](Arg1: &u64) + 3: LdTrue + 4: Call point_add_internal(&u64, &u64, bool): u64 + 5: Pop + 6: MoveLoc[0](Arg0: &mut u64) + 7: Ret +} +point_add_internal(Arg0: &u64, Arg1: &u64, Arg2: bool): u64 /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: &u64) + 1: ReadRef + 2: MoveLoc[1](Arg1: &u64) + 3: ReadRef + 4: Add + 5: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.exp new file mode 100644 index 0000000000000..ea241604569a6 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.exp @@ -0,0 +1,30 @@ + +============ disassembled file-format ================== +// Move bytecode v8 +module c0ffee.m { + + +id_mut(Arg0: &mut Ty0): &mut Ty0 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: &mut Ty0) + 1: Ret +} +t0() /* def_idx: 1 */ { +L0: loc0: u64 +L1: loc1: &mut u64 +B0: + 0: LdU64(0) + 1: StLoc[0](loc0: u64) + 2: MutBorrowLoc[0](loc0: u64) + 3: StLoc[1](loc1: &mut u64) + 4: CopyLoc[1](loc1: &mut u64) + 5: Call id_mut(&mut u64): &mut u64 + 6: ReadRef + 7: MoveLoc[1](loc1: &mut u64) + 8: ReadRef + 9: Pop + 10: Pop + 11: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.move b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.move new file mode 100644 index 0000000000000..9b68029dcaa1b --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.move @@ -0,0 +1,13 @@ +// Example taken from https://github.com/aptos-labs/aptos-core/issues/14243 +module 0xc0ffee::m { + fun id_mut(r: &mut T): &mut T { + r + } + + fun t0() { + let x = &mut 0; + let y = id_mut(x); + *y; + *x; + } +} diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.opt.exp new file mode 100644 index 0000000000000..5df7d4d578d5a --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/issue_14243.opt.exp @@ -0,0 +1,30 @@ + +============ disassembled file-format ================== +// Move bytecode v8 +module c0ffee.m { + + +id_mut(Arg0: &mut Ty0): &mut Ty0 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: &mut Ty0) + 1: Ret +} +t0() /* def_idx: 1 */ { +L0: loc0: u64 +L1: loc1: &mut u64 +B0: + 0: LdU64(0) + 1: StLoc[0](loc0: u64) + 2: MutBorrowLoc[0](loc0: u64) + 3: StLoc[1](loc1: &mut u64) + 4: CopyLoc[1](loc1: &mut u64) + 5: Call id_mut(&mut u64): &mut u64 + 6: ReadRef + 7: Pop + 8: MoveLoc[1](loc1: &mut u64) + 9: ReadRef + 10: Pop + 11: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/misc/issue_11022.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/issue_11022.exp new file mode 100644 index 0000000000000..8469fa11de6e3 --- /dev/null +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/issue_11022.exp @@ -0,0 +1,14 @@ +comparison between v1 and v2 failed: +- processed 2 tasks +- +- task 1 'publish'. lines 11-16: +- Error: bug[ICE12001]: BYTECODE GENERATION FAILED +- ┌─ TEMPFILE1:12:18 +- │ +- 12 │ module 0xc0ffee::dummy2 { +- │ ^^^^^^ IR ERROR: Missing constant definition for CC +- +- +- ++ processed 2 tasks ++ diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/misc/issue_11022.move b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/issue_11022.move new file mode 100644 index 0000000000000..3889ca39302ef --- /dev/null +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/issue_11022.move @@ -0,0 +1,16 @@ +// Example taken from https://github.com/aptos-labs/aptos-core/issues/11022 +//# publish +module 0xc0ffee::dummy1 { + const CC: u64 = 1; + + public inline fun expose(): u64 { + CC + } +} + +//# publish +module 0xc0ffee::dummy2 { + public fun main(): u64 { + 0xc0ffee::dummy1::expose() + } +}