From 34025227eb5367c449bf9dae3cd226fe5c187904 Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Mon, 16 Dec 2024 14:58:52 -0500 Subject: [PATCH 1/5] Cherry pick certain optimization PRs (#15612) * Creating temps for each arg. (#15514) * [compiler-v2] Enable recent stack-optimizations by default (#15595) --- .../aptos_test_harness/diamond_clicker.v2_exp | 68 +- .../tests/compiler-v2-doc/aptos_governance.md | 3 + .../tests/compiler-v2-doc/coin.md | 166 +- .../tests/compiler-v2-doc/genesis.md | 2 +- .../tests/compiler-v2-doc/staking_config.md | 15 + .../tests/compiler-v2-doc/features.md | 68 + .../tests/compiler-v2-doc/vector.md | 131 +- .../src/bytecode_generator.rs | 9 +- .../move/move-compiler-v2/src/experiments.rs | 6 - .../function_generator.rs | 18 +- third_party/move/move-compiler-v2/src/lib.rs | 4 +- .../src/pipeline/dead_store_elimination.rs | 76 +- .../src/pipeline/flush_writes_processor.rs | 143 +- .../tests/ability-check/bug_14189.exp | 7 +- .../tests/ability-check/operator_drop.exp | 8 +- .../ability-check/typing/eq_invalid2.exp | 11 +- .../ability-check/typing/neq_invalid2.exp | 6 +- .../borrowed_from_one_path.exp | 604 +++++-- .../tests/ability-transform/by_reference.exp | 751 +++++++++ .../ability-transform/copy_ability_tuple.exp | 221 ++- .../ability-transform/dead_but_borrowed.exp | 86 + .../ability-transform/destroy_after_call.exp | 172 ++ .../ability-transform/drop_after_loop.exp | 436 ++++- .../ability-transform/drop_at_branch.exp | 117 ++ .../foreach_mut_expanded.exp | 938 ++++++++--- .../tests/ability-transform/mutate_return.exp | 138 ++ .../tests/ability-transform/mutate_vector.exp | 198 +++ .../tests/bytecode-generator/assign.exp | 54 +- .../bytecode-generator/assign_inline.exp | 12 + .../tests/bytecode-generator/borrow.exp | 70 + .../borrow_deref_optimize.exp | 60 + .../bug_14300_update_variant_select.exp | 121 ++ .../bug_14300_variant_select_autoref.exp | 26 + .../bug_14471_receiver_inference.exp | 70 +- .../tests/bytecode-generator/bug_14629.exp | 29 + .../bytecode-generator/conditional_borrow.exp | 345 +++- .../bytecode-generator/escape_autoref.exp | 46 + .../tests/bytecode-generator/fields.exp | 122 ++ .../bytecode-generator/freeze_mut_ref.exp | 257 ++- .../tests/bytecode-generator/globals.exp | 57 +- .../tests/bytecode-generator/if_else.exp | 133 +- .../tests/bytecode-generator/inline_specs.exp | 34 +- .../tests/bytecode-generator/loop.exp | 266 ++- .../tests/bytecode-generator/loop_labels.exp | 14 + .../tests/bytecode-generator/matching_ok.exp | 20 +- .../matching_refutable_err.exp | 19 + .../tests/bytecode-generator/operators.exp | 264 ++- .../tests/bytecode-generator/pack_order.exp | 106 +- .../tests/bytecode-generator/pack_unpack.exp | 37 +- .../reference_conversion.exp | 28 + .../bytecode-generator/spec_construct.exp | 21 + .../tests/bytecode-generator/vector.exp | 11 + .../tests/bytecode-generator/wildcard5.exp | 19 + .../bytecode-verify-failure/equality.exp | 24 +- .../bug-10253.off.exp | 4 - .../bug-10253.on.exp | 168 +- .../jump-label.off.exp | 25 +- .../jump-label.on.exp | 25 +- .../args_with_side_effects.exp | 40 +- .../tests/copy-propagation/branch_1.exp | 16 +- .../tests/copy-propagation/bug_12068.exp | 84 +- .../tests/copy-propagation/loop_1.exp | 62 +- .../tests/copy-propagation/loop_2.exp | 62 +- .../tests/copy-propagation/seq_kills_1.exp | 26 +- .../tests/copy-propagation/seq_kills_2.exp | 26 +- .../copy-propagation/straight_line_kills.exp | 26 +- .../tests/eager-pushes/eager_load_03.exp | 19 +- .../eager-pushes/framework_reduced_01.exp | 43 +- .../eager-pushes/framework_reduced_02.exp | 62 +- .../eager-pushes/framework_reduced_03.exp | 92 +- .../eager-pushes/framework_reduced_04.exp | 29 +- .../eager-pushes/framework_reduced_05.exp | 95 +- .../eager-pushes/framework_reduced_06.exp | 107 +- .../eager-pushes/framework_reduced_07.exp | 97 +- .../eager-pushes/framework_reduced_08.exp | 97 +- .../eager-pushes/framework_reduced_09.exp | 116 +- .../eager-pushes/framework_reduced_10.exp | 221 +-- .../eager-pushes/move_stdlib_reduced.exp | 85 +- .../tests/eager-pushes/txn_reduced_01.exp | 179 +- .../tests/file-format-generator/assign.exp | 8 +- .../tests/file-format-generator/bug_14762.exp | 100 +- .../file-format-generator/bug_14762.opt.exp | 47 +- .../tests/file-format-generator/const.exp | 5 +- .../file-format-generator/eager_push_01.exp | 28 + .../file-format-generator/eager_push_01.move | 11 + .../eager_push_01.opt.exp | 28 + .../file-format-generator/eager_push_02.exp | 17 + .../file-format-generator/eager_push_02.move | 5 + .../eager_push_02.opt.exp | 17 + .../tests/file-format-generator/fields.exp | 15 +- .../file-format-generator/fields.opt.exp | 14 +- .../framework_reduced_06.exp | 70 +- .../framework_reduced_06.opt.exp | 22 +- .../file-format-generator/generic_call.exp | 5 +- .../tests/file-format-generator/globals.exp | 13 +- .../file-format-generator/globals.opt.exp | 22 +- .../tests/file-format-generator/if_else.exp | 96 +- .../file-format-generator/if_else.opt.exp | 2 - .../tests/file-format-generator/loop.exp | 167 +- .../tests/file-format-generator/loop.opt.exp | 3 - .../tests/file-format-generator/multi_use.exp | 15 +- .../file-format-generator/multi_use.opt.exp | 1 - .../tests/file-format-generator/operators.exp | 26 +- .../file-format-generator/operators.opt.exp | 25 +- .../file-format-generator/opt_load_01.exp | 119 +- .../file-format-generator/opt_load_01.opt.exp | 14 - .../file-format-generator/opt_load_02.exp | 185 +- .../file-format-generator/opt_load_02.opt.exp | 72 +- .../file-format-generator/opt_load_04.exp | 16 +- .../file-format-generator/opt_load_04.opt.exp | 2 - .../file-format-generator/opt_load_05.exp | 45 +- .../file-format-generator/opt_load_05.opt.exp | 7 +- .../file-format-generator/pack_order.exp | 86 +- .../file-format-generator/pack_unpack.exp | 23 +- .../file-format-generator/pack_unpack.opt.exp | 13 +- .../pack_unpack_ref.opt.exp | 29 +- .../file-format-generator/struct_variants.exp | 118 +- .../unpack_generic_struct.exp | 30 +- .../unpack_generic_struct_typed.exp | 30 +- .../tests/file-format-generator/vector.exp | 106 +- .../file-format-generator/vector.opt.exp | 5 +- .../tests/flush-writes/def_use_01.on.exp | 1 + .../tests/flush-writes/def_use_02.on.exp | 1 + .../tests/flush-writes/def_use_03.on.exp | 7 +- .../tests/flush-writes/def_use_04.on.exp | 7 +- .../tests/flush-writes/def_use_05.on.exp | 1 + .../tests/flush-writes/def_use_06.on.exp | 8 +- .../tests/flush-writes/def_use_07.off.exp | 1 - .../tests/flush-writes/def_use_07.on.exp | 14 +- .../tests/flush-writes/def_use_08.on.exp | 3 + .../tests/flush-writes/in_order_use_01.move | 26 + .../flush-writes/in_order_use_01.off.exp | 29 + .../tests/flush-writes/in_order_use_01.on.exp | 83 + .../tests/flush-writes/loop_01.off.exp | 1 - .../tests/flush-writes/loop_01.on.exp | 32 +- .../tests/flush-writes/loop_02.off.exp | 2 - .../tests/flush-writes/loop_02.on.exp | 33 +- .../flush-writes/out_of_order_use_01.on.exp | 6 + .../flush-writes/out_of_order_use_02.off.exp | 13 +- .../flush-writes/out_of_order_use_02.on.exp | 8 +- .../flush-writes/out_of_order_use_03.off.exp | 13 +- .../flush-writes/out_of_order_use_03.on.exp | 21 +- .../flush-writes/out_of_order_use_04.on.exp | 9 +- .../flush-writes/unused_flush_early_02.on.exp | 15 +- .../flush-writes/unused_flush_early_03.on.exp | 56 +- .../inline-parity/non_lambda_arg.lambda.exp | 68 +- .../tests/lambda/non_lambda_arg.lambda.exp | 68 +- .../tests/live-var/bug_9717_looponly.exp | 787 +++++++-- .../tests/live-var/mut_inline.exp | 1484 ++++++++++++++--- .../tests/live-var/mut_inline_typed.exp | 1484 ++++++++++++++--- .../tests/live-var/mut_ref.exp | 232 ++- .../tests/more-v1/liveness/mut_ref.exp | 4 +- .../more-v1/locals/use_after_move_if.exp | 2 +- .../more-v1/locals/use_after_move_if_else.exp | 6 +- .../more-v1/locals/use_after_move_simple.exp | 2 +- .../commands/branch_assigns_then_moves.exp | 2 +- .../move/commands/else_moves_if_doesnt.exp | 2 +- .../move/commands/if_moves_else_doesnt.exp | 2 +- .../move/commands/if_moves_no_else.exp | 2 +- .../moved_var_not_simplified.exp | 2 +- .../tests/op-equal/eval_order.exp | 159 +- .../tests/op-equal/invalid1.exp | 28 +- .../tests/op-equal/valid0.exp | 105 +- .../tests/op-equal/valid1.exp | 53 +- .../tests/reference-safety/duplicate_use.exp | 4 +- .../reference-safety/duplicate_use.no-opt.exp | 4 +- .../reference-safety/duplicate_use.old.exp | 4 +- .../tests/reference-safety/freeze.exp | 4 +- .../tests/reference-safety/freeze.no-opt.exp | 4 +- .../tests/reference-safety/freeze.old.exp | 4 +- .../reference-safety/multiple_use_invalid.exp | 2 +- .../multiple_use_invalid.no-opt.exp | 2 +- .../multiple_use_invalid.old.exp | 13 +- .../v1-borrow-tests/factor_invalid_1.exp | 2 +- .../factor_invalid_1.no-opt.exp | 2 +- .../v1-borrow-tests/factor_invalid_1.old.exp | 12 + .../imm_borrow_global_invalid.exp | 4 +- .../imm_borrow_global_invalid.no-opt.exp | 4 +- .../v1-borrow-tests/imm_borrow_loc.old.exp | 6 +- .../imm_borrow_loc_valid.old.exp | 4 +- .../v1-tests/call_mutual_borrows_invalid.exp | 12 +- .../call_mutual_borrows_invalid.no-opt.exp | 12 +- .../call_mutual_borrows_invalid.old.exp | 60 +- .../v1-tests/copy_full_invalid.exp | 4 +- .../v1-tests/copy_full_invalid.no-opt.exp | 4 +- .../v1-tests/copy_full_invalid.old.exp | 8 +- .../else_assigns_if_doesnt.exp | 2 +- .../if_assigns_else_doesnt.exp | 2 +- .../moved_var_not_simplified.exp | 2 +- .../use_before_assign_loop.exp | 2 +- .../simplifier/moved_var_not_simplified.exp | 2 +- .../move/move-compiler-v2/tests/testsuite.rs | 25 +- .../uninit-use-checker/assign_both_branch.exp | 25 + .../assign_in_one_if_branch_unfoldable.exp | 43 +- ...ign_wrong_if_branch_no_else_unfoldable.exp | 79 +- .../assign_wrong_if_branch_unfoldable.exp | 79 +- .../else_assigns_if_doesnt_unfoldable.exp | 85 +- .../if_assigns_else_doesnt_unfoldable.exp | 85 +- .../if_assigns_no_else_unfoldable.exp | 79 +- .../tests/uninit-use-checker/no_error.exp | 69 +- .../use_twice_before_assign.exp | 19 +- .../uninit-use-checker/uses_before_assign.exp | 15 +- .../v1-borrows/eq_unassigned_local.exp | 31 +- .../v1-commands/assign_in_one_if_branch.exp | 47 +- .../v1-commands/assign_wrong_if_branch.exp | 81 +- .../assign_wrong_if_branch_no_else.exp | 81 +- .../v1-commands/else_assigns_if_doesnt.exp | 87 +- .../v1-commands/if_assigns_else_doesnt.exp | 87 +- .../v1-commands/if_assigns_no_else.exp | 81 +- .../v1-locals/use_before_assign_if.exp | 43 +- .../v1-locals/use_before_assign_loop.exp | 85 +- .../v1-locals/use_before_assign_simple.exp | 41 +- .../unreachable-code-remover/abort_only.exp | 11 + .../abort_or_return_always.exp | 17 + .../always_false_branch.exp | 83 +- .../break_unreachable.exp | 159 +- .../conditional_loop_unreachable.exp | 70 +- .../inter_procedural_abort.exp | 56 +- .../loop_unreachable.exp | 10 + .../return_after_abort.exp | 11 + .../args_with_side_effects.exp | 109 +- .../args_with_side_effects.opt.exp | 109 +- .../tests/variable-coalescing/branch_1.exp | 64 +- .../variable-coalescing/branch_1.opt.exp | 64 +- .../tests/variable-coalescing/bug_12068.exp | 211 +-- .../variable-coalescing/bug_12068.opt.exp | 211 +-- .../tests/variable-coalescing/call_1.exp | 8 +- .../tests/variable-coalescing/call_1.opt.exp | 8 +- .../tests/variable-coalescing/call_2.exp | 13 +- .../tests/variable-coalescing/call_2.opt.exp | 13 +- .../variable-coalescing/cant_coalesce_1.exp | 62 +- .../cant_coalesce_1.opt.exp | 44 +- .../cant_copy_propagate.exp | 72 +- .../cant_copy_propagate.opt.exp | 72 +- .../tests/variable-coalescing/conditional.exp | 67 +- .../tests/variable-coalescing/consume_2.exp | 10 +- .../variable-coalescing/consume_2.opt.exp | 10 +- .../variable-coalescing/cyclic_dead_store.exp | 315 ++-- .../cyclic_dead_store.opt.exp | 315 ++-- .../variable-coalescing/dead_assignment_1.exp | 3 +- .../dead_assignment_1.opt.exp | 3 +- .../variable-coalescing/dead_assignment_2.exp | 3 +- .../dead_assignment_2.opt.exp | 3 +- .../variable-coalescing/dead_assignment_4.exp | 3 +- .../dead_assignment_4.opt.exp | 3 +- .../variable-coalescing/intermingled_1.exp | 64 +- .../intermingled_1.opt.exp | 59 +- .../variable-coalescing/intermingled_2.exp | 109 +- .../intermingled_2.opt.exp | 91 +- .../variable-coalescing/intermingled_3.exp | 84 +- .../intermingled_3.opt.exp | 59 +- .../tests/variable-coalescing/loop_1.exp | 176 +- .../tests/variable-coalescing/loop_1.opt.exp | 176 +- .../tests/variable-coalescing/loop_2.exp | 182 +- .../tests/variable-coalescing/loop_2.opt.exp | 182 +- .../non_overlapping_vars1.exp | 106 +- .../non_overlapping_vars1.opt.exp | 106 +- .../non_overlapping_vars_diff_type.exp | 122 +- .../non_overlapping_vars_diff_type.opt.exp | 122 +- .../variable-coalescing/overlapping_vars.exp | 37 +- .../variable-coalescing/reassigned_var.exp | 29 +- .../reassigned_var.opt.exp | 49 +- .../variable-coalescing/self_assigns.exp | 319 ++-- .../variable-coalescing/self_assigns.opt.exp | 319 ++-- .../tests/variable-coalescing/seq_kills_1.exp | 82 +- .../variable-coalescing/seq_kills_1.opt.exp | 82 +- .../tests/variable-coalescing/seq_kills_2.exp | 82 +- .../variable-coalescing/seq_kills_2.opt.exp | 82 +- .../sequential_assign_struct.exp | 3 +- .../sequential_assign_struct.opt.exp | 3 +- .../simple_sequential_assign.exp | 3 +- .../simple_sequential_assign.opt.exp | 3 +- .../straight_line_kills.exp | 78 +- .../straight_line_kills.opt.exp | 78 +- .../tests/variable-coalescing/swap.exp | 10 +- .../tests/variable-coalescing/swap.opt.exp | 10 +- .../variable-coalescing/swap_in_a_loop.exp | 205 ++- .../swap_in_a_loop.opt.exp | 205 ++- .../tests/variable-coalescing/unused_add.exp | 29 +- .../tests/inlining/deep_exp.no-optimize.exp | 29 +- .../tests/misc/bitwise_features.exp | 3 + .../tests/misc/bitwise_features.move | 58 + .../misc/bug_14243_stack_size.no-optimize.exp | 6 +- .../tests/misc/vector_popback.exp | 3 + .../tests/misc/vector_popback.move | 37 + .../assert_one.no-optimize.exp | 2 +- .../tests/abort_example.exp | 111 +- .../tests/bit_vector_loop_example.exp | 988 +++++------ .../tests/conditionals.exp | 130 +- .../ast-generator-tests/tests/loops.exp | 379 +++-- .../functional/ModifiesErrorTest.v2_exp | 1 - .../functional/ModifiesSchemaTest.v2_exp | 2 +- .../sources/functional/address_quant.v2_exp | 1 - .../functional/bitwise_features.v2_exp | 12 + .../tests/sources/functional/choice.v2_exp | 3 - .../data_invariant_for_mut_ref_arg.v2_exp | 2 - .../functional/data_invariant_in_map.v2_exp | 2 +- .../tests/sources/functional/emits.v2_exp | 19 - .../functional/fixed_point_arithm.v2_exp | 8 - .../functional/global_invariants.v2_exp | 1 - .../sources/functional/global_vars.v2_exp | 1 - .../sources/functional/loop_unroll.v2_exp | 12 - .../tests/sources/functional/loops.v2_exp | 8 - .../functional/loops_with_memory_ops.v2_exp | 3 - .../functional/macro_verification.v2_exp | 8 - .../functional/module_level_spec.v2_exp | 1 - .../tests/sources/functional/mut_ref.v2_exp | 1 - .../functional/nested_invariants.v2_exp | 4 +- .../functional/script_incorrect.v2_exp | 2 - .../sources/functional/specs_in_fun.v2_exp | 1 - .../sources/functional/strong_edges.v2_exp | 2 +- .../tests/sources/functional/trace.v2_exp | 6 +- .../tests/sources/regression/Escape.v2_exp | 2 - .../mono_after_global_invariant.v2_exp | 2 - .../regression/type_param_bug_121721.v2_exp | 1 - .../vector_theory_boogie_array.v2_exp | 2 +- .../move-decompiler/tests/bit_vector.exp | 72 +- .../move-decompiler/tests/fixed_point32.exp | 6 +- .../move-decompiler/tests/simple_map.exp | 24 +- .../tools/move-decompiler/tests/string.exp | 14 +- .../tools/move-decompiler/tests/vector.exp | 22 +- 321 files changed, 16625 insertions(+), 7393 deletions(-) create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.exp create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.move create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.opt.exp create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.exp create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.move create mode 100644 third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.opt.exp create mode 100644 third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.move create mode 100644 third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.off.exp create mode 100644 third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.on.exp create mode 100644 third_party/move/move-compiler-v2/transactional-tests/tests/misc/bitwise_features.exp create mode 100644 third_party/move/move-compiler-v2/transactional-tests/tests/misc/bitwise_features.move create mode 100644 third_party/move/move-compiler-v2/transactional-tests/tests/misc/vector_popback.exp create mode 100644 third_party/move/move-compiler-v2/transactional-tests/tests/misc/vector_popback.move create mode 100644 third_party/move/move-prover/tests/sources/functional/bitwise_features.v2_exp diff --git a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/diamond_clicker.v2_exp b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/diamond_clicker.v2_exp index 0a49bf4ec95ce..6da8712401946 100644 --- a/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/diamond_clicker.v2_exp +++ b/aptos-move/aptos-transactional-test-harness/tests/aptos_test_harness/diamond_clicker.v2_exp @@ -15,49 +15,45 @@ struct OuterStruct has key { } entry public test_upgrade(Arg0: &signer) /* def_idx: 0 */ { -L1: loc0: OuterStruct -L2: loc1: &mut vector +L1: loc0: &mut vector +L2: loc1: u64 L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: 0: CopyLoc[0](Arg0: &signer) 1: Call signer::address_of(&signer): address - 2: VecPack(3, 0) - 3: Pack[1](OuterStruct) - 4: StLoc[1](loc0: OuterStruct) - 5: MoveLoc[0](Arg0: &signer) - 6: MoveLoc[1](loc0: OuterStruct) - 7: MoveTo[1](OuterStruct) - 8: MutBorrowGlobal[1](OuterStruct) - 9: MutBorrowField[0](OuterStruct.any_field: vector) - 10: StLoc[2](loc1: &mut vector) - 11: LdU64(0) - 12: StLoc[3](loc2: u64) - 13: CopyLoc[2](loc1: &mut vector) - 14: FreezeRef - 15: VecLen(3) - 16: StLoc[4](loc3: u64) + 2: MoveLoc[0](Arg0: &signer) + 3: VecPack(3, 0) + 4: Pack[1](OuterStruct) + 5: MoveTo[1](OuterStruct) + 6: MutBorrowGlobal[1](OuterStruct) + 7: MutBorrowField[0](OuterStruct.any_field: vector) + 8: StLoc[1](loc0: &mut vector) + 9: LdU64(0) + 10: StLoc[2](loc1: u64) + 11: CopyLoc[1](loc0: &mut vector) + 12: FreezeRef + 13: VecLen(3) + 14: StLoc[3](loc2: u64) B1: - 17: CopyLoc[3](loc2: u64) - 18: CopyLoc[4](loc3: u64) - 19: Lt - 20: BrFalse(31) + 15: CopyLoc[2](loc1: u64) + 16: CopyLoc[3](loc2: u64) + 17: Lt + 18: BrFalse(29) B2: - 21: CopyLoc[2](loc1: &mut vector) - 22: CopyLoc[3](loc2: u64) - 23: VecMutBorrow(3) - 24: FreezeRef - 25: Call debug::print(&InnerStruct) - 26: MoveLoc[3](loc2: u64) - 27: LdU64(1) - 28: Add - 29: StLoc[3](loc2: u64) - 30: Branch(17) + 19: CopyLoc[1](loc0: &mut vector) + 20: CopyLoc[2](loc1: u64) + 21: VecMutBorrow(3) + 22: FreezeRef + 23: Call debug::print(&InnerStruct) + 24: MoveLoc[2](loc1: u64) + 25: LdU64(1) + 26: Add + 27: StLoc[2](loc1: u64) + 28: Branch(15) B3: - 31: MoveLoc[2](loc1: &mut vector) - 32: Pop - 33: Ret + 29: MoveLoc[1](loc0: &mut vector) + 30: Pop + 31: Ret } } diff --git a/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/aptos_governance.md b/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/aptos_governance.md index 64445190ff092..05b579a9fc508 100644 --- a/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/aptos_governance.md +++ b/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/aptos_governance.md @@ -883,6 +883,7 @@ This function is private because it's called directly from the vm. system_addresses::assert_aptos_framework(aptos_framework); voting::register<GovernanceProposal>(aptos_framework); + initialize_partial_voting(aptos_framework); move_to(aptos_framework, GovernanceConfig { voting_duration_secs, min_voting_threshold, @@ -2132,6 +2133,7 @@ Limit addition overflow. ensures exists<GovernanceEvents>(addr); ensures exists<VotingRecords>(addr); ensures exists<ApprovedExecutionHashes>(addr); +ensures exists<VotingRecordsV2>(addr); @@ -2204,6 +2206,7 @@ Abort if structs have already been created. aborts_if exists<VotingRecords>(addr); aborts_if exists<ApprovedExecutionHashes>(addr); aborts_if !exists<account::Account>(addr); + aborts_if exists<VotingRecordsV2>(addr); } diff --git a/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/coin.md b/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/coin.md index 2a7bff1d84289..363acc14af2c3 100644 --- a/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/coin.md +++ b/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/coin.md @@ -19,7 +19,6 @@ This module provides the foundation for typesafe Coins. - [Struct `WithdrawEvent`](#0x1_coin_WithdrawEvent) - [Struct `CoinEventHandleDeletion`](#0x1_coin_CoinEventHandleDeletion) - [Struct `PairCreation`](#0x1_coin_PairCreation) -- [Resource `MigrationFlag`](#0x1_coin_MigrationFlag) - [Struct `MintCapability`](#0x1_coin_MintCapability) - [Struct `FreezeCapability`](#0x1_coin_FreezeCapability) - [Struct `BurnCapability`](#0x1_coin_BurnCapability) @@ -29,6 +28,7 @@ This module provides the foundation for typesafe Coins. - [Struct `MintRefReceipt`](#0x1_coin_MintRefReceipt) - [Struct `TransferRefReceipt`](#0x1_coin_TransferRefReceipt) - [Struct `BurnRefReceipt`](#0x1_coin_BurnRefReceipt) +- [Resource `MigrationFlag`](#0x1_coin_MigrationFlag) - [Resource `Ghost$supply`](#0x1_coin_Ghost$supply) - [Resource `Ghost$aggregate_supply`](#0x1_coin_Ghost$aggregate_supply) - [Constants](#@Constants_0) @@ -57,6 +57,7 @@ This module provides the foundation for typesafe Coins. - [Function `calculate_amount_to_withdraw`](#0x1_coin_calculate_amount_to_withdraw) - [Function `maybe_convert_to_fungible_store`](#0x1_coin_maybe_convert_to_fungible_store) - [Function `migrate_to_fungible_store`](#0x1_coin_migrate_to_fungible_store) +- [Function `migrate_coin_store_to_fungible_store`](#0x1_coin_migrate_coin_store_to_fungible_store) - [Function `coin_address`](#0x1_coin_coin_address) - [Function `balance`](#0x1_coin_balance) - [Function `is_balance_at_least`](#0x1_coin_is_balance_at_least) @@ -72,7 +73,7 @@ This module provides the foundation for typesafe Coins. - [Function `burn`](#0x1_coin_burn) - [Function `burn_from`](#0x1_coin_burn_from) - [Function `deposit`](#0x1_coin_deposit) -- [Function `migrated_primary_fungible_store_exists`](#0x1_coin_migrated_primary_fungible_store_exists) +- [Function `can_receive_paired_fungible_asset`](#0x1_coin_can_receive_paired_fungible_asset) - [Function `force_deposit`](#0x1_coin_force_deposit) - [Function `destroy_zero`](#0x1_coin_destroy_zero) - [Function `extract`](#0x1_coin_extract) @@ -151,6 +152,7 @@ This module provides the foundation for typesafe Coins. use 0x1::system_addresses; use 0x1::table; use 0x1::type_info; +use 0x1::vector; @@ -621,35 +623,6 @@ Module event emitted when a new pair of coin and fungible asset is created. - - - - -## Resource `MigrationFlag` - -The flag the existence of which indicates the primary fungible store is created by the migration from CoinStore. - - -
#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
-struct MigrationFlag has key
-
- - - -
-Fields - - -
-
-dummy_field: bool -
-
- -
-
- -
@@ -916,6 +889,36 @@ The hot potato receipt for flash borrowing BurnRef. + + + + +## Resource `MigrationFlag` + +The flag the existence of which indicates the primary fungible store is created by the migration from CoinStore. + + +
#[resource_group_member(#[group = 0x1::object::ObjectGroup])]
+#[deprecated]
+struct MigrationFlag has key
+
+ + + +
+Fields + + +
+
+dummy_field: bool +
+
+ +
+
+ +
@@ -2038,7 +2041,6 @@ or disallow upgradability of total supply. let metadata = ensure_paired_metadata<CoinType>(); let store = primary_fungible_store::ensure_primary_store_exists(account, metadata); - let store_address = object::object_address(&store); if (exists<CoinStore<CoinType>>(account)) { let CoinStore<CoinType> { coin, frozen, deposit_events, withdraw_events } = move_from<CoinStore<CoinType>>( account @@ -2052,13 +2054,21 @@ or disallow upgradability of total supply. deleted_withdraw_event_handle_creation_number: guid::creation_num(event::guid(&withdraw_events)) } ); - event::destroy_handle(deposit_events); - event::destroy_handle(withdraw_events); if (coin.value == 0) { destroy_zero(coin); } else { - fungible_asset::deposit(store, coin_to_fungible_asset(coin)); + if (std::features::module_event_migration_enabled()) { + event::emit(CoinWithdraw { coin_type: type_name<CoinType>(), account, amount: coin.value }); + } else { + event::emit_event<WithdrawEvent>( + &mut withdraw_events, + WithdrawEvent { amount: coin.value }, + ); + }; + fungible_asset::deposit_internal(object_address(&store), coin_to_fungible_asset(coin)); }; + event::destroy_handle(deposit_events); + event::destroy_handle(withdraw_events); // Note: // It is possible the primary fungible store may already exist before this function call. // In this case, if the account owns a frozen CoinStore and an unfrozen primary fungible store, this @@ -2068,9 +2078,6 @@ or disallow upgradability of total supply. fungible_asset::set_frozen_flag_internal(store, frozen); } }; - if (!exists<MigrationFlag>(store_address)) { - move_to(&create_signer::create_signer(store_address), MigrationFlag {}); - } } @@ -2103,6 +2110,37 @@ Voluntarily migrate to fungible store for CoinType if not yet. + + + + +## Function `migrate_coin_store_to_fungible_store` + +Migrate to fungible store for CoinType if not yet. + + +
public entry fun migrate_coin_store_to_fungible_store<CoinType>(accounts: vector<address>)
+
+ + + +
+Implementation + + +
public entry fun migrate_coin_store_to_fungible_store<CoinType>(
+    accounts: vector<address>
+) acquires CoinStore, CoinConversionMap, CoinInfo {
+    if (features::new_accounts_default_to_fa_apt_store_enabled()) {
+        std::vector::for_each(accounts, |account| {
+            maybe_convert_to_fungible_store<CoinType>(account);
+        });
+    }
+}
+
+ + +
@@ -2314,7 +2352,7 @@ Returns true if account_addr is registered to r let paired_metadata_opt = paired_metadata<CoinType>(); (option::is_some( &paired_metadata_opt - ) && migrated_primary_fungible_store_exists(account_addr, option::destroy_some(paired_metadata_opt))) + ) && can_receive_paired_fungible_asset(account_addr, option::destroy_some(paired_metadata_opt))) } } @@ -2590,7 +2628,7 @@ Deposit the coin balance into the recipient's account and emit an event. merge(&mut coin_store.coin, coin); } else { let metadata = paired_metadata<CoinType>(); - if (option::is_some(&metadata) && migrated_primary_fungible_store_exists( + if (option::is_some(&metadata) && can_receive_paired_fungible_asset( account_addr, option::destroy_some(metadata) )) { @@ -2606,13 +2644,13 @@ Deposit the coin balance into the recipient's account and emit an event. - + -## Function `migrated_primary_fungible_store_exists` +## Function `can_receive_paired_fungible_asset` -
fun migrated_primary_fungible_store_exists(account_address: address, metadata: object::Object<fungible_asset::Metadata>): bool
+
fun can_receive_paired_fungible_asset(account_address: address, metadata: object::Object<fungible_asset::Metadata>): bool
 
@@ -2621,15 +2659,17 @@ Deposit the coin balance into the recipient's account and emit an event. Implementation -
inline fun migrated_primary_fungible_store_exists(
+
inline fun can_receive_paired_fungible_asset(
     account_address: address,
     metadata: Object<Metadata>
 ): bool {
-    let primary_store_address = primary_fungible_store::primary_store_address<Metadata>(account_address, metadata);
-    fungible_asset::store_exists(primary_store_address) && (
-        // migration flag is needed, until we start defaulting new accounts to APT PFS
-        features::new_accounts_default_to_fa_apt_store_enabled() || exists<MigrationFlag>(primary_store_address)
-    )
+    (features::new_accounts_default_to_fa_apt_store_enabled() && object::object_address(&metadata) == @0xa) || {
+        let primary_store_address = primary_fungible_store::primary_store_address<Metadata>(
+            account_address,
+            metadata
+        );
+        fungible_asset::store_exists(primary_store_address)
+    }
 }
 
@@ -2663,13 +2703,13 @@ This is for internal use only and doesn't emit an DepositEvent. merge(&mut coin_store.coin, coin); } else { let metadata = paired_metadata<CoinType>(); - if (option::is_some(&metadata) && migrated_primary_fungible_store_exists( + if (option::is_some(&metadata) && can_receive_paired_fungible_asset( account_addr, option::destroy_some(metadata) )) { let fa = coin_to_fungible_asset(coin); let metadata = fungible_asset::asset_metadata(&fa); - let store = primary_fungible_store::primary_store(account_addr, metadata); + let store = primary_fungible_store::ensure_primary_store_exists(account_addr, metadata); fungible_asset::deposit_internal(object::object_address(&store), fa); } else { abort error::not_found(ECOIN_STORE_NOT_PUBLISHED) @@ -3782,7 +3822,8 @@ Get address by reflection.
fun spec_is_account_registered<CoinType>(account_addr: address): bool {
    let paired_metadata_opt = spec_paired_metadata<CoinType>();
-   exists<CoinStore<CoinType>>(account_addr) || (option::spec_is_some(
+   exists<CoinStore<CoinType>>(account_addr) || features::spec_new_accounts_default_to_fa_apt_store_enabled(
+   ) || (option::spec_is_some(
        paired_metadata_opt
    ) && primary_fungible_store::spec_primary_store_exists(account_addr, option::spec_borrow(paired_metadata_opt)))
 }
@@ -4195,27 +4236,6 @@ The creator of CoinType must be @aptos_framework.
 
-Make sure name and symbol are legal length. -Only the creator of CoinType can initialize. - - - - - -
schema InitializeInternalSchema<CoinType> {
-    account: signer;
-    name: vector<u8>;
-    symbol: vector<u8>;
-    let account_addr = signer::address_of(account);
-    let coin_address = type_info::type_of<CoinType>().account_address;
-    aborts_if coin_address != account_addr;
-    aborts_if exists<CoinInfo<CoinType>>(account_addr);
-    aborts_if len(name) > MAX_COIN_NAME_LENGTH;
-    aborts_if len(symbol) > MAX_COIN_SYMBOL_LENGTH;
-}
-
- - diff --git a/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/genesis.md b/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/genesis.md index b9895b4393743..ff4866aad7c8f 100644 --- a/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/genesis.md +++ b/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/genesis.md @@ -340,6 +340,7 @@ Genesis step 1: Initialize aptos framework account and core modules on chain. execution_config::set(&aptos_framework_account, execution_config); version::initialize(&aptos_framework_account, initial_version); stake::initialize(&aptos_framework_account); + timestamp::set_time_has_started(&aptos_framework_account); staking_config::initialize( &aptos_framework_account, minimum_stake, @@ -360,7 +361,6 @@ Genesis step 1: Initialize aptos framework account and core modules on chain. reconfiguration::initialize(&aptos_framework_account); block::initialize(&aptos_framework_account, epoch_interval_microsecs); state_storage::initialize(&aptos_framework_account); - timestamp::set_time_has_started(&aptos_framework_account); }
diff --git a/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/staking_config.md b/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/staking_config.md index f053716b0e392..b4d2a86a61a27 100644 --- a/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/staking_config.md +++ b/aptos-move/framework/aptos-framework/tests/compiler-v2-doc/staking_config.md @@ -386,6 +386,17 @@ Only called during genesis. rewards_rate_denominator, voting_power_increase_limit, }); + + // Initialize StakingRewardsConfig with the given rewards_rate and rewards_rate_denominator, + // while setting min_rewards_rate and rewards_rate_decrease_rate to 0. + initialize_rewards( + aptos_framework, + fixed_point64::create_from_rational((rewards_rate as u128), (rewards_rate_denominator as u128)), + fixed_point64::create_from_rational(0, 1000), + ONE_YEAR_IN_SECS, + 0, + fixed_point64::create_from_rational(0, 1000), + ); }
@@ -1072,6 +1083,7 @@ Can only be called as part of the Aptos governance proposal process established
invariant [suspendable] chain_status::is_operating() ==> exists<StakingConfig>(@aptos_framework);
+invariant [suspendable] chain_status::is_operating() ==> exists<StakingRewardsConfig>(@aptos_framework);
 pragma verify = true;
 pragma aborts_if_is_strict;
 
@@ -1223,6 +1235,7 @@ StakingConfig does not exist under the aptos_framework before creating it.
let addr = signer::address_of(aptos_framework);
+requires exists<timestamp::CurrentTimeMicroseconds>(@aptos_framework);
 // This enforces high-level requirement 1:
 aborts_if addr != @aptos_framework;
 aborts_if minimum_stake > maximum_stake || maximum_stake == 0;
@@ -1234,7 +1247,9 @@ StakingConfig does not exist under the aptos_framework before creating it.
 aborts_if rewards_rate > MAX_REWARDS_RATE;
 aborts_if rewards_rate > rewards_rate_denominator;
 aborts_if exists<StakingConfig>(addr);
+aborts_if exists<StakingRewardsConfig>(addr);
 ensures exists<StakingConfig>(addr);
+ensures exists<StakingRewardsConfig>(addr);
 
diff --git a/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/features.md b/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/features.md index 6bfd2a4d4554a..ba2122e8a9788 100644 --- a/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/features.md +++ b/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/features.md @@ -133,6 +133,8 @@ return true. - [Function `transaction_simulation_enhancement_enabled`](#0x1_features_transaction_simulation_enhancement_enabled) - [Function `get_collection_owner_feature`](#0x1_features_get_collection_owner_feature) - [Function `is_collection_owner_enabled`](#0x1_features_is_collection_owner_enabled) +- [Function `get_native_memory_operations_feature`](#0x1_features_get_native_memory_operations_feature) +- [Function `is_native_memory_operations_enabled`](#0x1_features_is_native_memory_operations_enabled) - [Function `change_feature_flags`](#0x1_features_change_feature_flags) - [Function `change_feature_flags_internal`](#0x1_features_change_feature_flags_internal) - [Function `change_feature_flags_for_next_epoch`](#0x1_features_change_feature_flags_for_next_epoch) @@ -670,6 +672,15 @@ Lifetime: transient + + + + +
const NATIVE_MEMORY_OPERATIONS: u64 = 80;
+
+ + + Lifetime: transient @@ -3273,6 +3284,52 @@ Deprecated feature + + + + +## Function `get_native_memory_operations_feature` + + + +
public fun get_native_memory_operations_feature(): u64
+
+ + + +
+Implementation + + +
public fun get_native_memory_operations_feature(): u64 { NATIVE_MEMORY_OPERATIONS }
+
+ + + +
+ + + +## Function `is_native_memory_operations_enabled` + + + +
public fun is_native_memory_operations_enabled(): bool
+
+ + + +
+Implementation + + +
public fun is_native_memory_operations_enabled(): bool acquires Features {
+    is_enabled(NATIVE_MEMORY_OPERATIONS)
+}
+
+ + +
@@ -3697,6 +3754,17 @@ Helper to check whether a feature flag is enabled. + + + +
fun spec_new_accounts_default_to_fa_apt_store_enabled(): bool {
+   spec_is_enabled(NEW_ACCOUNTS_DEFAULT_TO_FA_APT_STORE)
+}
+
+ + + + diff --git a/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/vector.md b/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/vector.md index b56160dbaf27e..9e837c9c1cfae 100644 --- a/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/vector.md +++ b/aptos-move/framework/move-stdlib/tests/compiler-v2-doc/vector.md @@ -40,6 +40,7 @@ the return on investment didn't seem worth it for these simple functions. - [Function `remove`](#0x1_vector_remove) - [Function `remove_value`](#0x1_vector_remove_value) - [Function `swap_remove`](#0x1_vector_swap_remove) +- [Function `replace`](#0x1_vector_replace) - [Function `for_each`](#0x1_vector_for_each) - [Function `for_each_reverse`](#0x1_vector_for_each_reverse) - [Function `for_each_ref`](#0x1_vector_for_each_ref) @@ -146,6 +147,18 @@ The length of the vectors are not equal. + + +Whether to utilize native vector::move_range +Vector module cannot call features module, due to cyclic dependency, +so this is a constant. + + +
const USE_MOVE_RANGE: bool = true;
+
+ + + ## Function `empty` @@ -482,8 +495,15 @@ Pushes all of the elements of the other vector into the self<
public fun append<Element>(self: &mut vector<Element>, other: vector<Element>) {
-    reverse(&mut other);
-    reverse_append(self, other);
+    if (USE_MOVE_RANGE) {
+        let self_length = length(self);
+        let other_length = length(&other);
+        move_range(&mut other, 0, other_length, self, self_length);
+        destroy_empty(other);
+    } else {
+        reverse(&mut other);
+        reverse_append(self, other);
+    }
 }
 
@@ -525,7 +545,11 @@ Pushes all of the elements of the other vector into the self< ## Function `trim` -Trim a vector to a smaller size, returning the evicted elements in order +Splits (trims) the collection into two at the given index. +Returns a newly allocated vector containing the elements in the range [new_len, len). +After the call, the original vector will be left containing the elements [0, new_len) +with its previous capacity unchanged. +In many languages this is also called split_off.
public fun trim<Element>(self: &mut vector<Element>, new_len: u64): vector<Element>
@@ -538,9 +562,21 @@ Trim a vector to a smaller size, returning the evicted elements in order
 
 
 
public fun trim<Element>(self: &mut vector<Element>, new_len: u64): vector<Element> {
-    let res = trim_reverse(self, new_len);
-    reverse(&mut res);
-    res
+    let len = length(self);
+    assert!(new_len <= len, EINDEX_OUT_OF_BOUNDS);
+
+    let other = empty();
+    if (USE_MOVE_RANGE) {
+        move_range(self, new_len, len - new_len, &mut other, 0);
+    } else {
+        while (len > new_len) {
+            push_back(&mut other, pop_back(self));
+            len = len - 1;
+        };
+        reverse(&mut other);
+    };
+
+    other
 }
 
@@ -728,10 +764,27 @@ Aborts if out of bounds.
public fun insert<Element>(self: &mut vector<Element>, i: u64, e: Element) {
     let len = length(self);
     assert!(i <= len, EINDEX_OUT_OF_BOUNDS);
-    push_back(self, e);
-    while (i < len) {
-        swap(self, i, len);
-        i = i + 1;
+
+    if (USE_MOVE_RANGE) {
+        if (i + 2 >= len) {
+            // When we are close to the end, it is cheaper to not create
+            // a temporary vector, and swap directly
+            push_back(self, e);
+            while (i < len) {
+                swap(self, i, len);
+                i = i + 1;
+            };
+        } else {
+            let other = singleton(e);
+            move_range(&mut other, 0, 1, self, i);
+            destroy_empty(other);
+        }
+    } else {
+        push_back(self, e);
+        while (i < len) {
+            swap(self, i, len);
+            i = i + 1;
+        };
     };
 }
 
@@ -763,9 +816,25 @@ Aborts if i is out of bounds. // i out of bounds; abort if (i >= len) abort EINDEX_OUT_OF_BOUNDS; - len = len - 1; - while (i < len) swap(self, i, { i = i + 1; i }); - pop_back(self) + if (USE_MOVE_RANGE) { + // When we are close to the end, it is cheaper to not create + // a temporary vector, and swap directly + if (i + 3 >= len) { + len = len - 1; + while (i < len) swap(self, i, { i = i + 1; i }); + pop_back(self) + } else { + let other = empty(); + move_range(self, i, 1, &mut other, 0); + let result = pop_back(&mut other); + destroy_empty(other); + result + } + } else { + len = len - 1; + while (i < len) swap(self, i, { i = i + 1; i }); + pop_back(self) + } }
@@ -838,6 +907,42 @@ Aborts if i is out of bounds. + + + + +## Function `replace` + +Replace the ith element of the vector self with the given value, and return +to the caller the value that was there before. +Aborts if i is out of bounds. + + +
public fun replace<Element>(self: &mut vector<Element>, i: u64, val: Element): Element
+
+ + + +
+Implementation + + +
public fun replace<Element>(self: &mut vector<Element>, i: u64, val: Element): Element {
+    let last_idx = length(self);
+    assert!(i < last_idx, EINDEX_OUT_OF_BOUNDS);
+    // TODO: Enable after tests are fixed.
+    // if (USE_MOVE_RANGE) {
+    //     mem::replace(borrow_mut(self, i), val)
+    // } else {
+    push_back(self, val);
+    swap(self, i, last_idx);
+    pop_back(self)
+    // }
+}
+
+ + +
diff --git a/third_party/move/move-compiler-v2/src/bytecode_generator.rs b/third_party/move/move-compiler-v2/src/bytecode_generator.rs index e6be8ca0e80c5..cebd84c748329 100644 --- a/third_party/move/move-compiler-v2/src/bytecode_generator.rs +++ b/third_party/move/move-compiler-v2/src/bytecode_generator.rs @@ -1108,15 +1108,12 @@ impl<'env> Generator<'env> { /// Generate the code for a list of arguments. /// Note that the arguments are evaluated in left-to-right order. fn gen_arg_list(&mut self, exps: &[Exp]) -> Vec { - // If all args are side-effect free, we don't need to force temporary generation - // to get left-to-right evaluation. - let with_forced_temp = !exps.iter().all(is_definitely_pure); let len = exps.len(); - // Generate code with (potentially) forced creation of temporaries for all except last arg. + // Generate code with forced creation of temporaries for all except last arg. let mut args = exps .iter() .take(if len == 0 { 0 } else { len - 1 }) - .map(|exp| self.gen_escape_auto_ref_arg(exp, with_forced_temp)) + .map(|exp| self.gen_escape_auto_ref_arg(exp, true)) .collect::>(); // If there is a last arg, we don't need to force create a temporary for it. if let Some(last_arg) = exps @@ -2438,6 +2435,7 @@ impl<'a> fmt::Display for ValueShapeDisplay<'a> { // Helpers /// Is this a leaf expression which cannot contain another expression? +#[allow(dead_code)] fn is_leaf_exp(exp: &Exp) -> bool { matches!( exp.as_ref(), @@ -2446,6 +2444,7 @@ fn is_leaf_exp(exp: &Exp) -> bool { } /// Can we be certain that this expression is side-effect free? +#[allow(dead_code)] fn is_definitely_pure(exp: &Exp) -> bool { is_leaf_exp(exp) // A leaf expression is pure. || match exp.as_ref() { diff --git a/third_party/move/move-compiler-v2/src/experiments.rs b/third_party/move/move-compiler-v2/src/experiments.rs index fd6174e8231bf..a519049690013 100644 --- a/third_party/move/move-compiler-v2/src/experiments.rs +++ b/third_party/move/move-compiler-v2/src/experiments.rs @@ -271,11 +271,6 @@ pub static EXPERIMENTS: Lazy> = Lazy::new(|| { .to_string(), default: Given(false), }, - Experiment { - name: Experiment::AVOID_STORE_IN_ASSIGNS.to_string(), - description: "Avoid storing to a local during assigns".to_string(), - default: Inherited(Experiment::OPTIMIZE_WAITING_FOR_COMPARE_TESTS.to_string()), - }, ]; experiments .into_iter() @@ -291,7 +286,6 @@ impl Experiment { pub const AST_SIMPLIFY: &'static str = "ast-simplify"; pub const AST_SIMPLIFY_FULL: &'static str = "ast-simplify-full"; pub const ATTACH_COMPILED_MODULE: &'static str = "attach-compiled-module"; - pub const AVOID_STORE_IN_ASSIGNS: &'static str = "avoid-store-in-assigns"; pub const CFG_SIMPLIFICATION: &'static str = "cfg-simplification"; pub const CHECKS: &'static str = "checks"; pub const COPY_PROPAGATION: &'static str = "copy-propagation"; diff --git a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs index 85e5e9402fc54..ea383d6298e2f 100644 --- a/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs +++ b/third_party/move/move-compiler-v2/src/file_format_generator/function_generator.rs @@ -285,22 +285,8 @@ impl<'a> FunctionGenerator<'a> { std::slice::from_ref(source), ); self.abstract_push_args(ctx, vec![*source], Some(mode)); - // TODO: the below conditional check is temporary, the plan is to get rid of the `else` - // case if comparison testing is successful. - let options = ctx - .fun_ctx - .module - .env - .get_extension::() - .expect("Options is available"); - if options.experiment_on(Experiment::AVOID_STORE_IN_ASSIGNS) { - self.abstract_pop(ctx); - self.abstract_push_result(ctx, std::slice::from_ref(dest)); - } else { - let local = self.temp_to_local(ctx.fun_ctx, Some(ctx.attr_id), *dest); - self.emit(FF::Bytecode::StLoc(local)); - self.abstract_pop(ctx); - } + self.abstract_pop(ctx); + self.abstract_push_result(ctx, std::slice::from_ref(dest)); }, Bytecode::Ret(_, result) => { self.balance_stack_end_of_block(ctx, result); diff --git a/third_party/move/move-compiler-v2/src/lib.rs b/third_party/move/move-compiler-v2/src/lib.rs index 84eda127b9f03..2b7e6d18b8c25 100644 --- a/third_party/move/move-compiler-v2/src/lib.rs +++ b/third_party/move/move-compiler-v2/src/lib.rs @@ -465,7 +465,7 @@ pub fn bytecode_pipeline(env: &GlobalEnv) -> FunctionTargetPipeline { pipeline.add_processor(Box::new(UnreachableCodeProcessor {})); pipeline.add_processor(Box::new(UnreachableCodeRemover {})); pipeline.add_processor(Box::new(LiveVarAnalysisProcessor::new(true))); - pipeline.add_processor(Box::new(DeadStoreElimination {})); + pipeline.add_processor(Box::new(DeadStoreElimination::new(true))); } if options.experiment_on(Experiment::VARIABLE_COALESCING) { @@ -484,7 +484,7 @@ pub fn bytecode_pipeline(env: &GlobalEnv) -> FunctionTargetPipeline { if options.experiment_on(Experiment::DEAD_CODE_ELIMINATION) { pipeline.add_processor(Box::new(LiveVarAnalysisProcessor::new(true))); - pipeline.add_processor(Box::new(DeadStoreElimination {})); + pipeline.add_processor(Box::new(DeadStoreElimination::new(false))); } // Run live var analysis again because it could be invalidated by previous pipeline steps, diff --git a/third_party/move/move-compiler-v2/src/pipeline/dead_store_elimination.rs b/third_party/move/move-compiler-v2/src/pipeline/dead_store_elimination.rs index 95f54dba5f04f..62d336cf064cb 100644 --- a/third_party/move/move-compiler-v2/src/pipeline/dead_store_elimination.rs +++ b/third_party/move/move-compiler-v2/src/pipeline/dead_store_elimination.rs @@ -14,6 +14,8 @@ //! this transformation removes dead stores, i.e., assignments and loads to locals which //! are not live afterwards (or are live only in dead code, making them effectively dead). //! In addition, it also removes self-assignments, i.e., assignments of the form `x = x`. +//! One can also remove only those self-assignments where the definition is in the same block +//! before the self-assign by using `eliminate_all_self_assigns=false`. use crate::pipeline::livevar_analysis_processor::LiveVarAnnotation; use move_binary_format::file_format::CodeOffset; @@ -22,6 +24,7 @@ use move_stackless_bytecode::{ function_target::{FunctionData, FunctionTarget}, function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, stackless_bytecode::Bytecode, + stackless_control_flow_graph::StacklessControlFlowGraph, }; use std::collections::{BTreeMap, BTreeSet}; @@ -59,19 +62,26 @@ struct ReducedDefUseGraph { impl ReducedDefUseGraph { /// Get the dead stores that are safe to remove from the function `target`. - pub fn dead_stores(target: &FunctionTarget) -> BTreeSet { + /// If `eliminate_all_self_assigns` is true, all self-assignments are removed. + pub fn dead_stores(target: &FunctionTarget, eliminate_all_self_assigns: bool) -> BTreeSet { Self { children: BTreeMap::new(), parents: BTreeMap::new(), defs_alive: BTreeSet::new(), defs_dead: BTreeSet::new(), } - .run_stages(target) + .run_stages(target, eliminate_all_self_assigns) } /// Run various stages to return the dead stores from `target`. - fn run_stages(mut self, target: &FunctionTarget) -> BTreeSet { + /// If `eliminate_all_self_assigns` is true, all self-assignments are removed. + fn run_stages( + mut self, + target: &FunctionTarget, + eliminate_all_self_assigns: bool, + ) -> BTreeSet { let code = target.get_bytecode(); + let cfg = StacklessControlFlowGraph::new_forward(code); let live_vars = target .get_annotations() .get::() @@ -97,8 +107,19 @@ impl ReducedDefUseGraph { for dead_def_leaf in self.defs_dead.clone() { self.disconnect_from_parents(dead_def_leaf); } - // Stage 3: Let's disconnect all the self-assignments from the graph and kill them. + // Stage 3: Let's disconnect self-assignments from the graph and kill them + // (conditioned upon `eliminate_all_self_assigns`). for self_assign in self_assigns { + let eliminate_this_self_assign = Self::should_eliminate_given_self_assign( + self_assign, + code, + &cfg, + live_vars, + eliminate_all_self_assigns, + ); + if !eliminate_this_self_assign { + continue; + } let mut parents = self.disconnect_from_parents(self_assign); let mut children = self.disconnect_from_children(self_assign); // In case there is a cycle of self-assignments in the graph. @@ -208,12 +229,55 @@ impl ReducedDefUseGraph { self.defs_dead.insert(def); // def without a use is dead } } + + /// Should `self_assign` be eliminated? + fn should_eliminate_given_self_assign( + self_assign: CodeOffset, + code: &[Bytecode], + cfg: &StacklessControlFlowGraph, + live_vars: &LiveVarAnnotation, + eliminate_all_self_assigns: bool, + ) -> bool { + if !eliminate_all_self_assigns { + // Eliminate this self assign if the definition for this self-assign is in the same block + // before the self assign. + let block = cfg.enclosing_block(self_assign); + let block_begin_offset = cfg.code_range(block).start; + let self_assign_instr = &code[self_assign as usize]; + let self_assign_temp = self_assign_instr.dests()[0]; + // Is `self_assign_temp` live before this block? + let info = live_vars + .get_info_at(block_begin_offset as CodeOffset) + .before + .get(&self_assign_temp); + match info { + None => true, // must be defined in the block + Some(live) => !live.usage_offsets().contains(&self_assign), + } + } else { + true + } + } } /// A processor which performs dead store elimination transformation. -pub struct DeadStoreElimination {} +pub struct DeadStoreElimination { + /// If true, eliminate all self-assignments of the form `x = x`. + /// Otherwise, only self assignments where the definition is in the same block + /// before the self-assign are removed. + eliminate_all_self_assigns: bool, +} impl DeadStoreElimination { + /// If `eliminate_all_self_assigns` is true, all self-assignments are removed. + /// Otherwise, only self assignments where the definition is in the same block + /// before the self-assign are removed. + pub fn new(eliminate_all_self_assigns: bool) -> Self { + Self { + eliminate_all_self_assigns, + } + } + /// Transforms the `code` of a function by removing the instructions corresponding to /// the code offsets contained in `dead_stores`. /// @@ -242,7 +306,7 @@ impl FunctionTargetProcessor for DeadStoreElimination { return data; } let target = FunctionTarget::new(func_env, &data); - let dead_stores = ReducedDefUseGraph::dead_stores(&target); + let dead_stores = ReducedDefUseGraph::dead_stores(&target, self.eliminate_all_self_assigns); let new_code = Self::transform(&target, dead_stores); // Note that the file format generator will not include unused locals in the generated code, // so we don't need to prune unused locals here for various fields of `data` (like `local_types`). diff --git a/third_party/move/move-compiler-v2/src/pipeline/flush_writes_processor.rs b/third_party/move/move-compiler-v2/src/pipeline/flush_writes_processor.rs index 1a9c6456cb146..23c748713d8be 100644 --- a/third_party/move/move-compiler-v2/src/pipeline/flush_writes_processor.rs +++ b/third_party/move/move-compiler-v2/src/pipeline/flush_writes_processor.rs @@ -207,17 +207,21 @@ impl FlushWritesProcessor { flush_writes: &mut BTreeMap>, ) { let upper = *block_range.end(); - for offset in block_range { + // Traverse the block in reverse order: for each definition starting from the + // latest in a block, we compute whether is should be flushed away. This + // information is available for subsequent definitions processed. + for offset in block_range.rev() { let instr = &code[offset as usize]; - // Only `Load` and `Call` instructions push temps to the stack. + use Bytecode::{Assign, Call, Load}; + // Only `Assign`, `Call`, and `Load` instructions push temps to the stack. // We need to find if any of these temps are better flushed right away. - if matches!(instr, Bytecode::Load(..) | Bytecode::Call(..)) { - for (dest_index, dest) in instr.dests().into_iter().enumerate() { + if matches!(instr, Assign(..) | Call(..) | Load(..)) { + for (dest_index, dest) in instr.dests().into_iter().enumerate().rev() { let def = DefOrUsePoint { offset, index: dest_index, }; - if Self::could_flush_right_away(def, upper, use_def_links) { + if Self::could_flush_right_away(def, upper, code, use_def_links, flush_writes) { flush_writes.entry(offset).or_default().insert(dest); } } @@ -230,7 +234,9 @@ impl FlushWritesProcessor { fn could_flush_right_away( def: DefOrUsePoint, block_end: CodeOffset, + code: &[Bytecode], use_def_links: &UseDefLinks, + flush_writes: &BTreeMap>, ) -> bool { use_def_links.def_to_use.get(&def).map_or(true, |uses| { let exactly_one_use = uses.len() == 1; @@ -244,8 +250,17 @@ impl FlushWritesProcessor { // If used outside the basic block, flush right away. return true; } - // If has intervening definition, flush right away. - Self::has_intervening_def(def, use_, use_def_links) + // If has intervening definitions, flush right away. + // The first call checks the definitions of preceding uses in the same instruction. + // The second call checks definitions between `def` and `use_`. + Self::has_intervening_def(&def, use_, use_def_links) + || Self::has_flush_causing_defs_in_between( + &def, + use_, + code, + use_def_links, + flush_writes, + ) }) } @@ -253,7 +268,7 @@ impl FlushWritesProcessor { /// instruction as `use_`, which has a definition after `def` and before /// the `use_` instruction? fn has_intervening_def( - def: DefOrUsePoint, + def: &DefOrUsePoint, use_: &DefOrUsePoint, use_def_links: &UseDefLinks, ) -> bool { @@ -271,12 +286,122 @@ impl FlushWritesProcessor { .get(&prev_use_at_usage_instr) .map_or(false, |defs| { defs.iter().any(|defs_of_prev_use| { - defs_of_prev_use > &def && defs_of_prev_use.offset < *use_offset + defs_of_prev_use > def && defs_of_prev_use.offset < *use_offset }) }) }) } + /// Check for various conditions where between a `def` and its `use_`, there are other + /// definitions that could cause `def` to be flushed before its `use_`. + fn has_flush_causing_defs_in_between( + def: &DefOrUsePoint, + use_: &DefOrUsePoint, + code: &[Bytecode], + use_def_links: &UseDefLinks, + flush_writes: &BTreeMap>, + ) -> bool { + // For each definition in between `def` and `use_`, is there at least one that is: + // 1. not marked to be flushed right away? + // 2. not consumed before `use_`? + // 3. not used in the same offset as `use_`? + // If so, `def` could be flushed before its `use_`, so we should suggest flush it + // right after definition. + // Note that we expect the code in the block to be processed in the reverse order. + let defs_in_between = Self::get_defs_between(def, use_, use_def_links); + for def_in_between in defs_in_between { + if Self::is_def_flushed_away(&def_in_between, code, flush_writes) { + continue; + } + if Self::consumed_before(&def_in_between, use_, use_def_links) { + continue; + } + if Self::consumed_at(&def_in_between, use_, use_def_links) { + continue; + } + return true; + } + false + } + + /// Has `def` been marked to be flushed right away? + fn is_def_flushed_away( + def: &DefOrUsePoint, + code: &[Bytecode], + flush_writes: &BTreeMap>, + ) -> bool { + if let Some(temps) = flush_writes.get(&def.offset) { + // Some temps were marked to be flushed right away at `instr`. + let instr = &code[def.offset as usize]; + // Was it this `def`? + let def_temp = instr.dests()[def.index]; + return temps.contains(&def_temp); + } + false + } + + /// Is `def` consumed before `use_`? + fn consumed_before( + def: &DefOrUsePoint, + use_: &DefOrUsePoint, + use_def_links: &UseDefLinks, + ) -> bool { + use_def_links + .def_to_use + .get(def) + .map_or(false, |uses| uses.iter().all(|u| u.offset < use_.offset)) + } + + /// Is `def` consumed at `use_`'s offset? + fn consumed_at(def: &DefOrUsePoint, use_: &DefOrUsePoint, use_def_links: &UseDefLinks) -> bool { + let use_offset = use_.offset; + use_def_links + .def_to_use + .get(def) + .map_or(false, |uses| uses.iter().all(|u| u.offset == use_offset)) + } + + /// Get all the definitions between `def` and `use_`. + fn get_defs_between( + def: &DefOrUsePoint, + use_: &DefOrUsePoint, + use_def_links: &UseDefLinks, + ) -> Vec { + let DefOrUsePoint { + offset: def_offset, + index: def_index, + } = def; + let use_offset = use_.offset; + let mut defs = vec![]; + if *def_offset == use_offset { + return defs; + } + // Are there defs at def_offset with index > def_index? + for index in def_index + 1.. { + let potential_def = DefOrUsePoint { + offset: *def_offset, + index, + }; + if use_def_links.def_to_use.contains_key(&potential_def) { + defs.push(potential_def); + } else { + break; + } + } + // Are there defs after def_offset and before use_offset? + for offset in (*def_offset + 1)..use_offset { + for index in 0.. { + let potential_def = DefOrUsePoint { offset, index }; + if use_def_links.def_to_use.contains_key(&potential_def) { + defs.push(potential_def); + } else { + break; + } + } + } + defs + } + /// Registers annotation formatter at the given function target. /// Helps with testing and debugging. pub fn register_formatters(target: &FunctionTarget) { diff --git a/third_party/move/move-compiler-v2/tests/ability-check/bug_14189.exp b/third_party/move/move-compiler-v2/tests/ability-check/bug_14189.exp index 1f466890ce1b3..4d2c8549aa074 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/bug_14189.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/bug_14189.exp @@ -1,7 +1,10 @@ Diagnostics: error: local `x1` of type `S2` does not have the `copy` ability - ┌─ tests/ability-check/bug_14189.move:34:18 + ┌─ tests/ability-check/bug_14189.move:34:26 │ 34 │ let x2 = S3 { x: x1, y: x0, z: x1 }; - │ ^^^^^^^^^^^^^^^^^^^^^^^^^^ copy needed here because value is still in use + │ --------^^---------------- + │ │ │ + │ │ copy needed here because value is still in use + │ used here diff --git a/third_party/move/move-compiler-v2/tests/ability-check/operator_drop.exp b/third_party/move/move-compiler-v2/tests/ability-check/operator_drop.exp index 9d3c3eb96312d..4fbd6c57e9049 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/operator_drop.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/operator_drop.exp @@ -1,24 +1,24 @@ Diagnostics: -error: local `x` of type `T` does not have the `drop` ability +error: local `y` of type `T` does not have the `drop` ability ┌─ tests/ability-check/operator_drop.move:4:9 │ 4 │ x == y │ ^^^^^^ operator drops value here (consider borrowing the argument) -error: local `y` of type `T` does not have the `drop` ability +error: value of type `T` does not have the `drop` ability ┌─ tests/ability-check/operator_drop.move:4:9 │ 4 │ x == y │ ^^^^^^ operator drops value here (consider borrowing the argument) -error: local `x` of type `T` does not have the `drop` ability +error: local `y` of type `T` does not have the `drop` ability ┌─ tests/ability-check/operator_drop.move:8:9 │ 8 │ x != y │ ^^^^^^ operator drops value here (consider borrowing the argument) -error: local `y` of type `T` does not have the `drop` ability +error: value of type `T` does not have the `drop` ability ┌─ tests/ability-check/operator_drop.move:8:9 │ 8 │ x != y diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/eq_invalid2.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/eq_invalid2.exp index a415502fc4815..0f2e6871fd706 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/eq_invalid2.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/eq_invalid2.exp @@ -4,7 +4,10 @@ error: local `r` of type `R` does not have the `copy` ability ┌─ tests/ability-check/typing/eq_invalid2.move:11:9 │ 11 │ r == r; - │ ^^^^^^ copy needed here because value is still in use + │ ^----- + │ │ + │ used here + │ copy needed here because value is still in use error: local `r` of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/eq_invalid2.move:11:9 @@ -12,6 +15,12 @@ error: local `r` of type `R` does not have the `drop` ability 11 │ r == r; │ ^^^^^^ operator drops value here (consider borrowing the argument) +error: value of type `R` does not have the `drop` ability + ┌─ tests/ability-check/typing/eq_invalid2.move:11:9 + │ +11 │ r == r; + │ ^^^^^^ operator drops value here (consider borrowing the argument) + error: value of type `G1` does not have the `drop` ability ┌─ tests/ability-check/typing/eq_invalid2.move:15:9 │ diff --git a/third_party/move/move-compiler-v2/tests/ability-check/typing/neq_invalid2.exp b/third_party/move/move-compiler-v2/tests/ability-check/typing/neq_invalid2.exp index c07bea1c68b1b..8f68d6cc3dbeb 100644 --- a/third_party/move/move-compiler-v2/tests/ability-check/typing/neq_invalid2.exp +++ b/third_party/move/move-compiler-v2/tests/ability-check/typing/neq_invalid2.exp @@ -6,19 +6,19 @@ error: local `s2` of type `S` does not have the `drop` ability 17 │ s != s2; │ ^^^^^^^ operator drops value here (consider borrowing the argument) -error: local `s` of type `S` does not have the `drop` ability +error: value of type `S` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:17:9 │ 17 │ s != s2; │ ^^^^^^^ operator drops value here (consider borrowing the argument) -error: local `r1` of type `R` does not have the `drop` ability +error: local `r2` of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:22:9 │ 22 │ r1 != r2; │ ^^^^^^^^ operator drops value here (consider borrowing the argument) -error: local `r2` of type `R` does not have the `drop` ability +error: value of type `R` does not have the `drop` ability ┌─ tests/ability-check/typing/neq_invalid2.move:22:9 │ 22 │ r1 != r2; diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/borrowed_from_one_path.exp b/third_party/move/move-compiler-v2/tests/ability-transform/borrowed_from_one_path.exp index 64fd1e4a61b95..10e16f2fa63ea 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/borrowed_from_one_path.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/borrowed_from_one_path.exp @@ -6,25 +6,29 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &0x42::m::R - var $t7: address - var $t8: &u64 - var $t9: u64 - 0: $t5 := 0 - 1: $t4 := ==($t0, $t5) - 2: if ($t4) goto 3 else goto 8 - 3: label L0 - 4: $t7 := 0x1 - 5: $t6 := borrow_global<0x42::m::R>($t7) - 6: $t3 := borrow_field<0x42::m::R>.data($t6) - 7: goto 10 - 8: label L1 - 9: $t3 := infer($t1) - 10: label L2 - 11: $t9 := 0 - 12: $t8 := vector::borrow($t3, $t9) - 13: $t2 := read_ref($t8) - 14: return $t2 + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 + 0: $t5 := infer($t0) + 1: $t6 := 0 + 2: $t4 := ==($t5, $t6) + 3: if ($t4) goto 4 else goto 9 + 4: label L0 + 5: $t8 := 0x1 + 6: $t7 := borrow_global<0x42::m::R>($t8) + 7: $t3 := borrow_field<0x42::m::R>.data($t7) + 8: goto 11 + 9: label L1 + 10: $t3 := infer($t1) + 11: label L2 + 12: $t10 := infer($t3) + 13: $t11 := 0 + 14: $t9 := vector::borrow($t10, $t11) + 15: $t2 := read_ref($t9) + 16: return $t2 } ============ after LiveVarAnalysisProcessor: ================ @@ -35,40 +39,46 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &0x42::m::R - var $t7: address - var $t8: &u64 - var $t9: u64 + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 # live vars: $t0, $t1 - 0: $t5 := 0 - # live vars: $t0, $t1, $t5 - 1: $t4 := ==($t0, $t5) + 0: $t5 := infer($t0) + # live vars: $t1, $t5 + 1: $t6 := 0 + # live vars: $t1, $t5, $t6 + 2: $t4 := ==($t5, $t6) # live vars: $t1, $t4 - 2: if ($t4) goto 3 else goto 8 + 3: if ($t4) goto 4 else goto 9 # live vars: $t1 - 3: label L0 + 4: label L0 # live vars: - 4: $t7 := 0x1 + 5: $t8 := 0x1 + # live vars: $t8 + 6: $t7 := borrow_global<0x42::m::R>($t8) # live vars: $t7 - 5: $t6 := borrow_global<0x42::m::R>($t7) - # live vars: $t6 - 6: $t3 := borrow_field<0x42::m::R>.data($t6) + 7: $t3 := borrow_field<0x42::m::R>.data($t7) # live vars: $t3 - 7: goto 10 + 8: goto 11 # live vars: $t1 - 8: label L1 + 9: label L1 # live vars: $t1 - 9: $t3 := infer($t1) + 10: $t3 := infer($t1) # live vars: $t3 - 10: label L2 + 11: label L2 # live vars: $t3 - 11: $t9 := 0 - # live vars: $t3, $t9 - 12: $t8 := vector::borrow($t3, $t9) - # live vars: $t8 - 13: $t2 := read_ref($t8) + 12: $t10 := infer($t3) + # live vars: $t10 + 13: $t11 := 0 + # live vars: $t10, $t11 + 14: $t9 := vector::borrow($t10, $t11) + # live vars: $t9 + 15: $t2 := read_ref($t9) # live vars: $t2 - 14: return $t2 + 16: return $t2 } ============ after LiveVarAnalysisProcessor: ================ @@ -79,40 +89,46 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &0x42::m::R - var $t7: address - var $t8: &u64 - var $t9: u64 + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 # live vars: $t0, $t1 - 0: $t5 := 0 - # live vars: $t0, $t1, $t5 - 1: $t4 := ==($t0, $t5) + 0: $t5 := infer($t0) + # live vars: $t1, $t5 + 1: $t6 := 0 + # live vars: $t1, $t5, $t6 + 2: $t4 := ==($t5, $t6) # live vars: $t1, $t4 - 2: if ($t4) goto 3 else goto 8 + 3: if ($t4) goto 4 else goto 9 # live vars: $t1 - 3: label L0 + 4: label L0 # live vars: - 4: $t7 := 0x1 + 5: $t8 := 0x1 + # live vars: $t8 + 6: $t7 := borrow_global<0x42::m::R>($t8) # live vars: $t7 - 5: $t6 := borrow_global<0x42::m::R>($t7) - # live vars: $t6 - 6: $t3 := borrow_field<0x42::m::R>.data($t6) + 7: $t3 := borrow_field<0x42::m::R>.data($t7) # live vars: $t3 - 7: goto 10 + 8: goto 11 # live vars: $t1 - 8: label L1 + 9: label L1 # live vars: $t1 - 9: $t3 := infer($t1) + 10: $t3 := infer($t1) # live vars: $t3 - 10: label L2 + 11: label L2 # live vars: $t3 - 11: $t9 := 0 - # live vars: $t3, $t9 - 12: $t8 := vector::borrow($t3, $t9) - # live vars: $t8 - 13: $t2 := read_ref($t8) + 12: $t10 := infer($t3) + # live vars: $t10 + 13: $t11 := 0 + # live vars: $t10, $t11 + 14: $t9 := vector::borrow($t10, $t11) + # live vars: $t9 + 15: $t2 := read_ref($t9) # live vars: $t2 - 14: return $t2 + 16: return $t2 } ============ after ReferenceSafetyProcessor: ================ @@ -123,10 +139,12 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &0x42::m::R - var $t7: address - var $t8: &u64 - var $t9: u64 + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 # live vars: $t0, $t1 # refs: [$t1 => #1] # #1 @@ -134,15 +152,23 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 0: $t5 := 0 - # live vars: $t0, $t1, $t5 + 0: $t5 := infer($t0) + # live vars: $t1, $t5 + # refs: [$t1 => #1] + # #1 + # + # #root + # + # + 1: $t6 := 0 + # live vars: $t1, $t5, $t6 # refs: [$t1 => #1] # #1 # # #root # # - 1: $t4 := ==($t0, $t5) + 2: $t4 := ==($t5, $t6) # live vars: $t1, $t4 # refs: [$t1 => #1] # #1 @@ -150,7 +176,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 2: if ($t4) goto 3 else goto 8 + 3: if ($t4) goto 4 else goto 9 # live vars: $t1 # refs: [$t1 => #1] # #1 @@ -158,23 +184,23 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 3: label L0 + 4: label L0 # live vars: # refs: [] # - 4: $t7 := 0x1 - # live vars: $t7 + 5: $t8 := 0x1 + # live vars: $t8 # refs: [] # - 5: $t6 := borrow_global<0x42::m::R>($t7) - # live vars: $t6 - # refs: [$t6 => #6] - # #6 + 6: $t7 := borrow_global<0x42::m::R>($t8) + # live vars: $t7 + # refs: [$t7 => #7] + # #7 # # #root - # -> #6 via [struct `m::R`] at line 12 + # -> #7 via [struct `m::R`] at line 12 # - 6: $t3 := borrow_field<0x42::m::R>.data($t6) + 7: $t3 := borrow_field<0x42::m::R>.data($t7) # live vars: $t3 # refs: [$t3 => #3] # #3 @@ -182,7 +208,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # -> #3 via [struct `m::R`] at line 12 # - 7: goto 10 + 8: goto 11 # live vars: $t1 # refs: [$t1 => #1] # #1 @@ -190,7 +216,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 8: label L1 + 9: label L1 # live vars: $t1 # refs: [$t1 => #1] # #1 @@ -198,7 +224,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 9: $t3 := infer($t1) + 10: $t3 := infer($t1) # live vars: $t3 # refs: [$t3 => #3] # #3 @@ -206,7 +232,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # -> #3 via [struct `m::R`] at line 12 # - 10: label L2 + 11: label L2 # live vars: $t3 # refs: [$t3 => #3] # #3 @@ -214,27 +240,35 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # -> #3 via [struct `m::R`] at line 12 # - 11: $t9 := 0 - # live vars: $t3, $t9 - # refs: [$t3 => #3] - # #3 + 12: $t10 := infer($t3) + # live vars: $t10 + # refs: [$t10 => #10] + # #10 # # #root - # -> #3 via [struct `m::R`] at line 12 + # -> #10 via [struct `m::R`] at line 12 # - 12: $t8 := vector::borrow($t3, $t9) - # live vars: $t8 - # refs: [$t8 => #8] - # #8 + 13: $t11 := 0 + # live vars: $t10, $t11 + # refs: [$t10 => #10] + # #10 + # + # #root + # -> #10 via [struct `m::R`] at line 12 + # + 14: $t9 := vector::borrow($t10, $t11) + # live vars: $t9 + # refs: [$t9 => #9] + # #9 # # #root - # -> #8 via [struct `m::R`] at line 16 + # -> #9 via [struct `m::R`] at line 16 # - 13: $t2 := read_ref($t8) + 15: $t2 := read_ref($t9) # live vars: $t2 # refs: [] # - 14: return $t2 + 16: return $t2 } ============ after AbortAnalysisProcessor: ================ @@ -245,10 +279,12 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &0x42::m::R - var $t7: address - var $t8: &u64 - var $t9: u64 + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 # abort state: {returns,aborts} # live vars: $t0, $t1 # refs: [$t1 => #1] @@ -257,16 +293,25 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 0: $t5 := 0 + 0: $t5 := infer($t0) # abort state: {returns,aborts} - # live vars: $t0, $t1, $t5 + # live vars: $t1, $t5 # refs: [$t1 => #1] # #1 # # #root # # - 1: $t4 := ==($t0, $t5) + 1: $t6 := 0 + # abort state: {returns,aborts} + # live vars: $t1, $t5, $t6 + # refs: [$t1 => #1] + # #1 + # + # #root + # + # + 2: $t4 := ==($t5, $t6) # abort state: {returns,aborts} # live vars: $t1, $t4 # refs: [$t1 => #1] @@ -275,7 +320,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 2: if ($t4) goto 3 else goto 8 + 3: if ($t4) goto 4 else goto 9 # abort state: {returns,aborts} # live vars: $t1 # refs: [$t1 => #1] @@ -284,26 +329,26 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 3: label L0 + 4: label L0 # abort state: {returns,aborts} # live vars: # refs: [] # - 4: $t7 := 0x1 + 5: $t8 := 0x1 # abort state: {returns,aborts} - # live vars: $t7 + # live vars: $t8 # refs: [] # - 5: $t6 := borrow_global<0x42::m::R>($t7) + 6: $t7 := borrow_global<0x42::m::R>($t8) # abort state: {returns,aborts} - # live vars: $t6 - # refs: [$t6 => #6] - # #6 + # live vars: $t7 + # refs: [$t7 => #7] + # #7 # # #root - # -> #6 via [struct `m::R`] at line 12 + # -> #7 via [struct `m::R`] at line 12 # - 6: $t3 := borrow_field<0x42::m::R>.data($t6) + 7: $t3 := borrow_field<0x42::m::R>.data($t7) # abort state: {returns,aborts} # live vars: $t3 # refs: [$t3 => #3] @@ -312,7 +357,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # -> #3 via [struct `m::R`] at line 12 # - 7: goto 10 + 8: goto 11 # abort state: {returns,aborts} # live vars: $t1 # refs: [$t1 => #1] @@ -321,7 +366,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 8: label L1 + 9: label L1 # abort state: {returns,aborts} # live vars: $t1 # refs: [$t1 => #1] @@ -330,7 +375,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # # - 9: $t3 := infer($t1) + 10: $t3 := infer($t1) # abort state: {returns,aborts} # live vars: $t3 # refs: [$t3 => #3] @@ -339,7 +384,7 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # -> #3 via [struct `m::R`] at line 12 # - 10: label L2 + 11: label L2 # abort state: {returns,aborts} # live vars: $t3 # refs: [$t3 => #3] @@ -348,30 +393,39 @@ fun m::f($t0: u8, $t1: &vector): u64 { # #root # -> #3 via [struct `m::R`] at line 12 # - 11: $t9 := 0 + 12: $t10 := infer($t3) # abort state: {returns,aborts} - # live vars: $t3, $t9 - # refs: [$t3 => #3] - # #3 + # live vars: $t10 + # refs: [$t10 => #10] + # #10 # # #root - # -> #3 via [struct `m::R`] at line 12 + # -> #10 via [struct `m::R`] at line 12 + # + 13: $t11 := 0 + # abort state: {returns,aborts} + # live vars: $t10, $t11 + # refs: [$t10 => #10] + # #10 + # + # #root + # -> #10 via [struct `m::R`] at line 12 # - 12: $t8 := vector::borrow($t3, $t9) + 14: $t9 := vector::borrow($t10, $t11) # abort state: {returns} - # live vars: $t8 - # refs: [$t8 => #8] - # #8 + # live vars: $t9 + # refs: [$t9 => #9] + # #9 # # #root - # -> #8 via [struct `m::R`] at line 16 + # -> #9 via [struct `m::R`] at line 16 # - 13: $t2 := read_ref($t8) + 15: $t2 := read_ref($t9) # abort state: {returns} # live vars: $t2 # refs: [] # - 14: return $t2 + 16: return $t2 } ============ after AbilityProcessor: ================ @@ -382,24 +436,272 @@ fun m::f($t0: u8, $t1: &vector): u64 { var $t3: &vector var $t4: bool var $t5: u8 - var $t6: &0x42::m::R - var $t7: address - var $t8: &u64 - var $t9: u64 - 0: $t5 := 0 - 1: $t4 := ==($t0, $t5) - 2: if ($t4) goto 3 else goto 9 - 3: label L0 - 4: drop($t1) - 5: $t7 := 0x1 - 6: $t6 := borrow_global<0x42::m::R>($t7) - 7: $t3 := borrow_field<0x42::m::R>.data($t6) - 8: goto 11 - 9: label L1 - 10: $t3 := move($t1) - 11: label L2 - 12: $t9 := 0 - 13: $t8 := vector::borrow($t3, $t9) - 14: $t2 := read_ref($t8) - 15: return $t2 + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 + 0: $t5 := move($t0) + 1: $t6 := 0 + 2: $t4 := ==($t5, $t6) + 3: if ($t4) goto 4 else goto 10 + 4: label L0 + 5: drop($t1) + 6: $t8 := 0x1 + 7: $t7 := borrow_global<0x42::m::R>($t8) + 8: $t3 := borrow_field<0x42::m::R>.data($t7) + 9: goto 12 + 10: label L1 + 11: $t3 := move($t1) + 12: label L2 + 13: $t10 := move($t3) + 14: $t11 := 0 + 15: $t9 := vector::borrow($t10, $t11) + 16: $t2 := read_ref($t9) + 17: return $t2 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f($t0: u8, $t1: &vector): u64 { + var $t2: u64 + var $t3: &vector + var $t4: bool + var $t5: u8 + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 + # live vars: $t0, $t1 + 0: $t5 := move($t0) + # live vars: $t1, $t5 + 1: $t6 := 0 + # live vars: $t1, $t5, $t6 + 2: $t4 := ==($t5, $t6) + # live vars: $t1, $t4 + 3: if ($t4) goto 4 else goto 15 + # live vars: $t1 + 4: label L0 + # live vars: $t1 + 5: drop($t1) + # live vars: + 6: $t8 := 0x1 + # live vars: $t8 + 7: $t7 := borrow_global<0x42::m::R>($t8) + # live vars: $t7 + 8: $t3 := borrow_field<0x42::m::R>.data($t7) + # live vars: $t3 + 9: label L2 + # live vars: $t3 + 10: $t10 := move($t3) + # live vars: $t10 + 11: $t11 := 0 + # live vars: $t10, $t11 + 12: $t9 := vector::borrow($t10, $t11) + # live vars: $t9 + 13: $t2 := read_ref($t9) + # live vars: $t2 + 14: return $t2 + # live vars: $t1 + 15: label L1 + # live vars: $t1 + 16: $t3 := move($t1) + # live vars: $t3 + 17: goto 9 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f($t0: u8, $t1: &vector): u64 { + var $t2: u64 + var $t3: &vector + var $t4: bool + var $t5: u8 + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 + # live vars: $t0, $t1 + 0: $t5 := move($t0) + # live vars: $t1, $t5 + 1: $t6 := 0 + # live vars: $t1, $t5, $t6 + 2: $t4 := ==($t5, $t6) + # live vars: $t1, $t4 + 3: if ($t4) goto 4 else goto 15 + # live vars: $t1 + 4: label L0 + # live vars: $t1 + 5: drop($t1) + # live vars: + 6: $t8 := 0x1 + # live vars: $t8 + 7: $t7 := borrow_global<0x42::m::R>($t8) + # live vars: $t7 + 8: $t3 := borrow_field<0x42::m::R>.data($t7) + # live vars: $t3 + 9: label L2 + # live vars: $t3 + 10: $t10 := move($t3) + # live vars: $t10 + 11: $t11 := 0 + # live vars: $t10, $t11 + 12: $t9 := vector::borrow($t10, $t11) + # live vars: $t9 + 13: $t2 := read_ref($t9) + # live vars: $t2 + 14: return $t2 + # live vars: $t1 + 15: label L1 + # live vars: $t1 + 16: $t3 := move($t1) + # live vars: $t3 + 17: goto 9 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f($t0: u8, $t1: &vector): u64 { + var $t2: u64 [unused] + var $t3: &vector + var $t4: bool + var $t5: u8 [unused] + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 + # live vars: $t0, $t1 + 0: $t0 := move($t0) + # live vars: $t0, $t1 + 1: $t6 := 0 + # live vars: $t0, $t1, $t6 + 2: $t4 := ==($t0, $t6) + # live vars: $t1, $t4 + 3: if ($t4) goto 4 else goto 15 + # live vars: $t1 + 4: label L0 + # live vars: $t1 + 5: drop($t1) + # live vars: + 6: $t8 := 0x1 + # live vars: $t8 + 7: $t7 := borrow_global<0x42::m::R>($t8) + # live vars: $t7 + 8: $t3 := borrow_field<0x42::m::R>.data($t7) + # live vars: $t3 + 9: label L2 + # live vars: $t3 + 10: $t10 := move($t3) + # live vars: $t10 + 11: $t11 := 0 + # live vars: $t10, $t11 + 12: $t9 := vector::borrow($t10, $t11) + # live vars: $t9 + 13: $t11 := read_ref($t9) + # live vars: $t11 + 14: return $t11 + # live vars: $t1 + 15: label L1 + # live vars: $t1 + 16: $t3 := move($t1) + # live vars: $t3 + 17: goto 9 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f($t0: u8, $t1: &vector): u64 { + var $t2: u64 [unused] + var $t3: &vector + var $t4: bool + var $t5: u8 [unused] + var $t6: u8 + var $t7: &0x42::m::R + var $t8: address + var $t9: &u64 + var $t10: &vector + var $t11: u64 + # live vars: $t0, $t1 + 0: $t0 := move($t0) + # live vars: $t0, $t1 + 1: $t6 := 0 + # live vars: $t0, $t1, $t6 + 2: $t4 := ==($t0, $t6) + # live vars: $t1, $t4 + 3: if ($t4) goto 4 else goto 15 + # live vars: $t1 + 4: label L0 + # live vars: $t1 + 5: drop($t1) + # live vars: + 6: $t8 := 0x1 + # live vars: $t8 + 7: $t7 := borrow_global<0x42::m::R>($t8) + # live vars: $t7 + 8: $t3 := borrow_field<0x42::m::R>.data($t7) + # live vars: $t3 + 9: label L2 + # live vars: $t3 + 10: $t10 := move($t3) + # live vars: $t10 + 11: $t11 := 0 + # live vars: $t10, $t11 + 12: $t9 := vector::borrow($t10, $t11) + # live vars: $t9 + 13: $t11 := read_ref($t9) + # live vars: $t11 + 14: return $t11 + # live vars: $t1 + 15: label L1 + # live vars: $t1 + 16: $t3 := move($t1) + # live vars: $t3 + 17: goto 9 +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { +struct R has key { + data: vector +} + +f(Arg0: u8, Arg1: &vector): u64 /* def_idx: 0 */ { +L2: loc0: &vector +B0: + 0: MoveLoc[0](Arg0: u8) + 1: LdU8(0) + 2: Eq + 3: BrFalse(15) +B1: + 4: MoveLoc[1](Arg1: &vector) + 5: Pop + 6: LdConst[0](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) + 7: ImmBorrowGlobal[0](R) + 8: ImmBorrowField[0](R.data: vector) + 9: StLoc[2](loc0: &vector) +B2: + 10: MoveLoc[2](loc0: &vector) + 11: LdU64(0) + 12: VecImmBorrow(1) + 13: ReadRef + 14: Ret +B3: + 15: MoveLoc[1](Arg1: &vector) + 16: StLoc[2](loc0: &vector) + 17: Branch(10) +} } +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/by_reference.exp b/third_party/move/move-compiler-v2/tests/ability-transform/by_reference.exp index 1840279efaab9..cc091f905d208 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/by_reference.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/by_reference.exp @@ -1567,3 +1567,754 @@ fun _0::check() { 80: label L23 81: return () } + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun _0::check() { + var $t0: bool + var $t1: u64 + var $t2: bool + var $t3: u64 + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: u64 + var $t8: bool + var $t9: vector + var $t10: vector + var $t11: u64 + var $t12: &mut u64 + var $t13: u64 + var $t14: u64 + var $t15: &mut vector + var $t16: vector + var $t17: vector + var $t18: bool + var $t19: u64 + var $t20: u64 + var $t21: u64 + var $t22: bool + var $t23: vector + var $t24: vector + var $t25: u64 + var $t26: bool + var $t27: u64 + var $t28: bool + var $t29: u64 + # live vars: + 0: $t0 := true + # live vars: $t0 + 1: if ($t0) goto 2 else goto 63 + # live vars: + 2: label L0 + # live vars: + 3: $t2 := true + # live vars: $t2 + 4: if ($t2) goto 5 else goto 60 + # live vars: + 5: label L3 + # live vars: + 6: $t5 := 0 + # live vars: $t5 + 7: $t6 := 0 + # live vars: $t5, $t6 + 8: $t4 := ==($t5, $t6) + # live vars: $t4 + 9: if ($t4) goto 10 else goto 57 + # live vars: + 10: label L6 + # live vars: + 11: $t9 := [104, 101, 108, 108, 111] + # live vars: $t9 + 12: $t10 := [104, 101, 108, 108, 111] + # live vars: $t9, $t10 + 13: $t8 := ==($t9, $t10) + # live vars: $t8 + 14: if ($t8) goto 15 else goto 54 + # live vars: + 15: label L9 + # live vars: + 16: $t13 := 0 + # live vars: $t13 + 17: $t12 := borrow_local($t13) + # live vars: $t12 + 18: $t14 := 1 + # live vars: $t12, $t14 + 19: write_ref($t12, $t14) + # live vars: $t12 + 20: $t16 := [104, 101, 108, 108, 111] + # live vars: $t12, $t16 + 21: $t15 := borrow_local($t16) + # live vars: $t12, $t15 + 22: $t17 := [98, 121, 101] + # live vars: $t12, $t15, $t17 + 23: write_ref($t15, $t17) + # live vars: $t12, $t15 + 24: $t19 := read_ref($t12) + # live vars: $t15, $t19 + 25: $t20 := 1 + # live vars: $t15, $t19, $t20 + 26: $t18 := ==($t19, $t20) + # live vars: $t15, $t18 + 27: if ($t18) goto 28 else goto 50 + # live vars: $t15 + 28: label L12 + # live vars: $t15 + 29: $t23 := read_ref($t15) + # live vars: $t23 + 30: $t24 := [98, 121, 101] + # live vars: $t23, $t24 + 31: $t22 := ==($t23, $t24) + # live vars: $t22 + 32: if ($t22) goto 33 else goto 47 + # live vars: + 33: label L15 + # live vars: + 34: $t26 := true + # live vars: $t26 + 35: if ($t26) goto 36 else goto 44 + # live vars: + 36: label L18 + # live vars: + 37: $t28 := true + # live vars: $t28 + 38: if ($t28) goto 39 else goto 41 + # live vars: + 39: label L21 + # live vars: + 40: return () + # live vars: + 41: label L22 + # live vars: + 42: $t29 := 42 + # live vars: $t29 + 43: abort($t29) + # live vars: + 44: label L19 + # live vars: + 45: $t27 := 42 + # live vars: $t27 + 46: abort($t27) + # live vars: + 47: label L16 + # live vars: + 48: $t25 := 42 + # live vars: $t25 + 49: abort($t25) + # live vars: $t15 + 50: label L13 + # live vars: $t15 + 51: drop($t15) + # live vars: + 52: $t21 := 42 + # live vars: $t21 + 53: abort($t21) + # live vars: + 54: label L10 + # live vars: + 55: $t11 := 42 + # live vars: $t11 + 56: abort($t11) + # live vars: + 57: label L7 + # live vars: + 58: $t7 := 42 + # live vars: $t7 + 59: abort($t7) + # live vars: + 60: label L4 + # live vars: + 61: $t3 := 42 + # live vars: $t3 + 62: abort($t3) + # live vars: + 63: label L1 + # live vars: + 64: $t1 := 42 + # live vars: $t1 + 65: abort($t1) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun _0::check() { + var $t0: bool + var $t1: u64 + var $t2: bool + var $t3: u64 + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: u64 + var $t8: bool + var $t9: vector + var $t10: vector + var $t11: u64 + var $t12: &mut u64 + var $t13: u64 + var $t14: u64 + var $t15: &mut vector + var $t16: vector + var $t17: vector + var $t18: bool + var $t19: u64 + var $t20: u64 + var $t21: u64 + var $t22: bool + var $t23: vector + var $t24: vector + var $t25: u64 + var $t26: bool + var $t27: u64 + var $t28: bool + var $t29: u64 + # live vars: + 0: $t0 := true + # live vars: $t0 + 1: if ($t0) goto 2 else goto 63 + # live vars: + 2: label L0 + # live vars: + 3: $t2 := true + # live vars: $t2 + 4: if ($t2) goto 5 else goto 60 + # live vars: + 5: label L3 + # live vars: + 6: $t5 := 0 + # live vars: $t5 + 7: $t6 := 0 + # live vars: $t5, $t6 + 8: $t4 := ==($t5, $t6) + # live vars: $t4 + 9: if ($t4) goto 10 else goto 57 + # live vars: + 10: label L6 + # live vars: + 11: $t9 := [104, 101, 108, 108, 111] + # live vars: $t9 + 12: $t10 := [104, 101, 108, 108, 111] + # live vars: $t9, $t10 + 13: $t8 := ==($t9, $t10) + # live vars: $t8 + 14: if ($t8) goto 15 else goto 54 + # live vars: + 15: label L9 + # live vars: + 16: $t13 := 0 + # live vars: $t13 + 17: $t12 := borrow_local($t13) + # live vars: $t12 + 18: $t14 := 1 + # live vars: $t12, $t14 + 19: write_ref($t12, $t14) + # live vars: $t12 + 20: $t16 := [104, 101, 108, 108, 111] + # live vars: $t12, $t16 + 21: $t15 := borrow_local($t16) + # live vars: $t12, $t15 + 22: $t17 := [98, 121, 101] + # live vars: $t12, $t15, $t17 + 23: write_ref($t15, $t17) + # live vars: $t12, $t15 + 24: $t19 := read_ref($t12) + # live vars: $t15, $t19 + 25: $t20 := 1 + # live vars: $t15, $t19, $t20 + 26: $t18 := ==($t19, $t20) + # live vars: $t15, $t18 + 27: if ($t18) goto 28 else goto 50 + # live vars: $t15 + 28: label L12 + # live vars: $t15 + 29: $t23 := read_ref($t15) + # live vars: $t23 + 30: $t24 := [98, 121, 101] + # live vars: $t23, $t24 + 31: $t22 := ==($t23, $t24) + # live vars: $t22 + 32: if ($t22) goto 33 else goto 47 + # live vars: + 33: label L15 + # live vars: + 34: $t26 := true + # live vars: $t26 + 35: if ($t26) goto 36 else goto 44 + # live vars: + 36: label L18 + # live vars: + 37: $t28 := true + # live vars: $t28 + 38: if ($t28) goto 39 else goto 41 + # live vars: + 39: label L21 + # live vars: + 40: return () + # live vars: + 41: label L22 + # live vars: + 42: $t29 := 42 + # live vars: $t29 + 43: abort($t29) + # live vars: + 44: label L19 + # live vars: + 45: $t27 := 42 + # live vars: $t27 + 46: abort($t27) + # live vars: + 47: label L16 + # live vars: + 48: $t25 := 42 + # live vars: $t25 + 49: abort($t25) + # live vars: $t15 + 50: label L13 + # live vars: $t15 + 51: drop($t15) + # live vars: + 52: $t21 := 42 + # live vars: $t21 + 53: abort($t21) + # live vars: + 54: label L10 + # live vars: + 55: $t11 := 42 + # live vars: $t11 + 56: abort($t11) + # live vars: + 57: label L7 + # live vars: + 58: $t7 := 42 + # live vars: $t7 + 59: abort($t7) + # live vars: + 60: label L4 + # live vars: + 61: $t3 := 42 + # live vars: $t3 + 62: abort($t3) + # live vars: + 63: label L1 + # live vars: + 64: $t1 := 42 + # live vars: $t1 + 65: abort($t1) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun _0::check() { + var $t0: bool + var $t1: u64 [unused] + var $t2: bool [unused] + var $t3: u64 [unused] + var $t4: bool [unused] + var $t5: u64 + var $t6: u64 + var $t7: u64 [unused] + var $t8: bool [unused] + var $t9: vector + var $t10: vector + var $t11: u64 [unused] + var $t12: &mut u64 + var $t13: u64 + var $t14: u64 [unused] + var $t15: &mut vector + var $t16: vector + var $t17: vector [unused] + var $t18: bool [unused] + var $t19: u64 [unused] + var $t20: u64 [unused] + var $t21: u64 [unused] + var $t22: bool [unused] + var $t23: vector [unused] + var $t24: vector [unused] + var $t25: u64 [unused] + var $t26: bool [unused] + var $t27: u64 [unused] + var $t28: bool [unused] + var $t29: u64 [unused] + # live vars: + 0: $t0 := true + # live vars: $t0 + 1: if ($t0) goto 2 else goto 63 + # live vars: + 2: label L0 + # live vars: + 3: $t0 := true + # live vars: $t0 + 4: if ($t0) goto 5 else goto 60 + # live vars: + 5: label L3 + # live vars: + 6: $t5 := 0 + # live vars: $t5 + 7: $t6 := 0 + # live vars: $t5, $t6 + 8: $t0 := ==($t5, $t6) + # live vars: $t0 + 9: if ($t0) goto 10 else goto 57 + # live vars: + 10: label L6 + # live vars: + 11: $t9 := [104, 101, 108, 108, 111] + # live vars: $t9 + 12: $t10 := [104, 101, 108, 108, 111] + # live vars: $t9, $t10 + 13: $t0 := ==($t9, $t10) + # live vars: $t0 + 14: if ($t0) goto 15 else goto 54 + # live vars: + 15: label L9 + # live vars: + 16: $t13 := 0 + # live vars: $t13 + 17: $t12 := borrow_local($t13) + # live vars: $t12 + 18: $t5 := 1 + # live vars: $t5, $t12 + 19: write_ref($t12, $t5) + # live vars: $t12 + 20: $t16 := [104, 101, 108, 108, 111] + # live vars: $t12, $t16 + 21: $t15 := borrow_local($t16) + # live vars: $t12, $t15 + 22: $t9 := [98, 121, 101] + # live vars: $t9, $t12, $t15 + 23: write_ref($t15, $t9) + # live vars: $t12, $t15 + 24: $t5 := read_ref($t12) + # live vars: $t5, $t15 + 25: $t6 := 1 + # live vars: $t5, $t6, $t15 + 26: $t0 := ==($t5, $t6) + # live vars: $t0, $t15 + 27: if ($t0) goto 28 else goto 50 + # live vars: $t15 + 28: label L12 + # live vars: $t15 + 29: $t9 := read_ref($t15) + # live vars: $t9 + 30: $t10 := [98, 121, 101] + # live vars: $t9, $t10 + 31: $t0 := ==($t9, $t10) + # live vars: $t0 + 32: if ($t0) goto 33 else goto 47 + # live vars: + 33: label L15 + # live vars: + 34: $t0 := true + # live vars: $t0 + 35: if ($t0) goto 36 else goto 44 + # live vars: + 36: label L18 + # live vars: + 37: $t0 := true + # live vars: $t0 + 38: if ($t0) goto 39 else goto 41 + # live vars: + 39: label L21 + # live vars: + 40: return () + # live vars: + 41: label L22 + # live vars: + 42: $t5 := 42 + # live vars: $t5 + 43: abort($t5) + # live vars: + 44: label L19 + # live vars: + 45: $t5 := 42 + # live vars: $t5 + 46: abort($t5) + # live vars: + 47: label L16 + # live vars: + 48: $t5 := 42 + # live vars: $t5 + 49: abort($t5) + # live vars: $t15 + 50: label L13 + # live vars: $t15 + 51: drop($t15) + # live vars: + 52: $t5 := 42 + # live vars: $t5 + 53: abort($t5) + # live vars: + 54: label L10 + # live vars: + 55: $t5 := 42 + # live vars: $t5 + 56: abort($t5) + # live vars: + 57: label L7 + # live vars: + 58: $t5 := 42 + # live vars: $t5 + 59: abort($t5) + # live vars: + 60: label L4 + # live vars: + 61: $t5 := 42 + # live vars: $t5 + 62: abort($t5) + # live vars: + 63: label L1 + # live vars: + 64: $t5 := 42 + # live vars: $t5 + 65: abort($t5) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun _0::check() { + var $t0: bool + var $t1: u64 [unused] + var $t2: bool [unused] + var $t3: u64 [unused] + var $t4: bool [unused] + var $t5: u64 + var $t6: u64 + var $t7: u64 [unused] + var $t8: bool [unused] + var $t9: vector + var $t10: vector + var $t11: u64 [unused] + var $t12: &mut u64 + var $t13: u64 + var $t14: u64 [unused] + var $t15: &mut vector + var $t16: vector + var $t17: vector [unused] + var $t18: bool [unused] + var $t19: u64 [unused] + var $t20: u64 [unused] + var $t21: u64 [unused] + var $t22: bool [unused] + var $t23: vector [unused] + var $t24: vector [unused] + var $t25: u64 [unused] + var $t26: bool [unused] + var $t27: u64 [unused] + var $t28: bool [unused] + var $t29: u64 [unused] + # live vars: + 0: $t0 := true + # live vars: $t0 + 1: if ($t0) goto 2 else goto 63 + # live vars: + 2: label L0 + # live vars: + 3: $t0 := true + # live vars: $t0 + 4: if ($t0) goto 5 else goto 60 + # live vars: + 5: label L3 + # live vars: + 6: $t5 := 0 + # live vars: $t5 + 7: $t6 := 0 + # live vars: $t5, $t6 + 8: $t0 := ==($t5, $t6) + # live vars: $t0 + 9: if ($t0) goto 10 else goto 57 + # live vars: + 10: label L6 + # live vars: + 11: $t9 := [104, 101, 108, 108, 111] + # live vars: $t9 + 12: $t10 := [104, 101, 108, 108, 111] + # live vars: $t9, $t10 + 13: $t0 := ==($t9, $t10) + # live vars: $t0 + 14: if ($t0) goto 15 else goto 54 + # live vars: + 15: label L9 + # live vars: + 16: $t13 := 0 + # live vars: $t13 + 17: $t12 := borrow_local($t13) + # live vars: $t12 + 18: $t5 := 1 + # live vars: $t5, $t12 + 19: write_ref($t12, $t5) + # live vars: $t12 + 20: $t16 := [104, 101, 108, 108, 111] + # live vars: $t12, $t16 + 21: $t15 := borrow_local($t16) + # live vars: $t12, $t15 + 22: $t9 := [98, 121, 101] + # live vars: $t9, $t12, $t15 + 23: write_ref($t15, $t9) + # live vars: $t12, $t15 + 24: $t5 := read_ref($t12) + # live vars: $t5, $t15 + 25: $t6 := 1 + # live vars: $t5, $t6, $t15 + 26: $t0 := ==($t5, $t6) + # live vars: $t0, $t15 + 27: if ($t0) goto 28 else goto 50 + # live vars: $t15 + 28: label L12 + # live vars: $t15 + 29: $t9 := read_ref($t15) + # live vars: $t9 + 30: $t10 := [98, 121, 101] + # live vars: $t9, $t10 + 31: $t0 := ==($t9, $t10) + # live vars: $t0 + 32: if ($t0) goto 33 else goto 47 + # live vars: + 33: label L15 + # live vars: + 34: $t0 := true + # live vars: $t0 + 35: if ($t0) goto 36 else goto 44 + # live vars: + 36: label L18 + # live vars: + 37: $t0 := true + # live vars: $t0 + 38: if ($t0) goto 39 else goto 41 + # live vars: + 39: label L21 + # live vars: + 40: return () + # live vars: + 41: label L22 + # live vars: + 42: $t5 := 42 + # live vars: $t5 + 43: abort($t5) + # live vars: + 44: label L19 + # live vars: + 45: $t5 := 42 + # live vars: $t5 + 46: abort($t5) + # live vars: + 47: label L16 + # live vars: + 48: $t5 := 42 + # live vars: $t5 + 49: abort($t5) + # live vars: $t15 + 50: label L13 + # live vars: $t15 + 51: drop($t15) + # live vars: + 52: $t5 := 42 + # live vars: $t5 + 53: abort($t5) + # live vars: + 54: label L10 + # live vars: + 55: $t5 := 42 + # live vars: $t5 + 56: abort($t5) + # live vars: + 57: label L7 + # live vars: + 58: $t5 := 42 + # live vars: $t5 + 59: abort($t5) + # live vars: + 60: label L4 + # live vars: + 61: $t5 := 42 + # live vars: $t5 + 62: abort($t5) + # live vars: + 63: label L1 + # live vars: + 64: $t5 := 42 + # live vars: $t5 + 65: abort($t5) +} + + +============ disassembled file-format ================== +// Move bytecode v7 +script { + + +main() /* def_idx: 0 */ { +L0: loc0: u64 +L1: loc1: &mut u64 +L2: loc2: vector +L3: loc3: &mut vector +B0: + 0: LdU64(0) + 1: LdU64(0) + 2: Eq + 3: BrFalse(45) +B1: + 4: LdConst[0](Vector(U8): [5, 104, 101, 108, 108, 111]) + 5: LdConst[0](Vector(U8): [5, 104, 101, 108, 108, 111]) + 6: Eq + 7: BrFalse(43) +B2: + 8: LdU64(0) + 9: StLoc[0](loc0: u64) + 10: MutBorrowLoc[0](loc0: u64) + 11: StLoc[1](loc1: &mut u64) + 12: LdU64(1) + 13: CopyLoc[1](loc1: &mut u64) + 14: WriteRef + 15: LdConst[0](Vector(U8): [5, 104, 101, 108, 108, 111]) + 16: StLoc[2](loc2: vector) + 17: MutBorrowLoc[2](loc2: vector) + 18: StLoc[3](loc3: &mut vector) + 19: LdConst[1](Vector(U8): [3, 98, 121, 101]) + 20: CopyLoc[3](loc3: &mut vector) + 21: WriteRef + 22: MoveLoc[1](loc1: &mut u64) + 23: ReadRef + 24: LdU64(1) + 25: Eq + 26: BrFalse(39) +B3: + 27: MoveLoc[3](loc3: &mut vector) + 28: ReadRef + 29: LdConst[1](Vector(U8): [3, 98, 121, 101]) + 30: Eq + 31: BrFalse(37) +B4: + 32: Ret +B5: + 33: LdU64(42) + 34: Abort +B6: + 35: LdU64(42) + 36: Abort +B7: + 37: LdU64(42) + 38: Abort +B8: + 39: MoveLoc[3](loc3: &mut vector) + 40: Pop + 41: LdU64(42) + 42: Abort +B9: + 43: LdU64(42) + 44: Abort +B10: + 45: LdU64(42) + 46: Abort +B11: + 47: LdU64(42) + 48: Abort +B12: + 49: LdU64(42) + 50: Abort +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/copy_ability_tuple.exp b/third_party/move/move-compiler-v2/tests/ability-transform/copy_ability_tuple.exp index 3af453f1202a4..6631e64df9b64 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/copy_ability_tuple.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/copy_ability_tuple.exp @@ -15,12 +15,14 @@ public fun M::g($t0: &signer) { var $t1: 0x42::M::R var $t2: u64 var $t3: u64 + var $t4: &signer 0: $t2 := 1 1: $t1 := pack 0x42::M::R($t2) 2: $t3 := 3 3: ($t1, $t3) := M::f($t1) - 4: move_to<0x42::M::R>($t0, $t1) - 5: return () + 4: $t4 := infer($t0) + 5: move_to<0x42::M::R>($t4, $t1) + 6: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -43,6 +45,7 @@ public fun M::g($t0: &signer) { var $t1: 0x42::M::R var $t2: u64 var $t3: u64 + var $t4: &signer # live vars: $t0 0: $t2 := 1 # live vars: $t0, $t2 @@ -52,9 +55,11 @@ public fun M::g($t0: &signer) { # live vars: $t0, $t1 3: ($t1, $t3) := M::f($t1) # live vars: $t0, $t1 - 4: move_to<0x42::M::R>($t0, $t1) + 4: $t4 := infer($t0) + # live vars: $t1, $t4 + 5: move_to<0x42::M::R>($t4, $t1) # live vars: - 5: return () + 6: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -77,6 +82,7 @@ public fun M::g($t0: &signer) { var $t1: 0x42::M::R var $t2: u64 var $t3: u64 + var $t4: &signer # live vars: $t0 0: $t2 := 1 # live vars: $t0, $t2 @@ -86,9 +92,11 @@ public fun M::g($t0: &signer) { # live vars: $t0, $t1 3: ($t1, $t3) := M::f($t1) # live vars: $t0, $t1 - 4: move_to<0x42::M::R>($t0, $t1) + 4: $t4 := infer($t0) + # live vars: $t1, $t4 + 5: move_to<0x42::M::R>($t4, $t1) # live vars: - 5: return () + 6: return () } ============ after ReferenceSafetyProcessor: ================ @@ -117,6 +125,7 @@ public fun M::g($t0: &signer) { var $t1: 0x42::M::R var $t2: u64 var $t3: u64 + var $t4: &signer # live vars: $t0 # refs: [$t0 => #0] # #0 @@ -156,11 +165,19 @@ public fun M::g($t0: &signer) { # #root # # - 4: move_to<0x42::M::R>($t0, $t1) + 4: $t4 := infer($t0) + # live vars: $t1, $t4 + # refs: [$t4 => #4] + # #4 + # + # #root + # + # + 5: move_to<0x42::M::R>($t4, $t1) # live vars: # refs: [] # - 5: return () + 6: return () } ============ after AbortAnalysisProcessor: ================ @@ -192,6 +209,7 @@ public fun M::g($t0: &signer) { var $t1: 0x42::M::R var $t2: u64 var $t3: u64 + var $t4: &signer # abort state: {returns,aborts} # live vars: $t0 # refs: [$t0 => #0] @@ -236,12 +254,21 @@ public fun M::g($t0: &signer) { # #root # # - 4: move_to<0x42::M::R>($t0, $t1) + 4: $t4 := infer($t0) + # abort state: {returns,aborts} + # live vars: $t1, $t4 + # refs: [$t4 => #4] + # #4 + # + # #root + # + # + 5: move_to<0x42::M::R>($t4, $t1) # abort state: {returns} # live vars: # refs: [] # - 5: return () + 6: return () } ============ after AbilityProcessor: ================ @@ -261,10 +288,184 @@ public fun M::g($t0: &signer) { var $t1: 0x42::M::R var $t2: u64 var $t3: u64 + var $t4: &signer 0: $t2 := 1 1: $t1 := pack 0x42::M::R($t2) 2: $t3 := 3 3: ($t1, $t3) := M::f($t1) + 4: $t4 := move($t0) + 5: move_to<0x42::M::R>($t4, $t1) + 6: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R + var $t2: u64 + # live vars: $t0 + 0: $t1 := move($t0) + # live vars: $t1 + 1: $t2 := 0 + # live vars: $t1, $t2 + 2: return ($t1, $t2) +} + + +[variant baseline] +public fun M::g($t0: &signer) { + var $t1: 0x42::M::R + var $t2: u64 + var $t3: u64 + var $t4: &signer + # live vars: $t0 + 0: $t2 := 1 + # live vars: $t0, $t2 + 1: $t1 := pack 0x42::M::R($t2) + # live vars: $t0, $t1 + 2: $t3 := 3 + # live vars: $t0, $t1 + 3: ($t1, $t3) := M::f($t1) + # live vars: $t0, $t1 + 4: $t4 := move($t0) + # live vars: $t1, $t4 + 5: move_to<0x42::M::R>($t4, $t1) + # live vars: + 6: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R + var $t2: u64 + # live vars: $t0 + 0: $t1 := move($t0) + # live vars: $t1 + 1: $t2 := 0 + # live vars: $t1, $t2 + 2: return ($t1, $t2) +} + + +[variant baseline] +public fun M::g($t0: &signer) { + var $t1: 0x42::M::R + var $t2: u64 + var $t3: u64 + var $t4: &signer + # live vars: $t0 + 0: $t2 := 1 + # live vars: $t0, $t2 + 1: $t1 := pack 0x42::M::R($t2) + # live vars: $t0, $t1 + 2: ($t1, $t3) := M::f($t1) + # live vars: $t0, $t1 + 3: $t4 := move($t0) + # live vars: $t1, $t4 + 4: move_to<0x42::M::R>($t4, $t1) + # live vars: + 5: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R [unused] + var $t2: u64 + # live vars: $t0 + 0: $t0 := move($t0) + # live vars: $t0 + 1: $t2 := 0 + # live vars: $t0, $t2 + 2: return ($t0, $t2) +} + + +[variant baseline] +public fun M::g($t0: &signer) { + var $t1: 0x42::M::R + var $t2: u64 + var $t3: u64 [unused] + var $t4: &signer [unused] + # live vars: $t0 + 0: $t2 := 1 + # live vars: $t0, $t2 + 1: $t1 := pack 0x42::M::R($t2) + # live vars: $t0, $t1 + 2: ($t1, $t2) := M::f($t1) + # live vars: $t0, $t1 + 3: $t0 := move($t0) + # live vars: $t0, $t1 4: move_to<0x42::M::R>($t0, $t1) + # live vars: 5: return () } + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun M::f($t0: 0x42::M::R): (0x42::M::R, u64) { + var $t1: 0x42::M::R [unused] + var $t2: u64 + # live vars: $t0 + 0: $t0 := move($t0) + # live vars: $t0 + 1: $t2 := 0 + # live vars: $t0, $t2 + 2: return ($t0, $t2) +} + + +[variant baseline] +public fun M::g($t0: &signer) { + var $t1: 0x42::M::R + var $t2: u64 + var $t3: u64 [unused] + var $t4: &signer [unused] + # live vars: $t0 + 0: $t2 := 1 + # live vars: $t0, $t2 + 1: $t1 := pack 0x42::M::R($t2) + # live vars: $t0, $t1 + 2: ($t1, $t2) := M::f($t1) + # live vars: $t0, $t1 + 3: $t0 := move($t0) + # live vars: $t0, $t1 + 4: move_to<0x42::M::R>($t0, $t1) + # live vars: + 5: return () +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.M { +struct R has key { + f: u64 +} + +public f(Arg0: R): R * u64 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: R) + 1: LdU64(0) + 2: Ret +} +public g(Arg0: &signer) /* def_idx: 1 */ { +L1: loc0: R +B0: + 0: LdU64(1) + 1: Pack[0](R) + 2: Call f(R): R * u64 + 3: Pop + 4: StLoc[1](loc0: R) + 5: MoveLoc[0](Arg0: &signer) + 6: MoveLoc[1](loc0: R) + 7: MoveTo[0](R) + 8: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/dead_but_borrowed.exp b/third_party/move/move-compiler-v2/tests/ability-transform/dead_but_borrowed.exp index 7a124dba2860a..45d341c56e269 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/dead_but_borrowed.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/dead_but_borrowed.exp @@ -119,3 +119,89 @@ fun explicate_drop::test0(): u8 { 2: $t0 := read_ref($t1) 3: return $t0 } + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun explicate_drop::test0(): u8 { + var $t0: u8 + var $t1: &u8 + var $t2: u8 + # live vars: + 0: $t2 := 42 + # live vars: $t2 + 1: $t1 := borrow_local($t2) + # live vars: $t1 + 2: $t0 := read_ref($t1) + # live vars: $t0 + 3: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun explicate_drop::test0(): u8 { + var $t0: u8 + var $t1: &u8 + var $t2: u8 + # live vars: + 0: $t2 := 42 + # live vars: $t2 + 1: $t1 := borrow_local($t2) + # live vars: $t1 + 2: $t0 := read_ref($t1) + # live vars: $t0 + 3: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun explicate_drop::test0(): u8 { + var $t0: u8 + var $t1: &u8 + var $t2: u8 + # live vars: + 0: $t2 := 42 + # live vars: $t2 + 1: $t1 := borrow_local($t2) + # live vars: $t1 + 2: $t0 := read_ref($t1) + # live vars: $t0 + 3: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun explicate_drop::test0(): u8 { + var $t0: u8 + var $t1: &u8 + var $t2: u8 + # live vars: + 0: $t2 := 42 + # live vars: $t2 + 1: $t1 := borrow_local($t2) + # live vars: $t1 + 2: $t0 := read_ref($t1) + # live vars: $t0 + 3: return $t0 +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.explicate_drop { + + +test0(): u8 /* def_idx: 0 */ { +L0: loc0: u8 +B0: + 0: LdU8(42) + 1: StLoc[0](loc0: u8) + 2: ImmBorrowLoc[0](loc0: u8) + 3: ReadRef + 4: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/destroy_after_call.exp b/third_party/move/move-compiler-v2/tests/ability-transform/destroy_after_call.exp index fcd3f543c20eb..ed7fd966f9853 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/destroy_after_call.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/destroy_after_call.exp @@ -255,3 +255,175 @@ fun m::g() { 6: drop($t3) 7: return () } + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f($t0: &mut u64): &mut u64 { + var $t1: &mut u64 + # live vars: $t0 + 0: $t1 := move($t0) + # live vars: $t1 + 1: return $t1 +} + + +[variant baseline] +fun m::g() { + var $t0: u64 + var $t1: &mut u64 + var $t2: &mut u64 + var $t3: &u64 + # live vars: + 0: $t0 := 22 + # live vars: $t0 + 1: $t1 := borrow_local($t0) + # live vars: $t0, $t1 + 2: $t2 := m::f($t1) + # live vars: $t0, $t2 + 3: $t1 := move($t2) + # live vars: $t0, $t1 + 4: drop($t1) + # live vars: $t0 + 5: $t3 := borrow_local($t0) + # live vars: $t3 + 6: drop($t3) + # live vars: + 7: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f($t0: &mut u64): &mut u64 { + var $t1: &mut u64 + # live vars: $t0 + 0: $t1 := move($t0) + # live vars: $t1 + 1: return $t1 +} + + +[variant baseline] +fun m::g() { + var $t0: u64 + var $t1: &mut u64 + var $t2: &mut u64 + var $t3: &u64 + # live vars: + 0: $t0 := 22 + # live vars: $t0 + 1: $t1 := borrow_local($t0) + # live vars: $t0, $t1 + 2: $t2 := m::f($t1) + # live vars: $t0, $t2 + 3: $t1 := move($t2) + # live vars: $t0, $t1 + 4: drop($t1) + # live vars: $t0 + 5: $t3 := borrow_local($t0) + # live vars: $t3 + 6: drop($t3) + # live vars: + 7: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f($t0: &mut u64): &mut u64 { + var $t1: &mut u64 [unused] + # live vars: $t0 + 0: $t0 := move($t0) + # live vars: $t0 + 1: return $t0 +} + + +[variant baseline] +fun m::g() { + var $t0: u64 + var $t1: &mut u64 + var $t2: &mut u64 + var $t3: &u64 + # live vars: + 0: $t0 := 22 + # live vars: $t0 + 1: $t1 := borrow_local($t0) + # live vars: $t0, $t1 + 2: $t2 := m::f($t1) + # live vars: $t0, $t2 + 3: $t1 := move($t2) + # live vars: $t0, $t1 + 4: drop($t1) + # live vars: $t0 + 5: $t3 := borrow_local($t0) + # live vars: $t3 + 6: drop($t3) + # live vars: + 7: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f($t0: &mut u64): &mut u64 { + var $t1: &mut u64 [unused] + # live vars: $t0 + 0: $t0 := move($t0) + # live vars: $t0 + 1: return $t0 +} + + +[variant baseline] +fun m::g() { + var $t0: u64 + var $t1: &mut u64 + var $t2: &mut u64 + var $t3: &u64 + # live vars: + 0: $t0 := 22 + # live vars: $t0 + 1: $t1 := borrow_local($t0) + # live vars: $t0, $t1 + 2: $t2 := m::f($t1) + # live vars: $t0, $t2 + 3: $t1 := move($t2) + # live vars: $t0, $t1 + 4: drop($t1) + # live vars: $t0 + 5: $t3 := borrow_local($t0) + # live vars: $t3 + 6: drop($t3) + # live vars: + 7: return () +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { + + +f(Arg0: &mut u64): &mut u64 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: &mut u64) + 1: Ret +} +g() /* def_idx: 1 */ { +L0: loc0: u64 +L1: loc1: &mut u64 +L2: loc2: &u64 +B0: + 0: LdU64(22) + 1: StLoc[0](loc0: u64) + 2: MutBorrowLoc[0](loc0: u64) + 3: Call f(&mut u64): &mut u64 + 4: Pop + 5: ImmBorrowLoc[0](loc0: u64) + 6: Pop + 7: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/drop_after_loop.exp b/third_party/move/move-compiler-v2/tests/ability-transform/drop_after_loop.exp index a136f62c2134d..cba211794ffba 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/drop_after_loop.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/drop_after_loop.exp @@ -10,6 +10,7 @@ fun m::drop_after_loop() { var $t5: bool var $t6: u64 var $t7: u64 + var $t8: u64 0: $t0 := 1 1: $t1 := borrow_local($t0) 2: $t2 := true @@ -26,16 +27,17 @@ fun m::drop_after_loop() { 13: label L4 14: goto 3 15: label L1 - 16: $t6 := 2 - 17: $t5 := ==($t0, $t6) - 18: if ($t5) goto 19 else goto 21 - 19: label L5 - 20: goto 24 - 21: label L6 - 22: $t7 := 0 - 23: abort($t7) - 24: label L7 - 25: return () + 16: $t6 := infer($t0) + 17: $t7 := 2 + 18: $t5 := ==($t6, $t7) + 19: if ($t5) goto 20 else goto 22 + 20: label L5 + 21: goto 25 + 22: label L6 + 23: $t8 := 0 + 24: abort($t8) + 25: label L7 + 26: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -50,6 +52,7 @@ fun m::drop_after_loop() { var $t5: bool var $t6: u64 var $t7: u64 + var $t8: u64 # live vars: 0: $t0 := 1 # live vars: $t0 @@ -83,25 +86,27 @@ fun m::drop_after_loop() { # live vars: $t0 15: label L1 # live vars: $t0 - 16: $t6 := 2 - # live vars: $t0, $t6 - 17: $t5 := ==($t0, $t6) + 16: $t6 := infer($t0) + # live vars: $t6 + 17: $t7 := 2 + # live vars: $t6, $t7 + 18: $t5 := ==($t6, $t7) # live vars: $t5 - 18: if ($t5) goto 19 else goto 21 + 19: if ($t5) goto 20 else goto 22 # live vars: - 19: label L5 + 20: label L5 # live vars: - 20: goto 24 + 21: goto 25 # live vars: - 21: label L6 + 22: label L6 # live vars: - 22: $t7 := 0 - # live vars: $t7 - 23: abort($t7) + 23: $t8 := 0 + # live vars: $t8 + 24: abort($t8) # live vars: - 24: label L7 + 25: label L7 # live vars: - 25: return () + 26: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -116,6 +121,7 @@ fun m::drop_after_loop() { var $t5: bool var $t6: u64 var $t7: u64 + var $t8: u64 # live vars: 0: $t0 := 1 # live vars: $t0 @@ -149,25 +155,27 @@ fun m::drop_after_loop() { # live vars: $t0 15: label L1 # live vars: $t0 - 16: $t6 := 2 - # live vars: $t0, $t6 - 17: $t5 := ==($t0, $t6) + 16: $t6 := infer($t0) + # live vars: $t6 + 17: $t7 := 2 + # live vars: $t6, $t7 + 18: $t5 := ==($t6, $t7) # live vars: $t5 - 18: if ($t5) goto 19 else goto 21 + 19: if ($t5) goto 20 else goto 22 # live vars: - 19: label L5 + 20: label L5 # live vars: - 20: goto 24 + 21: goto 25 # live vars: - 21: label L6 + 22: label L6 # live vars: - 22: $t7 := 0 - # live vars: $t7 - 23: abort($t7) + 23: $t8 := 0 + # live vars: $t8 + 24: abort($t8) # live vars: - 24: label L7 + 25: label L7 # live vars: - 25: return () + 26: return () } ============ after ReferenceSafetyProcessor: ================ @@ -182,6 +190,7 @@ fun m::drop_after_loop() { var $t5: bool var $t6: u64 var $t7: u64 + var $t8: u64 # live vars: # refs: [] # @@ -297,43 +306,47 @@ fun m::drop_after_loop() { # live vars: $t0 # refs: [] # - 16: $t6 := 2 - # live vars: $t0, $t6 + 16: $t6 := infer($t0) + # live vars: $t6 # refs: [] # - 17: $t5 := ==($t0, $t6) + 17: $t7 := 2 + # live vars: $t6, $t7 + # refs: [] + # + 18: $t5 := ==($t6, $t7) # live vars: $t5 # refs: [] # - 18: if ($t5) goto 19 else goto 21 + 19: if ($t5) goto 20 else goto 22 # live vars: # refs: [] # - 19: label L5 + 20: label L5 # live vars: # refs: [] # - 20: goto 24 + 21: goto 25 # live vars: # refs: [] # - 21: label L6 + 22: label L6 # live vars: # refs: [] # - 22: $t7 := 0 - # live vars: $t7 + 23: $t8 := 0 + # live vars: $t8 # refs: [] # - 23: abort($t7) + 24: abort($t8) # live vars: # refs: [] # - 24: label L7 + 25: label L7 # live vars: # refs: [] # - 25: return () + 26: return () } ============ after AbortAnalysisProcessor: ================ @@ -348,6 +361,7 @@ fun m::drop_after_loop() { var $t5: bool var $t6: u64 var $t7: u64 + var $t8: u64 # abort state: {returns,aborts} # live vars: # refs: [] @@ -480,52 +494,57 @@ fun m::drop_after_loop() { # live vars: $t0 # refs: [] # - 16: $t6 := 2 + 16: $t6 := infer($t0) + # abort state: {returns,aborts} + # live vars: $t6 + # refs: [] + # + 17: $t7 := 2 # abort state: {returns,aborts} - # live vars: $t0, $t6 + # live vars: $t6, $t7 # refs: [] # - 17: $t5 := ==($t0, $t6) + 18: $t5 := ==($t6, $t7) # abort state: {returns,aborts} # live vars: $t5 # refs: [] # - 18: if ($t5) goto 19 else goto 21 + 19: if ($t5) goto 20 else goto 22 # abort state: {returns} # live vars: # refs: [] # - 19: label L5 + 20: label L5 # abort state: {returns} # live vars: # refs: [] # - 20: goto 24 + 21: goto 25 # abort state: {aborts} # live vars: # refs: [] # - 21: label L6 + 22: label L6 # abort state: {aborts} # live vars: # refs: [] # - 22: $t7 := 0 + 23: $t8 := 0 # abort state: {aborts} - # live vars: $t7 + # live vars: $t8 # refs: [] # - 23: abort($t7) + 24: abort($t8) # abort state: {returns} # live vars: # refs: [] # - 24: label L7 + 25: label L7 # abort state: {returns} # live vars: # refs: [] # - 25: return () + 26: return () } ============ after AbilityProcessor: ================ @@ -540,6 +559,7 @@ fun m::drop_after_loop() { var $t5: bool var $t6: u64 var $t7: u64 + var $t8: u64 0: $t0 := 1 1: $t1 := borrow_local($t0) 2: $t2 := true @@ -557,14 +577,294 @@ fun m::drop_after_loop() { 14: label L4 15: goto 3 16: label L1 - 17: $t6 := 2 - 18: $t5 := ==($t0, $t6) - 19: if ($t5) goto 20 else goto 22 - 20: label L5 - 21: goto 25 - 22: label L6 - 23: $t7 := 0 - 24: abort($t7) - 25: label L7 - 26: return () + 17: $t6 := move($t0) + 18: $t7 := 2 + 19: $t5 := ==($t6, $t7) + 20: if ($t5) goto 21 else goto 23 + 21: label L5 + 22: goto 26 + 23: label L6 + 24: $t8 := 0 + 25: abort($t8) + 26: label L7 + 27: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::drop_after_loop() { + var $t0: u64 + var $t1: &mut u64 + var $t2: bool + var $t3: u64 + var $t4: bool + var $t5: bool + var $t6: u64 + var $t7: u64 + var $t8: u64 + # live vars: + 0: $t0 := 1 + # live vars: $t0 + 1: $t1 := borrow_local($t0) + # live vars: $t0, $t1 + 2: $t2 := true + # live vars: $t0, $t1, $t2 + 3: label L0 + # live vars: $t0, $t1, $t2 + 4: if ($t2) goto 5 else goto 11 + # live vars: $t0, $t1 + 5: label L2 + # live vars: $t0, $t1 + 6: $t3 := 2 + # live vars: $t0, $t1, $t3 + 7: write_ref($t1, $t3) + # live vars: $t0, $t1 + 8: $t4 := false + # live vars: $t0, $t1, $t4 + 9: $t2 := move($t4) + # live vars: $t0, $t1, $t2 + 10: goto 3 + # live vars: $t0, $t1 + 11: label L3 + # live vars: $t0, $t1 + 12: drop($t1) + # live vars: $t0 + 13: $t6 := move($t0) + # live vars: $t6 + 14: $t7 := 2 + # live vars: $t6, $t7 + 15: $t5 := ==($t6, $t7) + # live vars: $t5 + 16: if ($t5) goto 17 else goto 19 + # live vars: + 17: label L5 + # live vars: + 18: return () + # live vars: + 19: label L6 + # live vars: + 20: $t8 := 0 + # live vars: $t8 + 21: abort($t8) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::drop_after_loop() { + var $t0: u64 + var $t1: &mut u64 + var $t2: bool + var $t3: u64 + var $t4: bool + var $t5: bool + var $t6: u64 + var $t7: u64 + var $t8: u64 + # live vars: + 0: $t0 := 1 + # live vars: $t0 + 1: $t1 := borrow_local($t0) + # live vars: $t0, $t1 + 2: $t2 := true + # live vars: $t0, $t1, $t2 + 3: label L0 + # live vars: $t0, $t1, $t2 + 4: if ($t2) goto 5 else goto 11 + # live vars: $t0, $t1 + 5: label L2 + # live vars: $t0, $t1 + 6: $t3 := 2 + # live vars: $t0, $t1, $t3 + 7: write_ref($t1, $t3) + # live vars: $t0, $t1 + 8: $t4 := false + # live vars: $t0, $t1, $t4 + 9: $t2 := move($t4) + # live vars: $t0, $t1, $t2 + 10: goto 3 + # live vars: $t0, $t1 + 11: label L3 + # live vars: $t0, $t1 + 12: drop($t1) + # live vars: $t0 + 13: $t6 := move($t0) + # live vars: $t6 + 14: $t7 := 2 + # live vars: $t6, $t7 + 15: $t5 := ==($t6, $t7) + # live vars: $t5 + 16: if ($t5) goto 17 else goto 19 + # live vars: + 17: label L5 + # live vars: + 18: return () + # live vars: + 19: label L6 + # live vars: + 20: $t8 := 0 + # live vars: $t8 + 21: abort($t8) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::drop_after_loop() { + var $t0: u64 + var $t1: &mut u64 + var $t2: bool + var $t3: u64 + var $t4: bool + var $t5: bool [unused] + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] + # live vars: + 0: $t0 := 1 + # live vars: $t0 + 1: $t1 := borrow_local($t0) + # live vars: $t0, $t1 + 2: $t2 := true + # live vars: $t0, $t1, $t2 + 3: label L0 + # live vars: $t0, $t1, $t2 + 4: if ($t2) goto 5 else goto 11 + # live vars: $t0, $t1 + 5: label L2 + # live vars: $t0, $t1 + 6: $t3 := 2 + # live vars: $t0, $t1, $t3 + 7: write_ref($t1, $t3) + # live vars: $t0, $t1 + 8: $t4 := false + # live vars: $t0, $t1, $t4 + 9: $t2 := move($t4) + # live vars: $t0, $t1, $t2 + 10: goto 3 + # live vars: $t0, $t1 + 11: label L3 + # live vars: $t0, $t1 + 12: drop($t1) + # live vars: $t0 + 13: $t3 := move($t0) + # live vars: $t3 + 14: $t7 := 2 + # live vars: $t3, $t7 + 15: $t2 := ==($t3, $t7) + # live vars: $t2 + 16: if ($t2) goto 17 else goto 19 + # live vars: + 17: label L5 + # live vars: + 18: return () + # live vars: + 19: label L6 + # live vars: + 20: $t3 := 0 + # live vars: $t3 + 21: abort($t3) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::drop_after_loop() { + var $t0: u64 + var $t1: &mut u64 + var $t2: bool + var $t3: u64 + var $t4: bool + var $t5: bool [unused] + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] + # live vars: + 0: $t0 := 1 + # live vars: $t0 + 1: $t1 := borrow_local($t0) + # live vars: $t0, $t1 + 2: $t2 := true + # live vars: $t0, $t1, $t2 + 3: label L0 + # live vars: $t0, $t1, $t2 + 4: if ($t2) goto 5 else goto 11 + # live vars: $t0, $t1 + 5: label L2 + # live vars: $t0, $t1 + 6: $t3 := 2 + # live vars: $t0, $t1, $t3 + 7: write_ref($t1, $t3) + # live vars: $t0, $t1 + 8: $t4 := false + # live vars: $t0, $t1, $t4 + 9: $t2 := move($t4) + # live vars: $t0, $t1, $t2 + 10: goto 3 + # live vars: $t0, $t1 + 11: label L3 + # live vars: $t0, $t1 + 12: drop($t1) + # live vars: $t0 + 13: $t3 := move($t0) + # live vars: $t3 + 14: $t7 := 2 + # live vars: $t3, $t7 + 15: $t2 := ==($t3, $t7) + # live vars: $t2 + 16: if ($t2) goto 17 else goto 19 + # live vars: + 17: label L5 + # live vars: + 18: return () + # live vars: + 19: label L6 + # live vars: + 20: $t3 := 0 + # live vars: $t3 + 21: abort($t3) +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { + + +drop_after_loop() /* def_idx: 0 */ { +L0: loc0: u64 +L1: loc1: &mut u64 +L2: loc2: bool +B0: + 0: LdU64(1) + 1: StLoc[0](loc0: u64) + 2: MutBorrowLoc[0](loc0: u64) + 3: StLoc[1](loc1: &mut u64) + 4: LdTrue + 5: StLoc[2](loc2: bool) +B1: + 6: MoveLoc[2](loc2: bool) + 7: BrFalse(14) +B2: + 8: LdU64(2) + 9: CopyLoc[1](loc1: &mut u64) + 10: WriteRef + 11: LdFalse + 12: StLoc[2](loc2: bool) + 13: Branch(6) +B3: + 14: MoveLoc[1](loc1: &mut u64) + 15: Pop + 16: MoveLoc[0](loc0: u64) + 17: LdU64(2) + 18: Eq + 19: BrFalse(21) +B4: + 20: Ret +B5: + 21: LdU64(0) + 22: Abort +} } +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/drop_at_branch.exp b/third_party/move/move-compiler-v2/tests/ability-transform/drop_at_branch.exp index 3d11eed78fe83..2a72ca3c481ba 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/drop_at_branch.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/drop_at_branch.exp @@ -159,3 +159,120 @@ fun explicate_drop::drop_at_branch($t0: bool): u8 { 6: label L2 7: return $t1 } + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun explicate_drop::drop_at_branch($t0: bool): u8 { + var $t1: u8 + # live vars: $t0 + 0: if ($t0) goto 1 else goto 5 + # live vars: + 1: label L0 + # live vars: + 2: $t1 := 1 + # live vars: $t1 + 3: label L2 + # live vars: $t1 + 4: return $t1 + # live vars: + 5: label L1 + # live vars: + 6: $t1 := 0 + # live vars: $t1 + 7: goto 3 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun explicate_drop::drop_at_branch($t0: bool): u8 { + var $t1: u8 + # live vars: $t0 + 0: if ($t0) goto 1 else goto 5 + # live vars: + 1: label L0 + # live vars: + 2: $t1 := 1 + # live vars: $t1 + 3: label L2 + # live vars: $t1 + 4: return $t1 + # live vars: + 5: label L1 + # live vars: + 6: $t1 := 0 + # live vars: $t1 + 7: goto 3 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun explicate_drop::drop_at_branch($t0: bool): u8 { + var $t1: u8 + # live vars: $t0 + 0: if ($t0) goto 1 else goto 5 + # live vars: + 1: label L0 + # live vars: + 2: $t1 := 1 + # live vars: $t1 + 3: label L2 + # live vars: $t1 + 4: return $t1 + # live vars: + 5: label L1 + # live vars: + 6: $t1 := 0 + # live vars: $t1 + 7: goto 3 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun explicate_drop::drop_at_branch($t0: bool): u8 { + var $t1: u8 + # live vars: $t0 + 0: if ($t0) goto 1 else goto 5 + # live vars: + 1: label L0 + # live vars: + 2: $t1 := 1 + # live vars: $t1 + 3: label L2 + # live vars: $t1 + 4: return $t1 + # live vars: + 5: label L1 + # live vars: + 6: $t1 := 0 + # live vars: $t1 + 7: goto 3 +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.explicate_drop { + + +drop_at_branch(Arg0: bool): u8 /* def_idx: 0 */ { +L1: loc0: u8 +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrFalse(6) +B1: + 2: LdU8(1) + 3: StLoc[1](loc0: u8) +B2: + 4: MoveLoc[1](loc0: u8) + 5: Ret +B3: + 6: LdU8(0) + 7: StLoc[1](loc0: u8) + 8: Branch(4) +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/foreach_mut_expanded.exp b/third_party/move/move-compiler-v2/tests/ability-transform/foreach_mut_expanded.exp index 7ab9fcebe971c..62571bab81005 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/foreach_mut_expanded.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/foreach_mut_expanded.exp @@ -8,44 +8,52 @@ fun m::test_for_each_mut() { var $t3: &vector var $t4: &mut vector var $t5: bool - var $t6: &mut u64 - var $t7: u64 - var $t8: u64 + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector var $t9: u64 - var $t10: bool - var $t11: vector + var $t10: u64 + var $t11: u64 var $t12: u64 + var $t13: bool + var $t14: vector + var $t15: vector + var $t16: u64 0: $t0 := ["1", "2", "3"] 1: $t1 := 0 2: $t3 := borrow_local($t0) 3: $t2 := vector::length($t3) 4: $t4 := borrow_local($t0) 5: label L0 - 6: $t5 := <($t1, $t2) - 7: if ($t5) goto 8 else goto 16 - 8: label L2 - 9: $t6 := vector::borrow_mut($t4, $t1) - 10: $t7 := 2 - 11: write_ref($t6, $t7) - 12: $t9 := 1 - 13: $t8 := +($t1, $t9) - 14: $t1 := infer($t8) - 15: goto 18 - 16: label L3 - 17: goto 20 - 18: label L4 - 19: goto 5 - 20: label L1 - 21: $t11 := ["2", "3", "4"] - 22: $t10 := ==($t0, $t11) - 23: if ($t10) goto 24 else goto 26 - 24: label L5 - 25: goto 29 - 26: label L6 - 27: $t12 := 0 - 28: abort($t12) - 29: label L7 - 30: return () + 6: $t6 := infer($t1) + 7: $t5 := <($t6, $t2) + 8: if ($t5) goto 9 else goto 19 + 9: label L2 + 10: $t8 := infer($t4) + 11: $t7 := vector::borrow_mut($t8, $t1) + 12: $t9 := 2 + 13: write_ref($t7, $t9) + 14: $t11 := infer($t1) + 15: $t12 := 1 + 16: $t10 := +($t11, $t12) + 17: $t1 := infer($t10) + 18: goto 21 + 19: label L3 + 20: goto 23 + 21: label L4 + 22: goto 5 + 23: label L1 + 24: $t14 := infer($t0) + 25: $t15 := ["2", "3", "4"] + 26: $t13 := ==($t14, $t15) + 27: if ($t13) goto 28 else goto 30 + 28: label L5 + 29: goto 33 + 30: label L6 + 31: $t16 := 0 + 32: abort($t16) + 33: label L7 + 34: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -58,13 +66,17 @@ fun m::test_for_each_mut() { var $t3: &vector var $t4: &mut vector var $t5: bool - var $t6: &mut u64 - var $t7: u64 - var $t8: u64 + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector var $t9: u64 - var $t10: bool - var $t11: vector + var $t10: u64 + var $t11: u64 var $t12: u64 + var $t13: bool + var $t14: vector + var $t15: vector + var $t16: u64 # live vars: 0: $t0 := ["1", "2", "3"] # live vars: $t0 @@ -78,55 +90,63 @@ fun m::test_for_each_mut() { # live vars: $t0, $t1, $t2, $t4 5: label L0 # live vars: $t0, $t1, $t2, $t4 - 6: $t5 := <($t1, $t2) + 6: $t6 := infer($t1) + # live vars: $t0, $t1, $t2, $t4, $t6 + 7: $t5 := <($t6, $t2) # live vars: $t0, $t1, $t2, $t4, $t5 - 7: if ($t5) goto 8 else goto 16 + 8: if ($t5) goto 9 else goto 19 # live vars: $t0, $t1, $t2, $t4 - 8: label L2 + 9: label L2 # live vars: $t0, $t1, $t2, $t4 - 9: $t6 := vector::borrow_mut($t4, $t1) - # live vars: $t0, $t1, $t2, $t4, $t6 - 10: $t7 := 2 - # live vars: $t0, $t1, $t2, $t4, $t6, $t7 - 11: write_ref($t6, $t7) + 10: $t8 := infer($t4) + # live vars: $t0, $t1, $t2, $t4, $t8 + 11: $t7 := vector::borrow_mut($t8, $t1) + # live vars: $t0, $t1, $t2, $t4, $t7 + 12: $t9 := 2 + # live vars: $t0, $t1, $t2, $t4, $t7, $t9 + 13: write_ref($t7, $t9) # live vars: $t0, $t1, $t2, $t4 - 12: $t9 := 1 - # live vars: $t0, $t1, $t2, $t4, $t9 - 13: $t8 := +($t1, $t9) - # live vars: $t0, $t2, $t4, $t8 - 14: $t1 := infer($t8) + 14: $t11 := infer($t1) + # live vars: $t0, $t2, $t4, $t11 + 15: $t12 := 1 + # live vars: $t0, $t2, $t4, $t11, $t12 + 16: $t10 := +($t11, $t12) + # live vars: $t0, $t2, $t4, $t10 + 17: $t1 := infer($t10) # live vars: $t0, $t1, $t2, $t4 - 15: goto 18 + 18: goto 21 # live vars: $t0, $t1, $t2, $t4 - 16: label L3 + 19: label L3 # live vars: $t0 - 17: goto 20 + 20: goto 23 # live vars: $t0, $t1, $t2, $t4 - 18: label L4 + 21: label L4 # live vars: $t0, $t1, $t2, $t4 - 19: goto 5 + 22: goto 5 # live vars: $t0 - 20: label L1 + 23: label L1 # live vars: $t0 - 21: $t11 := ["2", "3", "4"] - # live vars: $t0, $t11 - 22: $t10 := ==($t0, $t11) - # live vars: $t10 - 23: if ($t10) goto 24 else goto 26 + 24: $t14 := infer($t0) + # live vars: $t14 + 25: $t15 := ["2", "3", "4"] + # live vars: $t14, $t15 + 26: $t13 := ==($t14, $t15) + # live vars: $t13 + 27: if ($t13) goto 28 else goto 30 # live vars: - 24: label L5 + 28: label L5 # live vars: - 25: goto 29 + 29: goto 33 # live vars: - 26: label L6 + 30: label L6 # live vars: - 27: $t12 := 0 - # live vars: $t12 - 28: abort($t12) + 31: $t16 := 0 + # live vars: $t16 + 32: abort($t16) # live vars: - 29: label L7 + 33: label L7 # live vars: - 30: return () + 34: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -139,13 +159,17 @@ fun m::test_for_each_mut() { var $t3: &vector var $t4: &mut vector var $t5: bool - var $t6: &mut u64 - var $t7: u64 - var $t8: u64 + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector var $t9: u64 - var $t10: bool - var $t11: vector + var $t10: u64 + var $t11: u64 var $t12: u64 + var $t13: bool + var $t14: vector + var $t15: vector + var $t16: u64 # live vars: 0: $t0 := ["1", "2", "3"] # live vars: $t0 @@ -159,55 +183,63 @@ fun m::test_for_each_mut() { # live vars: $t0, $t1, $t2, $t4 5: label L0 # live vars: $t0, $t1, $t2, $t4 - 6: $t5 := <($t1, $t2) + 6: $t6 := infer($t1) + # live vars: $t0, $t1, $t2, $t4, $t6 + 7: $t5 := <($t6, $t2) # live vars: $t0, $t1, $t2, $t4, $t5 - 7: if ($t5) goto 8 else goto 16 + 8: if ($t5) goto 9 else goto 19 # live vars: $t0, $t1, $t2, $t4 - 8: label L2 + 9: label L2 # live vars: $t0, $t1, $t2, $t4 - 9: $t6 := vector::borrow_mut($t4, $t1) - # live vars: $t0, $t1, $t2, $t4, $t6 - 10: $t7 := 2 - # live vars: $t0, $t1, $t2, $t4, $t6, $t7 - 11: write_ref($t6, $t7) + 10: $t8 := infer($t4) + # live vars: $t0, $t1, $t2, $t4, $t8 + 11: $t7 := vector::borrow_mut($t8, $t1) + # live vars: $t0, $t1, $t2, $t4, $t7 + 12: $t9 := 2 + # live vars: $t0, $t1, $t2, $t4, $t7, $t9 + 13: write_ref($t7, $t9) # live vars: $t0, $t1, $t2, $t4 - 12: $t9 := 1 - # live vars: $t0, $t1, $t2, $t4, $t9 - 13: $t8 := +($t1, $t9) - # live vars: $t0, $t2, $t4, $t8 - 14: $t1 := infer($t8) + 14: $t11 := infer($t1) + # live vars: $t0, $t2, $t4, $t11 + 15: $t12 := 1 + # live vars: $t0, $t2, $t4, $t11, $t12 + 16: $t10 := +($t11, $t12) + # live vars: $t0, $t2, $t4, $t10 + 17: $t1 := infer($t10) # live vars: $t0, $t1, $t2, $t4 - 15: goto 18 + 18: goto 21 # live vars: $t0, $t1, $t2, $t4 - 16: label L3 + 19: label L3 # live vars: $t0 - 17: goto 20 + 20: goto 23 # live vars: $t0, $t1, $t2, $t4 - 18: label L4 + 21: label L4 # live vars: $t0, $t1, $t2, $t4 - 19: goto 5 + 22: goto 5 # live vars: $t0 - 20: label L1 + 23: label L1 # live vars: $t0 - 21: $t11 := ["2", "3", "4"] - # live vars: $t0, $t11 - 22: $t10 := ==($t0, $t11) - # live vars: $t10 - 23: if ($t10) goto 24 else goto 26 + 24: $t14 := infer($t0) + # live vars: $t14 + 25: $t15 := ["2", "3", "4"] + # live vars: $t14, $t15 + 26: $t13 := ==($t14, $t15) + # live vars: $t13 + 27: if ($t13) goto 28 else goto 30 # live vars: - 24: label L5 + 28: label L5 # live vars: - 25: goto 29 + 29: goto 33 # live vars: - 26: label L6 + 30: label L6 # live vars: - 27: $t12 := 0 - # live vars: $t12 - 28: abort($t12) + 31: $t16 := 0 + # live vars: $t16 + 32: abort($t16) # live vars: - 29: label L7 + 33: label L7 # live vars: - 30: return () + 34: return () } ============ after ReferenceSafetyProcessor: ================ @@ -220,13 +252,17 @@ fun m::test_for_each_mut() { var $t3: &vector var $t4: &mut vector var $t5: bool - var $t6: &mut u64 - var $t7: u64 - var $t8: u64 + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector var $t9: u64 - var $t10: bool - var $t11: vector + var $t10: u64 + var $t11: u64 var $t12: u64 + var $t13: bool + var $t14: vector + var $t15: vector + var $t16: u64 # live vars: # refs: [] # @@ -266,7 +302,15 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 6: $t5 := <($t1, $t2) + 6: $t6 := infer($t1) + # live vars: $t0, $t1, $t2, $t4, $t6 + # refs: [$t4 => #4] + # #4 + # + # #root + # => (mut) #4 via [local `v`] at line 9 + # + 7: $t5 := <($t6, $t2) # live vars: $t0, $t1, $t2, $t4, $t5 # refs: [$t4 => #4] # #4 @@ -274,7 +318,7 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 7: if ($t5) goto 8 else goto 16 + 8: if ($t5) goto 9 else goto 19 # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] # #4 @@ -282,7 +326,7 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 8: label L2 + 9: label L2 # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] # #4 @@ -290,27 +334,37 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 9: $t6 := vector::borrow_mut($t4, $t1) - # live vars: $t0, $t1, $t2, $t4, $t6 - # refs: [$t4 => #4, $t6 => #6] + 10: $t8 := infer($t4) + # live vars: $t0, $t1, $t2, $t4, $t8 + # refs: [$t4 => #4, $t8 => #8] # #4 - # -> (mut) #6 via [] at line 11 - # #6 + # => (mut) #8 via [] at line 11 + # #8 # # #root # => (mut) #4 via [local `v`] at line 9 # - 10: $t7 := 2 - # live vars: $t0, $t1, $t2, $t4, $t6, $t7 - # refs: [$t4 => #4, $t6 => #6] + 11: $t7 := vector::borrow_mut($t8, $t1) + # live vars: $t0, $t1, $t2, $t4, $t7 + # refs: [$t4 => #4, $t7 => #7] + # #4 + # -> (mut) #7 via [] at line 11 + # #7 + # + # #root + # => (mut) #4 via [local `v`] at line 9 + # + 12: $t9 := 2 + # live vars: $t0, $t1, $t2, $t4, $t7, $t9 + # refs: [$t4 => #4, $t7 => #7] # #4 - # -> (mut) #6 via [] at line 11 - # #6 + # -> (mut) #7 via [] at line 11 + # #7 # # #root # => (mut) #4 via [local `v`] at line 9 # - 11: write_ref($t6, $t7) + 13: write_ref($t7, $t9) # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] # #4 @@ -318,23 +372,31 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 12: $t9 := 1 - # live vars: $t0, $t1, $t2, $t4, $t9 + 14: $t11 := infer($t1) + # live vars: $t0, $t2, $t4, $t11 + # refs: [$t4 => #4] + # #4 + # + # #root + # => (mut) #4 via [local `v`] at line 9 + # + 15: $t12 := 1 + # live vars: $t0, $t2, $t4, $t11, $t12 # refs: [$t4 => #4] # #4 # # #root # => (mut) #4 via [local `v`] at line 9 # - 13: $t8 := +($t1, $t9) - # live vars: $t0, $t2, $t4, $t8 + 16: $t10 := +($t11, $t12) + # live vars: $t0, $t2, $t4, $t10 # refs: [$t4 => #4] # #4 # # #root # => (mut) #4 via [local `v`] at line 9 # - 14: $t1 := infer($t8) + 17: $t1 := infer($t10) # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] # #4 @@ -342,7 +404,7 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 15: goto 18 + 18: goto 21 # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] # #4 @@ -350,11 +412,11 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 16: label L3 + 19: label L3 # live vars: $t0 # refs: [] # - 17: goto 20 + 20: goto 23 # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] # #4 @@ -362,7 +424,7 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 18: label L4 + 21: label L4 # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] # #4 @@ -370,51 +432,55 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 19: goto 5 + 22: goto 5 # live vars: $t0 # refs: [] # - 20: label L1 + 23: label L1 # live vars: $t0 # refs: [] # - 21: $t11 := ["2", "3", "4"] - # live vars: $t0, $t11 + 24: $t14 := infer($t0) + # live vars: $t14 + # refs: [] + # + 25: $t15 := ["2", "3", "4"] + # live vars: $t14, $t15 # refs: [] # - 22: $t10 := ==($t0, $t11) - # live vars: $t10 + 26: $t13 := ==($t14, $t15) + # live vars: $t13 # refs: [] # - 23: if ($t10) goto 24 else goto 26 + 27: if ($t13) goto 28 else goto 30 # live vars: # refs: [] # - 24: label L5 + 28: label L5 # live vars: # refs: [] # - 25: goto 29 + 29: goto 33 # live vars: # refs: [] # - 26: label L6 + 30: label L6 # live vars: # refs: [] # - 27: $t12 := 0 - # live vars: $t12 + 31: $t16 := 0 + # live vars: $t16 # refs: [] # - 28: abort($t12) + 32: abort($t16) # live vars: # refs: [] # - 29: label L7 + 33: label L7 # live vars: # refs: [] # - 30: return () + 34: return () } ============ after AbortAnalysisProcessor: ================ @@ -427,13 +493,17 @@ fun m::test_for_each_mut() { var $t3: &vector var $t4: &mut vector var $t5: bool - var $t6: &mut u64 - var $t7: u64 - var $t8: u64 + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector var $t9: u64 - var $t10: bool - var $t11: vector + var $t10: u64 + var $t11: u64 var $t12: u64 + var $t13: bool + var $t14: vector + var $t15: vector + var $t16: u64 # abort state: {returns,aborts} # live vars: # refs: [] @@ -480,7 +550,16 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 6: $t5 := <($t1, $t2) + 6: $t6 := infer($t1) + # abort state: {returns,aborts} + # live vars: $t0, $t1, $t2, $t4, $t6 + # refs: [$t4 => #4] + # #4 + # + # #root + # => (mut) #4 via [local `v`] at line 9 + # + 7: $t5 := <($t6, $t2) # abort state: {returns,aborts} # live vars: $t0, $t1, $t2, $t4, $t5 # refs: [$t4 => #4] @@ -489,7 +568,7 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 7: if ($t5) goto 8 else goto 16 + 8: if ($t5) goto 9 else goto 19 # abort state: {returns,aborts} # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] @@ -498,7 +577,7 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 8: label L2 + 9: label L2 # abort state: {returns,aborts} # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] @@ -507,29 +586,40 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 9: $t6 := vector::borrow_mut($t4, $t1) + 10: $t8 := infer($t4) # abort state: {returns,aborts} - # live vars: $t0, $t1, $t2, $t4, $t6 - # refs: [$t4 => #4, $t6 => #6] + # live vars: $t0, $t1, $t2, $t4, $t8 + # refs: [$t4 => #4, $t8 => #8] # #4 - # -> (mut) #6 via [] at line 11 - # #6 + # => (mut) #8 via [] at line 11 + # #8 # # #root # => (mut) #4 via [local `v`] at line 9 # - 10: $t7 := 2 + 11: $t7 := vector::borrow_mut($t8, $t1) # abort state: {returns,aborts} - # live vars: $t0, $t1, $t2, $t4, $t6, $t7 - # refs: [$t4 => #4, $t6 => #6] + # live vars: $t0, $t1, $t2, $t4, $t7 + # refs: [$t4 => #4, $t7 => #7] + # #4 + # -> (mut) #7 via [] at line 11 + # #7 + # + # #root + # => (mut) #4 via [local `v`] at line 9 + # + 12: $t9 := 2 + # abort state: {returns,aborts} + # live vars: $t0, $t1, $t2, $t4, $t7, $t9 + # refs: [$t4 => #4, $t7 => #7] # #4 - # -> (mut) #6 via [] at line 11 - # #6 + # -> (mut) #7 via [] at line 11 + # #7 # # #root # => (mut) #4 via [local `v`] at line 9 # - 11: write_ref($t6, $t7) + 13: write_ref($t7, $t9) # abort state: {returns,aborts} # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] @@ -538,25 +628,34 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 12: $t9 := 1 + 14: $t11 := infer($t1) + # abort state: {returns,aborts} + # live vars: $t0, $t2, $t4, $t11 + # refs: [$t4 => #4] + # #4 + # + # #root + # => (mut) #4 via [local `v`] at line 9 + # + 15: $t12 := 1 # abort state: {returns,aborts} - # live vars: $t0, $t1, $t2, $t4, $t9 + # live vars: $t0, $t2, $t4, $t11, $t12 # refs: [$t4 => #4] # #4 # # #root # => (mut) #4 via [local `v`] at line 9 # - 13: $t8 := +($t1, $t9) + 16: $t10 := +($t11, $t12) # abort state: {returns,aborts} - # live vars: $t0, $t2, $t4, $t8 + # live vars: $t0, $t2, $t4, $t10 # refs: [$t4 => #4] # #4 # # #root # => (mut) #4 via [local `v`] at line 9 # - 14: $t1 := infer($t8) + 17: $t1 := infer($t10) # abort state: {returns,aborts} # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] @@ -565,7 +664,7 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 15: goto 18 + 18: goto 21 # abort state: {returns,aborts} # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] @@ -574,12 +673,12 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 16: label L3 + 19: label L3 # abort state: {returns,aborts} # live vars: $t0 # refs: [] # - 17: goto 20 + 20: goto 23 # abort state: {returns,aborts} # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] @@ -588,7 +687,7 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 18: label L4 + 21: label L4 # abort state: {returns,aborts} # live vars: $t0, $t1, $t2, $t4 # refs: [$t4 => #4] @@ -597,62 +696,67 @@ fun m::test_for_each_mut() { # #root # => (mut) #4 via [local `v`] at line 9 # - 19: goto 5 + 22: goto 5 # abort state: {returns,aborts} # live vars: $t0 # refs: [] # - 20: label L1 + 23: label L1 # abort state: {returns,aborts} # live vars: $t0 # refs: [] # - 21: $t11 := ["2", "3", "4"] + 24: $t14 := infer($t0) + # abort state: {returns,aborts} + # live vars: $t14 + # refs: [] + # + 25: $t15 := ["2", "3", "4"] # abort state: {returns,aborts} - # live vars: $t0, $t11 + # live vars: $t14, $t15 # refs: [] # - 22: $t10 := ==($t0, $t11) + 26: $t13 := ==($t14, $t15) # abort state: {returns,aborts} - # live vars: $t10 + # live vars: $t13 # refs: [] # - 23: if ($t10) goto 24 else goto 26 + 27: if ($t13) goto 28 else goto 30 # abort state: {returns} # live vars: # refs: [] # - 24: label L5 + 28: label L5 # abort state: {returns} # live vars: # refs: [] # - 25: goto 29 + 29: goto 33 # abort state: {aborts} # live vars: # refs: [] # - 26: label L6 + 30: label L6 # abort state: {aborts} # live vars: # refs: [] # - 27: $t12 := 0 + 31: $t16 := 0 # abort state: {aborts} - # live vars: $t12 + # live vars: $t16 # refs: [] # - 28: abort($t12) + 32: abort($t16) # abort state: {returns} # live vars: # refs: [] # - 29: label L7 + 33: label L7 # abort state: {returns} # live vars: # refs: [] # - 30: return () + 34: return () } ============ after AbilityProcessor: ================ @@ -665,43 +769,439 @@ fun m::test_for_each_mut() { var $t3: &vector var $t4: &mut vector var $t5: bool - var $t6: &mut u64 - var $t7: u64 - var $t8: u64 + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector var $t9: u64 - var $t10: bool - var $t11: vector + var $t10: u64 + var $t11: u64 var $t12: u64 + var $t13: bool + var $t14: vector + var $t15: vector + var $t16: u64 0: $t0 := ["1", "2", "3"] 1: $t1 := 0 2: $t3 := borrow_local($t0) 3: $t2 := vector::length($t3) 4: $t4 := borrow_local($t0) 5: label L0 - 6: $t5 := <($t1, $t2) - 7: if ($t5) goto 8 else goto 16 - 8: label L2 - 9: $t6 := vector::borrow_mut($t4, $t1) - 10: $t7 := 2 - 11: write_ref($t6, $t7) - 12: $t9 := 1 - 13: $t8 := +($t1, $t9) - 14: $t1 := move($t8) - 15: goto 19 - 16: label L3 - 17: drop($t4) - 18: goto 21 - 19: label L4 - 20: goto 5 - 21: label L1 - 22: $t11 := ["2", "3", "4"] - 23: $t10 := ==($t0, $t11) - 24: if ($t10) goto 25 else goto 27 + 6: $t6 := copy($t1) + 7: $t5 := <($t6, $t2) + 8: if ($t5) goto 9 else goto 19 + 9: label L2 + 10: $t8 := copy($t4) + 11: $t7 := vector::borrow_mut($t8, $t1) + 12: $t9 := 2 + 13: write_ref($t7, $t9) + 14: $t11 := move($t1) + 15: $t12 := 1 + 16: $t10 := +($t11, $t12) + 17: $t1 := move($t10) + 18: goto 22 + 19: label L3 + 20: drop($t4) + 21: goto 24 + 22: label L4 + 23: goto 5 + 24: label L1 + 25: $t14 := move($t0) + 26: $t15 := ["2", "3", "4"] + 27: $t13 := ==($t14, $t15) + 28: if ($t13) goto 29 else goto 31 + 29: label L5 + 30: goto 34 + 31: label L6 + 32: $t16 := 0 + 33: abort($t16) + 34: label L7 + 35: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::test_for_each_mut() { + var $t0: vector + var $t1: u64 + var $t2: u64 + var $t3: &vector + var $t4: &mut vector + var $t5: bool + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector + var $t9: u64 + var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: bool + var $t14: vector + var $t15: vector + var $t16: u64 + # live vars: + 0: $t0 := ["1", "2", "3"] + # live vars: $t0 + 1: $t1 := 0 + # live vars: $t0, $t1 + 2: $t3 := borrow_local($t0) + # live vars: $t0, $t1, $t3 + 3: $t2 := vector::length($t3) + # live vars: $t0, $t1, $t2 + 4: $t4 := borrow_local($t0) + # live vars: $t0, $t1, $t2, $t4 + 5: label L0 + # live vars: $t0, $t1, $t2, $t4 + 6: $t6 := copy($t1) + # live vars: $t0, $t1, $t2, $t4, $t6 + 7: $t5 := <($t6, $t2) + # live vars: $t0, $t1, $t2, $t4, $t5 + 8: if ($t5) goto 9 else goto 19 + # live vars: $t0, $t1, $t2, $t4 + 9: label L2 + # live vars: $t0, $t1, $t2, $t4 + 10: $t8 := copy($t4) + # live vars: $t0, $t1, $t2, $t4, $t8 + 11: $t7 := vector::borrow_mut($t8, $t1) + # live vars: $t0, $t1, $t2, $t4, $t7 + 12: $t9 := 2 + # live vars: $t0, $t1, $t2, $t4, $t7, $t9 + 13: write_ref($t7, $t9) + # live vars: $t0, $t1, $t2, $t4 + 14: $t11 := move($t1) + # live vars: $t0, $t2, $t4, $t11 + 15: $t12 := 1 + # live vars: $t0, $t2, $t4, $t11, $t12 + 16: $t10 := +($t11, $t12) + # live vars: $t0, $t2, $t4, $t10 + 17: $t1 := move($t10) + # live vars: $t0, $t1, $t2, $t4 + 18: goto 5 + # live vars: $t0, $t1, $t2, $t4 + 19: label L3 + # live vars: $t0, $t4 + 20: drop($t4) + # live vars: $t0 + 21: $t14 := move($t0) + # live vars: $t14 + 22: $t15 := ["2", "3", "4"] + # live vars: $t14, $t15 + 23: $t13 := ==($t14, $t15) + # live vars: $t13 + 24: if ($t13) goto 25 else goto 27 + # live vars: + 25: label L5 + # live vars: + 26: return () + # live vars: + 27: label L6 + # live vars: + 28: $t16 := 0 + # live vars: $t16 + 29: abort($t16) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::test_for_each_mut() { + var $t0: vector + var $t1: u64 + var $t2: u64 + var $t3: &vector + var $t4: &mut vector + var $t5: bool + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector + var $t9: u64 + var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: bool + var $t14: vector + var $t15: vector + var $t16: u64 + # live vars: + 0: $t0 := ["1", "2", "3"] + # live vars: $t0 + 1: $t1 := 0 + # live vars: $t0, $t1 + 2: $t3 := borrow_local($t0) + # live vars: $t0, $t1, $t3 + 3: $t2 := vector::length($t3) + # live vars: $t0, $t1, $t2 + 4: $t4 := borrow_local($t0) + # live vars: $t0, $t1, $t2, $t4 + 5: label L0 + # live vars: $t0, $t1, $t2, $t4 + 6: $t6 := copy($t1) + # live vars: $t0, $t1, $t2, $t4, $t6 + 7: $t5 := <($t6, $t2) + # live vars: $t0, $t1, $t2, $t4, $t5 + 8: if ($t5) goto 9 else goto 19 + # live vars: $t0, $t1, $t2, $t4 + 9: label L2 + # live vars: $t0, $t1, $t2, $t4 + 10: $t8 := copy($t4) + # live vars: $t0, $t1, $t2, $t4, $t8 + 11: $t7 := vector::borrow_mut($t8, $t1) + # live vars: $t0, $t1, $t2, $t4, $t7 + 12: $t9 := 2 + # live vars: $t0, $t1, $t2, $t4, $t7, $t9 + 13: write_ref($t7, $t9) + # live vars: $t0, $t1, $t2, $t4 + 14: $t11 := move($t1) + # live vars: $t0, $t2, $t4, $t11 + 15: $t12 := 1 + # live vars: $t0, $t2, $t4, $t11, $t12 + 16: $t10 := +($t11, $t12) + # live vars: $t0, $t2, $t4, $t10 + 17: $t1 := move($t10) + # live vars: $t0, $t1, $t2, $t4 + 18: goto 5 + # live vars: $t0, $t1, $t2, $t4 + 19: label L3 + # live vars: $t0, $t4 + 20: drop($t4) + # live vars: $t0 + 21: $t14 := move($t0) + # live vars: $t14 + 22: $t15 := ["2", "3", "4"] + # live vars: $t14, $t15 + 23: $t13 := ==($t14, $t15) + # live vars: $t13 + 24: if ($t13) goto 25 else goto 27 + # live vars: + 25: label L5 + # live vars: + 26: return () + # live vars: + 27: label L6 + # live vars: + 28: $t16 := 0 + # live vars: $t16 + 29: abort($t16) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::test_for_each_mut() { + var $t0: vector + var $t1: u64 + var $t2: u64 + var $t3: &vector + var $t4: &mut vector + var $t5: bool + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector + var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] + var $t12: u64 + var $t13: bool [unused] + var $t14: vector + var $t15: vector + var $t16: u64 [unused] + # live vars: + 0: $t0 := ["1", "2", "3"] + # live vars: $t0 + 1: $t1 := 0 + # live vars: $t0, $t1 + 2: $t3 := borrow_local($t0) + # live vars: $t0, $t1, $t3 + 3: $t2 := vector::length($t3) + # live vars: $t0, $t1, $t2 + 4: $t4 := borrow_local($t0) + # live vars: $t0, $t1, $t2, $t4 + 5: label L0 + # live vars: $t0, $t1, $t2, $t4 + 6: $t6 := copy($t1) + # live vars: $t0, $t1, $t2, $t4, $t6 + 7: $t5 := <($t6, $t2) + # live vars: $t0, $t1, $t2, $t4, $t5 + 8: if ($t5) goto 9 else goto 19 + # live vars: $t0, $t1, $t2, $t4 + 9: label L2 + # live vars: $t0, $t1, $t2, $t4 + 10: $t8 := copy($t4) + # live vars: $t0, $t1, $t2, $t4, $t8 + 11: $t7 := vector::borrow_mut($t8, $t1) + # live vars: $t0, $t1, $t2, $t4, $t7 + 12: $t6 := 2 + # live vars: $t0, $t1, $t2, $t4, $t6, $t7 + 13: write_ref($t7, $t6) + # live vars: $t0, $t1, $t2, $t4 + 14: $t6 := move($t1) + # live vars: $t0, $t2, $t4, $t6 + 15: $t12 := 1 + # live vars: $t0, $t2, $t4, $t6, $t12 + 16: $t6 := +($t6, $t12) + # live vars: $t0, $t2, $t4, $t6 + 17: $t1 := move($t6) + # live vars: $t0, $t1, $t2, $t4 + 18: goto 5 + # live vars: $t0, $t1, $t2, $t4 + 19: label L3 + # live vars: $t0, $t4 + 20: drop($t4) + # live vars: $t0 + 21: $t14 := move($t0) + # live vars: $t14 + 22: $t15 := ["2", "3", "4"] + # live vars: $t14, $t15 + 23: $t5 := ==($t14, $t15) + # live vars: $t5 + 24: if ($t5) goto 25 else goto 27 + # live vars: 25: label L5 - 26: goto 30 + # live vars: + 26: return () + # live vars: 27: label L6 - 28: $t12 := 0 - 29: abort($t12) - 30: label L7 - 31: return () + # live vars: + 28: $t1 := 0 + # live vars: $t1 + 29: abort($t1) +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::test_for_each_mut() { + var $t0: vector + var $t1: u64 + var $t2: u64 + var $t3: &vector + var $t4: &mut vector + var $t5: bool + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut vector + var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] + var $t12: u64 + var $t13: bool [unused] + var $t14: vector + var $t15: vector + var $t16: u64 [unused] + # live vars: + 0: $t0 := ["1", "2", "3"] + # live vars: $t0 + 1: $t1 := 0 + # live vars: $t0, $t1 + 2: $t3 := borrow_local($t0) + # live vars: $t0, $t1, $t3 + 3: $t2 := vector::length($t3) + # live vars: $t0, $t1, $t2 + 4: $t4 := borrow_local($t0) + # live vars: $t0, $t1, $t2, $t4 + 5: label L0 + # live vars: $t0, $t1, $t2, $t4 + 6: $t6 := copy($t1) + # live vars: $t0, $t1, $t2, $t4, $t6 + 7: $t5 := <($t6, $t2) + # live vars: $t0, $t1, $t2, $t4, $t5 + 8: if ($t5) goto 9 else goto 19 + # live vars: $t0, $t1, $t2, $t4 + 9: label L2 + # live vars: $t0, $t1, $t2, $t4 + 10: $t8 := copy($t4) + # live vars: $t0, $t1, $t2, $t4, $t8 + 11: $t7 := vector::borrow_mut($t8, $t1) + # live vars: $t0, $t1, $t2, $t4, $t7 + 12: $t6 := 2 + # live vars: $t0, $t1, $t2, $t4, $t6, $t7 + 13: write_ref($t7, $t6) + # live vars: $t0, $t1, $t2, $t4 + 14: $t6 := move($t1) + # live vars: $t0, $t2, $t4, $t6 + 15: $t12 := 1 + # live vars: $t0, $t2, $t4, $t6, $t12 + 16: $t6 := +($t6, $t12) + # live vars: $t0, $t2, $t4, $t6 + 17: $t1 := move($t6) + # live vars: $t0, $t1, $t2, $t4 + 18: goto 5 + # live vars: $t0, $t1, $t2, $t4 + 19: label L3 + # live vars: $t0, $t4 + 20: drop($t4) + # live vars: $t0 + 21: $t14 := move($t0) + # live vars: $t14 + 22: $t15 := ["2", "3", "4"] + # live vars: $t14, $t15 + 23: $t5 := ==($t14, $t15) + # live vars: $t5 + 24: if ($t5) goto 25 else goto 27 + # live vars: + 25: label L5 + # live vars: + 26: return () + # live vars: + 27: label L6 + # live vars: + 28: $t1 := 0 + # live vars: $t1 + 29: abort($t1) +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { + + +test_for_each_mut() /* def_idx: 0 */ { +L0: loc0: vector +L1: loc1: u64 +L2: loc2: u64 +L3: loc3: &mut vector +L4: loc4: &mut u64 +B0: + 0: LdConst[0](Vector(U64): [3, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](loc0: vector) + 2: LdU64(0) + 3: StLoc[1](loc1: u64) + 4: ImmBorrowLoc[0](loc0: vector) + 5: VecLen(1) + 6: StLoc[2](loc2: u64) + 7: MutBorrowLoc[0](loc0: vector) + 8: StLoc[3](loc3: &mut vector) +B1: + 9: CopyLoc[1](loc1: u64) + 10: CopyLoc[2](loc2: u64) + 11: Lt + 12: BrFalse(25) +B2: + 13: CopyLoc[3](loc3: &mut vector) + 14: CopyLoc[1](loc1: u64) + 15: VecMutBorrow(1) + 16: StLoc[4](loc4: &mut u64) + 17: LdU64(2) + 18: MoveLoc[4](loc4: &mut u64) + 19: WriteRef + 20: MoveLoc[1](loc1: u64) + 21: LdU64(1) + 22: Add + 23: StLoc[1](loc1: u64) + 24: Branch(9) +B3: + 25: MoveLoc[3](loc3: &mut vector) + 26: Pop + 27: MoveLoc[0](loc0: vector) + 28: LdConst[1](Vector(U64): [3, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]) + 29: Eq + 30: BrFalse(32) +B4: + 31: Ret +B5: + 32: LdU64(0) + 33: Abort +} } +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/mutate_return.exp b/third_party/move/move-compiler-v2/tests/ability-transform/mutate_return.exp index 8598b7358c1ab..af7b55902c140 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/mutate_return.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/mutate_return.exp @@ -188,3 +188,141 @@ fun m::g<#0>($t0: &mut vector<#0>) { 0: drop($t0) 1: return () } + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun m::singleton<#0>($t0: #0): vector<#0> { + var $t1: vector<#0> + var $t2: vector<#0> + var $t3: &mut vector<#0> + # live vars: $t0 + 0: $t2 := vector($t0) + # live vars: $t2 + 1: $t3 := borrow_local($t2) + # live vars: $t2, $t3 + 2: m::g<#0>($t3) + # live vars: $t2 + 3: $t1 := move($t2) + # live vars: $t1 + 4: return $t1 +} + + +[variant baseline] +fun m::g<#0>($t0: &mut vector<#0>) { + # live vars: $t0 + 0: drop($t0) + # live vars: + 1: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun m::singleton<#0>($t0: #0): vector<#0> { + var $t1: vector<#0> + var $t2: vector<#0> + var $t3: &mut vector<#0> + # live vars: $t0 + 0: $t2 := vector($t0) + # live vars: $t2 + 1: $t3 := borrow_local($t2) + # live vars: $t2, $t3 + 2: m::g<#0>($t3) + # live vars: $t2 + 3: $t1 := move($t2) + # live vars: $t1 + 4: return $t1 +} + + +[variant baseline] +fun m::g<#0>($t0: &mut vector<#0>) { + # live vars: $t0 + 0: drop($t0) + # live vars: + 1: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun m::singleton<#0>($t0: #0): vector<#0> { + var $t1: vector<#0> + var $t2: vector<#0> + var $t3: &mut vector<#0> + # live vars: $t0 + 0: $t2 := vector($t0) + # live vars: $t2 + 1: $t3 := borrow_local($t2) + # live vars: $t2, $t3 + 2: m::g<#0>($t3) + # live vars: $t2 + 3: $t1 := move($t2) + # live vars: $t1 + 4: return $t1 +} + + +[variant baseline] +fun m::g<#0>($t0: &mut vector<#0>) { + # live vars: $t0 + 0: drop($t0) + # live vars: + 1: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun m::singleton<#0>($t0: #0): vector<#0> { + var $t1: vector<#0> + var $t2: vector<#0> + var $t3: &mut vector<#0> + # live vars: $t0 + 0: $t2 := vector($t0) + # live vars: $t2 + 1: $t3 := borrow_local($t2) + # live vars: $t2, $t3 + 2: m::g<#0>($t3) + # live vars: $t2 + 3: $t1 := move($t2) + # live vars: $t1 + 4: return $t1 +} + + +[variant baseline] +fun m::g<#0>($t0: &mut vector<#0>) { + # live vars: $t0 + 0: drop($t0) + # live vars: + 1: return () +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +public singleton(Arg0: Ty0): vector /* def_idx: 0 */ { +L1: loc0: vector +B0: + 0: MoveLoc[0](Arg0: Ty0) + 1: VecPack(0, 1) + 2: StLoc[1](loc0: vector) + 3: MutBorrowLoc[1](loc0: vector) + 4: Call g(&mut vector) + 5: MoveLoc[1](loc0: vector) + 6: Ret +} +g(Arg0: &mut vector) /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: &mut vector) + 1: Pop + 2: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/ability-transform/mutate_vector.exp b/third_party/move/move-compiler-v2/tests/ability-transform/mutate_vector.exp index 7259af56e7847..9808a45e289f0 100644 --- a/third_party/move/move-compiler-v2/tests/ability-transform/mutate_vector.exp +++ b/third_party/move/move-compiler-v2/tests/ability-transform/mutate_vector.exp @@ -308,3 +308,201 @@ public fun m::scalar_zero(): 0x42::m::Scalar { 1: $t0 := pack 0x42::m::Scalar($t1) 2: return $t0 } + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar + var $t3: &mut u8 + var $t4: &mut vector + var $t5: &mut 0x42::m::Scalar + var $t6: u64 + # live vars: $t0 + 0: $t2 := m::scalar_zero() + # live vars: $t0, $t2 + 1: $t5 := borrow_local($t2) + # live vars: $t0, $t2, $t5 + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) + # live vars: $t0, $t2, $t4 + 3: $t6 := 0 + # live vars: $t0, $t2, $t4, $t6 + 4: $t3 := vector::borrow_mut($t4, $t6) + # live vars: $t0, $t2, $t3 + 5: write_ref($t3, $t0) + # live vars: $t2 + 6: $t1 := move($t2) + # live vars: $t1 + 7: return $t1 +} + + +[variant baseline] +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar + var $t1: vector + # live vars: + 0: $t1 := [0] + # live vars: $t1 + 1: $t0 := pack 0x42::m::Scalar($t1) + # live vars: $t0 + 2: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar + var $t3: &mut u8 + var $t4: &mut vector + var $t5: &mut 0x42::m::Scalar + var $t6: u64 + # live vars: $t0 + 0: $t2 := m::scalar_zero() + # live vars: $t0, $t2 + 1: $t5 := borrow_local($t2) + # live vars: $t0, $t2, $t5 + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) + # live vars: $t0, $t2, $t4 + 3: $t6 := 0 + # live vars: $t0, $t2, $t4, $t6 + 4: $t3 := vector::borrow_mut($t4, $t6) + # live vars: $t0, $t2, $t3 + 5: write_ref($t3, $t0) + # live vars: $t2 + 6: $t1 := move($t2) + # live vars: $t1 + 7: return $t1 +} + + +[variant baseline] +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar + var $t1: vector + # live vars: + 0: $t1 := [0] + # live vars: $t1 + 1: $t0 := pack 0x42::m::Scalar($t1) + # live vars: $t0 + 2: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar + var $t3: &mut u8 + var $t4: &mut vector + var $t5: &mut 0x42::m::Scalar + var $t6: u64 + # live vars: $t0 + 0: $t2 := m::scalar_zero() + # live vars: $t0, $t2 + 1: $t5 := borrow_local($t2) + # live vars: $t0, $t2, $t5 + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) + # live vars: $t0, $t2, $t4 + 3: $t6 := 0 + # live vars: $t0, $t2, $t4, $t6 + 4: $t3 := vector::borrow_mut($t4, $t6) + # live vars: $t0, $t2, $t3 + 5: write_ref($t3, $t0) + # live vars: $t2 + 6: $t1 := move($t2) + # live vars: $t1 + 7: return $t1 +} + + +[variant baseline] +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar + var $t1: vector + # live vars: + 0: $t1 := [0] + # live vars: $t1 + 1: $t0 := pack 0x42::m::Scalar($t1) + # live vars: $t0 + 2: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun m::new_scalar_from_u8($t0: u8): 0x42::m::Scalar { + var $t1: 0x42::m::Scalar + var $t2: 0x42::m::Scalar + var $t3: &mut u8 + var $t4: &mut vector + var $t5: &mut 0x42::m::Scalar + var $t6: u64 + # live vars: $t0 + 0: $t2 := m::scalar_zero() + # live vars: $t0, $t2 + 1: $t5 := borrow_local($t2) + # live vars: $t0, $t2, $t5 + 2: $t4 := borrow_field<0x42::m::Scalar>.data($t5) + # live vars: $t0, $t2, $t4 + 3: $t6 := 0 + # live vars: $t0, $t2, $t4, $t6 + 4: $t3 := vector::borrow_mut($t4, $t6) + # live vars: $t0, $t2, $t3 + 5: write_ref($t3, $t0) + # live vars: $t2 + 6: $t1 := move($t2) + # live vars: $t1 + 7: return $t1 +} + + +[variant baseline] +public fun m::scalar_zero(): 0x42::m::Scalar { + var $t0: 0x42::m::Scalar + var $t1: vector + # live vars: + 0: $t1 := [0] + # live vars: $t1 + 1: $t0 := pack 0x42::m::Scalar($t1) + # live vars: $t0 + 2: return $t0 +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { +struct Scalar has copy, drop, store { + data: vector +} + +public new_scalar_from_u8(Arg0: u8): Scalar /* def_idx: 0 */ { +L1: loc0: Scalar +L2: loc1: &mut u8 +B0: + 0: Call scalar_zero(): Scalar + 1: StLoc[1](loc0: Scalar) + 2: MutBorrowLoc[1](loc0: Scalar) + 3: MutBorrowField[0](Scalar.data: vector) + 4: LdU64(0) + 5: VecMutBorrow(0) + 6: StLoc[2](loc1: &mut u8) + 7: MoveLoc[0](Arg0: u8) + 8: MoveLoc[2](loc1: &mut u8) + 9: WriteRef + 10: MoveLoc[1](loc0: Scalar) + 11: Ret +} +public scalar_zero(): Scalar /* def_idx: 1 */ { +B0: + 0: LdConst[0](Vector(U8): [1, 0]) + 1: Pack[0](Scalar) + 2: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp index 19a38d4478a92..68478954e23e8 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp @@ -73,10 +73,12 @@ fun assign::assign_int($t0: &mut u64) { fun assign::assign_pattern($t0: 0x42::assign::S, $t1: u64, $t2: u64): u64 { var $t3: u64 var $t4: 0x42::assign::T + var $t5: u64 0: ($t1, $t4) := unpack 0x42::assign::S($t0) 1: $t2 := unpack 0x42::assign::T($t4) - 2: $t3 := +($t1, $t2) - 3: return $t3 + 2: $t5 := infer($t1) + 3: $t3 := +($t5, $t2) + 4: return $t3 } @@ -95,4 +97,52 @@ fun assign::assign_struct($t0: &mut 0x42::assign::S) { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.assign { +struct T has drop { + h: u64 +} +struct S has drop { + f: u64, + g: T +} + +assign_field(Arg0: &mut S, Arg1: u64) /* def_idx: 0 */ { +L2: loc0: &mut u64 +B0: + 0: MoveLoc[0](Arg0: &mut S) + 1: MutBorrowField[0](S.f: u64) + 2: StLoc[2](loc0: &mut u64) + 3: MoveLoc[1](Arg1: u64) + 4: MoveLoc[2](loc0: &mut u64) + 5: WriteRef + 6: Ret +} +assign_int(Arg0: &mut u64) /* def_idx: 1 */ { +B0: + 0: LdU64(42) + 1: MoveLoc[0](Arg0: &mut u64) + 2: WriteRef + 3: Ret +} +assign_pattern(Arg0: S, Arg1: u64, Arg2: u64): u64 /* def_idx: 2 */ { +B0: + 0: MoveLoc[0](Arg0: S) + 1: Unpack[1](S) + 2: Unpack[0](T) + 3: Add + 4: Ret +} +assign_struct(Arg0: &mut S) /* def_idx: 3 */ { +B0: + 0: LdU64(42) + 1: LdU64(42) + 2: Pack[0](T) + 3: Pack[1](S) + 4: MoveLoc[0](Arg0: &mut S) + 5: WriteRef + 6: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp index 4a09468c4d890..5cd8580b46bb1 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp @@ -30,4 +30,16 @@ public fun assign::main(): (u64, u64) { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.assign { + + +public main(): u64 * u64 /* def_idx: 0 */ { +B0: + 0: LdU64(1) + 1: LdU64(3) + 2: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp index 2ede6b56aa928..cd348d9e72963 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp @@ -171,4 +171,74 @@ fun borrow::mut_param($t0: u64): u64 { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.borrow { +struct S { + f: u64 +} + +field(Arg0: &S): u64 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: &S) + 1: ImmBorrowField[0](S.f: u64) + 2: ReadRef + 3: Ret +} +local(Arg0: u64): u64 /* def_idx: 1 */ { +L1: loc0: u64 +B0: + 0: LdU64(33) + 1: StLoc[1](loc0: u64) + 2: ImmBorrowLoc[1](loc0: u64) + 3: ReadRef + 4: Ret +} +param(Arg0: u64): u64 /* def_idx: 2 */ { +B0: + 0: ImmBorrowLoc[0](Arg0: u64) + 1: ReadRef + 2: Ret +} +mut_field(Arg0: &mut S): u64 /* def_idx: 3 */ { +L1: loc0: &mut u64 +B0: + 0: MoveLoc[0](Arg0: &mut S) + 1: MutBorrowField[0](S.f: u64) + 2: StLoc[1](loc0: &mut u64) + 3: LdU64(22) + 4: CopyLoc[1](loc0: &mut u64) + 5: WriteRef + 6: MoveLoc[1](loc0: &mut u64) + 7: ReadRef + 8: Ret +} +mut_local(Arg0: u64): u64 /* def_idx: 4 */ { +L1: loc0: u64 +L2: loc1: &mut u64 +B0: + 0: LdU64(33) + 1: StLoc[1](loc0: u64) + 2: MutBorrowLoc[1](loc0: u64) + 3: StLoc[2](loc1: &mut u64) + 4: LdU64(22) + 5: CopyLoc[2](loc1: &mut u64) + 6: WriteRef + 7: MoveLoc[2](loc1: &mut u64) + 8: ReadRef + 9: Ret +} +mut_param(Arg0: u64): u64 /* def_idx: 5 */ { +L1: loc0: &mut u64 +B0: + 0: MutBorrowLoc[0](Arg0: u64) + 1: StLoc[1](loc0: &mut u64) + 2: LdU64(22) + 3: CopyLoc[1](loc0: &mut u64) + 4: WriteRef + 5: MoveLoc[1](loc0: &mut u64) + 6: ReadRef + 7: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_deref_optimize.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_deref_optimize.exp index bc23929966e0e..21034a034b38a 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_deref_optimize.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow_deref_optimize.exp @@ -140,4 +140,64 @@ fun test::optimize_vector() { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.test { +struct X has copy, drop, key { + value: bool +} + +no_optimize_resource(): bool /* def_idx: 0 */ { +L0: loc0: X +B0: + 0: LdConst[0](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) + 1: ImmBorrowGlobal[0](X) + 2: ReadRef + 3: StLoc[0](loc0: X) + 4: MutBorrowLoc[0](loc0: X) + 5: ImmBorrowField[0](X.value: bool) + 6: ReadRef + 7: Ret +} +no_optimize_vector() /* def_idx: 1 */ { +L0: loc0: vector> +L1: loc1: vector +L2: loc2: &mut u64 +B0: + 0: LdConst[1](Vector(Vector(U64)): [1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](loc0: vector>) + 2: ImmBorrowLoc[0](loc0: vector>) + 3: LdU64(0) + 4: VecImmBorrow(3) + 5: ReadRef + 6: StLoc[1](loc1: vector) + 7: MutBorrowLoc[1](loc1: vector) + 8: LdU64(1) + 9: VecMutBorrow(4) + 10: Pop + 11: Ret +} +optimize_resource(): bool /* def_idx: 2 */ { +B0: + 0: LdConst[0](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) + 1: ImmBorrowGlobal[0](X) + 2: ImmBorrowField[0](X.value: bool) + 3: ReadRef + 4: Ret +} +optimize_vector() /* def_idx: 3 */ { +L0: loc0: vector> +L1: loc1: &mut u64 +B0: + 0: LdConst[1](Vector(Vector(U64)): [1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](loc0: vector>) + 2: MutBorrowLoc[0](loc0: vector>) + 3: LdU64(0) + 4: VecMutBorrow(3) + 5: LdU64(1) + 6: VecMutBorrow(4) + 7: Pop + 8: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_update_variant_select.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_update_variant_select.exp index e81fbf75afa73..19090c4f6c297 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_update_variant_select.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_update_variant_select.exp @@ -179,4 +179,125 @@ fun m::update_non_common_field(): u32 { } +============ disassembled file-format ================== +// Move bytecode v7 +module 815.m { +enum CommonFields has drop { + Foo{ + x: u64, + y: u8 + }, + Bar{ + x: u64, + y: u8, + z: u32 + }, + Baz{ + y: u8 + } +} + +update_common_field(): u64 /* def_idx: 0 */ { +L0: loc0: CommonFields +B0: + 0: LdU64(30) + 1: LdU8(40) + 2: LdU32(50) + 3: PackVariant[0](CommonFields/Bar) + 4: StLoc[0](loc0: CommonFields) + 5: LdU64(15) + 6: MutBorrowLoc[0](loc0: CommonFields) + 7: MutBorrowVariantField[0](Foo.x|Bar.x: u64) + 8: WriteRef + 9: ImmBorrowLoc[0](loc0: CommonFields) + 10: ImmBorrowVariantField[0](Foo.x|Bar.x: u64) + 11: ReadRef + 12: Ret +} +update_common_field_different_offset(): u8 /* def_idx: 1 */ { +L0: loc0: CommonFields +L1: loc1: u8 +L2: loc2: &mut CommonFields +L3: loc3: &mut u8 +L4: loc4: &CommonFields +L5: loc5: &u8 +B0: + 0: LdU64(30) + 1: LdU8(40) + 2: LdU32(50) + 3: PackVariant[0](CommonFields/Bar) + 4: StLoc[0](loc0: CommonFields) + 5: LdU8(15) + 6: StLoc[1](loc1: u8) + 7: MutBorrowLoc[0](loc0: CommonFields) + 8: StLoc[2](loc2: &mut CommonFields) + 9: CopyLoc[2](loc2: &mut CommonFields) + 10: TestVariant[1](CommonFields/Foo) + 11: BrFalse(39) +B1: + 12: Branch(13) +B2: + 13: MoveLoc[2](loc2: &mut CommonFields) + 14: MutBorrowVariantField[1](Foo.y|Bar.y: u8) + 15: StLoc[3](loc3: &mut u8) +B3: + 16: MoveLoc[1](loc1: u8) + 17: MoveLoc[3](loc3: &mut u8) + 18: WriteRef + 19: ImmBorrowLoc[0](loc0: CommonFields) + 20: StLoc[4](loc4: &CommonFields) + 21: CopyLoc[4](loc4: &CommonFields) + 22: TestVariant[1](CommonFields/Foo) + 23: BrFalse(31) +B4: + 24: Branch(25) +B5: + 25: MoveLoc[4](loc4: &CommonFields) + 26: ImmBorrowVariantField[1](Foo.y|Bar.y: u8) + 27: StLoc[5](loc5: &u8) +B6: + 28: MoveLoc[5](loc5: &u8) + 29: ReadRef + 30: Ret +B7: + 31: CopyLoc[4](loc4: &CommonFields) + 32: TestVariant[0](CommonFields/Bar) + 33: BrFalse(35) +B8: + 34: Branch(25) +B9: + 35: MoveLoc[4](loc4: &CommonFields) + 36: ImmBorrowVariantField[2](Baz.y: u8) + 37: StLoc[5](loc5: &u8) + 38: Branch(28) +B10: + 39: CopyLoc[2](loc2: &mut CommonFields) + 40: TestVariant[0](CommonFields/Bar) + 41: BrFalse(43) +B11: + 42: Branch(13) +B12: + 43: MoveLoc[2](loc2: &mut CommonFields) + 44: MutBorrowVariantField[2](Baz.y: u8) + 45: StLoc[3](loc3: &mut u8) + 46: Branch(16) +} +update_non_common_field(): u32 /* def_idx: 2 */ { +L0: loc0: CommonFields +B0: + 0: LdU64(30) + 1: LdU8(40) + 2: LdU32(50) + 3: PackVariant[0](CommonFields/Bar) + 4: StLoc[0](loc0: CommonFields) + 5: LdU32(15) + 6: MutBorrowLoc[0](loc0: CommonFields) + 7: MutBorrowVariantField[3](Bar.z: u32) + 8: WriteRef + 9: ImmBorrowLoc[0](loc0: CommonFields) + 10: ImmBorrowVariantField[3](Bar.z: u32) + 11: ReadRef + 12: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_variant_select_autoref.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_variant_select_autoref.exp index c26adc0db393d..fc0bec82c9031 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_variant_select_autoref.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14300_variant_select_autoref.exp @@ -55,4 +55,30 @@ fun m::test_common_access(): u8 { } +============ disassembled file-format ================== +// Move bytecode v7 +module 815.m { +enum Positional has drop { + A{ + _0: u8 + }, + B{ + _0: u8 + } +} + +test_common_access(): u8 /* def_idx: 0 */ { +L0: loc0: Positional +B0: + 0: LdU8(42) + 1: PackVariant[0](Positional/A) + 2: StLoc[0](loc0: Positional) + 3: LdU8(19) + 4: MutBorrowLoc[0](loc0: Positional) + 5: MutBorrowVariantField[0](A._0|B._0: u8) + 6: WriteRef + 7: LdU8(20) + 8: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14471_receiver_inference.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14471_receiver_inference.exp index 693daacb1ff71..12e828b0b7a36 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14471_receiver_inference.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14471_receiver_inference.exp @@ -87,21 +87,79 @@ public fun m::add_when_missing($t0: address, $t1: u64) { var $t6: &0x815::m::Table var $t7: 0x815::m::ValueWrap var $t8: &mut 0x815::m::Table + var $t9: address 0: $t3 := 0x815 1: $t2 := borrow_global<0x815::m::MyMap>($t3) 2: $t6 := borrow_field<0x815::m::MyMap>.table($t2) 3: $t5 := m::contains($t6, $t0) 4: $t4 := !($t5) - 5: if ($t4) goto 6 else goto 11 + 5: if ($t4) goto 6 else goto 12 6: label L0 7: $t7 := pack 0x815::m::ValueWrap($t1) 8: $t8 := borrow_field<0x815::m::MyMap>.table($t2) - 9: m::add($t8, $t0, $t7) - 10: goto 12 - 11: label L1 - 12: label L2 - 13: return () + 9: $t9 := infer($t0) + 10: m::add($t8, $t9, $t7) + 11: goto 13 + 12: label L1 + 13: label L2 + 14: return () } +============ disassembled file-format ================== +// Move bytecode v7 +module 815.m { +struct MyMap has key { + table: Table +} +struct Table has store { + x: Ty0, + y: Ty1 +} +struct ValueWrap has drop, store { + val: u64 +} + +contains(Arg0: &Table, Arg1: Ty0): bool /* def_idx: 0 */ { +B0: + 0: LdTrue + 1: MoveLoc[0](Arg0: &Table) + 2: Pop + 3: Ret +} +add(Arg0: &mut Table, Arg1: Ty0, Arg2: Ty1) /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: &mut Table) + 1: Pop + 2: Ret +} +public add_when_missing(Arg0: address, Arg1: u64) /* def_idx: 2 */ { +L2: loc0: &mut MyMap +L3: loc1: ValueWrap +B0: + 0: LdConst[0](Address: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 21]) + 1: MutBorrowGlobal[0](MyMap) + 2: StLoc[2](loc0: &mut MyMap) + 3: CopyLoc[2](loc0: &mut MyMap) + 4: ImmBorrowField[0](MyMap.table: Table) + 5: CopyLoc[0](Arg0: address) + 6: Call contains(&Table, address): bool + 7: BrTrue(17) +B1: + 8: MoveLoc[1](Arg1: u64) + 9: Pack[2](ValueWrap) + 10: StLoc[3](loc1: ValueWrap) + 11: MoveLoc[2](loc0: &mut MyMap) + 12: MutBorrowField[0](MyMap.table: Table) + 13: MoveLoc[0](Arg0: address) + 14: MoveLoc[3](loc1: ValueWrap) + 15: Call add(&mut Table, address, ValueWrap) +B2: + 16: Ret +B3: + 17: MoveLoc[2](loc0: &mut MyMap) + 18: Pop + 19: Branch(16) +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14629.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14629.exp index 74202644fcec6..8c840d334cfe2 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14629.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/bug_14629.exp @@ -74,4 +74,33 @@ fun M::t0_u128() { } +============ disassembled file-format ================== +// Move bytecode v7 +module 8675309.M { +struct R { + r: Ty0 +} +struct X has drop, key { + r: Ty0 +} + +t0() /* def_idx: 0 */ { +B0: + 0: LdU64(0) + 1: PackGeneric[0](X) + 2: PackGeneric[1](R>) + 3: UnpackGeneric[1](R>) + 4: Pop + 5: Ret +} +t0_u128() /* def_idx: 1 */ { +B0: + 0: LdU128(18446744073709551616) + 1: PackGeneric[2](X) + 2: PackGeneric[3](R>) + 3: UnpackGeneric[3](R>) + 4: Pop + 5: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp index 2e4693e518bd7..6d359a9b8806a 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp @@ -179,82 +179,86 @@ fun M::test1($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 - var $t8: &mut u64 - var $t9: u64 + var $t8: u64 + var $t9: &mut u64 var $t10: u64 var $t11: u64 var $t12: u64 - var $t13: &mut u64 - var $t14: u64 + var $t13: u64 + var $t14: &mut u64 var $t15: u64 var $t16: u64 var $t17: u64 var $t18: u64 var $t19: u64 - var $t20: &mut u64 + var $t20: u64 var $t21: u64 - var $t22: u64 + var $t22: &mut u64 var $t23: u64 var $t24: u64 - var $t25: &mut u64 + var $t25: u64 var $t26: u64 - var $t27: u64 + var $t27: &mut u64 var $t28: u64 var $t29: u64 - var $t30: &mut u64 + var $t30: u64 var $t31: u64 - var $t32: u64 + var $t32: &mut u64 var $t33: u64 var $t34: u64 var $t35: u64 - 0: $t5 := 4 - 1: $t4 := <($t0, $t5) - 2: if ($t4) goto 3 else goto 6 - 3: label L0 - 4: $t3 := infer($t0) - 5: goto 8 - 6: label L1 - 7: $t3 := 3 - 8: label L2 - 9: $t2 := borrow_local($t3) - 10: $t6 := 10 - 11: write_ref($t2, $t6) - 12: $t7 := infer($t0) - 13: $t8 := borrow_local($t7) - 14: $t10 := read_ref($t8) - 15: $t11 := 1 - 16: $t9 := +($t10, $t11) - 17: write_ref($t8, $t9) - 18: $t12 := infer($t7) - 19: $t15 := 0 - 20: $t14 := +($t12, $t15) - 21: $t13 := borrow_local($t14) - 22: $t17 := read_ref($t13) - 23: $t18 := 2 - 24: $t16 := +($t17, $t18) - 25: write_ref($t13, $t16) - 26: $t19 := infer($t12) - 27: $t21 := infer($t19) - 28: $t20 := borrow_local($t21) - 29: $t23 := read_ref($t20) - 30: $t24 := 4 - 31: $t22 := +($t23, $t24) - 32: write_ref($t20, $t22) - 33: $t26 := infer($t19) - 34: $t25 := borrow_local($t26) - 35: $t28 := read_ref($t25) - 36: $t29 := 8 - 37: $t27 := +($t28, $t29) - 38: write_ref($t25, $t27) - 39: $t32 := 3 - 40: $t31 := infer($t19) - 41: $t30 := borrow_local($t31) - 42: $t34 := read_ref($t30) - 43: $t35 := 16 - 44: $t33 := +($t34, $t35) - 45: write_ref($t30, $t33) - 46: $t1 := infer($t19) - 47: return $t1 + var $t36: u64 + var $t37: u64 + 0: $t5 := infer($t0) + 1: $t6 := 4 + 2: $t4 := <($t5, $t6) + 3: if ($t4) goto 4 else goto 7 + 4: label L0 + 5: $t3 := infer($t0) + 6: goto 9 + 7: label L1 + 8: $t3 := 3 + 9: label L2 + 10: $t2 := borrow_local($t3) + 11: $t7 := 10 + 12: write_ref($t2, $t7) + 13: $t8 := infer($t0) + 14: $t9 := borrow_local($t8) + 15: $t11 := read_ref($t9) + 16: $t12 := 1 + 17: $t10 := +($t11, $t12) + 18: write_ref($t9, $t10) + 19: $t13 := infer($t8) + 20: $t16 := infer($t13) + 21: $t17 := 0 + 22: $t15 := +($t16, $t17) + 23: $t14 := borrow_local($t15) + 24: $t19 := read_ref($t14) + 25: $t20 := 2 + 26: $t18 := +($t19, $t20) + 27: write_ref($t14, $t18) + 28: $t21 := infer($t13) + 29: $t23 := infer($t21) + 30: $t22 := borrow_local($t23) + 31: $t25 := read_ref($t22) + 32: $t26 := 4 + 33: $t24 := +($t25, $t26) + 34: write_ref($t22, $t24) + 35: $t28 := infer($t21) + 36: $t27 := borrow_local($t28) + 37: $t30 := read_ref($t27) + 38: $t31 := 8 + 39: $t29 := +($t30, $t31) + 40: write_ref($t27, $t29) + 41: $t34 := 3 + 42: $t33 := infer($t21) + 43: $t32 := borrow_local($t33) + 44: $t36 := read_ref($t32) + 45: $t37 := 16 + 46: $t35 := +($t36, $t37) + 47: write_ref($t32, $t35) + 48: $t1 := infer($t21) + 49: return $t1 } @@ -408,4 +412,229 @@ public fun M::testb(): u64 { } +============ disassembled file-format ================== +// Move bytecode v7 +module 8675.M { +struct S has copy, drop { + f: u64 +} + +public test(): u64 /* def_idx: 0 */ { +B0: + 0: LdU64(7) + 1: Call test1(u64): u64 + 2: LdU64(2) + 3: Call test1(u64): u64 + 4: Add + 5: Ret +} +test1(Arg0: u64): u64 /* def_idx: 1 */ { +L1: loc0: u64 +L2: loc1: &mut u64 +L3: loc2: u64 +L4: loc3: u64 +L5: loc4: u64 +L6: loc5: u64 +L7: loc6: u64 +L8: loc7: u64 +B0: + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(4) + 2: Lt + 3: BrFalse(67) +B1: + 4: CopyLoc[0](Arg0: u64) + 5: StLoc[1](loc0: u64) +B2: + 6: MutBorrowLoc[1](loc0: u64) + 7: StLoc[2](loc1: &mut u64) + 8: LdU64(10) + 9: MoveLoc[2](loc1: &mut u64) + 10: WriteRef + 11: MoveLoc[0](Arg0: u64) + 12: StLoc[3](loc2: u64) + 13: MutBorrowLoc[3](loc2: u64) + 14: StLoc[2](loc1: &mut u64) + 15: CopyLoc[2](loc1: &mut u64) + 16: ReadRef + 17: LdU64(1) + 18: Add + 19: MoveLoc[2](loc1: &mut u64) + 20: WriteRef + 21: MoveLoc[3](loc2: u64) + 22: StLoc[4](loc3: u64) + 23: CopyLoc[4](loc3: u64) + 24: LdU64(0) + 25: Add + 26: StLoc[5](loc4: u64) + 27: MutBorrowLoc[5](loc4: u64) + 28: StLoc[2](loc1: &mut u64) + 29: CopyLoc[2](loc1: &mut u64) + 30: ReadRef + 31: LdU64(2) + 32: Add + 33: MoveLoc[2](loc1: &mut u64) + 34: WriteRef + 35: CopyLoc[4](loc3: u64) + 36: StLoc[6](loc5: u64) + 37: MutBorrowLoc[6](loc5: u64) + 38: StLoc[2](loc1: &mut u64) + 39: CopyLoc[2](loc1: &mut u64) + 40: ReadRef + 41: LdU64(4) + 42: Add + 43: MoveLoc[2](loc1: &mut u64) + 44: WriteRef + 45: CopyLoc[4](loc3: u64) + 46: StLoc[7](loc6: u64) + 47: MutBorrowLoc[7](loc6: u64) + 48: StLoc[2](loc1: &mut u64) + 49: CopyLoc[2](loc1: &mut u64) + 50: ReadRef + 51: LdU64(8) + 52: Add + 53: MoveLoc[2](loc1: &mut u64) + 54: WriteRef + 55: CopyLoc[4](loc3: u64) + 56: StLoc[8](loc7: u64) + 57: MutBorrowLoc[8](loc7: u64) + 58: StLoc[2](loc1: &mut u64) + 59: CopyLoc[2](loc1: &mut u64) + 60: ReadRef + 61: LdU64(16) + 62: Add + 63: MoveLoc[2](loc1: &mut u64) + 64: WriteRef + 65: MoveLoc[4](loc3: u64) + 66: Ret +B3: + 67: LdU64(3) + 68: StLoc[1](loc0: u64) + 69: Branch(6) +} +test1b(Arg0: S): u64 /* def_idx: 2 */ { +L1: loc0: S +L2: loc1: S +L3: loc2: &mut S +L4: loc3: S +L5: loc4: S +L6: loc5: S +L7: loc6: S +L8: loc7: S +L9: loc8: &mut u64 +L10: loc9: S +L11: loc10: u64 +L12: loc11: u64 +L13: loc12: u64 +B0: + 0: LdU64(3) + 1: Pack[0](S) + 2: StLoc[1](loc0: S) + 3: ImmBorrowLoc[0](Arg0: S) + 4: ImmBorrowField[0](S.f: u64) + 5: ReadRef + 6: LdU64(4) + 7: Lt + 8: BrFalse(91) +B1: + 9: CopyLoc[0](Arg0: S) + 10: StLoc[2](loc1: S) +B2: + 11: MutBorrowLoc[2](loc1: S) + 12: StLoc[3](loc2: &mut S) + 13: LdU64(10) + 14: MoveLoc[3](loc2: &mut S) + 15: ReadRef + 16: StLoc[4](loc3: S) + 17: MutBorrowLoc[4](loc3: S) + 18: MutBorrowField[0](S.f: u64) + 19: WriteRef + 20: MoveLoc[0](Arg0: S) + 21: StLoc[5](loc4: S) + 22: MutBorrowLoc[5](loc4: S) + 23: StLoc[3](loc2: &mut S) + 24: CopyLoc[3](loc2: &mut S) + 25: ReadRef + 26: StLoc[6](loc5: S) + 27: ImmBorrowLoc[6](loc5: S) + 28: ImmBorrowField[0](S.f: u64) + 29: ReadRef + 30: LdU64(1) + 31: Add + 32: MoveLoc[3](loc2: &mut S) + 33: ReadRef + 34: StLoc[7](loc6: S) + 35: MutBorrowLoc[7](loc6: S) + 36: MutBorrowField[0](S.f: u64) + 37: WriteRef + 38: MoveLoc[5](loc4: S) + 39: StLoc[8](loc7: S) + 40: MutBorrowLoc[8](loc7: S) + 41: MutBorrowField[0](S.f: u64) + 42: StLoc[9](loc8: &mut u64) + 43: CopyLoc[9](loc8: &mut u64) + 44: ReadRef + 45: LdU64(1) + 46: Add + 47: MoveLoc[9](loc8: &mut u64) + 48: WriteRef + 49: MoveLoc[8](loc7: S) + 50: StLoc[10](loc9: S) + 51: ImmBorrowLoc[10](loc9: S) + 52: ImmBorrowField[0](S.f: u64) + 53: ReadRef + 54: StLoc[11](loc10: u64) + 55: MutBorrowLoc[11](loc10: u64) + 56: StLoc[9](loc8: &mut u64) + 57: CopyLoc[9](loc8: &mut u64) + 58: ReadRef + 59: LdU64(1) + 60: Add + 61: MoveLoc[9](loc8: &mut u64) + 62: WriteRef + 63: ImmBorrowLoc[10](loc9: S) + 64: ImmBorrowField[0](S.f: u64) + 65: ReadRef + 66: StLoc[12](loc11: u64) + 67: MutBorrowLoc[12](loc11: u64) + 68: StLoc[9](loc8: &mut u64) + 69: CopyLoc[9](loc8: &mut u64) + 70: ReadRef + 71: LdU64(8) + 72: Add + 73: MoveLoc[9](loc8: &mut u64) + 74: WriteRef + 75: ImmBorrowLoc[10](loc9: S) + 76: ImmBorrowField[0](S.f: u64) + 77: ReadRef + 78: StLoc[13](loc12: u64) + 79: MutBorrowLoc[13](loc12: u64) + 80: StLoc[9](loc8: &mut u64) + 81: CopyLoc[9](loc8: &mut u64) + 82: ReadRef + 83: LdU64(16) + 84: Add + 85: MoveLoc[9](loc8: &mut u64) + 86: WriteRef + 87: ImmBorrowLoc[10](loc9: S) + 88: ImmBorrowField[0](S.f: u64) + 89: ReadRef + 90: Ret +B3: + 91: MoveLoc[1](loc0: S) + 92: StLoc[2](loc1: S) + 93: Branch(11) +} +public testb(): u64 /* def_idx: 3 */ { +B0: + 0: LdU64(7) + 1: Pack[0](S) + 2: Call test1b(S): u64 + 3: LdU64(2) + 4: Pack[0](S) + 5: Call test1b(S): u64 + 6: Add + 7: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp index aae0dcbebfe42..023d9b8e57d10 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp @@ -116,4 +116,50 @@ fun m::will_autoref(): address { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { +struct Object has copy, drop { + inner: address +} +struct ObjectCore has key { + owner: address +} + +make(): Object /* def_idx: 0 */ { +B0: + 0: LdU64(0) + 1: Abort +} +owner_correct(Arg0: Object): address /* def_idx: 1 */ { +B0: + 0: ImmBorrowLoc[0](Arg0: Object) + 1: ImmBorrowField[0](Object.inner: address) + 2: ReadRef + 3: ImmBorrowGlobal[1](ObjectCore) + 4: ImmBorrowField[1](ObjectCore.owner: address) + 5: ReadRef + 6: Ret +} +owner_read_ref_missing(Arg0: Object): address /* def_idx: 2 */ { +B0: + 0: ImmBorrowLoc[0](Arg0: Object) + 1: ImmBorrowField[0](Object.inner: address) + 2: ReadRef + 3: ImmBorrowGlobal[1](ObjectCore) + 4: ImmBorrowField[1](ObjectCore.owner: address) + 5: ReadRef + 6: Ret +} +will_autoref(): address /* def_idx: 3 */ { +L0: loc0: Object +B0: + 0: Call make(): Object + 1: StLoc[0](loc0: Object) + 2: ImmBorrowLoc[0](loc0: Object) + 3: ImmBorrowField[0](Object.inner: address) + 4: ReadRef + 5: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp index 72ad2c417ca09..8fee7cb9bb152 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp @@ -263,4 +263,126 @@ fun fields::write_val($t0: 0x42::fields::S): 0x42::fields::S { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.fields { +struct T has drop { + h: u64 +} +struct G has drop { + f: Ty0 +} +struct S has drop { + f: u64, + g: T +} + +read_generic_val(Arg0: G): u64 /* def_idx: 0 */ { +B0: + 0: ImmBorrowLoc[0](Arg0: G) + 1: ImmBorrowFieldGeneric[0](G.f: Ty0) + 2: ReadRef + 3: Ret +} +read_ref(Arg0: &S): u64 /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: &S) + 1: ImmBorrowField[1](S.g: T) + 2: ImmBorrowField[2](T.h: u64) + 3: ReadRef + 4: Ret +} +read_val(Arg0: S): u64 /* def_idx: 2 */ { +B0: + 0: ImmBorrowLoc[0](Arg0: S) + 1: ImmBorrowField[1](S.g: T) + 2: ImmBorrowField[2](T.h: u64) + 3: ReadRef + 4: Ret +} +write_generic_val(Arg0: &mut G, Arg1: u64) /* def_idx: 3 */ { +L2: loc0: &mut u64 +B0: + 0: MoveLoc[0](Arg0: &mut G) + 1: MutBorrowFieldGeneric[0](G.f: Ty0) + 2: StLoc[2](loc0: &mut u64) + 3: MoveLoc[1](Arg1: u64) + 4: MoveLoc[2](loc0: &mut u64) + 5: WriteRef + 6: Ret +} +write_local_direct(): S /* def_idx: 4 */ { +L0: loc0: S +B0: + 0: LdU64(0) + 1: LdU64(0) + 2: Pack[0](T) + 3: Pack[2](S) + 4: StLoc[0](loc0: S) + 5: LdU64(42) + 6: MutBorrowLoc[0](loc0: S) + 7: MutBorrowField[1](S.g: T) + 8: MutBorrowField[2](T.h: u64) + 9: WriteRef + 10: MoveLoc[0](loc0: S) + 11: Ret +} +write_local_via_ref(): S /* def_idx: 5 */ { +L0: loc0: S +L1: loc1: &mut S +B0: + 0: LdU64(0) + 1: LdU64(0) + 2: Pack[0](T) + 3: Pack[2](S) + 4: StLoc[0](loc0: S) + 5: MutBorrowLoc[0](loc0: S) + 6: StLoc[1](loc1: &mut S) + 7: LdU64(42) + 8: MoveLoc[1](loc1: &mut S) + 9: MutBorrowField[1](S.g: T) + 10: MutBorrowField[2](T.h: u64) + 11: WriteRef + 12: MoveLoc[0](loc0: S) + 13: Ret +} +write_local_via_ref_2(): S /* def_idx: 6 */ { +L0: loc0: S +L1: loc1: &mut u64 +B0: + 0: LdU64(0) + 1: LdU64(0) + 2: Pack[0](T) + 3: Pack[2](S) + 4: StLoc[0](loc0: S) + 5: MutBorrowLoc[0](loc0: S) + 6: MutBorrowField[1](S.g: T) + 7: MutBorrowField[2](T.h: u64) + 8: StLoc[1](loc1: &mut u64) + 9: LdU64(42) + 10: MoveLoc[1](loc1: &mut u64) + 11: WriteRef + 12: MoveLoc[0](loc0: S) + 13: Ret +} +write_param(Arg0: &mut S) /* def_idx: 7 */ { +B0: + 0: LdU64(42) + 1: MoveLoc[0](Arg0: &mut S) + 2: MutBorrowField[1](S.g: T) + 3: MutBorrowField[2](T.h: u64) + 4: WriteRef + 5: Ret +} +write_val(Arg0: S): S /* def_idx: 8 */ { +B0: + 0: LdU64(42) + 1: MutBorrowLoc[0](Arg0: S) + 2: MutBorrowField[1](S.g: T) + 3: MutBorrowField[2](T.h: u64) + 4: WriteRef + 5: MoveLoc[0](Arg0: S) + 6: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp index cf24cf3290946..c6e038e4bb34f 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp @@ -174,11 +174,13 @@ module 0x42::freeze_mut_ref { public fun freeze_mut_ref::borrow_mut<#0>($t0: &mut vector<#0>): � { var $t1: � var $t2: &mut #0 - var $t3: u64 - 0: $t3 := 0 - 1: $t2 := vector::borrow_mut<#0>($t0, $t3) - 2: $t1 := freeze_ref(implicit)($t2) - 3: return $t1 + var $t3: &mut vector<#0> + var $t4: u64 + 0: $t3 := infer($t0) + 1: $t4 := 0 + 2: $t2 := vector::borrow_mut<#0>($t3, $t4) + 3: $t1 := freeze_ref(implicit)($t2) + 4: return $t1 } @@ -276,38 +278,42 @@ public fun freeze_mut_ref::t5($t0: &mut 0x42::freeze_mut_ref::G) { var $t3: &mut 0x42::freeze_mut_ref::G var $t4: u64 var $t5: u64 - var $t6: &mut u64 - var $t7: &mut 0x42::freeze_mut_ref::G - var $t8: u64 + var $t6: u64 + var $t7: &mut u64 + var $t8: &mut 0x42::freeze_mut_ref::G var $t9: u64 - var $t10: &mut u64 + var $t10: u64 var $t11: u64 - var $t12: &u64 + var $t12: &mut u64 var $t13: u64 - var $t14: &mut u64 + var $t14: &u64 var $t15: u64 - var $t16: &u64 + var $t16: &mut u64 + var $t17: u64 + var $t18: &u64 0: $t1 := 0 - 1: $t5 := 1 - 2: $t4 := +($t1, $t5) - 3: $t1 := infer($t4) - 4: $t3 := infer($t0) - 5: $t2 := borrow_field<0x42::freeze_mut_ref::G>.f($t3) - 6: $t9 := 1 - 7: $t8 := +($t1, $t9) - 8: $t1 := infer($t8) - 9: $t7 := infer($t0) - 10: $t6 := borrow_field<0x42::freeze_mut_ref::G>.f($t7) - 11: $t11 := 2 - 12: $t10 := borrow_local($t11) + 1: $t5 := infer($t1) + 2: $t6 := 1 + 3: $t4 := +($t5, $t6) + 4: $t1 := infer($t4) + 5: $t3 := infer($t0) + 6: $t2 := borrow_field<0x42::freeze_mut_ref::G>.f($t3) + 7: $t10 := infer($t1) + 8: $t11 := 1 + 9: $t9 := +($t10, $t11) + 10: $t1 := infer($t9) + 11: $t8 := infer($t0) + 12: $t7 := borrow_field<0x42::freeze_mut_ref::G>.f($t8) 13: $t13 := 2 - 14: $t15 := 0 - 15: write_ref($t2, $t15) - 16: $t16 := freeze_ref(implicit)($t10) - 17: $t12 := infer($t16) - 18: $t14 := infer($t6) - 19: write_ref($t14, $t13) - 20: return () + 14: $t12 := borrow_local($t13) + 15: $t15 := 2 + 16: $t17 := 0 + 17: write_ref($t2, $t17) + 18: $t18 := freeze_ref(implicit)($t12) + 19: $t14 := infer($t18) + 20: $t16 := infer($t7) + 21: write_ref($t16, $t15) + 22: return () } @@ -397,4 +403,193 @@ warning: Unused assignment to `x`. Consider removing or prefixing with an unders │ ^^^^^^^^^ +============ disassembled file-format ================== +// Move bytecode v7 +module 42.freeze_mut_ref { +struct G { + f: u64 +} +struct S has drop { + dummy_field: bool +} + +public borrow_mut(Arg0: &mut vector): &Ty0 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: &mut vector) + 1: LdU64(0) + 2: VecMutBorrow(2) + 3: FreezeRef + 4: Ret +} +public borrow_mut2(Arg0: &mut Ty0): &Ty0 /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: &mut Ty0) + 1: FreezeRef + 2: Ret +} +public borrow_mut3(Arg0: &mut Ty0, Arg1: &Ty0): &Ty0 /* def_idx: 2 */ { +L2: loc0: &Ty0 +B0: + 0: MoveLoc[1](Arg1: &Ty0) + 1: Pop + 2: MoveLoc[0](Arg0: &mut Ty0) + 3: FreezeRef + 4: StLoc[2](loc0: &Ty0) +B1: + 5: MoveLoc[2](loc0: &Ty0) + 6: Ret +B2: + 7: MoveLoc[0](Arg0: &mut Ty0) + 8: Pop + 9: MoveLoc[1](Arg1: &Ty0) + 10: StLoc[2](loc0: &Ty0) + 11: Branch(5) +} +public borrow_mut4(Arg0: &mut Ty0): &Ty0 /* def_idx: 3 */ { +B0: + 0: MoveLoc[0](Arg0: &mut Ty0) + 1: FreezeRef + 2: Ret +} +t0() /* def_idx: 4 */ { +L0: loc0: u64 +L1: loc1: &u64 +B0: + 0: LdU64(0) + 1: StLoc[0](loc0: u64) + 2: MutBorrowLoc[0](loc0: u64) + 3: FreezeRef + 4: Pop + 5: Ret +} +t1(Arg0: &mut S): &S /* def_idx: 5 */ { +B0: + 0: MoveLoc[0](Arg0: &mut S) + 1: FreezeRef + 2: Ret +} +t2(Arg0: &mut u64, Arg1: &mut u64): &u64 * &mut u64 /* def_idx: 6 */ { +B0: + 0: MoveLoc[0](Arg0: &mut u64) + 1: FreezeRef + 2: MoveLoc[1](Arg1: &mut u64) + 3: Ret +} +public t4() /* def_idx: 7 */ { +L0: loc0: u64 +L1: loc1: &u64 +L2: loc2: u64 +B0: + 0: LdU64(0) + 1: StLoc[0](loc0: u64) + 2: MutBorrowLoc[0](loc0: u64) + 3: FreezeRef + 4: Pop + 5: LdU64(0) + 6: StLoc[2](loc2: u64) + 7: MutBorrowLoc[2](loc2: u64) + 8: FreezeRef + 9: Pop + 10: Ret +} +public t5(Arg0: &mut G) /* def_idx: 8 */ { +L1: loc0: &mut u64 +L2: loc1: &mut u64 +L3: loc2: u64 +L4: loc3: &mut u64 +L5: loc4: &u64 +B0: + 0: LdU64(0) + 1: LdU64(1) + 2: Add + 3: CopyLoc[0](Arg0: &mut G) + 4: MutBorrowField[0](G.f: u64) + 5: StLoc[1](loc0: &mut u64) + 6: LdU64(1) + 7: Add + 8: Pop + 9: MoveLoc[0](Arg0: &mut G) + 10: MutBorrowField[0](G.f: u64) + 11: StLoc[2](loc1: &mut u64) + 12: LdU64(2) + 13: StLoc[3](loc2: u64) + 14: MutBorrowLoc[3](loc2: u64) + 15: StLoc[4](loc3: &mut u64) + 16: LdU64(2) + 17: LdU64(0) + 18: MoveLoc[1](loc0: &mut u64) + 19: WriteRef + 20: MoveLoc[4](loc3: &mut u64) + 21: FreezeRef + 22: Pop + 23: MoveLoc[2](loc1: &mut u64) + 24: WriteRef + 25: Ret +} +t6(Arg0: bool, Arg1: &mut S, Arg2: &S) /* def_idx: 9 */ { +L3: loc0: &S +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrFalse(10) +B1: + 2: MoveLoc[2](Arg2: &S) + 3: Pop + 4: CopyLoc[1](Arg1: &mut S) + 5: MoveLoc[1](Arg1: &mut S) + 6: Pop + 7: FreezeRef + 8: Pop +B2: + 9: Ret +B3: + 10: MoveLoc[1](Arg1: &mut S) + 11: Pop + 12: MoveLoc[2](Arg2: &S) + 13: Pop + 14: Branch(9) +} +t7(Arg0: bool, Arg1: &mut S, Arg2: &S) /* def_idx: 10 */ { +L3: loc0: &S +L4: loc1: &S +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrFalse(10) +B1: + 2: MoveLoc[2](Arg2: &S) + 3: Pop + 4: MoveLoc[1](Arg1: &mut S) + 5: FreezeRef + 6: StLoc[3](loc0: &S) +B2: + 7: MoveLoc[3](loc0: &S) + 8: Pop + 9: Ret +B3: + 10: MoveLoc[1](Arg1: &mut S) + 11: Pop + 12: MoveLoc[2](Arg2: &S) + 13: StLoc[3](loc0: &S) + 14: Branch(7) +} +t8(Arg0: bool, Arg1: &mut S, Arg2: &S) /* def_idx: 11 */ { +L3: loc0: &S +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrFalse(8) +B1: + 2: MoveLoc[2](Arg2: &S) + 3: Pop + 4: MoveLoc[1](Arg1: &mut S) + 5: FreezeRef + 6: Pop +B2: + 7: Ret +B3: + 8: MoveLoc[1](Arg1: &mut S) + 9: Pop + 10: MoveLoc[2](Arg2: &S) + 11: Pop + 12: Branch(7) +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp index 58f17e58316dc..ee19b08313cc7 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp @@ -75,12 +75,14 @@ fun globals::check($t0: address): bool { [variant baseline] fun globals::publish($t0: &signer) { - var $t1: 0x42::globals::R - var $t2: u64 - 0: $t2 := 1 - 1: $t1 := pack 0x42::globals::R($t2) - 2: move_to<0x42::globals::R>($t0, $t1) - 3: return () + var $t1: &signer + var $t2: 0x42::globals::R + var $t3: u64 + 0: $t1 := infer($t0) + 1: $t3 := 1 + 2: $t2 := pack 0x42::globals::R($t3) + 3: move_to<0x42::globals::R>($t1, $t2) + 4: return () } @@ -111,4 +113,47 @@ fun globals::write($t0: address, $t1: u64): u64 { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.globals { +struct R has store, key { + f: u64 +} + +check(Arg0: address): bool /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: address) + 1: Exists[0](R) + 2: Ret +} +publish(Arg0: &signer) /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: &signer) + 1: LdU64(1) + 2: Pack[0](R) + 3: MoveTo[0](R) + 4: Ret +} +read(Arg0: address): u64 /* def_idx: 2 */ { +B0: + 0: MoveLoc[0](Arg0: address) + 1: ImmBorrowGlobal[0](R) + 2: ImmBorrowField[0](R.f: u64) + 3: ReadRef + 4: Ret +} +write(Arg0: address, Arg1: u64): u64 /* def_idx: 3 */ { +L2: loc0: &mut R +B0: + 0: MoveLoc[0](Arg0: address) + 1: MutBorrowGlobal[0](R) + 2: StLoc[2](loc0: &mut R) + 3: LdU64(2) + 4: MoveLoc[2](loc0: &mut R) + 5: MutBorrowField[0](R.f: u64) + 6: WriteRef + 7: LdU64(9) + 8: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp index a8faa766b2a7a..357a4135d110f 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp @@ -37,16 +37,20 @@ fun if_else::if_else($t0: bool, $t1: u64): u64 { var $t2: u64 var $t3: u64 var $t4: u64 - 0: if ($t0) goto 1 else goto 5 + var $t5: u64 + var $t6: u64 + 0: if ($t0) goto 1 else goto 6 1: label L0 - 2: $t3 := 1 - 3: $t2 := +($t1, $t3) - 4: goto 8 - 5: label L1 - 6: $t4 := 1 - 7: $t2 := -($t1, $t4) - 8: label L2 - 9: return $t2 + 2: $t3 := infer($t1) + 3: $t4 := 1 + 4: $t2 := +($t3, $t4) + 5: goto 10 + 6: label L1 + 7: $t5 := infer($t1) + 8: $t6 := 1 + 9: $t2 := -($t5, $t6) + 10: label L2 + 11: return $t2 } @@ -60,28 +64,99 @@ fun if_else::if_else_nested($t0: bool, $t1: u64): u64 { var $t7: u64 var $t8: u64 var $t9: u64 - 0: if ($t0) goto 1 else goto 5 + var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: u64 + 0: if ($t0) goto 1 else goto 6 1: label L0 - 2: $t5 := 1 - 3: $t4 := +($t1, $t5) - 4: goto 8 - 5: label L1 - 6: $t6 := 1 - 7: $t4 := -($t1, $t6) - 8: label L2 - 9: $t7 := 10 - 10: $t3 := >($t4, $t7) - 11: if ($t3) goto 12 else goto 16 - 12: label L3 - 13: $t8 := 2 - 14: $t2 := *($t1, $t8) - 15: goto 19 - 16: label L4 - 17: $t9 := 2 - 18: $t2 := /($t1, $t9) - 19: label L5 - 20: return $t2 + 2: $t5 := infer($t1) + 3: $t6 := 1 + 4: $t4 := +($t5, $t6) + 5: goto 10 + 6: label L1 + 7: $t7 := infer($t1) + 8: $t8 := 1 + 9: $t4 := -($t7, $t8) + 10: label L2 + 11: $t9 := 10 + 12: $t3 := >($t4, $t9) + 13: if ($t3) goto 14 else goto 19 + 14: label L3 + 15: $t10 := infer($t1) + 16: $t11 := 2 + 17: $t2 := *($t10, $t11) + 18: goto 23 + 19: label L4 + 20: $t12 := infer($t1) + 21: $t13 := 2 + 22: $t2 := /($t12, $t13) + 23: label L5 + 24: return $t2 } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.if_else { + + +if_else(Arg0: bool, Arg1: u64): u64 /* def_idx: 0 */ { +L2: loc0: u64 +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrFalse(8) +B1: + 2: MoveLoc[1](Arg1: u64) + 3: LdU64(1) + 4: Add + 5: StLoc[2](loc0: u64) +B2: + 6: MoveLoc[2](loc0: u64) + 7: Ret +B3: + 8: MoveLoc[1](Arg1: u64) + 9: LdU64(1) + 10: Sub + 11: StLoc[2](loc0: u64) + 12: Branch(6) +} +if_else_nested(Arg0: bool, Arg1: u64): u64 /* def_idx: 1 */ { +L2: loc0: u64 +L3: loc1: u64 +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrFalse(21) +B1: + 2: CopyLoc[1](Arg1: u64) + 3: LdU64(1) + 4: Add + 5: StLoc[2](loc0: u64) +B2: + 6: MoveLoc[2](loc0: u64) + 7: LdU64(10) + 8: Gt + 9: BrFalse(16) +B3: + 10: MoveLoc[1](Arg1: u64) + 11: LdU64(2) + 12: Mul + 13: StLoc[3](loc1: u64) +B4: + 14: MoveLoc[3](loc1: u64) + 15: Ret +B5: + 16: MoveLoc[1](Arg1: u64) + 17: LdU64(2) + 18: Div + 19: StLoc[3](loc1: u64) + 20: Branch(14) +B6: + 21: CopyLoc[1](Arg1: u64) + 22: LdU64(1) + 23: Sub + 24: StLoc[2](loc0: u64) + 25: Branch(6) +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp index 2f77eb1351425..0901c91cacf7a 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp @@ -71,10 +71,38 @@ fun inline_specs::specs(): u64 { fun inline_specs::succ($t0: u64): u64 { var $t1: u64 var $t2: u64 - 0: $t2 := 1 - 1: $t1 := +($t0, $t2) - 2: return $t1 + var $t3: u64 + 0: $t2 := infer($t0) + 1: $t3 := 1 + 2: $t1 := +($t2, $t3) + 3: return $t1 } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.inline_specs { + + +specs(): u64 /* def_idx: 0 */ { +L0: loc0: u64 +B0: + 0: LdU64(0) + 1: StLoc[0](loc0: u64) + 2: Nop + 3: MoveLoc[0](loc0: u64) + 4: Call succ(u64): u64 + 5: StLoc[0](loc0: u64) + 6: Nop + 7: MoveLoc[0](loc0: u64) + 8: Ret +} +succ(Arg0: u64): u64 /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: LdU64(1) + 2: Add + 3: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp index 85bca4397bfc9..a203d708b09bd 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp @@ -91,44 +91,52 @@ fun loops::nested_loop($t0: u64): u64 { var $t1: u64 var $t2: bool var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 var $t7: u64 var $t8: u64 var $t9: u64 + var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: u64 0: label L0 - 1: $t3 := 0 - 2: $t2 := >($t0, $t3) - 3: if ($t2) goto 4 else goto 25 - 4: label L2 - 5: label L5 - 6: $t5 := 10 - 7: $t4 := >($t0, $t5) - 8: if ($t4) goto 9 else goto 15 - 9: label L7 - 10: $t7 := 1 - 11: $t6 := -($t0, $t7) - 12: $t0 := infer($t6) - 13: goto 19 - 14: goto 17 - 15: label L8 - 16: goto 19 - 17: label L9 - 18: goto 5 - 19: label L6 - 20: $t9 := 1 - 21: $t8 := -($t0, $t9) - 22: $t0 := infer($t8) - 23: goto 0 - 24: goto 27 - 25: label L3 - 26: goto 29 - 27: label L4 - 28: goto 0 - 29: label L1 - 30: $t1 := infer($t0) - 31: return $t1 + 1: $t3 := infer($t0) + 2: $t4 := 0 + 3: $t2 := >($t3, $t4) + 4: if ($t2) goto 5 else goto 29 + 5: label L2 + 6: label L5 + 7: $t6 := infer($t0) + 8: $t7 := 10 + 9: $t5 := >($t6, $t7) + 10: if ($t5) goto 11 else goto 18 + 11: label L7 + 12: $t9 := infer($t0) + 13: $t10 := 1 + 14: $t8 := -($t9, $t10) + 15: $t0 := infer($t8) + 16: goto 22 + 17: goto 20 + 18: label L8 + 19: goto 22 + 20: label L9 + 21: goto 6 + 22: label L6 + 23: $t12 := infer($t0) + 24: $t13 := 1 + 25: $t11 := -($t12, $t13) + 26: $t0 := infer($t11) + 27: goto 0 + 28: goto 31 + 29: label L3 + 30: goto 33 + 31: label L4 + 32: goto 0 + 33: label L1 + 34: $t1 := infer($t0) + 35: return $t1 } @@ -139,22 +147,26 @@ fun loops::while_loop($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: label L0 - 1: $t3 := 0 - 2: $t2 := >($t0, $t3) - 3: if ($t2) goto 4 else goto 9 - 4: label L2 - 5: $t5 := 1 - 6: $t4 := -($t0, $t5) - 7: $t0 := infer($t4) - 8: goto 11 - 9: label L3 + 1: $t3 := infer($t0) + 2: $t4 := 0 + 3: $t2 := >($t3, $t4) + 4: if ($t2) goto 5 else goto 11 + 5: label L2 + 6: $t6 := infer($t0) + 7: $t7 := 1 + 8: $t5 := -($t6, $t7) + 9: $t0 := infer($t5) 10: goto 13 - 11: label L4 - 12: goto 0 - 13: label L1 - 14: $t1 := infer($t0) - 15: return $t1 + 11: label L3 + 12: goto 15 + 13: label L4 + 14: goto 0 + 15: label L1 + 16: $t1 := infer($t0) + 17: return $t1 } @@ -163,45 +175,135 @@ fun loops::while_loop_with_break_and_continue($t0: u64): u64 { var $t1: u64 var $t2: bool var $t3: u64 - var $t4: bool - var $t5: u64 - var $t6: bool + var $t4: u64 + var $t5: bool + var $t6: u64 var $t7: u64 - var $t8: u64 + var $t8: bool var $t9: u64 + var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: u64 0: label L0 - 1: $t3 := 0 - 2: $t2 := >($t0, $t3) - 3: if ($t2) goto 4 else goto 25 - 4: label L2 - 5: $t5 := 42 - 6: $t4 := ==($t0, $t5) - 7: if ($t4) goto 8 else goto 11 - 8: label L5 - 9: goto 29 - 10: goto 12 - 11: label L6 - 12: label L7 - 13: $t7 := 21 - 14: $t6 := ==($t0, $t7) - 15: if ($t6) goto 16 else goto 19 - 16: label L8 - 17: goto 0 - 18: goto 20 - 19: label L9 - 20: label L10 - 21: $t9 := 1 - 22: $t8 := -($t0, $t9) - 23: $t0 := infer($t8) - 24: goto 27 - 25: label L3 - 26: goto 29 - 27: label L4 - 28: goto 0 - 29: label L1 - 30: $t1 := infer($t0) - 31: return $t1 + 1: $t3 := infer($t0) + 2: $t4 := 0 + 3: $t2 := >($t3, $t4) + 4: if ($t2) goto 5 else goto 29 + 5: label L2 + 6: $t6 := infer($t0) + 7: $t7 := 42 + 8: $t5 := ==($t6, $t7) + 9: if ($t5) goto 10 else goto 13 + 10: label L5 + 11: goto 33 + 12: goto 14 + 13: label L6 + 14: label L7 + 15: $t9 := infer($t0) + 16: $t10 := 21 + 17: $t8 := ==($t9, $t10) + 18: if ($t8) goto 19 else goto 22 + 19: label L8 + 20: goto 0 + 21: goto 23 + 22: label L9 + 23: label L10 + 24: $t12 := infer($t0) + 25: $t13 := 1 + 26: $t11 := -($t12, $t13) + 27: $t0 := infer($t11) + 28: goto 31 + 29: label L3 + 30: goto 33 + 31: label L4 + 32: goto 0 + 33: label L1 + 34: $t1 := infer($t0) + 35: return $t1 } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.loops { + + +nested_loop(Arg0: u64): u64 /* def_idx: 0 */ { +B0: + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(0) + 2: Gt + 3: BrFalse(18) +B1: + 4: CopyLoc[0](Arg0: u64) + 5: LdU64(10) + 6: Gt + 7: BrTrue(9) +B2: + 8: Branch(13) +B3: + 9: MoveLoc[0](Arg0: u64) + 10: LdU64(1) + 11: Sub + 12: StLoc[0](Arg0: u64) +B4: + 13: MoveLoc[0](Arg0: u64) + 14: LdU64(1) + 15: Sub + 16: StLoc[0](Arg0: u64) + 17: Branch(0) +B5: + 18: MoveLoc[0](Arg0: u64) + 19: Ret +} +while_loop(Arg0: u64): u64 /* def_idx: 1 */ { +B0: + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(0) + 2: Gt + 3: BrFalse(9) +B1: + 4: MoveLoc[0](Arg0: u64) + 5: LdU64(1) + 6: Sub + 7: StLoc[0](Arg0: u64) + 8: Branch(0) +B2: + 9: MoveLoc[0](Arg0: u64) + 10: Ret +} +while_loop_with_break_and_continue(Arg0: u64): u64 /* def_idx: 2 */ { +B0: + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(0) + 2: Gt + 3: BrTrue(5) +B1: + 4: Branch(10) +B2: + 5: CopyLoc[0](Arg0: u64) + 6: LdU64(42) + 7: Eq + 8: BrFalse(12) +B3: + 9: Branch(10) +B4: + 10: MoveLoc[0](Arg0: u64) + 11: Ret +B5: + 12: CopyLoc[0](Arg0: u64) + 13: LdU64(21) + 14: Eq + 15: BrFalse(17) +B6: + 16: Branch(0) +B7: + 17: MoveLoc[0](Arg0: u64) + 18: LdU64(1) + 19: Sub + 20: StLoc[0](Arg0: u64) + 21: Branch(0) +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop_labels.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop_labels.exp index 247f1e144dfdb..89bd08ec9c7b6 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop_labels.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop_labels.exp @@ -75,4 +75,18 @@ fun test::f1() { } +============ disassembled file-format ================== +// Move bytecode v7 +module 815.test { + + +f1() /* def_idx: 0 */ { +B0: + 0: Branch(2) +B1: + 1: Branch(0) +B2: + 2: Branch(0) +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ok.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ok.exp index 0e40ef6056174..a4fda769f9cbd 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ok.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_ok.exp @@ -347,25 +347,27 @@ public fun m::inner_value($t0: 0xc0ffee::m::Inner): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 0: $t2 := borrow_local($t0) 1: $t3 := test_variant 0xc0ffee::m::Inner::Inner1($t2) 2: if ($t3) goto 3 else goto 7 3: label L2 4: $t4 := unpack_variant 0xc0ffee::m::Inner::Inner1($t0) 5: $t1 := infer($t4) - 6: goto 17 + 6: goto 18 7: label L1 8: $t3 := test_variant 0xc0ffee::m::Inner::Inner2($t2) - 9: if ($t3) goto 10 else goto 14 + 9: if ($t3) goto 10 else goto 15 10: label L4 11: ($t5, $t6) := unpack_variant 0xc0ffee::m::Inner::Inner2($t0) - 12: $t1 := +($t5, $t6) - 13: goto 17 - 14: label L3 - 15: $t7 := 14566554180833181697 - 16: abort($t7) - 17: label L0 - 18: return $t1 + 12: $t7 := infer($t5) + 13: $t1 := +($t7, $t6) + 14: goto 18 + 15: label L3 + 16: $t8 := 14566554180833181697 + 17: abort($t8) + 18: label L0 + 19: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_refutable_err.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_refutable_err.exp index c930a13a552b1..a8af7fd83d17a 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_refutable_err.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/matching_refutable_err.exp @@ -40,4 +40,23 @@ fun m::t($t0: 0x815::m::E): u64 { } +============ disassembled file-format ================== +// Move bytecode v7 +module 815.m { +enum E { + None{ + + }, + Some{ + _0: u64 + } +} + +t(Arg0: E): u64 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: E) + 1: UnpackVariant[0](E/Some) + 2: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp index 3260942440feb..958118005acac 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp @@ -51,12 +51,18 @@ fun operators::arithm($t0: u64, $t1: u64): u64 { var $t4: u64 var $t5: u64 var $t6: u64 - 0: $t6 := -($t0, $t1) - 1: $t5 := /($t1, $t6) - 2: $t4 := *($t5, $t1) - 3: $t3 := %($t4, $t0) - 4: $t2 := +($t0, $t3) - 5: return $t2 + var $t7: u64 + var $t8: u64 + var $t9: u64 + 0: $t3 := infer($t0) + 1: $t7 := infer($t1) + 2: $t9 := infer($t0) + 3: $t8 := -($t9, $t1) + 4: $t6 := /($t7, $t8) + 5: $t5 := *($t6, $t1) + 6: $t4 := %($t5, $t0) + 7: $t2 := +($t3, $t4) + 8: return $t2 } @@ -64,9 +70,11 @@ fun operators::arithm($t0: u64, $t1: u64): u64 { fun operators::bits($t0: u64, $t1: u8): u64 { var $t2: u64 var $t3: u64 - 0: $t3 := <<($t0, $t1) - 1: $t2 := &($t3, $t0) - 2: return $t2 + var $t4: u64 + 0: $t4 := infer($t0) + 1: $t3 := <<($t4, $t1) + 2: $t2 := &($t3, $t0) + 3: return $t2 } @@ -133,16 +141,20 @@ fun operators::bools($t0: bool, $t1: bool): bool { [variant baseline] fun operators::equality<#0>($t0: #0, $t1: #0): bool { var $t2: bool - 0: $t2 := ==($t0, $t1) - 1: return $t2 + var $t3: #0 + 0: $t3 := infer($t0) + 1: $t2 := ==($t3, $t1) + 2: return $t2 } [variant baseline] fun operators::inequality<#0>($t0: #0, $t1: #0): bool { var $t2: bool - 0: $t2 := !=($t0, $t1) - 1: return $t2 + var $t3: #0 + 0: $t3 := infer($t0) + 1: $t2 := !=($t3, $t1) + 2: return $t2 } @@ -152,34 +164,206 @@ fun operators::order($t0: u64, $t1: u64): bool { var $t3: bool var $t4: bool var $t5: bool - var $t6: bool - var $t7: bool - 0: $t5 := <($t0, $t1) - 1: if ($t5) goto 2 else goto 5 - 2: label L0 - 3: $t4 := <=($t0, $t1) - 4: goto 7 - 5: label L1 - 6: $t4 := false - 7: label L2 - 8: if ($t4) goto 9 else goto 13 - 9: label L3 - 10: $t6 := >($t0, $t1) - 11: $t3 := !($t6) - 12: goto 15 - 13: label L4 - 14: $t3 := false - 15: label L5 - 16: if ($t3) goto 17 else goto 21 - 17: label L6 - 18: $t7 := >=($t0, $t1) - 19: $t2 := !($t7) - 20: goto 23 - 21: label L7 - 22: $t2 := false - 23: label L8 - 24: return $t2 + var $t6: u64 + var $t7: u64 + var $t8: bool + var $t9: u64 + var $t10: bool + var $t11: u64 + 0: $t6 := infer($t0) + 1: $t5 := <($t6, $t1) + 2: if ($t5) goto 3 else goto 7 + 3: label L0 + 4: $t7 := infer($t0) + 5: $t4 := <=($t7, $t1) + 6: goto 9 + 7: label L1 + 8: $t4 := false + 9: label L2 + 10: if ($t4) goto 11 else goto 16 + 11: label L3 + 12: $t9 := infer($t0) + 13: $t8 := >($t9, $t1) + 14: $t3 := !($t8) + 15: goto 18 + 16: label L4 + 17: $t3 := false + 18: label L5 + 19: if ($t3) goto 20 else goto 25 + 20: label L6 + 21: $t11 := infer($t0) + 22: $t10 := >=($t11, $t1) + 23: $t2 := !($t10) + 24: goto 27 + 25: label L7 + 26: $t2 := false + 27: label L8 + 28: return $t2 } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.operators { + + +arithm(Arg0: u64, Arg1: u64): u64 /* def_idx: 0 */ { +B0: + 0: CopyLoc[0](Arg0: u64) + 1: CopyLoc[1](Arg1: u64) + 2: CopyLoc[0](Arg0: u64) + 3: CopyLoc[1](Arg1: u64) + 4: Sub + 5: Div + 6: MoveLoc[1](Arg1: u64) + 7: Mul + 8: MoveLoc[0](Arg0: u64) + 9: Mod + 10: Add + 11: Ret +} +bits(Arg0: u64, Arg1: u8): u64 /* def_idx: 1 */ { +B0: + 0: CopyLoc[0](Arg0: u64) + 1: MoveLoc[1](Arg1: u8) + 2: Shl + 3: MoveLoc[0](Arg0: u64) + 4: BitAnd + 5: Ret +} +bools(Arg0: bool, Arg1: bool): bool /* def_idx: 2 */ { +L2: loc0: bool +L3: loc1: bool +L4: loc2: bool +L5: loc3: bool +B0: + 0: CopyLoc[0](Arg0: bool) + 1: BrFalse(44) +B1: + 2: CopyLoc[1](Arg1: bool) + 3: StLoc[2](loc0: bool) +B2: + 4: MoveLoc[2](loc0: bool) + 5: BrFalse(35) +B3: + 6: LdTrue + 7: StLoc[3](loc1: bool) +B4: + 8: MoveLoc[3](loc1: bool) + 9: BrFalse(27) +B5: + 10: LdTrue + 11: StLoc[4](loc2: bool) +B6: + 12: MoveLoc[4](loc2: bool) + 13: BrFalse(18) +B7: + 14: LdTrue + 15: StLoc[5](loc3: bool) +B8: + 16: MoveLoc[5](loc3: bool) + 17: Ret +B9: + 18: MoveLoc[0](Arg0: bool) + 19: BrTrue(24) +B10: + 20: MoveLoc[1](Arg1: bool) + 21: Not + 22: StLoc[5](loc3: bool) + 23: Branch(16) +B11: + 24: LdFalse + 25: StLoc[5](loc3: bool) + 26: Branch(16) +B12: + 27: CopyLoc[0](Arg0: bool) + 28: BrTrue(32) +B13: + 29: CopyLoc[1](Arg1: bool) + 30: StLoc[4](loc2: bool) + 31: Branch(12) +B14: + 32: LdFalse + 33: StLoc[4](loc2: bool) + 34: Branch(12) +B15: + 35: CopyLoc[0](Arg0: bool) + 36: BrFalse(41) +B16: + 37: CopyLoc[1](Arg1: bool) + 38: Not + 39: StLoc[3](loc1: bool) + 40: Branch(8) +B17: + 41: LdFalse + 42: StLoc[3](loc1: bool) + 43: Branch(8) +B18: + 44: LdFalse + 45: StLoc[2](loc0: bool) + 46: Branch(4) +} +equality(Arg0: Ty0, Arg1: Ty0): bool /* def_idx: 3 */ { +B0: + 0: MoveLoc[0](Arg0: Ty0) + 1: MoveLoc[1](Arg1: Ty0) + 2: Eq + 3: Ret +} +inequality(Arg0: Ty0, Arg1: Ty0): bool /* def_idx: 4 */ { +B0: + 0: MoveLoc[0](Arg0: Ty0) + 1: MoveLoc[1](Arg1: Ty0) + 2: Neq + 3: Ret +} +order(Arg0: u64, Arg1: u64): bool /* def_idx: 5 */ { +L2: loc0: bool +L3: loc1: bool +L4: loc2: bool +B0: + 0: CopyLoc[0](Arg0: u64) + 1: CopyLoc[1](Arg1: u64) + 2: Lt + 3: BrFalse(30) +B1: + 4: CopyLoc[0](Arg0: u64) + 5: CopyLoc[1](Arg1: u64) + 6: Le + 7: StLoc[2](loc0: bool) +B2: + 8: MoveLoc[2](loc0: bool) + 9: BrFalse(27) +B3: + 10: CopyLoc[0](Arg0: u64) + 11: CopyLoc[1](Arg1: u64) + 12: Gt + 13: Not + 14: StLoc[3](loc1: bool) +B4: + 15: MoveLoc[3](loc1: bool) + 16: BrFalse(24) +B5: + 17: MoveLoc[0](Arg0: u64) + 18: MoveLoc[1](Arg1: u64) + 19: Ge + 20: Not + 21: StLoc[4](loc2: bool) +B6: + 22: MoveLoc[4](loc2: bool) + 23: Ret +B7: + 24: LdFalse + 25: StLoc[4](loc2: bool) + 26: Branch(22) +B8: + 27: LdFalse + 28: StLoc[3](loc1: bool) + 29: Branch(15) +B9: + 30: LdFalse + 31: StLoc[2](loc0: bool) + 32: Branch(8) +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp index 52cea517af73a..d3d547a43fd85 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp @@ -89,8 +89,12 @@ module 0x42::pack_unpack { [variant baseline] fun pack_unpack::pack1($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { var $t3: 0x42::pack_unpack::S - 0: $t3 := pack 0x42::pack_unpack::S($t0, $t1, $t2) - 1: return $t3 + var $t4: u8 + var $t5: u8 + 0: $t4 := infer($t0) + 1: $t5 := infer($t1) + 2: $t3 := pack 0x42::pack_unpack::S($t4, $t5, $t2) + 3: return $t3 } @@ -99,10 +103,14 @@ fun pack_unpack::pack2($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { var $t3: 0x42::pack_unpack::S var $t4: u8 var $t5: u8 + var $t6: u8 + var $t7: u8 0: $t4 := infer($t0) 1: $t5 := infer($t1) - 2: $t3 := pack 0x42::pack_unpack::S($t4, $t2, $t5) - 3: return $t3 + 2: $t6 := infer($t4) + 3: $t7 := infer($t2) + 4: $t3 := pack 0x42::pack_unpack::S($t6, $t7, $t5) + 5: return $t3 } @@ -110,9 +118,13 @@ fun pack_unpack::pack2($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { fun pack_unpack::pack3($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { var $t3: 0x42::pack_unpack::S var $t4: u8 + var $t5: u8 + var $t6: u8 0: $t4 := infer($t0) - 1: $t3 := pack 0x42::pack_unpack::S($t1, $t4, $t2) - 2: return $t3 + 1: $t5 := infer($t1) + 2: $t6 := infer($t4) + 3: $t3 := pack 0x42::pack_unpack::S($t5, $t6, $t2) + 4: return $t3 } @@ -121,10 +133,14 @@ fun pack_unpack::pack4($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { var $t3: 0x42::pack_unpack::S var $t4: u8 var $t5: u8 + var $t6: u8 + var $t7: u8 0: $t4 := infer($t0) 1: $t5 := infer($t1) - 2: $t3 := pack 0x42::pack_unpack::S($t2, $t4, $t5) - 3: return $t3 + 2: $t6 := infer($t2) + 3: $t7 := infer($t4) + 4: $t3 := pack 0x42::pack_unpack::S($t6, $t7, $t5) + 5: return $t3 } @@ -132,9 +148,13 @@ fun pack_unpack::pack4($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { fun pack_unpack::pack5($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { var $t3: 0x42::pack_unpack::S var $t4: u8 + var $t5: u8 + var $t6: u8 0: $t4 := infer($t0) - 1: $t3 := pack 0x42::pack_unpack::S($t1, $t2, $t4) - 2: return $t3 + 1: $t5 := infer($t1) + 2: $t6 := infer($t2) + 3: $t3 := pack 0x42::pack_unpack::S($t5, $t6, $t4) + 4: return $t3 } @@ -143,11 +163,73 @@ fun pack_unpack::pack6($t0: u8, $t1: u8, $t2: u8): 0x42::pack_unpack::S { var $t3: 0x42::pack_unpack::S var $t4: u8 var $t5: u8 + var $t6: u8 + var $t7: u8 0: $t4 := infer($t0) 1: $t5 := infer($t1) - 2: $t3 := pack 0x42::pack_unpack::S($t2, $t5, $t4) - 3: return $t3 + 2: $t6 := infer($t2) + 3: $t7 := infer($t5) + 4: $t3 := pack 0x42::pack_unpack::S($t6, $t7, $t4) + 5: return $t3 } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.pack_unpack { +struct S { + f1: u8, + f2: u8, + f3: u8 +} + +pack1(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: u8) + 1: MoveLoc[1](Arg1: u8) + 2: MoveLoc[2](Arg2: u8) + 3: Pack[0](S) + 4: Ret +} +pack2(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: u8) + 1: MoveLoc[2](Arg2: u8) + 2: MoveLoc[1](Arg1: u8) + 3: Pack[0](S) + 4: Ret +} +pack3(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 2 */ { +B0: + 0: MoveLoc[1](Arg1: u8) + 1: MoveLoc[0](Arg0: u8) + 2: MoveLoc[2](Arg2: u8) + 3: Pack[0](S) + 4: Ret +} +pack4(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 3 */ { +B0: + 0: MoveLoc[2](Arg2: u8) + 1: MoveLoc[0](Arg0: u8) + 2: MoveLoc[1](Arg1: u8) + 3: Pack[0](S) + 4: Ret +} +pack5(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 4 */ { +B0: + 0: MoveLoc[1](Arg1: u8) + 1: MoveLoc[2](Arg2: u8) + 2: MoveLoc[0](Arg0: u8) + 3: Pack[0](S) + 4: Ret +} +pack6(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 5 */ { +B0: + 0: MoveLoc[2](Arg2: u8) + 1: MoveLoc[1](Arg1: u8) + 2: MoveLoc[0](Arg0: u8) + 3: Pack[0](S) + 4: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp index 17e454f6177ee..1d424b9e884a1 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp @@ -41,10 +41,12 @@ module 0x42::pack_unpack { [variant baseline] fun pack_unpack::pack($t0: u64, $t1: u64): 0x42::pack_unpack::S { var $t2: 0x42::pack_unpack::S - var $t3: 0x42::pack_unpack::T - 0: $t3 := pack 0x42::pack_unpack::T($t1) - 1: $t2 := pack 0x42::pack_unpack::S($t0, $t3) - 2: return $t2 + var $t3: u64 + var $t4: 0x42::pack_unpack::T + 0: $t3 := infer($t0) + 1: $t4 := pack 0x42::pack_unpack::T($t1) + 2: $t2 := pack 0x42::pack_unpack::S($t3, $t4) + 3: return $t2 } @@ -63,4 +65,31 @@ fun pack_unpack::unpack($t0: 0x42::pack_unpack::S): (u64, u64) { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.pack_unpack { +struct T { + h: u64 +} +struct S { + f: u64, + g: T +} + +pack(Arg0: u64, Arg1: u64): S /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: MoveLoc[1](Arg1: u64) + 2: Pack[0](T) + 3: Pack[1](S) + 4: Ret +} +unpack(Arg0: S): u64 * u64 /* def_idx: 1 */ { +B0: + 0: MoveLoc[0](Arg0: S) + 1: Unpack[1](S) + 2: Unpack[0](T) + 3: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp index 587b47b31883a..1a7186b1877b0 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp @@ -55,4 +55,32 @@ fun reference_conversion::use_it(): u64 { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.reference_conversion { + + +deref(Arg0: &u64): u64 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: &u64) + 1: ReadRef + 2: Ret +} +use_it(): u64 /* def_idx: 1 */ { +L0: loc0: u64 +L1: loc1: &mut u64 +B0: + 0: LdU64(42) + 1: StLoc[0](loc0: u64) + 2: MutBorrowLoc[0](loc0: u64) + 3: StLoc[1](loc1: &mut u64) + 4: LdU64(43) + 5: CopyLoc[1](loc1: &mut u64) + 6: WriteRef + 7: MoveLoc[1](loc1: &mut u64) + 8: FreezeRef + 9: Call deref(&u64): u64 + 10: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp index 6108d5abdaa96..4a95c4483a3a9 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp @@ -43,4 +43,25 @@ public fun m::foo($t0: &0x42::m::S): u8 { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { +struct E { + k: u8 +} +struct S { + data: vector +} + +public foo(Arg0: &S): u8 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: &S) + 1: ImmBorrowField[0](S.data: vector) + 2: LdU64(0) + 3: VecImmBorrow(2) + 4: ImmBorrowField[1](E.k: u8) + 5: ReadRef + 6: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp index 8843ffc5a4ac7..b3e3f13164e21 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp @@ -22,4 +22,15 @@ fun vector::create(): vector { } +============ disassembled file-format ================== +// Move bytecode v7 +module 42.vector { + + +create(): vector /* def_idx: 0 */ { +B0: + 0: LdConst[0](Vector(U64): [3, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0]) + 1: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp index 44dca347d8756..5eb3acb11c33c 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp @@ -44,4 +44,23 @@ public fun m::test() { } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { +struct S { + x: u64, + y: u64 +} + +public test() /* def_idx: 0 */ { +B0: + 0: LdU64(3) + 1: LdU64(4) + 2: Pack[0](S) + 3: Unpack[0](S) + 4: Pop + 5: Pop + 6: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-verify-failure/equality.exp b/third_party/move/move-compiler-v2/tests/bytecode-verify-failure/equality.exp index 3c99d92a1d3b8..601110318e585 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-verify-failure/equality.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-verify-failure/equality.exp @@ -1,23 +1,7 @@ -============ disassembled file-format ================== -// Move bytecode v7 -module c0ffee.m { - - -equality(Arg0: Ty0, Arg1: Ty0): bool /* def_idx: 0 */ { -B0: - 0: MoveLoc[0](Arg0: Ty0) - 1: MoveLoc[1](Arg1: Ty0) - 2: Eq - 3: Ret -} -} -============ bytecode verification failed ======== - Diagnostics: -bug: bytecode verification failed with unexpected status code `EQUALITY_OP_TYPE_MISMATCH_ERROR`. This is a compiler bug, consider reporting it. -Error message: none - ┌─ tests/bytecode-verify-failure/equality.move:3:9 +bug: file format generator: Inferred and Store AssignKind should be not appear here. + ┌─ tests/bytecode-verify-failure/equality.move:2:7 │ -3 │ x == y - │ ^^^^^^ +2 │ fun equality(x: T, y: T): bool { + │ ^^^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.off.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.off.exp index fcda55f1a11a3..d82b0f70c4794 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.off.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.off.exp @@ -7,7 +7,6 @@ module cafe.vectors { entry public guess_flips(Arg0: vector) /* def_idx: 0 */ { L1: loc0: &vector L2: loc1: u64 -L3: loc2: u64 B0: 0: ImmBorrowLoc[0](Arg0: vector) 1: StLoc[1](loc0: &vector) @@ -48,7 +47,6 @@ B7: } entry public guess_flips_directly(Arg0: vector) /* def_idx: 1 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) @@ -90,7 +88,6 @@ B0: entry public guess_without_break_with_inline(Arg0: vector) /* def_idx: 3 */ { L1: loc0: &vector L2: loc1: u64 -L3: loc2: u64 B0: 0: ImmBorrowLoc[0](Arg0: vector) 1: StLoc[1](loc0: &vector) @@ -134,7 +131,6 @@ B8: } loops_with_break_no_inline(Arg0: &vector) /* def_idx: 4 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.on.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.on.exp index 11a6f4028f8eb..9c62e420cdcaa 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.on.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/bug-10253.on.exp @@ -11,11 +11,13 @@ public fun vectors::guess_flips($t0: vector) { var $t7: bool var $t8: u8 var $t9: &u8 - var $t10: u8 - var $t11: u64 + var $t10: &vector + var $t11: u8 var $t12: u64 - var $t13: vector - var $t14: vector + var $t13: u64 + var $t14: u64 + var $t15: vector + var $t16: vector 0: $t2 := borrow_local($t0) 1: $t1 := move($t2) 2: $t3 := 0 @@ -23,27 +25,29 @@ public fun vectors::guess_flips($t0: vector) { 4: $t5 := copy($t3) 5: $t6 := vector::length($t1) 6: $t4 := <($t5, $t6) - 7: if ($t4) goto 8 else goto 25 + 7: if ($t4) goto 8 else goto 27 8: label L2 - 9: $t9 := vector::borrow($t1, $t3) - 10: $t8 := read_ref($t9) - 11: $t10 := 0 - 12: $t7 := !=($t8, $t10) - 13: if ($t7) goto 14 else goto 20 - 14: label L5 - 15: drop($t1) - 16: label L1 - 17: $t13 := copy($t0) - 18: $t14 := move($t0) - 19: return () - 20: label L7 - 21: $t12 := 1 - 22: $t11 := +($t3, $t12) - 23: $t3 := move($t11) - 24: goto 3 - 25: label L3 - 26: drop($t1) - 27: goto 16 + 9: $t10 := copy($t1) + 10: $t9 := vector::borrow($t10, $t3) + 11: $t8 := read_ref($t9) + 12: $t11 := 0 + 13: $t7 := !=($t8, $t11) + 14: if ($t7) goto 15 else goto 21 + 15: label L5 + 16: drop($t1) + 17: label L1 + 18: $t15 := copy($t0) + 19: $t16 := move($t0) + 20: return () + 21: label L7 + 22: $t13 := move($t3) + 23: $t14 := 1 + 24: $t12 := +($t13, $t14) + 25: $t3 := move($t12) + 26: goto 3 + 27: label L3 + 28: drop($t1) + 29: goto 17 } @@ -61,8 +65,9 @@ public fun vectors::guess_flips_directly($t0: vector) { var $t10: u8 var $t11: u64 var $t12: u64 - var $t13: vector + var $t13: u64 var $t14: vector + var $t15: vector 0: $t1 := 0 1: label L0 2: $t3 := copy($t1) @@ -78,14 +83,15 @@ public fun vectors::guess_flips_directly($t0: vector) { 12: $t6 := !=($t7, $t10) 13: if ($t6) goto 14 else goto 18 14: label L1 - 15: $t13 := copy($t0) - 16: $t14 := move($t0) + 15: $t14 := copy($t0) + 16: $t15 := move($t0) 17: return () 18: label L7 - 19: $t12 := 1 - 20: $t11 := +($t1, $t12) - 21: $t1 := move($t11) - 22: goto 1 + 19: $t12 := move($t1) + 20: $t13 := 1 + 21: $t11 := +($t12, $t13) + 22: $t1 := move($t11) + 23: goto 1 } @@ -113,12 +119,14 @@ public fun vectors::guess_without_break_with_inline($t0: vector) { var $t7: bool var $t8: u8 var $t9: &u8 - var $t10: u8 - var $t11: u64 + var $t10: &vector + var $t11: u8 var $t12: u64 var $t13: u64 - var $t14: vector - var $t15: vector + var $t14: u64 + var $t15: u64 + var $t16: vector + var $t17: vector 0: $t2 := borrow_local($t0) 1: $t1 := move($t2) 2: $t3 := 0 @@ -126,27 +134,29 @@ public fun vectors::guess_without_break_with_inline($t0: vector) { 4: $t5 := copy($t3) 5: $t6 := vector::length($t1) 6: $t4 := <($t5, $t6) - 7: if ($t4) goto 8 else goto 23 + 7: if ($t4) goto 8 else goto 25 8: label L2 - 9: $t9 := vector::borrow($t1, $t3) - 10: $t8 := read_ref($t9) - 11: $t10 := 0 - 12: $t7 := ==($t8, $t10) - 13: if ($t7) goto 14 else goto 19 - 14: label L5 - 15: $t13 := 1 - 16: $t12 := +($t3, $t13) - 17: $t3 := move($t12) - 18: goto 3 - 19: label L6 - 20: drop($t1) - 21: $t11 := 3 - 22: abort($t11) - 23: label L3 - 24: drop($t1) - 25: $t14 := copy($t0) - 26: $t15 := copy($t0) - 27: return () + 9: $t10 := copy($t1) + 10: $t9 := vector::borrow($t10, $t3) + 11: $t8 := read_ref($t9) + 12: $t11 := 0 + 13: $t7 := ==($t8, $t11) + 14: if ($t7) goto 15 else goto 21 + 15: label L5 + 16: $t14 := move($t3) + 17: $t15 := 1 + 18: $t13 := +($t14, $t15) + 19: $t3 := move($t13) + 20: goto 3 + 21: label L6 + 22: drop($t1) + 23: $t12 := 3 + 24: abort($t12) + 25: label L3 + 26: drop($t1) + 27: $t16 := copy($t0) + 28: $t17 := copy($t0) + 29: return () } @@ -159,33 +169,37 @@ fun vectors::loops_with_break_no_inline($t0: &vector) { var $t5: bool var $t6: u8 var $t7: &u8 - var $t8: u8 - var $t9: u64 + var $t8: &vector + var $t9: u8 var $t10: u64 + var $t11: u64 + var $t12: u64 0: $t1 := 0 1: label L0 2: $t3 := copy($t1) 3: $t4 := vector::length($t0) 4: $t2 := <($t3, $t4) - 5: if ($t2) goto 6 else goto 21 + 5: if ($t2) goto 6 else goto 23 6: label L2 - 7: $t7 := vector::borrow($t0, $t1) - 8: $t6 := read_ref($t7) - 9: $t8 := 0 - 10: $t5 := !=($t6, $t8) - 11: if ($t5) goto 12 else goto 16 - 12: label L5 - 13: drop($t0) - 14: label L1 - 15: return () - 16: label L7 - 17: $t10 := 1 - 18: $t9 := +($t1, $t10) - 19: $t1 := move($t9) - 20: goto 1 - 21: label L3 - 22: drop($t0) - 23: goto 14 + 7: $t8 := copy($t0) + 8: $t7 := vector::borrow($t8, $t1) + 9: $t6 := read_ref($t7) + 10: $t9 := 0 + 11: $t5 := !=($t6, $t9) + 12: if ($t5) goto 13 else goto 17 + 13: label L5 + 14: drop($t0) + 15: label L1 + 16: return () + 17: label L7 + 18: $t11 := move($t1) + 19: $t12 := 1 + 20: $t10 := +($t11, $t12) + 21: $t1 := move($t10) + 22: goto 1 + 23: label L3 + 24: drop($t0) + 25: goto 15 } @@ -233,7 +247,6 @@ module cafe.vectors { entry public guess_flips(Arg0: vector) /* def_idx: 0 */ { L1: loc0: &vector L2: loc1: u64 -L3: loc2: u64 B0: 0: ImmBorrowLoc[0](Arg0: vector) 1: StLoc[1](loc0: &vector) @@ -271,7 +284,6 @@ B6: } entry public guess_flips_directly(Arg0: vector) /* def_idx: 1 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) @@ -311,7 +323,6 @@ B0: entry public guess_without_break_with_inline(Arg0: vector) /* def_idx: 3 */ { L1: loc0: &vector L2: loc1: u64 -L3: loc2: u64 B0: 0: ImmBorrowLoc[0](Arg0: vector) 1: StLoc[1](loc0: &vector) @@ -349,7 +360,6 @@ B5: } loops_with_break_no_inline(Arg0: &vector) /* def_idx: 4 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.off.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.off.exp index af6586a3f5112..362c68f2794cb 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.off.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.off.exp @@ -9,7 +9,6 @@ use 0000000000000000000000000000000000000000000000000000000000000001::string; test(Arg0: vector): Ty0 /* def_idx: 0 */ { L1: loc0: String -L2: loc1: String B0: 0: Call foo(): String 1: StLoc[1](loc0: String) @@ -35,21 +34,19 @@ B3: 18: Call bar(bool): Ty0 19: Ret B4: - 20: LdConst[2](Vector(U8): [3, 117, 54, 52]) - 21: Call string::utf8(vector): String - 22: StLoc[2](loc1: String) - 23: MoveLoc[1](loc0: String) - 24: MoveLoc[2](loc1: String) - 25: Eq - 26: BrFalse(31) + 20: MoveLoc[1](loc0: String) + 21: LdConst[2](Vector(U8): [3, 117, 54, 52]) + 22: Call string::utf8(vector): String + 23: Eq + 24: BrFalse(29) B5: - 27: MoveLoc[0](Arg0: vector) - 28: Call baz(vector): bool - 29: Call bar(bool): Ty0 - 30: Ret + 25: MoveLoc[0](Arg0: vector) + 26: Call baz(vector): bool + 27: Call bar(bool): Ty0 + 28: Ret B6: - 31: LdU64(0) - 32: Abort + 29: LdU64(0) + 30: Abort } bar(Arg0: bool): Ty0 /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp index 23438ea680516..e4ecc4bc0e0da 100644 --- a/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp +++ b/third_party/move/move-compiler-v2/tests/control-flow-simplification/jump-label.on.exp @@ -93,7 +93,6 @@ use 0000000000000000000000000000000000000000000000000000000000000001::string; test(Arg0: vector): Ty0 /* def_idx: 0 */ { L1: loc0: String -L2: loc1: String B0: 0: Call foo(): String 1: StLoc[1](loc0: String) @@ -119,21 +118,19 @@ B3: 18: Call bar(bool): Ty0 19: Ret B4: - 20: LdConst[2](Vector(U8): [3, 117, 54, 52]) - 21: Call string::utf8(vector): String - 22: StLoc[2](loc1: String) - 23: MoveLoc[1](loc0: String) - 24: MoveLoc[2](loc1: String) - 25: Eq - 26: BrFalse(31) + 20: MoveLoc[1](loc0: String) + 21: LdConst[2](Vector(U8): [3, 117, 54, 52]) + 22: Call string::utf8(vector): String + 23: Eq + 24: BrFalse(29) B5: - 27: MoveLoc[0](Arg0: vector) - 28: Call baz(vector): bool - 29: Call bar(bool): Ty0 - 30: Ret + 25: MoveLoc[0](Arg0: vector) + 26: Call baz(vector): bool + 27: Call bar(bool): Ty0 + 28: Ret B6: - 31: LdU64(0) - 32: Abort + 29: LdU64(0) + 30: Abort } bar(Arg0: bool): Ty0 /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/args_with_side_effects.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/args_with_side_effects.exp index e607e6f3dc221..6c179173a5300 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/args_with_side_effects.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/args_with_side_effects.exp @@ -3,8 +3,10 @@ [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 - 0: $t2 := +($t0, $t1) - 1: return $t2 + var $t3: u64 + 0: $t3 := infer($t0) + 1: $t2 := +($t3, $t1) + 2: return $t2 } @@ -15,13 +17,15 @@ public fun m::test($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t2 := infer($t0) - 1: $t5 := 1 - 2: $t4 := +($t0, $t5) - 3: $t0 := infer($t4) - 4: $t3 := infer($t0) - 5: $t1 := m::add($t2, $t3) - 6: return $t1 + 1: $t5 := infer($t0) + 2: $t6 := 1 + 3: $t4 := +($t5, $t6) + 4: $t0 := infer($t4) + 5: $t3 := infer($t0) + 6: $t1 := m::add($t2, $t3) + 7: return $t1 } ============ after DeadStoreElimination: ================ @@ -29,8 +33,10 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 - 0: $t2 := +($t0, $t1) - 1: return $t2 + var $t3: u64 + 0: $t3 := move($t0) + 1: $t2 := +($t3, $t1) + 2: return $t2 } @@ -41,11 +47,13 @@ public fun m::test($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t2 := copy($t0) - 1: $t5 := 1 - 2: $t4 := +($t0, $t5) - 3: $t0 := move($t4) - 4: $t3 := move($t0) - 5: $t1 := m::add($t2, $t3) - 6: return $t1 + 1: $t5 := move($t0) + 2: $t6 := 1 + 3: $t4 := +($t5, $t6) + 4: $t0 := move($t4) + 5: $t3 := move($t0) + 6: $t1 := m::add($t2, $t3) + 7: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/branch_1.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/branch_1.exp index 3a436a82d1143..5599015c76fe7 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/branch_1.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/branch_1.exp @@ -6,6 +6,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t3 := infer($t1) 1: if ($t0) goto 2 else goto 6 2: label L0 @@ -14,9 +15,10 @@ fun m::foo($t0: bool, $t1: u64): u64 { 5: goto 7 6: label L1 7: label L2 - 8: $t5 := 1 - 9: $t2 := +($t3, $t5) - 10: return $t2 + 8: $t5 := infer($t3) + 9: $t6 := 1 + 10: $t2 := +($t5, $t6) + 11: return $t2 } ============ after DeadStoreElimination: ================ @@ -27,6 +29,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t3 := move($t1) 1: if ($t0) goto 4 else goto 2 2: label L3 @@ -35,7 +38,8 @@ fun m::foo($t0: bool, $t1: u64): u64 { 5: $t4 := 0 6: $t3 := move($t4) 7: label L2 - 8: $t5 := 1 - 9: $t2 := +($t3, $t5) - 10: return $t2 + 8: $t5 := move($t3) + 9: $t6 := 1 + 10: $t2 := +($t5, $t6) + 11: return $t2 } diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/bug_12068.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/bug_12068.exp index fe2ed828da30d..dd88a23a312d2 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/bug_12068.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/bug_12068.exp @@ -6,34 +6,38 @@ fun m::main() { var $t1: bool var $t2: u64 var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t0 := 0 1: label L0 2: $t1 := true - 3: if ($t1) goto 4 else goto 10 + 3: if ($t1) goto 4 else goto 11 4: label L2 - 5: $t3 := 1 - 6: $t2 := +($t0, $t3) - 7: $t0 := infer($t2) - 8: goto 14 - 9: goto 12 - 10: label L3 - 11: goto 14 - 12: label L4 - 13: goto 1 - 14: label L1 - 15: $t5 := 1 - 16: $t4 := ==($t0, $t5) - 17: if ($t4) goto 18 else goto 20 - 18: label L5 - 19: goto 23 - 20: label L6 - 21: $t6 := 42 - 22: abort($t6) - 23: label L7 - 24: return () + 5: $t3 := infer($t0) + 6: $t4 := 1 + 7: $t2 := +($t3, $t4) + 8: $t0 := infer($t2) + 9: goto 15 + 10: goto 13 + 11: label L3 + 12: goto 15 + 13: label L4 + 14: goto 1 + 15: label L1 + 16: $t6 := infer($t0) + 17: $t7 := 1 + 18: $t5 := ==($t6, $t7) + 19: if ($t5) goto 20 else goto 22 + 20: label L5 + 21: goto 25 + 22: label L6 + 23: $t8 := 42 + 24: abort($t8) + 25: label L7 + 26: return () } ============ after DeadStoreElimination: ================ @@ -44,25 +48,29 @@ fun m::main() { var $t1: bool var $t2: u64 var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t0 := 0 1: $t1 := true 2: if ($t1) goto 5 else goto 3 3: label L7 - 4: goto 9 + 4: goto 10 5: label L2 - 6: $t3 := 1 - 7: $t2 := +($t0, $t3) - 8: $t0 := move($t2) - 9: label L1 - 10: $t5 := 1 - 11: $t4 := ==($t0, $t5) - 12: if ($t4) goto 13 else goto 15 - 13: label L5 - 14: return () - 15: label L6 - 16: $t6 := 42 - 17: abort($t6) + 6: $t3 := move($t0) + 7: $t4 := 1 + 8: $t2 := +($t3, $t4) + 9: $t0 := move($t2) + 10: label L1 + 11: $t6 := move($t0) + 12: $t7 := 1 + 13: $t5 := ==($t6, $t7) + 14: if ($t5) goto 15 else goto 17 + 15: label L5 + 16: return () + 17: label L6 + 18: $t8 := 42 + 19: abort($t8) } diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/loop_1.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/loop_1.exp index 8a148663185e4..1466154c7fd52 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/loop_1.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/loop_1.exp @@ -9,25 +9,29 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := infer($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := infer($t6) - 11: goto 14 - 12: label L3 + 3: $t5 := infer($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := infer($t0) + 9: $t8 := infer($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := infer($t7) 13: goto 16 - 14: label L4 - 15: goto 2 - 16: label L1 - 17: $t1 := infer($t2) - 18: return $t1 + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 2 + 18: label L1 + 19: $t1 := infer($t2) + 20: return $t1 } ============ after DeadStoreElimination: ================ @@ -41,19 +45,23 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := move($t6) - 11: goto 2 - 12: label L3 - 13: $t1 := move($t2) - 14: return $t1 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t8 := move($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := move($t7) + 13: goto 2 + 14: label L3 + 15: $t1 := move($t2) + 16: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/loop_2.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/loop_2.exp index 40ae16d3a9341..a1ba6207122a7 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/loop_2.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/loop_2.exp @@ -9,25 +9,29 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := infer($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := infer($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := infer($t6) - 11: goto 14 - 12: label L3 + 3: $t5 := infer($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := infer($t0) + 9: $t8 := infer($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := infer($t7) 13: goto 16 - 14: label L4 - 15: goto 2 - 16: label L1 - 17: $t1 := infer($t2) - 18: return $t1 + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 2 + 18: label L1 + 19: $t1 := infer($t2) + 20: return $t1 } ============ after DeadStoreElimination: ================ @@ -41,19 +45,23 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := copy($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := move($t6) - 11: goto 2 - 12: label L3 - 13: $t1 := move($t2) - 14: return $t1 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t8 := move($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := move($t7) + 13: goto 2 + 14: label L3 + 15: $t1 := move($t2) + 16: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/seq_kills_1.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/seq_kills_1.exp index 5cafa1aff0973..2daf35777c985 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/seq_kills_1.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/seq_kills_1.exp @@ -8,14 +8,18 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t3 := infer($t5) - 6: $t1 := ==($t2, $t4) - 7: return $t1 + 3: $t6 := infer($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t3 := infer($t5) + 7: $t8 := infer($t2) + 8: $t1 := ==($t8, $t4) + 9: return $t1 } @@ -36,11 +40,15 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := copy($t0) 1: $t3 := copy($t2) 2: $t4 := move($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t1 := ==($t2, $t4) - 6: return $t1 + 3: $t6 := move($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t8 := move($t2) + 7: $t1 := ==($t8, $t4) + 8: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/seq_kills_2.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/seq_kills_2.exp index c4103b2556510..d7aac2eed7601 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/seq_kills_2.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/seq_kills_2.exp @@ -8,14 +8,18 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t2 := infer($t5) - 6: $t1 := ==($t3, $t4) - 7: return $t1 + 3: $t6 := infer($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t2 := infer($t5) + 7: $t8 := infer($t3) + 8: $t1 := ==($t8, $t4) + 9: return $t1 } @@ -36,11 +40,15 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := copy($t0) 1: $t3 := move($t2) 2: $t4 := copy($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t1 := ==($t3, $t4) - 6: return $t1 + 3: $t6 := move($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t8 := move($t3) + 7: $t1 := ==($t8, $t4) + 8: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/copy-propagation/straight_line_kills.exp b/third_party/move/move-compiler-v2/tests/copy-propagation/straight_line_kills.exp index 5b0207d4fbdac..59402c27689e4 100644 --- a/third_party/move/move-compiler-v2/tests/copy-propagation/straight_line_kills.exp +++ b/third_party/move/move-compiler-v2/tests/copy-propagation/straight_line_kills.exp @@ -7,13 +7,17 @@ fun m::copy_kill($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) - 2: $t5 := 1 - 3: $t4 := +($t0, $t5) - 4: $t0 := infer($t4) - 5: $t1 := +($t3, $t2) - 6: return $t1 + 2: $t5 := infer($t0) + 3: $t6 := 1 + 4: $t4 := +($t5, $t6) + 5: $t0 := infer($t4) + 6: $t7 := infer($t3) + 7: $t1 := +($t7, $t2) + 8: return $t1 } @@ -33,10 +37,14 @@ fun m::copy_kill($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t5 := 1 - 3: $t4 := +($t0, $t5) - 4: $t1 := +($t3, $t2) - 5: return $t1 + 2: $t5 := move($t0) + 3: $t6 := 1 + 4: $t4 := +($t5, $t6) + 5: $t7 := move($t3) + 6: $t1 := +($t7, $t2) + 7: return $t1 } diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/eager_load_03.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/eager_load_03.exp index bc43cd9fc3906..fc9d04860fc2b 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/eager_load_03.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/eager_load_03.exp @@ -16,11 +16,13 @@ fun m::baz($t0: u64, $t1: u64) { public fun m::foo($t0: u64) { var $t1: u64 var $t2: &mut u64 + var $t3: u64 0: $t1 := m::one() 1: $t2 := borrow_local($t0) 2: m::bar($t2) - 3: m::baz($t0, $t1) - 4: return () + 3: $t3 := infer($t0) + 4: m::baz($t3, $t1) + 5: return () } @@ -53,6 +55,7 @@ fun m::baz($t0: u64, $t1: u64) { public fun m::foo($t0: u64) { var $t1: u64 var $t2: &mut u64 + var $t3: u64 # live vars: $t0 0: $t1 := m::one() # live vars: $t0, $t1 @@ -60,9 +63,11 @@ public fun m::foo($t0: u64) { # live vars: $t0, $t1, $t2 2: m::bar($t2) # live vars: $t0, $t1 - 3: m::baz($t0, $t1) + 3: $t3 := move($t0) + # live vars: $t1, $t3 + 4: m::baz($t3, $t1) # live vars: - 4: return () + 5: return () } @@ -95,9 +100,9 @@ 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) + 1: StLoc[1](loc0: u64) + 2: MutBorrowLoc[0](Arg0: u64) + 3: Call bar(&mut u64) 4: MoveLoc[0](Arg0: u64) 5: MoveLoc[1](loc0: u64) 6: Call baz(u64, u64) diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_01.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_01.exp index 68d16c3fc8412..d0f01cb6ab0e2 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_01.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_01.exp @@ -72,25 +72,27 @@ public fun m::test($t0: u64) { # live vars: $t0 0: $t1 := m::two() # live vars: $t0, $t1 - 1: $t5 := m::one() + 1: $t0 := move($t0) + # live vars: $t0, $t1 + 2: $t5 := m::one() # live vars: $t0, $t1, $t5 - 2: $t0 := -($t0, $t5) + 3: $t0 := -($t0, $t5) # live vars: $t0, $t1 - 3: $t2 := >($t0, $t1) + 4: $t2 := >($t0, $t1) # live vars: $t2 - 4: if ($t2) goto 7 else goto 5 + 5: if ($t2) goto 8 else goto 6 # live vars: - 5: label L3 + 6: label L3 # live vars: - 6: goto 9 + 7: goto 10 # live vars: - 7: label L0 + 8: label L0 # live vars: - 8: m::foo() + 9: m::foo() # live vars: - 9: label L2 + 10: label L2 # live vars: - 10: return () + 11: return () } @@ -120,24 +122,21 @@ B0: } 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: BrTrue(11) + 2: MoveLoc[0](Arg0: u64) + 3: Call one(): u64 + 4: Sub + 5: MoveLoc[1](loc0: u64) + 6: Gt + 7: BrTrue(9) B1: - 10: Branch(12) + 8: Branch(10) B2: - 11: Call foo() + 9: Call foo() B3: - 12: Ret + 10: Ret } two(): u64 /* def_idx: 3 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_02.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_02.exp index e2b68c2225ac0..c0e3b1ea99dca 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_02.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_02.exp @@ -4,11 +4,17 @@ public fun m::make($t0: u64, $t1: u64, $t2: u64, $t3: &0xc0ffee::m::S, $t4: u64): 0xc0ffee::m::Wrap { var $t5: 0xc0ffee::m::Wrap var $t6: u64 - var $t7: &u64 - 0: $t7 := borrow_field<0xc0ffee::m::S>.x($t3) - 1: $t6 := read_ref($t7) - 2: $t5 := pack 0xc0ffee::m::Wrap($t0, $t1, $t2, $t6, $t4) - 3: return $t5 + var $t7: u64 + var $t8: u64 + var $t9: u64 + var $t10: &u64 + 0: $t6 := infer($t0) + 1: $t7 := infer($t1) + 2: $t8 := infer($t2) + 3: $t10 := borrow_field<0xc0ffee::m::S>.x($t3) + 4: $t9 := read_ref($t10) + 5: $t5 := pack 0xc0ffee::m::Wrap($t6, $t7, $t8, $t9, $t4) + 6: return $t5 } ============ after LiveVarAnalysisProcessor: ================ @@ -16,16 +22,25 @@ public fun m::make($t0: u64, $t1: u64, $t2: u64, $t3: &0xc0ffee::m::S, $t4: u64) [variant baseline] public fun m::make($t0: u64, $t1: u64, $t2: u64, $t3: &0xc0ffee::m::S, $t4: u64): 0xc0ffee::m::Wrap { var $t5: 0xc0ffee::m::Wrap - var $t6: u64 - var $t7: &u64 + var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 + var $t10: &u64 + # live vars: $t0, $t1, $t2, $t3, $t4 + 0: $t0 := move($t0) + # live vars: $t0, $t1, $t2, $t3, $t4 + 1: $t1 := move($t1) + # live vars: $t0, $t1, $t2, $t3, $t4 + 2: $t2 := move($t2) # live vars: $t0, $t1, $t2, $t3, $t4 - 0: $t7 := borrow_field<0xc0ffee::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 0xc0ffee::m::Wrap($t0, $t1, $t2, $t6, $t4) + 3: $t10 := borrow_field<0xc0ffee::m::S>.x($t3) + # live vars: $t0, $t1, $t2, $t4, $t10 + 4: $t9 := read_ref($t10) + # live vars: $t0, $t1, $t2, $t4, $t9 + 5: $t5 := pack 0xc0ffee::m::Wrap($t0, $t1, $t2, $t9, $t4) # live vars: $t5 - 3: return $t5 + 6: return $t5 } @@ -44,19 +59,16 @@ struct Wrap { } 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 + 0: MoveLoc[0](Arg0: u64) + 1: MoveLoc[1](Arg1: u64) + 2: MoveLoc[2](Arg2: u64) + 3: MoveLoc[3](Arg3: &S) + 4: ImmBorrowField[0](S.x: u64) + 5: ReadRef + 6: MoveLoc[4](Arg4: u64) + 7: Pack[1](Wrap) + 8: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_03.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_03.exp index a203fca7796c0..9a2f3f7a3e223 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_03.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_03.exp @@ -5,16 +5,24 @@ public fun m::make($t0: u64, $t1: u64, $t2: u64, $t3: address, $t4: u64): 0xc0ff var $t5: 0xc0ffee::m::Wrap var $t6: &0xc0ffee::m::S var $t7: u64 - var $t8: &u64 + var $t8: u64 var $t9: u64 - var $t10: &u64 + var $t10: u64 + var $t11: &u64 + var $t12: u64 + var $t13: u64 + var $t14: &u64 0: $t6 := borrow_global<0xc0ffee::m::S>($t3) - 1: $t8 := borrow_field<0xc0ffee::m::S>.x($t6) - 2: $t7 := read_ref($t8) - 3: $t10 := borrow_field<0xc0ffee::m::S>.y($t6) - 4: $t9 := read_ref($t10) - 5: $t5 := pack 0xc0ffee::m::Wrap($t0, $t1, $t2, $t7, $t4, $t9) - 6: return $t5 + 1: $t7 := infer($t0) + 2: $t8 := infer($t1) + 3: $t9 := infer($t2) + 4: $t11 := borrow_field<0xc0ffee::m::S>.x($t6) + 5: $t10 := read_ref($t11) + 6: $t12 := infer($t4) + 7: $t14 := borrow_field<0xc0ffee::m::S>.y($t6) + 8: $t13 := read_ref($t14) + 9: $t5 := pack 0xc0ffee::m::Wrap($t7, $t8, $t9, $t10, $t12, $t13) + 10: return $t5 } ============ after LiveVarAnalysisProcessor: ================ @@ -23,24 +31,36 @@ public fun m::make($t0: u64, $t1: u64, $t2: u64, $t3: address, $t4: u64): 0xc0ff public fun m::make($t0: u64, $t1: u64, $t2: u64, $t3: address, $t4: u64): 0xc0ffee::m::Wrap { var $t5: 0xc0ffee::m::Wrap var $t6: &0xc0ffee::m::S - var $t7: u64 - var $t8: &u64 - var $t9: u64 - var $t10: &u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] + var $t10: u64 + var $t11: &u64 + var $t12: u64 [unused] + var $t13: u64 + var $t14: &u64 [unused] # live vars: $t0, $t1, $t2, $t3, $t4 0: $t6 := borrow_global<0xc0ffee::m::S>($t3) # live vars: $t0, $t1, $t2, $t4, $t6 - 1: $t8 := borrow_field<0xc0ffee::m::S>.x($t6) - # live vars: $t0, $t1, $t2, $t4, $t6, $t8 - 2: $t7 := read_ref($t8) - # live vars: $t0, $t1, $t2, $t4, $t6, $t7 - 3: $t8 := borrow_field<0xc0ffee::m::S>.y($t6) - # live vars: $t0, $t1, $t2, $t4, $t7, $t8 - 4: $t9 := read_ref($t8) - # live vars: $t0, $t1, $t2, $t4, $t7, $t9 - 5: $t5 := pack 0xc0ffee::m::Wrap($t0, $t1, $t2, $t7, $t4, $t9) + 1: $t0 := move($t0) + # live vars: $t0, $t1, $t2, $t4, $t6 + 2: $t1 := move($t1) + # live vars: $t0, $t1, $t2, $t4, $t6 + 3: $t2 := move($t2) + # live vars: $t0, $t1, $t2, $t4, $t6 + 4: $t11 := borrow_field<0xc0ffee::m::S>.x($t6) + # live vars: $t0, $t1, $t2, $t4, $t6, $t11 + 5: $t10 := read_ref($t11) + # live vars: $t0, $t1, $t2, $t4, $t6, $t10 + 6: $t4 := move($t4) + # live vars: $t0, $t1, $t2, $t4, $t6, $t10 + 7: $t11 := borrow_field<0xc0ffee::m::S>.y($t6) + # live vars: $t0, $t1, $t2, $t4, $t10, $t11 + 8: $t13 := read_ref($t11) + # live vars: $t0, $t1, $t2, $t4, $t10, $t13 + 9: $t5 := pack 0xc0ffee::m::Wrap($t0, $t1, $t2, $t10, $t4, $t13) # live vars: $t5 - 6: return $t5 + 10: return $t5 } @@ -62,28 +82,22 @@ struct Wrap { public make(Arg0: u64, Arg1: u64, Arg2: u64, Arg3: address, Arg4: u64): Wrap /* def_idx: 0 */ { L5: loc0: &S -L6: loc1: u64 -L7: loc2: u64 B0: 0: MoveLoc[3](Arg3: address) 1: ImmBorrowGlobal[0](S) 2: StLoc[5](loc0: &S) - 3: CopyLoc[5](loc0: &S) - 4: ImmBorrowField[0](S.x: u64) - 5: ReadRef - 6: MoveLoc[5](loc0: &S) - 7: ImmBorrowField[1](S.y: u64) + 3: MoveLoc[0](Arg0: u64) + 4: MoveLoc[1](Arg1: u64) + 5: MoveLoc[2](Arg2: u64) + 6: CopyLoc[5](loc0: &S) + 7: ImmBorrowField[0](S.x: u64) 8: ReadRef - 9: StLoc[6](loc1: u64) - 10: StLoc[7](loc2: u64) - 11: MoveLoc[0](Arg0: u64) - 12: MoveLoc[1](Arg1: u64) - 13: MoveLoc[2](Arg2: u64) - 14: MoveLoc[7](loc2: u64) - 15: MoveLoc[4](Arg4: u64) - 16: MoveLoc[6](loc1: u64) - 17: Pack[1](Wrap) - 18: Ret + 9: MoveLoc[4](Arg4: u64) + 10: MoveLoc[5](loc0: &S) + 11: ImmBorrowField[1](S.y: u64) + 12: ReadRef + 13: Pack[1](Wrap) + 14: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_04.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_04.exp index 9aa46823a704c..d635928819623 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_04.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_04.exp @@ -116,29 +116,22 @@ B0: 4: Ret } public test(Arg0: signer, Arg1: address) /* def_idx: 1 */ { -L2: loc0: &signer -L3: loc1: &mut Wrap -L4: loc2: Wrap -L5: loc3: &mut u64 +L2: loc0: &mut Wrap B0: 0: MoveLoc[1](Arg1: address) 1: MutBorrowGlobal[0](Wrap) - 2: ImmBorrowLoc[0](Arg0: signer) - 3: StLoc[2](loc0: &signer) - 4: MutBorrowField[0](Wrap.a: u64) - 5: LdU64(0) + 2: StLoc[2](loc0: &mut Wrap) + 3: ImmBorrowLoc[0](Arg0: signer) + 4: MoveLoc[2](loc0: &mut Wrap) + 5: MutBorrowField[0](Wrap.a: u64) 6: LdU64(0) 7: LdU64(0) - 8: Call zero(u64): u64 - 9: LdU64(0) - 10: Pack[0](Wrap) - 11: StLoc[4](loc2: Wrap) - 12: StLoc[5](loc3: &mut u64) - 13: MoveLoc[2](loc0: &signer) - 14: MoveLoc[5](loc3: &mut u64) - 15: MoveLoc[4](loc2: Wrap) - 16: Call bar(&signer, &mut u64, Wrap) - 17: Ret + 8: LdU64(0) + 9: Call zero(u64): u64 + 10: LdU64(0) + 11: Pack[0](Wrap) + 12: Call bar(&signer, &mut u64, Wrap) + 13: Ret } zero(Arg0: u64): u64 /* def_idx: 2 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_05.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_05.exp index df80a414a62d7..c2ca65e0b72da 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_05.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_05.exp @@ -8,20 +8,22 @@ fun m::foo($t0: &signer, $t1: u64, $t2: u64) { [variant baseline] public fun m::test($t0: &signer, $t1: 0xc0ffee::m::S) { - var $t2: u64 - var $t3: &0xc0ffee::m::S - var $t4: &u64 - var $t5: u64 - var $t6: &0xc0ffee::m::S - var $t7: &u64 - 0: $t3 := borrow_local($t1) - 1: $t4 := borrow_field<0xc0ffee::m::S>.a($t3) - 2: $t2 := read_ref($t4) - 3: $t6 := borrow_local($t1) - 4: $t7 := borrow_field<0xc0ffee::m::S>.b($t6) - 5: $t5 := read_ref($t7) - 6: m::foo($t0, $t2, $t5) - 7: return () + var $t2: &signer + var $t3: u64 + var $t4: &0xc0ffee::m::S + var $t5: &u64 + var $t6: u64 + var $t7: &0xc0ffee::m::S + var $t8: &u64 + 0: $t2 := infer($t0) + 1: $t4 := borrow_local($t1) + 2: $t5 := borrow_field<0xc0ffee::m::S>.a($t4) + 3: $t3 := read_ref($t5) + 4: $t7 := borrow_local($t1) + 5: $t8 := borrow_field<0xc0ffee::m::S>.b($t7) + 6: $t6 := read_ref($t8) + 7: m::foo($t2, $t3, $t6) + 8: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -37,28 +39,31 @@ fun m::foo($t0: &signer, $t1: u64, $t2: u64) { [variant baseline] public fun m::test($t0: &signer, $t1: 0xc0ffee::m::S) { - var $t2: u64 - var $t3: &0xc0ffee::m::S - var $t4: &u64 - var $t5: u64 - var $t6: &0xc0ffee::m::S [unused] - var $t7: &u64 [unused] + var $t2: &signer [unused] + var $t3: u64 + var $t4: &0xc0ffee::m::S + var $t5: &u64 + var $t6: u64 + var $t7: &0xc0ffee::m::S [unused] + var $t8: &u64 [unused] # live vars: $t0, $t1 - 0: $t3 := borrow_local($t1) - # live vars: $t0, $t1, $t3 - 1: $t4 := borrow_field<0xc0ffee::m::S>.a($t3) + 0: $t0 := move($t0) + # live vars: $t0, $t1 + 1: $t4 := borrow_local($t1) # live vars: $t0, $t1, $t4 - 2: $t2 := read_ref($t4) - # live vars: $t0, $t1, $t2 - 3: $t3 := borrow_local($t1) - # live vars: $t0, $t2, $t3 - 4: $t4 := borrow_field<0xc0ffee::m::S>.b($t3) - # live vars: $t0, $t2, $t4 - 5: $t5 := read_ref($t4) - # live vars: $t0, $t2, $t5 - 6: m::foo($t0, $t2, $t5) + 2: $t5 := borrow_field<0xc0ffee::m::S>.a($t4) + # live vars: $t0, $t1, $t5 + 3: $t3 := read_ref($t5) + # live vars: $t0, $t1, $t3 + 4: $t4 := borrow_local($t1) + # live vars: $t0, $t3, $t4 + 5: $t5 := borrow_field<0xc0ffee::m::S>.b($t4) + # live vars: $t0, $t3, $t5 + 6: $t6 := read_ref($t5) + # live vars: $t0, $t3, $t6 + 7: m::foo($t0, $t3, $t6) # live vars: - 7: return () + 8: return () } @@ -77,22 +82,16 @@ B0: 2: Ret } public test(Arg0: &signer, Arg1: S) /* def_idx: 1 */ { -L2: loc0: u64 -L3: loc1: u64 B0: - 0: ImmBorrowLoc[1](Arg1: S) - 1: ImmBorrowField[0](S.a: u64) - 2: ReadRef - 3: ImmBorrowLoc[1](Arg1: S) - 4: ImmBorrowField[1](S.b: u64) - 5: ReadRef - 6: StLoc[2](loc0: u64) - 7: StLoc[3](loc1: u64) - 8: MoveLoc[0](Arg0: &signer) - 9: MoveLoc[3](loc1: u64) - 10: MoveLoc[2](loc0: u64) - 11: Call foo(&signer, u64, u64) - 12: Ret + 0: MoveLoc[0](Arg0: &signer) + 1: ImmBorrowLoc[1](Arg1: S) + 2: ImmBorrowField[0](S.a: u64) + 3: ReadRef + 4: ImmBorrowLoc[1](Arg1: S) + 5: ImmBorrowField[1](S.b: u64) + 6: ReadRef + 7: Call foo(&signer, u64, u64) + 8: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_06.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_06.exp index 937040361d411..0f65187b98c3e 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_06.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_06.exp @@ -33,32 +33,36 @@ public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: 0xc0ffee::m::S) { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: &mut 0xc0ffee::m::S - var $t6: u64 - var $t7: &mut 0xc0ffee::m::S - var $t8: u64 + var $t5: u64 + var $t6: &mut 0xc0ffee::m::S + var $t7: u64 + var $t8: &mut 0xc0ffee::m::S var $t9: u64 + var $t10: u64 + var $t11: u64 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 14 - 5: label L2 - 6: $t5 := infer($t0) - 7: $t7 := borrow_local($t1) - 8: $t6 := m::bar($t7, $t2) - 9: m::foo($t5, $t6) - 10: $t9 := 1 - 11: $t8 := +($t2, $t9) - 12: $t2 := infer($t8) - 13: goto 16 - 14: label L3 + 2: $t4 := infer($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 16 + 6: label L2 + 7: $t6 := infer($t0) + 8: $t8 := borrow_local($t1) + 9: $t7 := m::bar($t8, $t2) + 10: m::foo($t6, $t7) + 11: $t10 := infer($t2) + 12: $t11 := 1 + 13: $t9 := +($t10, $t11) + 14: $t2 := infer($t9) 15: goto 18 - 16: label L4 - 17: goto 1 - 18: label L1 - 19: m::destroy($t1) - 20: return () + 16: label L3 + 17: goto 20 + 18: label L4 + 19: goto 1 + 20: label L1 + 21: m::destroy($t1) + 22: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -72,7 +76,9 @@ fun m::bar($t0: &mut 0xc0ffee::m::S, $t1: u64): u64 { # live vars: $t1, $t3 1: write_ref($t3, $t1) # live vars: $t1 - 2: return $t1 + 2: $t1 := move($t1) + # live vars: $t1 + 3: return $t1 } @@ -103,47 +109,53 @@ public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: 0xc0ffee::m::S) { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: &mut 0xc0ffee::m::S - var $t6: u64 [unused] - var $t7: &mut 0xc0ffee::m::S - var $t8: u64 [unused] + var $t5: u64 + var $t6: &mut 0xc0ffee::m::S + var $t7: u64 [unused] + var $t8: &mut 0xc0ffee::m::S var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] # live vars: $t0, $t1 0: $t2 := 0 # live vars: $t0, $t1, $t2 1: label L0 # live vars: $t0, $t1, $t2 - 2: $t4 := 42 + 2: $t4 := copy($t2) # live vars: $t0, $t1, $t2, $t4 - 3: $t3 := <($t2, $t4) + 3: $t5 := 42 + # live vars: $t0, $t1, $t2, $t4, $t5 + 4: $t3 := <($t4, $t5) # live vars: $t0, $t1, $t2, $t3 - 4: if ($t3) goto 5 else goto 14 + 5: if ($t3) goto 6 else goto 16 # live vars: $t0, $t1, $t2 - 5: label L2 + 6: label L2 # live vars: $t0, $t1, $t2 - 6: $t5 := copy($t0) - # live vars: $t0, $t1, $t2, $t5 - 7: $t7 := borrow_local($t1) - # live vars: $t0, $t1, $t2, $t5, $t7 - 8: $t4 := m::bar($t7, $t2) - # live vars: $t0, $t1, $t2, $t4, $t5 - 9: m::foo($t5, $t4) + 7: $t6 := copy($t0) + # live vars: $t0, $t1, $t2, $t6 + 8: $t8 := borrow_local($t1) + # live vars: $t0, $t1, $t2, $t6, $t8 + 9: $t4 := m::bar($t8, $t2) + # live vars: $t0, $t1, $t2, $t4, $t6 + 10: m::foo($t6, $t4) # live vars: $t0, $t1, $t2 - 10: $t4 := 1 - # live vars: $t0, $t1, $t2, $t4 - 11: $t4 := +($t2, $t4) + 11: $t4 := move($t2) + # live vars: $t0, $t1, $t4 + 12: $t5 := 1 + # live vars: $t0, $t1, $t4, $t5 + 13: $t4 := +($t4, $t5) # live vars: $t0, $t1, $t4 - 12: $t2 := move($t4) + 14: $t2 := move($t4) # live vars: $t0, $t1, $t2 - 13: goto 1 + 15: goto 1 # live vars: $t0, $t1, $t2 - 14: label L3 + 16: label L3 # live vars: $t0, $t1 - 15: drop($t0) + 17: drop($t0) # live vars: $t1 - 16: m::destroy($t1) + 18: m::destroy($t1) # live vars: - 17: return () + 19: return () } @@ -186,7 +198,6 @@ B0: } public test(Arg0: &mut S, Arg1: S) /* def_idx: 3 */ { L2: loc0: u64 -L3: loc1: u64 B0: 0: LdU64(0) 1: StLoc[2](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_07.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_07.exp index 2b2cd73ef54e5..e2018fce1b597 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_07.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_07.exp @@ -22,20 +22,24 @@ public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: u64) { var $t3: &mut u64 var $t4: u64 var $t5: u64 - var $t6: &u64 - var $t7: u64 + var $t6: u64 + var $t7: &u64 var $t8: u64 - var $t9: &u64 + var $t9: u64 + var $t10: u64 + var $t11: &u64 0: $t3 := borrow_field<0xc0ffee::m::S>.x($t0) - 1: $t6 := borrow_field<0xc0ffee::m::S>.y($t0) - 2: $t5 := read_ref($t6) - 3: $t4 := /($t1, $t5) - 4: $t2 := m::foo($t3, $t4) - 5: $t9 := borrow_field<0xc0ffee::m::S>.y($t0) - 6: $t8 := read_ref($t9) - 7: $t7 := /($t1, $t8) - 8: m::bar($t2, $t7) - 9: return () + 1: $t5 := infer($t1) + 2: $t7 := borrow_field<0xc0ffee::m::S>.y($t0) + 3: $t6 := read_ref($t7) + 4: $t4 := /($t5, $t6) + 5: $t2 := m::foo($t3, $t4) + 6: $t9 := infer($t1) + 7: $t11 := borrow_field<0xc0ffee::m::S>.y($t0) + 8: $t10 := read_ref($t11) + 9: $t8 := /($t9, $t10) + 10: m::bar($t2, $t8) + 11: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -55,7 +59,9 @@ fun m::foo($t0: &mut u64, $t1: u64): &mut u64 { # live vars: $t0, $t1 0: write_ref($t0, $t1) # live vars: $t0 - 1: return $t0 + 1: $t0 := move($t0) + # live vars: $t0 + 2: return $t0 } @@ -65,30 +71,36 @@ public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: u64) { var $t3: &mut u64 var $t4: u64 [unused] var $t5: u64 - var $t6: &u64 - var $t7: u64 [unused] + var $t6: u64 + var $t7: &u64 var $t8: u64 [unused] - var $t9: &u64 [unused] + var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: &u64 [unused] # live vars: $t0, $t1 0: $t3 := borrow_field<0xc0ffee::m::S>.x($t0) # live vars: $t0, $t1, $t3 - 1: $t6 := borrow_field<0xc0ffee::m::S>.y($t0) - # live vars: $t0, $t1, $t3, $t6 - 2: $t5 := read_ref($t6) + 1: $t5 := copy($t1) # live vars: $t0, $t1, $t3, $t5 - 3: $t5 := /($t1, $t5) + 2: $t7 := borrow_field<0xc0ffee::m::S>.y($t0) + # live vars: $t0, $t1, $t3, $t5, $t7 + 3: $t6 := read_ref($t7) + # live vars: $t0, $t1, $t3, $t5, $t6 + 4: $t5 := /($t5, $t6) # live vars: $t0, $t1, $t3, $t5 - 4: $t3 := m::foo($t3, $t5) + 5: $t3 := m::foo($t3, $t5) + # live vars: $t0, $t1, $t3 + 6: $t1 := move($t1) # live vars: $t0, $t1, $t3 - 5: $t6 := borrow_field<0xc0ffee::m::S>.y($t0) - # live vars: $t1, $t3, $t6 - 6: $t5 := read_ref($t6) + 7: $t7 := borrow_field<0xc0ffee::m::S>.y($t0) + # live vars: $t1, $t3, $t7 + 8: $t5 := read_ref($t7) # live vars: $t1, $t3, $t5 - 7: $t1 := /($t1, $t5) + 9: $t1 := /($t1, $t5) # live vars: $t1, $t3 - 8: m::bar($t3, $t1) + 10: m::bar($t3, $t1) # live vars: - 9: return () + 11: return () } @@ -116,27 +128,22 @@ B0: 4: Ret } public test(Arg0: &mut S, Arg1: u64) /* def_idx: 2 */ { -L2: loc0: u64 B0: 0: CopyLoc[0](Arg0: &mut S) 1: MutBorrowField[0](S.x: u64) - 2: CopyLoc[0](Arg0: &mut S) - 3: ImmBorrowField[1](S.y: u64) - 4: ReadRef - 5: StLoc[2](loc0: u64) - 6: CopyLoc[1](Arg1: u64) - 7: MoveLoc[2](loc0: u64) - 8: Div - 9: Call foo(&mut u64, u64): &mut u64 - 10: MoveLoc[0](Arg0: &mut S) - 11: ImmBorrowField[1](S.y: u64) - 12: ReadRef - 13: StLoc[2](loc0: u64) - 14: MoveLoc[1](Arg1: u64) - 15: MoveLoc[2](loc0: u64) - 16: Div - 17: Call bar(&mut u64, u64) - 18: Ret + 2: CopyLoc[1](Arg1: u64) + 3: CopyLoc[0](Arg0: &mut S) + 4: ImmBorrowField[1](S.y: u64) + 5: ReadRef + 6: Div + 7: Call foo(&mut u64, u64): &mut u64 + 8: MoveLoc[1](Arg1: u64) + 9: MoveLoc[0](Arg0: &mut S) + 10: ImmBorrowField[1](S.y: u64) + 11: ReadRef + 12: Div + 13: Call bar(&mut u64, u64) + 14: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_08.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_08.exp index f8557d046d801..fec0212ea2814 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_08.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_08.exp @@ -20,20 +20,24 @@ public fun m::test($t0: &0xc0ffee::m::S, $t1: u64) { var $t3: &u64 var $t4: u64 var $t5: u64 - var $t6: &u64 - var $t7: u64 + var $t6: u64 + var $t7: &u64 var $t8: u64 - var $t9: &u64 + var $t9: u64 + var $t10: u64 + var $t11: &u64 0: $t3 := borrow_field<0xc0ffee::m::S>.x($t0) - 1: $t6 := borrow_field<0xc0ffee::m::S>.y($t0) - 2: $t5 := read_ref($t6) - 3: $t4 := /($t1, $t5) - 4: $t2 := m::foo($t3, $t4) - 5: $t9 := borrow_field<0xc0ffee::m::S>.y($t0) - 6: $t8 := read_ref($t9) - 7: $t7 := /($t1, $t8) - 8: m::bar($t2, $t7) - 9: return () + 1: $t5 := infer($t1) + 2: $t7 := borrow_field<0xc0ffee::m::S>.y($t0) + 3: $t6 := read_ref($t7) + 4: $t4 := /($t5, $t6) + 5: $t2 := m::foo($t3, $t4) + 6: $t9 := infer($t1) + 7: $t11 := borrow_field<0xc0ffee::m::S>.y($t0) + 8: $t10 := read_ref($t11) + 9: $t8 := /($t9, $t10) + 10: m::bar($t2, $t8) + 11: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -51,7 +55,9 @@ fun m::bar($t0: &u64, $t1: u64) { fun m::foo($t0: &u64, $t1: u64): &u64 { var $t2: &u64 [unused] # live vars: $t0, $t1 - 0: return $t0 + 0: $t0 := move($t0) + # live vars: $t0 + 1: return $t0 } @@ -61,30 +67,36 @@ public fun m::test($t0: &0xc0ffee::m::S, $t1: u64) { var $t3: &u64 var $t4: u64 [unused] var $t5: u64 - var $t6: &u64 - var $t7: u64 [unused] + var $t6: u64 + var $t7: &u64 var $t8: u64 [unused] - var $t9: &u64 [unused] + var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: &u64 [unused] # live vars: $t0, $t1 0: $t3 := borrow_field<0xc0ffee::m::S>.x($t0) # live vars: $t0, $t1, $t3 - 1: $t6 := borrow_field<0xc0ffee::m::S>.y($t0) - # live vars: $t0, $t1, $t3, $t6 - 2: $t5 := read_ref($t6) + 1: $t5 := copy($t1) # live vars: $t0, $t1, $t3, $t5 - 3: $t5 := /($t1, $t5) + 2: $t7 := borrow_field<0xc0ffee::m::S>.y($t0) + # live vars: $t0, $t1, $t3, $t5, $t7 + 3: $t6 := read_ref($t7) + # live vars: $t0, $t1, $t3, $t5, $t6 + 4: $t5 := /($t5, $t6) # live vars: $t0, $t1, $t3, $t5 - 4: $t3 := m::foo($t3, $t5) + 5: $t3 := m::foo($t3, $t5) # live vars: $t0, $t1, $t3 - 5: $t6 := borrow_field<0xc0ffee::m::S>.y($t0) - # live vars: $t1, $t3, $t6 - 6: $t5 := read_ref($t6) + 6: $t1 := move($t1) + # live vars: $t0, $t1, $t3 + 7: $t7 := borrow_field<0xc0ffee::m::S>.y($t0) + # live vars: $t1, $t3, $t7 + 8: $t5 := read_ref($t7) # live vars: $t1, $t3, $t5 - 7: $t1 := /($t1, $t5) + 9: $t1 := /($t1, $t5) # live vars: $t1, $t3 - 8: m::bar($t3, $t1) + 10: m::bar($t3, $t1) # live vars: - 9: return () + 11: return () } @@ -108,27 +120,22 @@ B0: 1: Ret } public test(Arg0: &S, Arg1: u64) /* def_idx: 2 */ { -L2: loc0: u64 B0: 0: CopyLoc[0](Arg0: &S) 1: ImmBorrowField[0](S.x: u64) - 2: CopyLoc[0](Arg0: &S) - 3: ImmBorrowField[1](S.y: u64) - 4: ReadRef - 5: StLoc[2](loc0: u64) - 6: CopyLoc[1](Arg1: u64) - 7: MoveLoc[2](loc0: u64) - 8: Div - 9: Call foo(&u64, u64): &u64 - 10: MoveLoc[0](Arg0: &S) - 11: ImmBorrowField[1](S.y: u64) - 12: ReadRef - 13: StLoc[2](loc0: u64) - 14: MoveLoc[1](Arg1: u64) - 15: MoveLoc[2](loc0: u64) - 16: Div - 17: Call bar(&u64, u64) - 18: Ret + 2: CopyLoc[1](Arg1: u64) + 3: CopyLoc[0](Arg0: &S) + 4: ImmBorrowField[1](S.y: u64) + 5: ReadRef + 6: Div + 7: Call foo(&u64, u64): &u64 + 8: MoveLoc[1](Arg1: u64) + 9: MoveLoc[0](Arg0: &S) + 10: ImmBorrowField[1](S.y: u64) + 11: ReadRef + 12: Div + 13: Call bar(&u64, u64) + 14: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_09.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_09.exp index df94d0ba33f15..ecf2efc2599ef 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_09.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_09.exp @@ -33,26 +33,28 @@ public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: u64) { var $t6: &u64 var $t7: u64 var $t8: u64 - var $t9: &u64 - var $t10: &mut u64 + var $t9: u64 + var $t10: &u64 var $t11: &mut u64 + var $t12: &mut u64 0: $t3 := borrow_field<0xc0ffee::m::S>.x($t0) 1: $t2 := m::foo($t3) 2: $t6 := borrow_field<0xc0ffee::m::S>.x($t0) 3: $t5 := read_ref($t6) - 4: $t9 := borrow_field<0xc0ffee::m::S>.y($t0) - 5: $t8 := read_ref($t9) - 6: $t7 := *($t2, $t8) - 7: $t4 := ==($t5, $t7) - 8: if ($t4) goto 9 else goto 14 - 9: label L0 - 10: $t11 := borrow_field<0xc0ffee::m::S>.x($t0) - 11: $t10 := m::bar($t11, $t2) - 12: m::baz($t10, $t1) - 13: goto 15 - 14: label L1 - 15: label L2 - 16: return () + 4: $t8 := infer($t2) + 5: $t10 := borrow_field<0xc0ffee::m::S>.y($t0) + 6: $t9 := read_ref($t10) + 7: $t7 := *($t8, $t9) + 8: $t4 := ==($t5, $t7) + 9: if ($t4) goto 10 else goto 15 + 10: label L0 + 11: $t12 := borrow_field<0xc0ffee::m::S>.x($t0) + 12: $t11 := m::bar($t12, $t2) + 13: m::baz($t11, $t1) + 14: goto 16 + 15: label L1 + 16: label L2 + 17: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -63,7 +65,9 @@ fun m::bar($t0: &mut u64, $t1: u64): &mut u64 { # live vars: $t0, $t1 0: write_ref($t0, $t1) # live vars: $t0 - 1: return $t0 + 1: $t0 := move($t0) + # live vars: $t0 + 2: return $t0 } @@ -95,9 +99,10 @@ public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: u64) { var $t6: &u64 [unused] var $t7: u64 [unused] var $t8: u64 - var $t9: &u64 [unused] - var $t10: &mut u64 [unused] - var $t11: &mut u64 + var $t9: u64 + var $t10: &u64 [unused] + var $t11: &mut u64 [unused] + var $t12: &mut u64 # live vars: $t0, $t1 0: $t3 := borrow_field<0xc0ffee::m::S>.x($t0) # live vars: $t0, $t1, $t3 @@ -107,33 +112,35 @@ public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: u64) { # live vars: $t0, $t1, $t2, $t3 3: $t5 := read_ref($t3) # live vars: $t0, $t1, $t2, $t5 - 4: $t3 := borrow_field<0xc0ffee::m::S>.y($t0) - # live vars: $t0, $t1, $t2, $t3, $t5 - 5: $t8 := read_ref($t3) + 4: $t8 := copy($t2) # live vars: $t0, $t1, $t2, $t5, $t8 - 6: $t8 := *($t2, $t8) + 5: $t3 := borrow_field<0xc0ffee::m::S>.y($t0) + # live vars: $t0, $t1, $t2, $t3, $t5, $t8 + 6: $t9 := read_ref($t3) + # live vars: $t0, $t1, $t2, $t5, $t8, $t9 + 7: $t8 := *($t8, $t9) # live vars: $t0, $t1, $t2, $t5, $t8 - 7: $t4 := ==($t5, $t8) + 8: $t4 := ==($t5, $t8) # live vars: $t0, $t1, $t2, $t4 - 8: if ($t4) goto 9 else goto 15 + 9: if ($t4) goto 10 else goto 16 # live vars: $t0, $t1, $t2 - 9: label L0 + 10: label L0 # live vars: $t0, $t1, $t2 - 10: $t11 := borrow_field<0xc0ffee::m::S>.x($t0) - # live vars: $t1, $t2, $t11 - 11: $t11 := m::bar($t11, $t2) - # live vars: $t1, $t11 - 12: m::baz($t11, $t1) + 11: $t12 := borrow_field<0xc0ffee::m::S>.x($t0) + # live vars: $t1, $t2, $t12 + 12: $t12 := m::bar($t12, $t2) + # live vars: $t1, $t12 + 13: m::baz($t12, $t1) # live vars: - 13: label L2 + 14: label L2 # live vars: - 14: return () + 15: return () # live vars: $t0, $t1, $t2 - 15: label L1 + 16: label L1 # live vars: $t0 - 16: drop($t0) + 17: drop($t0) # live vars: - 17: goto 13 + 18: goto 14 } @@ -168,7 +175,6 @@ B0: } public test(Arg0: &mut S, Arg1: u64) /* def_idx: 3 */ { L2: loc0: u64 -L3: loc1: u64 B0: 0: CopyLoc[0](Arg0: &mut S) 1: ImmBorrowField[0](S.x: u64) @@ -177,28 +183,26 @@ B0: 4: CopyLoc[0](Arg0: &mut S) 5: ImmBorrowField[0](S.x: u64) 6: ReadRef - 7: CopyLoc[0](Arg0: &mut S) - 8: ImmBorrowField[1](S.y: u64) - 9: ReadRef - 10: StLoc[3](loc1: u64) - 11: CopyLoc[2](loc0: u64) - 12: MoveLoc[3](loc1: u64) - 13: Mul - 14: Eq - 15: BrFalse(23) + 7: CopyLoc[2](loc0: u64) + 8: CopyLoc[0](Arg0: &mut S) + 9: ImmBorrowField[1](S.y: u64) + 10: ReadRef + 11: Mul + 12: Eq + 13: BrFalse(21) B1: - 16: MoveLoc[0](Arg0: &mut S) - 17: MutBorrowField[0](S.x: u64) - 18: MoveLoc[2](loc0: u64) - 19: Call bar(&mut u64, u64): &mut u64 - 20: MoveLoc[1](Arg1: u64) - 21: Call baz(&mut u64, u64) + 14: MoveLoc[0](Arg0: &mut S) + 15: MutBorrowField[0](S.x: u64) + 16: MoveLoc[2](loc0: u64) + 17: Call bar(&mut u64, u64): &mut u64 + 18: MoveLoc[1](Arg1: u64) + 19: Call baz(&mut u64, u64) B2: - 22: Ret + 20: Ret B3: - 23: MoveLoc[0](Arg0: &mut S) - 24: Pop - 25: Branch(22) + 21: MoveLoc[0](Arg0: &mut S) + 22: Pop + 23: Branch(20) } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_10.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_10.exp index ff95289d51c83..f12e640934cca 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_10.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/framework_reduced_10.exp @@ -19,38 +19,46 @@ fun m::foo($t0: &u64): u64 { public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: u64) { var $t2: u64 var $t3: u64 - var $t4: &u64 - var $t5: u64 - var $t6: &u64 - var $t7: bool - var $t8: &mut u64 + var $t4: u64 + var $t5: &u64 + var $t6: u64 + var $t7: &u64 + var $t8: bool var $t9: u64 - var $t10: u64 + var $t10: &mut u64 var $t11: u64 var $t12: u64 - 0: $t4 := borrow_field<0xc0ffee::m::S>.x($t0) - 1: $t3 := read_ref($t4) - 2: $t2 := /($t1, $t3) - 3: $t6 := borrow_field<0xc0ffee::m::S>.y($t0) - 4: $t5 := m::foo($t6) - 5: label L0 - 6: $t7 := <($t2, $t5) - 7: if ($t7) goto 8 else goto 17 - 8: label L2 - 9: $t8 := borrow_field<0xc0ffee::m::S>.z($t0) - 10: $t10 := 1 - 11: $t9 := -($t2, $t10) - 12: m::bar($t8, $t9) - 13: $t12 := 1 - 14: $t11 := +($t2, $t12) - 15: $t2 := infer($t11) - 16: goto 19 - 17: label L3 - 18: goto 21 - 19: label L4 - 20: goto 5 - 21: label L1 - 22: return () + var $t13: u64 + var $t14: u64 + var $t15: u64 + var $t16: u64 + 0: $t3 := infer($t1) + 1: $t5 := borrow_field<0xc0ffee::m::S>.x($t0) + 2: $t4 := read_ref($t5) + 3: $t2 := /($t3, $t4) + 4: $t7 := borrow_field<0xc0ffee::m::S>.y($t0) + 5: $t6 := m::foo($t7) + 6: label L0 + 7: $t9 := infer($t2) + 8: $t8 := <($t9, $t6) + 9: if ($t8) goto 10 else goto 21 + 10: label L2 + 11: $t10 := borrow_field<0xc0ffee::m::S>.z($t0) + 12: $t12 := infer($t2) + 13: $t13 := 1 + 14: $t11 := -($t12, $t13) + 15: m::bar($t10, $t11) + 16: $t15 := infer($t2) + 17: $t16 := 1 + 18: $t14 := +($t15, $t16) + 19: $t2 := infer($t14) + 20: goto 23 + 21: label L3 + 22: goto 25 + 23: label L4 + 24: goto 6 + 25: label L1 + 26: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -77,56 +85,68 @@ fun m::foo($t0: &u64): u64 { [variant baseline] public fun m::test($t0: &mut 0xc0ffee::m::S, $t1: u64) { var $t2: u64 [unused] - var $t3: u64 - var $t4: &u64 - var $t5: u64 [unused] - var $t6: &u64 [unused] - var $t7: bool - var $t8: &mut u64 - var $t9: u64 [unused] - var $t10: u64 + var $t3: u64 [unused] + var $t4: u64 + var $t5: &u64 + var $t6: u64 [unused] + var $t7: &u64 [unused] + var $t8: bool + var $t9: u64 + var $t10: &mut u64 var $t11: u64 [unused] var $t12: u64 [unused] + var $t13: u64 + var $t14: u64 [unused] + var $t15: u64 [unused] + var $t16: u64 [unused] + # live vars: $t0, $t1 + 0: $t1 := move($t1) # live vars: $t0, $t1 - 0: $t4 := borrow_field<0xc0ffee::m::S>.x($t0) + 1: $t5 := borrow_field<0xc0ffee::m::S>.x($t0) + # live vars: $t0, $t1, $t5 + 2: $t4 := read_ref($t5) # live vars: $t0, $t1, $t4 - 1: $t3 := read_ref($t4) - # live vars: $t0, $t1, $t3 - 2: $t1 := /($t1, $t3) + 3: $t1 := /($t1, $t4) # live vars: $t0, $t1 - 3: $t4 := borrow_field<0xc0ffee::m::S>.y($t0) + 4: $t5 := borrow_field<0xc0ffee::m::S>.y($t0) + # live vars: $t0, $t1, $t5 + 5: $t4 := m::foo($t5) + # live vars: $t0, $t1, $t4 + 6: label L0 + # live vars: $t0, $t1, $t4 + 7: $t9 := copy($t1) + # live vars: $t0, $t1, $t4, $t9 + 8: $t8 := <($t9, $t4) + # live vars: $t0, $t1, $t4, $t8 + 9: if ($t8) goto 10 else goto 21 # live vars: $t0, $t1, $t4 - 4: $t3 := m::foo($t4) - # live vars: $t0, $t1, $t3 - 5: label L0 - # live vars: $t0, $t1, $t3 - 6: $t7 := <($t1, $t3) - # live vars: $t0, $t1, $t3, $t7 - 7: if ($t7) goto 8 else goto 17 - # live vars: $t0, $t1, $t3 - 8: label L2 - # live vars: $t0, $t1, $t3 - 9: $t8 := borrow_field<0xc0ffee::m::S>.z($t0) - # live vars: $t0, $t1, $t3, $t8 - 10: $t10 := 1 - # live vars: $t0, $t1, $t3, $t8, $t10 - 11: $t10 := -($t1, $t10) - # live vars: $t0, $t1, $t3, $t8, $t10 - 12: m::bar($t8, $t10) - # live vars: $t0, $t1, $t3 - 13: $t10 := 1 - # live vars: $t0, $t1, $t3, $t10 - 14: $t10 := +($t1, $t10) - # live vars: $t0, $t3, $t10 - 15: $t1 := move($t10) - # live vars: $t0, $t1, $t3 - 16: goto 5 - # live vars: $t0, $t1, $t3 - 17: label L3 + 10: label L2 + # live vars: $t0, $t1, $t4 + 11: $t10 := borrow_field<0xc0ffee::m::S>.z($t0) + # live vars: $t0, $t1, $t4, $t10 + 12: $t9 := copy($t1) + # live vars: $t0, $t1, $t4, $t9, $t10 + 13: $t13 := 1 + # live vars: $t0, $t1, $t4, $t9, $t10, $t13 + 14: $t9 := -($t9, $t13) + # live vars: $t0, $t1, $t4, $t9, $t10 + 15: m::bar($t10, $t9) + # live vars: $t0, $t1, $t4 + 16: $t9 := move($t1) + # live vars: $t0, $t4, $t9 + 17: $t13 := 1 + # live vars: $t0, $t4, $t9, $t13 + 18: $t9 := +($t9, $t13) + # live vars: $t0, $t4, $t9 + 19: $t1 := move($t9) + # live vars: $t0, $t1, $t4 + 20: goto 6 + # live vars: $t0, $t1, $t4 + 21: label L3 # live vars: $t0 - 18: drop($t0) + 22: drop($t0) # live vars: - 19: return () + 23: return () } @@ -154,41 +174,38 @@ B0: } public test(Arg0: &mut S, Arg1: u64) /* def_idx: 2 */ { L2: loc0: u64 -L3: loc1: u64 B0: - 0: CopyLoc[0](Arg0: &mut S) - 1: ImmBorrowField[0](S.x: u64) - 2: ReadRef - 3: StLoc[2](loc0: u64) - 4: MoveLoc[1](Arg1: u64) - 5: MoveLoc[2](loc0: u64) - 6: Div - 7: StLoc[1](Arg1: u64) - 8: CopyLoc[0](Arg0: &mut S) - 9: ImmBorrowField[1](S.y: u64) - 10: Call foo(&u64): u64 - 11: StLoc[2](loc0: u64) + 0: MoveLoc[1](Arg1: u64) + 1: CopyLoc[0](Arg0: &mut S) + 2: ImmBorrowField[0](S.x: u64) + 3: ReadRef + 4: Div + 5: StLoc[1](Arg1: u64) + 6: CopyLoc[0](Arg0: &mut S) + 7: ImmBorrowField[1](S.y: u64) + 8: Call foo(&u64): u64 + 9: StLoc[2](loc0: u64) B1: - 12: CopyLoc[1](Arg1: u64) - 13: CopyLoc[2](loc0: u64) - 14: Lt - 15: BrFalse(27) + 10: CopyLoc[1](Arg1: u64) + 11: CopyLoc[2](loc0: u64) + 12: Lt + 13: BrFalse(25) B2: - 16: CopyLoc[0](Arg0: &mut S) - 17: MutBorrowField[2](S.z: u64) - 18: CopyLoc[1](Arg1: u64) - 19: LdU64(1) - 20: Sub - 21: Call bar(&mut u64, u64) - 22: MoveLoc[1](Arg1: u64) - 23: LdU64(1) - 24: Add - 25: StLoc[1](Arg1: u64) - 26: Branch(12) + 14: CopyLoc[0](Arg0: &mut S) + 15: MutBorrowField[2](S.z: u64) + 16: CopyLoc[1](Arg1: u64) + 17: LdU64(1) + 18: Sub + 19: Call bar(&mut u64, u64) + 20: MoveLoc[1](Arg1: u64) + 21: LdU64(1) + 22: Add + 23: StLoc[1](Arg1: u64) + 24: Branch(10) B3: - 27: MoveLoc[0](Arg0: &mut S) - 28: Pop - 29: Ret + 25: MoveLoc[0](Arg0: &mut S) + 26: Pop + 27: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.exp index 2ebaeb0bea084..d4df43193625b 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/move_stdlib_reduced.exp @@ -11,28 +11,32 @@ fun m::bar($t0: &mut u64, $t1: u64) { public fun m::foo($t0: &mut u64, $t1: u64) { var $t2: bool var $t3: u64 - var $t4: &mut u64 - var $t5: u64 + var $t4: u64 + var $t5: &mut u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: label L0 - 1: $t3 := 0 - 2: $t2 := >($t1, $t3) - 3: if ($t2) goto 4 else goto 12 - 4: label L2 - 5: $t4 := infer($t0) - 6: $t5 := m::one() - 7: m::bar($t4, $t5) - 8: $t7 := 1 - 9: $t6 := -($t1, $t7) - 10: $t1 := infer($t6) - 11: goto 14 - 12: label L3 + 1: $t3 := infer($t1) + 2: $t4 := 0 + 3: $t2 := >($t3, $t4) + 4: if ($t2) goto 5 else goto 14 + 5: label L2 + 6: $t5 := infer($t0) + 7: $t6 := m::one() + 8: m::bar($t5, $t6) + 9: $t8 := infer($t1) + 10: $t9 := 1 + 11: $t7 := -($t8, $t9) + 12: $t1 := infer($t7) 13: goto 16 - 14: label L4 - 15: goto 0 - 16: label L1 - 17: return () + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 0 + 18: label L1 + 19: return () } @@ -58,40 +62,46 @@ fun m::bar($t0: &mut u64, $t1: u64) { public fun m::foo($t0: &mut u64, $t1: u64) { var $t2: bool var $t3: u64 - var $t4: &mut u64 - var $t5: u64 [unused] + var $t4: u64 + var $t5: &mut u64 var $t6: u64 [unused] var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] # live vars: $t0, $t1 0: label L0 # live vars: $t0, $t1 - 1: $t3 := 0 + 1: $t3 := copy($t1) # live vars: $t0, $t1, $t3 - 2: $t2 := >($t1, $t3) + 2: $t4 := 0 + # live vars: $t0, $t1, $t3, $t4 + 3: $t2 := >($t3, $t4) # live vars: $t0, $t1, $t2 - 3: if ($t2) goto 4 else goto 12 + 4: if ($t2) goto 5 else goto 14 # live vars: $t0, $t1 - 4: label L2 + 5: label L2 # live vars: $t0, $t1 - 5: $t4 := copy($t0) - # live vars: $t0, $t1, $t4 - 6: $t3 := m::one() - # live vars: $t0, $t1, $t3, $t4 - 7: m::bar($t4, $t3) + 6: $t5 := copy($t0) + # live vars: $t0, $t1, $t5 + 7: $t3 := m::one() + # live vars: $t0, $t1, $t3, $t5 + 8: m::bar($t5, $t3) # live vars: $t0, $t1 - 8: $t3 := 1 - # live vars: $t0, $t1, $t3 - 9: $t3 := -($t1, $t3) + 9: $t3 := move($t1) + # live vars: $t0, $t3 + 10: $t4 := 1 + # live vars: $t0, $t3, $t4 + 11: $t3 := -($t3, $t4) # live vars: $t0, $t3 - 10: $t1 := move($t3) + 12: $t1 := move($t3) # live vars: $t0, $t1 - 11: goto 0 + 13: goto 0 # live vars: $t0, $t1 - 12: label L3 + 14: label L3 # live vars: $t0 - 13: drop($t0) + 15: drop($t0) # live vars: - 14: return () + 16: return () } @@ -118,7 +128,6 @@ B0: 3: Ret } public foo(Arg0: &mut u64, Arg1: u64) /* def_idx: 1 */ { -L2: loc0: u64 B0: 0: CopyLoc[1](Arg1: u64) 1: LdU64(0) diff --git a/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.exp b/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.exp index a36517680038a..834258b42a956 100644 --- a/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.exp +++ b/third_party/move/move-compiler-v2/tests/eager-pushes/txn_reduced_01.exp @@ -12,38 +12,44 @@ public fun m::test($t0: &signer, $t1: vector
, $t2: vector) { var $t4: &vector
var $t5: u64 var $t6: bool - var $t7: &address - var $t8: &vector
- var $t9: &u64 - var $t10: &vector - var $t11: address - var $t12: u64 - var $t13: u64 + var $t7: u64 + var $t8: &address + var $t9: &vector
+ var $t10: &u64 + var $t11: &vector + var $t12: &signer + var $t13: address var $t14: u64 + var $t15: u64 + var $t16: u64 + var $t17: u64 0: $t4 := borrow_local($t1) 1: $t3 := vector::length
($t4) 2: $t5 := 0 3: label L0 - 4: $t6 := <($t5, $t3) - 5: if ($t6) goto 6 else goto 18 - 6: label L2 - 7: $t8 := borrow_local($t1) - 8: $t7 := vector::borrow
($t8, $t5) - 9: $t10 := borrow_local($t2) - 10: $t9 := vector::borrow($t10, $t5) - 11: $t11 := read_ref($t7) - 12: $t12 := read_ref($t9) - 13: m::call_other($t0, $t11, $t12) - 14: $t14 := 1 - 15: $t13 := +($t5, $t14) - 16: $t5 := infer($t13) - 17: goto 20 - 18: label L3 - 19: goto 22 - 20: label L4 - 21: goto 3 - 22: label L1 - 23: return () + 4: $t7 := infer($t5) + 5: $t6 := <($t7, $t3) + 6: if ($t6) goto 7 else goto 21 + 7: label L2 + 8: $t9 := borrow_local($t1) + 9: $t8 := vector::borrow
($t9, $t5) + 10: $t11 := borrow_local($t2) + 11: $t10 := vector::borrow($t11, $t5) + 12: $t12 := infer($t0) + 13: $t13 := read_ref($t8) + 14: $t14 := read_ref($t10) + 15: m::call_other($t12, $t13, $t14) + 16: $t16 := infer($t5) + 17: $t17 := 1 + 18: $t15 := +($t16, $t17) + 19: $t5 := infer($t15) + 20: goto 23 + 21: label L3 + 22: goto 25 + 23: label L4 + 24: goto 3 + 25: label L1 + 26: return () } ============ after LiveVarAnalysisProcessor: ================ @@ -63,14 +69,17 @@ public fun m::test($t0: &signer, $t1: vector
, $t2: vector) { var $t4: &vector
var $t5: u64 var $t6: bool - var $t7: &address - var $t8: &vector
[unused] - var $t9: &u64 - var $t10: &vector - var $t11: address - var $t12: u64 - var $t13: u64 [unused] + var $t7: u64 + var $t8: &address + var $t9: &vector
[unused] + var $t10: &u64 + var $t11: &vector + var $t12: &signer + var $t13: address var $t14: u64 [unused] + var $t15: u64 [unused] + var $t16: u64 [unused] + var $t17: u64 # live vars: $t0, $t1, $t2 0: $t4 := borrow_local($t1) # live vars: $t0, $t1, $t2, $t4 @@ -80,39 +89,45 @@ public fun m::test($t0: &signer, $t1: vector
, $t2: vector) { # live vars: $t0, $t1, $t2, $t3, $t5 3: label L0 # live vars: $t0, $t1, $t2, $t3, $t5 - 4: $t6 := <($t5, $t3) + 4: $t7 := copy($t5) + # live vars: $t0, $t1, $t2, $t3, $t5, $t7 + 5: $t6 := <($t7, $t3) # live vars: $t0, $t1, $t2, $t3, $t5, $t6 - 5: if ($t6) goto 6 else goto 18 + 6: if ($t6) goto 7 else goto 21 # live vars: $t0, $t1, $t2, $t3, $t5 - 6: label L2 + 7: label L2 # live vars: $t0, $t1, $t2, $t3, $t5 - 7: $t4 := borrow_local($t1) + 8: $t4 := borrow_local($t1) # live vars: $t0, $t1, $t2, $t3, $t4, $t5 - 8: $t7 := vector::borrow
($t4, $t5) - # live vars: $t0, $t1, $t2, $t3, $t5, $t7 - 9: $t10 := borrow_local($t2) - # live vars: $t0, $t1, $t2, $t3, $t5, $t7, $t10 - 10: $t9 := vector::borrow($t10, $t5) - # live vars: $t0, $t1, $t2, $t3, $t5, $t7, $t9 - 11: $t11 := read_ref($t7) - # live vars: $t0, $t1, $t2, $t3, $t5, $t9, $t11 - 12: $t12 := read_ref($t9) - # live vars: $t0, $t1, $t2, $t3, $t5, $t11, $t12 - 13: m::call_other($t0, $t11, $t12) + 9: $t8 := vector::borrow
($t4, $t5) + # live vars: $t0, $t1, $t2, $t3, $t5, $t8 + 10: $t11 := borrow_local($t2) + # live vars: $t0, $t1, $t2, $t3, $t5, $t8, $t11 + 11: $t10 := vector::borrow($t11, $t5) + # live vars: $t0, $t1, $t2, $t3, $t5, $t8, $t10 + 12: $t12 := copy($t0) + # live vars: $t0, $t1, $t2, $t3, $t5, $t8, $t10, $t12 + 13: $t13 := read_ref($t8) + # live vars: $t0, $t1, $t2, $t3, $t5, $t10, $t12, $t13 + 14: $t7 := read_ref($t10) + # live vars: $t0, $t1, $t2, $t3, $t5, $t7, $t12, $t13 + 15: m::call_other($t12, $t13, $t7) # live vars: $t0, $t1, $t2, $t3, $t5 - 14: $t12 := 1 - # live vars: $t0, $t1, $t2, $t3, $t5, $t12 - 15: $t12 := +($t5, $t12) - # live vars: $t0, $t1, $t2, $t3, $t12 - 16: $t5 := move($t12) + 16: $t7 := move($t5) + # live vars: $t0, $t1, $t2, $t3, $t7 + 17: $t17 := 1 + # live vars: $t0, $t1, $t2, $t3, $t7, $t17 + 18: $t7 := +($t7, $t17) + # live vars: $t0, $t1, $t2, $t3, $t7 + 19: $t5 := move($t7) # live vars: $t0, $t1, $t2, $t3, $t5 - 17: goto 3 + 20: goto 3 # live vars: $t0, $t1, $t2, $t3, $t5 - 18: label L3 + 21: label L3 # live vars: $t0 - 19: drop($t0) + 22: drop($t0) # live vars: - 20: return () + 23: return () } @@ -130,10 +145,8 @@ B0: public test(Arg0: &signer, Arg1: vector
, Arg2: vector) /* def_idx: 1 */ { L3: loc0: u64 L4: loc1: u64 -L5: loc2: &u64 -L6: loc3: &address -L7: loc4: u64 -L8: loc5: address +L5: loc2: &address +L6: loc3: &u64 B0: 0: ImmBorrowLoc[1](Arg1: vector
) 1: VecLen(3) @@ -144,33 +157,31 @@ B1: 5: CopyLoc[4](loc1: u64) 6: CopyLoc[3](loc0: u64) 7: Lt - 8: BrFalse(30) + 8: BrFalse(28) B2: 9: ImmBorrowLoc[1](Arg1: vector
) 10: CopyLoc[4](loc1: u64) 11: VecImmBorrow(3) - 12: ImmBorrowLoc[2](Arg2: vector) - 13: CopyLoc[4](loc1: u64) - 14: VecImmBorrow(4) - 15: StLoc[5](loc2: &u64) - 16: ReadRef - 17: MoveLoc[5](loc2: &u64) - 18: ReadRef - 19: StLoc[7](loc4: u64) - 20: StLoc[8](loc5: address) - 21: CopyLoc[0](Arg0: &signer) - 22: MoveLoc[8](loc5: address) - 23: MoveLoc[7](loc4: u64) - 24: Call call_other(&signer, address, u64) - 25: MoveLoc[4](loc1: u64) - 26: LdU64(1) - 27: Add - 28: StLoc[4](loc1: u64) - 29: Branch(5) + 12: StLoc[5](loc2: &address) + 13: ImmBorrowLoc[2](Arg2: vector) + 14: CopyLoc[4](loc1: u64) + 15: VecImmBorrow(4) + 16: StLoc[6](loc3: &u64) + 17: CopyLoc[0](Arg0: &signer) + 18: MoveLoc[5](loc2: &address) + 19: ReadRef + 20: MoveLoc[6](loc3: &u64) + 21: ReadRef + 22: Call call_other(&signer, address, u64) + 23: MoveLoc[4](loc1: u64) + 24: LdU64(1) + 25: Add + 26: StLoc[4](loc1: u64) + 27: Branch(5) B3: - 30: MoveLoc[0](Arg0: &signer) - 31: Pop - 32: Ret + 28: MoveLoc[0](Arg0: &signer) + 29: Pop + 30: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/assign.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/assign.exp index 0140492ccc133..1400c660aa9f9 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/assign.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/assign.exp @@ -33,8 +33,12 @@ B0: 0: MoveLoc[0](Arg0: S) 1: Unpack[1](S) 2: Unpack[0](T) - 3: Add - 4: Ret + 3: StLoc[2](Arg2: u64) + 4: StLoc[1](Arg1: u64) + 5: MoveLoc[1](Arg1: u64) + 6: MoveLoc[2](Arg2: u64) + 7: Add + 8: Ret } assign_struct(Arg0: &mut S) /* def_idx: 3 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.exp index 9d0f6f655fbc9..8289c4d42afd3 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.exp @@ -23,13 +23,9 @@ L3: loc1: bool L4: loc2: u64 L5: loc3: u64 L6: loc4: u64 -L7: loc5: &T -L8: loc6: &T -L9: loc7: u64 -L10: loc8: bool -L11: loc9: u64 -L12: loc10: Option -L13: loc11: Option +L7: loc5: u64 +L8: loc6: bool +L9: loc7: Option B0: 0: CopyLoc[0](Arg0: &mut S) 1: ImmBorrowField[0](S.entries: vector) @@ -47,68 +43,60 @@ B1: 12: CopyLoc[6](loc4: u64) 13: CopyLoc[5](loc3: u64) 14: Lt - 15: BrFalse(41) + 15: BrFalse(35) B2: 16: CopyLoc[2](loc0: &vector) 17: CopyLoc[6](loc4: u64) 18: VecImmBorrow(2) - 19: StLoc[7](loc5: &T) - 20: MoveLoc[7](loc5: &T) - 21: StLoc[8](loc6: &T) - 22: MoveLoc[8](loc6: &T) - 23: ImmBorrowField[1](T.issuer: vector) - 24: ReadRef - 25: CopyLoc[1](Arg1: vector) - 26: Eq - 27: BrFalse(34) + 19: ImmBorrowField[1](T.issuer: vector) + 20: ReadRef + 21: CopyLoc[1](Arg1: vector) + 22: Eq + 23: BrFalse(30) B3: - 28: LdTrue - 29: StLoc[3](loc1: bool) - 30: MoveLoc[6](loc4: u64) - 31: StLoc[4](loc2: u64) - 32: Branch(43) + 24: LdTrue + 25: StLoc[3](loc1: bool) + 26: MoveLoc[6](loc4: u64) + 27: StLoc[4](loc2: u64) + 28: Branch(37) B4: - 33: Branch(34) + 29: Branch(30) B5: - 34: LdU64(1) - 35: StLoc[9](loc7: u64) - 36: MoveLoc[6](loc4: u64) - 37: MoveLoc[9](loc7: u64) - 38: Add - 39: StLoc[6](loc4: u64) - 40: Branch(42) + 30: MoveLoc[6](loc4: u64) + 31: LdU64(1) + 32: Add + 33: StLoc[6](loc4: u64) + 34: Branch(36) B6: - 41: Branch(43) + 35: Branch(37) B7: - 42: Branch(12) + 36: Branch(12) B8: - 43: Nop - 44: MoveLoc[2](loc0: &vector) - 45: Pop - 46: MoveLoc[3](loc1: bool) - 47: StLoc[10](loc8: bool) - 48: MoveLoc[4](loc2: u64) - 49: StLoc[11](loc9: u64) - 50: MoveLoc[10](loc8: bool) - 51: BrFalse(59) + 37: Nop + 38: MoveLoc[2](loc0: &vector) + 39: Pop + 40: MoveLoc[3](loc1: bool) + 41: MoveLoc[4](loc2: u64) + 42: StLoc[7](loc5: u64) + 43: StLoc[8](loc6: bool) + 44: MoveLoc[8](loc6: bool) + 45: BrFalse(53) B9: - 52: MoveLoc[0](Arg0: &mut S) - 53: MutBorrowField[0](S.entries: vector) - 54: MoveLoc[11](loc9: u64) - 55: Call vector::remove(&mut vector, u64): T - 56: Call option::some(T): Option - 57: StLoc[12](loc10: Option) - 58: Branch(63) + 46: MoveLoc[0](Arg0: &mut S) + 47: MutBorrowField[0](S.entries: vector) + 48: MoveLoc[7](loc5: u64) + 49: Call vector::remove(&mut vector, u64): T + 50: Call option::some(T): Option + 51: StLoc[9](loc7: Option) + 52: Branch(57) B10: - 59: MoveLoc[0](Arg0: &mut S) - 60: Pop - 61: Call option::none(): Option - 62: StLoc[12](loc10: Option) + 53: MoveLoc[0](Arg0: &mut S) + 54: Pop + 55: Call option::none(): Option + 56: StLoc[9](loc7: Option) B11: - 63: MoveLoc[12](loc10: Option) - 64: StLoc[13](loc11: Option) - 65: MoveLoc[13](loc11: Option) - 66: Ret + 57: MoveLoc[9](loc7: Option) + 58: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.opt.exp index d04e138c63dba..99ccbf85e8dfb 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/bug_14762.opt.exp @@ -24,8 +24,7 @@ L4: loc2: u64 L5: loc3: u64 L6: loc4: u64 L7: loc5: u64 -L8: loc6: bool -L9: loc7: Option +L8: loc6: Option B0: 0: CopyLoc[0](Arg0: &mut S) 1: ImmBorrowField[0](S.entries: vector) @@ -54,7 +53,7 @@ B3: 21: ReadRef 22: CopyLoc[1](Arg1: vector) 23: Eq - 24: BrFalse(51) + 24: BrFalse(49) B4: 25: LdTrue 26: StLoc[3](loc1: bool) @@ -67,33 +66,29 @@ B5: 32: MoveLoc[3](loc1: bool) 33: MoveLoc[4](loc2: u64) 34: StLoc[7](loc5: u64) - 35: StLoc[8](loc6: bool) - 36: MoveLoc[8](loc6: bool) - 37: BrFalse(46) + 35: BrFalse(44) B6: - 38: MoveLoc[0](Arg0: &mut S) - 39: MutBorrowField[0](S.entries: vector) - 40: MoveLoc[7](loc5: u64) - 41: Call vector::remove(&mut vector, u64): T - 42: Call option::some(T): Option - 43: StLoc[9](loc7: Option) + 36: MoveLoc[0](Arg0: &mut S) + 37: MutBorrowField[0](S.entries: vector) + 38: MoveLoc[7](loc5: u64) + 39: Call vector::remove(&mut vector, u64): T + 40: Call option::some(T): Option + 41: StLoc[8](loc6: Option) B7: - 44: MoveLoc[9](loc7: Option) - 45: Ret + 42: MoveLoc[8](loc6: Option) + 43: Ret B8: - 46: MoveLoc[0](Arg0: &mut S) - 47: Pop - 48: Call option::none(): Option - 49: StLoc[9](loc7: Option) - 50: Branch(44) + 44: MoveLoc[0](Arg0: &mut S) + 45: Pop + 46: Call option::none(): Option + 47: StLoc[8](loc6: Option) + 48: Branch(42) B9: - 51: LdU64(1) - 52: StLoc[7](loc5: u64) - 53: MoveLoc[5](loc3: u64) - 54: MoveLoc[7](loc5: u64) - 55: Add - 56: StLoc[5](loc3: u64) - 57: Branch(12) + 49: MoveLoc[5](loc3: u64) + 50: LdU64(1) + 51: Add + 52: StLoc[5](loc3: u64) + 53: Branch(12) } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/const.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/const.exp index e3c70827b11a7..8c6bd9d68e95d 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/const.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/const.exp @@ -178,12 +178,9 @@ B0: 33: Ret } u(Arg0: Ty0): Ty0 /* def_idx: 1 */ { -L1: loc0: Ty0 B0: 0: MoveLoc[0](Arg0: Ty0) - 1: StLoc[1](loc0: Ty0) - 2: MoveLoc[1](loc0: Ty0) - 3: Ret + 1: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.exp new file mode 100644 index 0000000000000..677926f405b44 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.exp @@ -0,0 +1,28 @@ + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +bar(Arg0: u64, Arg1: u64, Arg2: u64, Arg3: u64, Arg4: u64, Arg5: u64) /* def_idx: 0 */ { +B0: + 0: Ret +} +one(): u64 /* def_idx: 1 */ { +B0: + 0: LdU64(1) + 1: Ret +} +public test(Arg0: u64) /* def_idx: 2 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: Call one(): u64 + 2: Call one(): u64 + 3: Call one(): u64 + 4: Call one(): u64 + 5: Call one(): u64 + 6: Call bar(u64, u64, u64, u64, u64, u64) + 7: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.move b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.move new file mode 100644 index 0000000000000..bcff6578e1e07 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.move @@ -0,0 +1,11 @@ +module 0xc0ffee::m { + fun one(): u64 { + 1 + } + + fun bar(_a: u64, _b: u64, _c: u64, _d: u64, _e: u64, _f: u64) {} + + public fun test(x: u64) { + bar(x, one(), one(), one(), one(), one()); + } +} diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.opt.exp new file mode 100644 index 0000000000000..677926f405b44 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_01.opt.exp @@ -0,0 +1,28 @@ + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +bar(Arg0: u64, Arg1: u64, Arg2: u64, Arg3: u64, Arg4: u64, Arg5: u64) /* def_idx: 0 */ { +B0: + 0: Ret +} +one(): u64 /* def_idx: 1 */ { +B0: + 0: LdU64(1) + 1: Ret +} +public test(Arg0: u64) /* def_idx: 2 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: Call one(): u64 + 2: Call one(): u64 + 3: Call one(): u64 + 4: Call one(): u64 + 5: Call one(): u64 + 6: Call bar(u64, u64, u64, u64, u64, u64) + 7: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.exp new file mode 100644 index 0000000000000..8f98258bd77db --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.exp @@ -0,0 +1,17 @@ + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test(Arg0: u64, Arg1: u64): u64 /* def_idx: 0 */ { +B0: + 0: CopyLoc[0](Arg0: u64) + 1: MoveLoc[1](Arg1: u64) + 2: MoveLoc[0](Arg0: u64) + 3: Mul + 4: Add + 5: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.move b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.move new file mode 100644 index 0000000000000..cd16357181f46 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.move @@ -0,0 +1,5 @@ +module 0xc0ffee::m { + fun test(x: u64, y: u64): u64 { + x + (y * x) + } +} diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.opt.exp new file mode 100644 index 0000000000000..8f98258bd77db --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/eager_push_02.opt.exp @@ -0,0 +1,17 @@ + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test(Arg0: u64, Arg1: u64): u64 /* def_idx: 0 */ { +B0: + 0: CopyLoc[0](Arg0: u64) + 1: MoveLoc[1](Arg1: u64) + 2: MoveLoc[0](Arg0: u64) + 3: Mul + 4: Add + 5: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/fields.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/fields.exp index 70d71108d70db..3337fb03ac051 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/fields.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/fields.exp @@ -28,7 +28,6 @@ B0: } write_local_direct(): S /* def_idx: 2 */ { L0: loc0: S -L1: loc1: S B0: 0: LdU64(0) 1: LdU64(0) @@ -41,16 +40,13 @@ B0: 8: MutBorrowField[1](T.h: u64) 9: WriteRef 10: MoveLoc[0](loc0: S) - 11: StLoc[1](loc1: S) - 12: MoveLoc[1](loc1: S) - 13: Ret + 11: Ret } write_local_via_ref(): S /* def_idx: 3 */ { L0: loc0: S L1: loc1: u64 L2: loc2: &mut S L3: loc3: &mut u64 -L4: loc4: S B0: 0: LdU64(0) 1: LdU64(0) @@ -69,9 +65,7 @@ B0: 14: MoveLoc[3](loc3: &mut u64) 15: WriteRef 16: MoveLoc[0](loc0: S) - 17: StLoc[4](loc4: S) - 18: MoveLoc[4](loc4: S) - 19: Ret + 17: Ret } write_param(Arg0: &mut S) /* def_idx: 4 */ { B0: @@ -83,7 +77,6 @@ B0: 5: Ret } write_val(Arg0: S): S /* def_idx: 5 */ { -L1: loc0: S B0: 0: LdU64(42) 1: MutBorrowLoc[0](Arg0: S) @@ -91,9 +84,7 @@ B0: 3: MutBorrowField[1](T.h: u64) 4: WriteRef 5: MoveLoc[0](Arg0: S) - 6: StLoc[1](loc0: S) - 7: MoveLoc[1](loc0: S) - 8: Ret + 6: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/fields.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/fields.opt.exp index bddcd323020fa..180ffa3a427e6 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/fields.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/fields.opt.exp @@ -44,9 +44,7 @@ B0: } write_local_via_ref(): S /* def_idx: 3 */ { L0: loc0: S -L1: loc1: u64 -L2: loc2: &mut S -L3: loc3: &mut u64 +L1: loc1: &mut S B0: 0: LdU64(0) 1: LdU64(0) @@ -54,11 +52,11 @@ B0: 3: Pack[1](S) 4: StLoc[0](loc0: S) 5: MutBorrowLoc[0](loc0: S) - 6: MutBorrowField[0](S.g: T) - 7: MutBorrowField[1](T.h: u64) - 8: StLoc[3](loc3: &mut u64) - 9: LdU64(42) - 10: MoveLoc[3](loc3: &mut u64) + 6: StLoc[1](loc1: &mut S) + 7: LdU64(42) + 8: MoveLoc[1](loc1: &mut S) + 9: MutBorrowField[0](S.g: T) + 10: MutBorrowField[1](T.h: u64) 11: WriteRef 12: MoveLoc[0](loc0: S) 13: Ret diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/framework_reduced_06.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/framework_reduced_06.exp index 92d40d16fd075..d3f45765c6ccf 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/framework_reduced_06.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/framework_reduced_06.exp @@ -16,20 +16,11 @@ B0: 4: Ret } f1(Arg0: &mut S, Arg1: u64, Arg2: address): &mut S * address * u64 /* def_idx: 1 */ { -L3: loc0: &mut S -L4: loc1: address -L5: loc2: u64 B0: 0: MoveLoc[0](Arg0: &mut S) - 1: StLoc[3](loc0: &mut S) - 2: MoveLoc[2](Arg2: address) - 3: StLoc[4](loc1: address) - 4: MoveLoc[1](Arg1: u64) - 5: StLoc[5](loc2: u64) - 6: MoveLoc[3](loc0: &mut S) - 7: MoveLoc[4](loc1: address) - 8: MoveLoc[5](loc2: u64) - 9: Ret + 1: MoveLoc[2](Arg2: address) + 2: MoveLoc[1](Arg1: u64) + 3: Ret } f2(Arg0: address, Arg1: &mut S, Arg2: address, Arg3: u64, Arg4: &mut S) /* def_idx: 2 */ { B0: @@ -47,37 +38,40 @@ B0: } foo(Arg0: address, Arg1: &mut S, Arg2: &mut S): u64 /* def_idx: 4 */ { L3: loc0: u64 -L4: loc1: u64 +L4: loc1: address L5: loc2: address L6: loc3: &mut S -L7: loc4: &u64 -L8: loc5: u64 +L7: loc4: u64 +L8: loc5: address +L9: loc6: &mut S B0: - 0: LdU64(1) - 1: StLoc[3](loc0: u64) - 2: MoveLoc[1](Arg1: &mut S) - 3: MoveLoc[3](loc0: u64) - 4: MoveLoc[0](Arg0: address) - 5: Call f1(&mut S, u64, address): &mut S * address * u64 - 6: StLoc[4](loc1: u64) + 0: MoveLoc[1](Arg1: &mut S) + 1: LdU64(1) + 2: MoveLoc[0](Arg0: address) + 3: Call f1(&mut S, u64, address): &mut S * address * u64 + 4: StLoc[3](loc0: u64) + 5: StLoc[4](loc1: address) + 6: CopyLoc[4](loc1: address) 7: StLoc[5](loc2: address) 8: StLoc[6](loc3: &mut S) - 9: CopyLoc[5](loc2: address) - 10: CopyLoc[6](loc3: &mut S) - 11: MoveLoc[5](loc2: address) - 12: CopyLoc[4](loc1: u64) - 13: MoveLoc[2](Arg2: &mut S) - 14: Call f2(address, &mut S, address, u64, &mut S) - 15: MoveLoc[6](loc3: &mut S) - 16: ImmBorrowField[0](S.g: u64) - 17: StLoc[7](loc4: &u64) - 18: CopyLoc[4](loc1: u64) - 19: MoveLoc[7](loc4: &u64) - 20: Call f3(u64, &u64) - 21: MoveLoc[4](loc1: u64) - 22: StLoc[8](loc5: u64) - 23: MoveLoc[8](loc5: u64) - 24: Ret + 9: CopyLoc[6](loc3: &mut S) + 10: MoveLoc[4](loc1: address) + 11: CopyLoc[3](loc0: u64) + 12: StLoc[7](loc4: u64) + 13: StLoc[8](loc5: address) + 14: StLoc[9](loc6: &mut S) + 15: MoveLoc[5](loc2: address) + 16: MoveLoc[9](loc6: &mut S) + 17: MoveLoc[8](loc5: address) + 18: MoveLoc[7](loc4: u64) + 19: MoveLoc[2](Arg2: &mut S) + 20: Call f2(address, &mut S, address, u64, &mut S) + 21: CopyLoc[3](loc0: u64) + 22: MoveLoc[6](loc3: &mut S) + 23: ImmBorrowField[0](S.g: u64) + 24: Call f3(u64, &u64) + 25: MoveLoc[3](loc0: u64) + 26: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/framework_reduced_06.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/framework_reduced_06.opt.exp index 5daf860469de1..41776e5da98bf 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/framework_reduced_06.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/framework_reduced_06.opt.exp @@ -38,7 +38,9 @@ B0: } foo(Arg0: address, Arg1: &mut S, Arg2: &mut S): u64 /* def_idx: 4 */ { L3: loc0: u64 -L4: loc1: &u64 +L4: loc1: u64 +L5: loc2: &mut S +L6: loc3: address B0: 0: MoveLoc[1](Arg1: &mut S) 1: LdU64(1) @@ -49,15 +51,15 @@ B0: 6: StLoc[1](Arg1: &mut S) 7: CopyLoc[0](Arg0: address) 8: CopyLoc[1](Arg1: &mut S) - 9: MoveLoc[0](Arg0: address) - 10: CopyLoc[3](loc0: u64) - 11: MoveLoc[2](Arg2: &mut S) - 12: Call f2(address, &mut S, address, u64, &mut S) - 13: MoveLoc[1](Arg1: &mut S) - 14: ImmBorrowField[0](S.g: u64) - 15: StLoc[4](loc1: &u64) - 16: CopyLoc[3](loc0: u64) - 17: MoveLoc[4](loc1: &u64) + 9: CopyLoc[3](loc0: u64) + 10: StLoc[4](loc1: u64) + 11: MoveLoc[0](Arg0: address) + 12: MoveLoc[4](loc1: u64) + 13: MoveLoc[2](Arg2: &mut S) + 14: Call f2(address, &mut S, address, u64, &mut S) + 15: CopyLoc[3](loc0: u64) + 16: MoveLoc[1](Arg1: &mut S) + 17: ImmBorrowField[0](S.g: u64) 18: Call f3(u64, &u64) 19: MoveLoc[3](loc0: u64) 20: Ret diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/generic_call.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/generic_call.exp index fc2e7c3271071..953ed238d97bb 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/generic_call.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/generic_call.exp @@ -11,12 +11,9 @@ B0: 2: Ret } identity(Arg0: Ty0): Ty0 /* def_idx: 1 */ { -L1: loc0: Ty0 B0: 0: MoveLoc[0](Arg0: Ty0) - 1: StLoc[1](loc0: Ty0) - 2: MoveLoc[1](loc0: Ty0) - 3: Ret + 1: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/globals.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/globals.exp index bd045f1d4f0fe..b844357e1f32c 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/globals.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/globals.exp @@ -21,15 +21,12 @@ B0: 2: Ret } publish(Arg0: &signer) /* def_idx: 1 */ { -L1: loc0: R B0: - 0: LdU64(1) - 1: Pack[0](R) - 2: StLoc[1](loc0: R) - 3: MoveLoc[0](Arg0: &signer) - 4: MoveLoc[1](loc0: R) - 5: MoveTo[0](R) - 6: Ret + 0: MoveLoc[0](Arg0: &signer) + 1: LdU64(1) + 2: Pack[0](R) + 3: MoveTo[0](R) + 4: Ret } read(Arg0: address): u64 /* def_idx: 2 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/globals.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/globals.opt.exp index a923eb6daffcf..602dc61fed548 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/globals.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/globals.opt.exp @@ -21,15 +21,12 @@ B0: 2: Ret } publish(Arg0: &signer) /* def_idx: 1 */ { -L1: loc0: R B0: - 0: LdU64(1) - 1: Pack[0](R) - 2: StLoc[1](loc0: R) - 3: MoveLoc[0](Arg0: &signer) - 4: MoveLoc[1](loc0: R) - 5: MoveTo[0](R) - 6: Ret + 0: MoveLoc[0](Arg0: &signer) + 1: LdU64(1) + 2: Pack[0](R) + 3: MoveTo[0](R) + 4: Ret } read(Arg0: address): u64 /* def_idx: 2 */ { B0: @@ -41,14 +38,13 @@ B0: } write(Arg0: address, Arg1: u64): u64 /* def_idx: 3 */ { L2: loc0: &mut R -L3: loc1: &mut u64 B0: 0: MoveLoc[0](Arg0: address) 1: MutBorrowGlobal[0](R) - 2: MutBorrowField[0](R.f: u64) - 3: StLoc[3](loc1: &mut u64) - 4: LdU64(2) - 5: MoveLoc[3](loc1: &mut u64) + 2: StLoc[2](loc0: &mut R) + 3: LdU64(2) + 4: MoveLoc[2](loc0: &mut R) + 5: MutBorrowField[0](R.f: u64) 6: WriteRef 7: LdU64(9) 8: Ret diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/if_else.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/if_else.exp index 905454c60a8de..7e6a2899f6d6a 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/if_else.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/if_else.exp @@ -6,81 +6,63 @@ module 42.if_else { if_else(Arg0: bool, Arg1: u64): u64 /* def_idx: 0 */ { L2: loc0: u64 -L3: loc1: u64 -L4: loc2: u64 B0: 0: MoveLoc[0](Arg0: bool) - 1: BrFalse(9) + 1: BrFalse(7) B1: - 2: LdU64(1) - 3: StLoc[2](loc0: u64) - 4: MoveLoc[1](Arg1: u64) - 5: MoveLoc[2](loc0: u64) - 6: Add - 7: StLoc[3](loc1: u64) - 8: Branch(15) + 2: MoveLoc[1](Arg1: u64) + 3: LdU64(1) + 4: Add + 5: StLoc[2](loc0: u64) + 6: Branch(11) B2: - 9: LdU64(1) - 10: StLoc[4](loc2: u64) - 11: MoveLoc[1](Arg1: u64) - 12: MoveLoc[4](loc2: u64) - 13: Sub - 14: StLoc[3](loc1: u64) + 7: MoveLoc[1](Arg1: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[2](loc0: u64) B3: - 15: MoveLoc[3](loc1: u64) - 16: Ret + 11: MoveLoc[2](loc0: u64) + 12: Ret } if_else_nested(Arg0: bool, Arg1: u64): u64 /* def_idx: 1 */ { L2: loc0: u64 L3: loc1: u64 L4: loc2: u64 -L5: loc3: u64 -L6: loc4: u64 -L7: loc5: u64 -L8: loc6: u64 B0: 0: MoveLoc[0](Arg0: bool) - 1: BrFalse(9) + 1: BrFalse(7) B1: - 2: LdU64(1) - 3: StLoc[2](loc0: u64) - 4: CopyLoc[1](Arg1: u64) - 5: MoveLoc[2](loc0: u64) - 6: Add - 7: StLoc[3](loc1: u64) - 8: Branch(15) + 2: CopyLoc[1](Arg1: u64) + 3: LdU64(1) + 4: Add + 5: StLoc[2](loc0: u64) + 6: Branch(11) B2: - 9: LdU64(1) - 10: StLoc[4](loc2: u64) - 11: CopyLoc[1](Arg1: u64) - 12: MoveLoc[4](loc2: u64) - 13: Sub - 14: StLoc[3](loc1: u64) + 7: CopyLoc[1](Arg1: u64) + 8: LdU64(1) + 9: Sub + 10: StLoc[2](loc0: u64) B3: - 15: LdU64(10) - 16: StLoc[5](loc3: u64) - 17: MoveLoc[3](loc1: u64) - 18: MoveLoc[5](loc3: u64) - 19: Gt - 20: BrFalse(28) + 11: LdU64(10) + 12: StLoc[3](loc1: u64) + 13: MoveLoc[2](loc0: u64) + 14: MoveLoc[3](loc1: u64) + 15: Gt + 16: BrFalse(22) B4: - 21: LdU64(2) - 22: StLoc[6](loc4: u64) - 23: MoveLoc[1](Arg1: u64) - 24: MoveLoc[6](loc4: u64) - 25: Mul - 26: StLoc[7](loc5: u64) - 27: Branch(34) + 17: MoveLoc[1](Arg1: u64) + 18: LdU64(2) + 19: Mul + 20: StLoc[4](loc2: u64) + 21: Branch(26) B5: - 28: LdU64(2) - 29: StLoc[8](loc6: u64) - 30: MoveLoc[1](Arg1: u64) - 31: MoveLoc[8](loc6: u64) - 32: Div - 33: StLoc[7](loc5: u64) + 22: MoveLoc[1](Arg1: u64) + 23: LdU64(2) + 24: Div + 25: StLoc[4](loc2: u64) B6: - 34: MoveLoc[7](loc5: u64) - 35: Ret + 26: MoveLoc[4](loc2: u64) + 27: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/if_else.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/if_else.opt.exp index 46d7ead1f3947..73a27449cd2ba 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/if_else.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/if_else.opt.exp @@ -6,7 +6,6 @@ module 42.if_else { if_else(Arg0: bool, Arg1: u64): u64 /* def_idx: 0 */ { L2: loc0: u64 -L3: loc1: u64 B0: 0: MoveLoc[0](Arg0: bool) 1: BrFalse(8) @@ -28,7 +27,6 @@ B3: if_else_nested(Arg0: bool, Arg1: u64): u64 /* def_idx: 1 */ { L2: loc0: u64 L3: loc1: u64 -L4: loc2: u64 B0: 0: MoveLoc[0](Arg0: bool) 1: BrFalse(21) diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/loop.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/loop.exp index 2548852af5529..4e092c9ac7c46 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/loop.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/loop.exp @@ -5,140 +5,101 @@ module 42.loops { nested_loop(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: - 0: LdU64(0) - 1: StLoc[1](loc0: u64) - 2: CopyLoc[0](Arg0: u64) - 3: MoveLoc[1](loc0: u64) - 4: Gt - 5: BrFalse(30) + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(0) + 2: Gt + 3: BrFalse(22) B1: - 6: LdU64(10) - 7: StLoc[2](loc1: u64) - 8: CopyLoc[0](Arg0: u64) - 9: MoveLoc[2](loc1: u64) - 10: Gt - 11: BrFalse(20) + 4: CopyLoc[0](Arg0: u64) + 5: LdU64(10) + 6: Gt + 7: BrFalse(14) B2: - 12: LdU64(1) - 13: StLoc[3](loc2: u64) - 14: MoveLoc[0](Arg0: u64) - 15: MoveLoc[3](loc2: u64) - 16: Sub - 17: StLoc[0](Arg0: u64) - 18: Branch(22) + 8: MoveLoc[0](Arg0: u64) + 9: LdU64(1) + 10: Sub + 11: StLoc[0](Arg0: u64) + 12: Branch(16) B3: - 19: Branch(21) + 13: Branch(15) B4: - 20: Branch(22) + 14: Branch(16) B5: - 21: Branch(6) + 15: Branch(4) B6: - 22: LdU64(1) - 23: StLoc[4](loc3: u64) - 24: MoveLoc[0](Arg0: u64) - 25: MoveLoc[4](loc3: u64) - 26: Sub - 27: StLoc[0](Arg0: u64) - 28: Branch(0) + 16: MoveLoc[0](Arg0: u64) + 17: LdU64(1) + 18: Sub + 19: StLoc[0](Arg0: u64) + 20: Branch(0) B7: - 29: Branch(31) + 21: Branch(23) B8: - 30: Branch(32) + 22: Branch(24) B9: - 31: Branch(0) + 23: Branch(0) B10: - 32: MoveLoc[0](Arg0: u64) - 33: StLoc[5](loc4: u64) - 34: MoveLoc[5](loc4: u64) - 35: Ret + 24: MoveLoc[0](Arg0: u64) + 25: Ret } while_loop(Arg0: u64): u64 /* def_idx: 1 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 B0: - 0: LdU64(0) - 1: StLoc[1](loc0: u64) - 2: CopyLoc[0](Arg0: u64) - 3: MoveLoc[1](loc0: u64) - 4: Gt - 5: BrFalse(13) + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(0) + 2: Gt + 3: BrFalse(9) B1: - 6: LdU64(1) - 7: StLoc[2](loc1: u64) - 8: MoveLoc[0](Arg0: u64) - 9: MoveLoc[2](loc1: u64) - 10: Sub - 11: StLoc[0](Arg0: u64) - 12: Branch(14) + 4: MoveLoc[0](Arg0: u64) + 5: LdU64(1) + 6: Sub + 7: StLoc[0](Arg0: u64) + 8: Branch(10) B2: - 13: Branch(15) + 9: Branch(11) B3: - 14: Branch(0) + 10: Branch(0) B4: - 15: MoveLoc[0](Arg0: u64) - 16: StLoc[3](loc2: u64) - 17: MoveLoc[3](loc2: u64) - 18: Ret + 11: MoveLoc[0](Arg0: u64) + 12: Ret } while_loop_with_break_and_continue(Arg0: u64): u64 /* def_idx: 2 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: - 0: LdU64(0) - 1: StLoc[1](loc0: u64) - 2: CopyLoc[0](Arg0: u64) - 3: MoveLoc[1](loc0: u64) - 4: Gt - 5: BrFalse(29) + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(0) + 2: Gt + 3: BrFalse(21) B1: - 6: LdU64(42) - 7: StLoc[2](loc1: u64) - 8: CopyLoc[0](Arg0: u64) - 9: MoveLoc[2](loc1: u64) - 10: Eq - 11: BrFalse(14) + 4: CopyLoc[0](Arg0: u64) + 5: LdU64(42) + 6: Eq + 7: BrFalse(10) B2: - 12: Branch(31) + 8: Branch(23) B3: - 13: Branch(14) + 9: Branch(10) B4: - 14: LdU64(21) - 15: StLoc[3](loc2: u64) - 16: CopyLoc[0](Arg0: u64) - 17: MoveLoc[3](loc2: u64) - 18: Eq - 19: BrFalse(22) + 10: CopyLoc[0](Arg0: u64) + 11: LdU64(21) + 12: Eq + 13: BrFalse(16) B5: - 20: Branch(0) + 14: Branch(0) B6: - 21: Branch(22) + 15: Branch(16) B7: - 22: LdU64(1) - 23: StLoc[4](loc3: u64) - 24: MoveLoc[0](Arg0: u64) - 25: MoveLoc[4](loc3: u64) - 26: Sub - 27: StLoc[0](Arg0: u64) - 28: Branch(30) + 16: MoveLoc[0](Arg0: u64) + 17: LdU64(1) + 18: Sub + 19: StLoc[0](Arg0: u64) + 20: Branch(22) B8: - 29: Branch(31) + 21: Branch(23) B9: - 30: Branch(0) + 22: Branch(0) B10: - 31: MoveLoc[0](Arg0: u64) - 32: StLoc[5](loc4: u64) - 33: MoveLoc[5](loc4: u64) - 34: Ret + 23: MoveLoc[0](Arg0: u64) + 24: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/loop.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/loop.opt.exp index c06febb790553..9c56b091164f6 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/loop.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/loop.opt.exp @@ -5,7 +5,6 @@ module 42.loops { nested_loop(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: LdU64(0) @@ -34,7 +33,6 @@ B5: 19: Ret } while_loop(Arg0: u64): u64 /* def_idx: 1 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: LdU64(0) @@ -51,7 +49,6 @@ B2: 10: Ret } while_loop_with_break_and_continue(Arg0: u64): u64 /* def_idx: 2 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: LdU64(0) diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/multi_use.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/multi_use.exp index f88ec059166e4..dbad90fc3f4b2 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/multi_use.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/multi_use.exp @@ -9,16 +9,13 @@ B0: 0: Ret } public test(Arg0: u64) /* def_idx: 1 */ { -L1: loc0: u64 B0: - 0: LdU64(1) - 1: StLoc[1](loc0: u64) - 2: CopyLoc[0](Arg0: u64) - 3: CopyLoc[0](Arg0: u64) - 4: MoveLoc[1](loc0: u64) - 5: MoveLoc[0](Arg0: u64) - 6: Call consume(u64, u64, u64, u64) - 7: Ret + 0: CopyLoc[0](Arg0: u64) + 1: CopyLoc[0](Arg0: u64) + 2: LdU64(1) + 3: MoveLoc[0](Arg0: u64) + 4: Call consume(u64, u64, u64, u64) + 5: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/multi_use.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/multi_use.opt.exp index a75676beab4a8..dbad90fc3f4b2 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/multi_use.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/multi_use.opt.exp @@ -9,7 +9,6 @@ B0: 0: Ret } public test(Arg0: u64) /* def_idx: 1 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: CopyLoc[0](Arg0: u64) diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/operators.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/operators.exp index d5d0dc85afcf0..313ac0f4abb86 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/operators.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/operators.exp @@ -5,25 +5,19 @@ module 42.operators { arithm(Arg0: u64, Arg1: u64): u64 /* def_idx: 0 */ { -L2: loc0: u64 -L3: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: CopyLoc[1](Arg1: u64) - 2: Sub - 3: StLoc[2](loc0: u64) - 4: CopyLoc[1](Arg1: u64) - 5: MoveLoc[2](loc0: u64) - 6: Div - 7: MoveLoc[1](Arg1: u64) - 8: Mul - 9: CopyLoc[0](Arg0: u64) - 10: Mod - 11: StLoc[3](loc1: u64) - 12: MoveLoc[0](Arg0: u64) - 13: MoveLoc[3](loc1: u64) - 14: Add - 15: Ret + 2: CopyLoc[0](Arg0: u64) + 3: CopyLoc[1](Arg1: u64) + 4: Sub + 5: Div + 6: MoveLoc[1](Arg1: u64) + 7: Mul + 8: MoveLoc[0](Arg0: u64) + 9: Mod + 10: Add + 11: Ret } bits(Arg0: u64, Arg1: u8): u64 /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/operators.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/operators.opt.exp index 3d429474d155e..94d263a3c0343 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/operators.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/operators.opt.exp @@ -5,24 +5,19 @@ module 42.operators { arithm(Arg0: u64, Arg1: u64): u64 /* def_idx: 0 */ { -L2: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: CopyLoc[1](Arg1: u64) - 2: Sub - 3: StLoc[2](loc0: u64) - 4: CopyLoc[1](Arg1: u64) - 5: MoveLoc[2](loc0: u64) - 6: Div - 7: MoveLoc[1](Arg1: u64) - 8: Mul - 9: CopyLoc[0](Arg0: u64) - 10: Mod - 11: StLoc[1](Arg1: u64) - 12: MoveLoc[0](Arg0: u64) - 13: MoveLoc[1](Arg1: u64) - 14: Add - 15: Ret + 2: CopyLoc[0](Arg0: u64) + 3: CopyLoc[1](Arg1: u64) + 4: Sub + 5: Div + 6: MoveLoc[1](Arg1: u64) + 7: Mul + 8: MoveLoc[0](Arg0: u64) + 9: Mod + 10: Add + 11: Ret } bits(Arg0: u64, Arg1: u8): u64 /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_01.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_01.exp index d036275676863..2c32c62eca7a1 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_01.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_01.exp @@ -9,101 +9,44 @@ B0: 0: Ret } public test01(Arg0: u64) /* def_idx: 1 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: - 0: LdU64(1) - 1: LdU64(2) - 2: LdU64(3) - 3: LdU64(4) - 4: LdU64(5) - 5: StLoc[1](loc0: u64) - 6: StLoc[2](loc1: u64) - 7: StLoc[3](loc2: u64) - 8: StLoc[4](loc3: u64) - 9: StLoc[5](loc4: u64) - 10: MoveLoc[0](Arg0: u64) - 11: MoveLoc[5](loc4: u64) - 12: MoveLoc[4](loc3: u64) - 13: MoveLoc[3](loc2: u64) - 14: MoveLoc[2](loc1: u64) - 15: MoveLoc[1](loc0: u64) - 16: Call consume(u64, u64, u64, u64, u64, u64) - 17: Ret + 0: MoveLoc[0](Arg0: u64) + 1: LdU64(1) + 2: LdU64(2) + 3: LdU64(3) + 4: LdU64(4) + 5: LdU64(5) + 6: Call consume(u64, u64, u64, u64, u64, u64) + 7: Ret } public test02(Arg0: u64) /* def_idx: 2 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 B0: - 0: LdU64(1) - 1: LdU64(2) - 2: LdU64(4) - 3: LdU64(5) - 4: StLoc[1](loc0: u64) - 5: StLoc[2](loc1: u64) - 6: StLoc[3](loc2: u64) - 7: StLoc[4](loc3: u64) - 8: CopyLoc[0](Arg0: u64) - 9: MoveLoc[4](loc3: u64) - 10: MoveLoc[3](loc2: u64) - 11: MoveLoc[0](Arg0: u64) - 12: MoveLoc[2](loc1: u64) - 13: MoveLoc[1](loc0: u64) - 14: Call consume(u64, u64, u64, u64, u64, u64) - 15: Ret + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(1) + 2: LdU64(2) + 3: MoveLoc[0](Arg0: u64) + 4: LdU64(4) + 5: LdU64(5) + 6: Call consume(u64, u64, u64, u64, u64, u64) + 7: Ret } public test03(Arg0: u64) /* def_idx: 3 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 -L6: loc5: u64 -L7: loc6: u64 -L8: loc7: u64 -L9: loc8: u64 -L10: loc9: u64 B0: - 0: LdU64(1) - 1: LdU64(2) - 2: LdU64(3) - 3: LdU64(4) - 4: LdU64(5) - 5: StLoc[1](loc0: u64) - 6: StLoc[2](loc1: u64) - 7: StLoc[3](loc2: u64) - 8: StLoc[4](loc3: u64) - 9: StLoc[5](loc4: u64) - 10: CopyLoc[0](Arg0: u64) - 11: MoveLoc[5](loc4: u64) - 12: MoveLoc[4](loc3: u64) - 13: MoveLoc[3](loc2: u64) - 14: MoveLoc[2](loc1: u64) - 15: MoveLoc[1](loc0: u64) - 16: Call consume(u64, u64, u64, u64, u64, u64) - 17: LdU64(1) - 18: LdU64(2) - 19: LdU64(3) - 20: LdU64(4) - 21: LdU64(5) - 22: StLoc[6](loc5: u64) - 23: StLoc[7](loc6: u64) - 24: StLoc[8](loc7: u64) - 25: StLoc[9](loc8: u64) - 26: StLoc[10](loc9: u64) - 27: MoveLoc[0](Arg0: u64) - 28: MoveLoc[10](loc9: u64) - 29: MoveLoc[9](loc8: u64) - 30: MoveLoc[8](loc7: u64) - 31: MoveLoc[7](loc6: u64) - 32: MoveLoc[6](loc5: u64) - 33: Call consume(u64, u64, u64, u64, u64, u64) - 34: Ret + 0: CopyLoc[0](Arg0: u64) + 1: LdU64(1) + 2: LdU64(2) + 3: LdU64(3) + 4: LdU64(4) + 5: LdU64(5) + 6: Call consume(u64, u64, u64, u64, u64, u64) + 7: MoveLoc[0](Arg0: u64) + 8: LdU64(1) + 9: LdU64(2) + 10: LdU64(3) + 11: LdU64(4) + 12: LdU64(5) + 13: Call consume(u64, u64, u64, u64, u64, u64) + 14: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_01.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_01.opt.exp index 8503b6e5d38c3..2c32c62eca7a1 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_01.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_01.opt.exp @@ -9,11 +9,6 @@ B0: 0: Ret } public test01(Arg0: u64) /* def_idx: 1 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: 0: MoveLoc[0](Arg0: u64) 1: LdU64(1) @@ -25,10 +20,6 @@ B0: 7: Ret } public test02(Arg0: u64) /* def_idx: 2 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: LdU64(1) @@ -40,11 +31,6 @@ B0: 7: Ret } public test03(Arg0: u64) /* def_idx: 3 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: LdU64(1) diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_02.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_02.exp index 07e0c3132d79f..ffe373d4103a1 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_02.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_02.exp @@ -29,152 +29,65 @@ B0: 4: Ret } public test01(Arg0: &S) /* def_idx: 3 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: - 0: LdU64(1) - 1: LdU64(2) - 2: LdU64(3) - 3: LdU64(4) - 4: LdU64(5) - 5: StLoc[1](loc0: u64) - 6: StLoc[2](loc1: u64) - 7: StLoc[3](loc2: u64) - 8: StLoc[4](loc3: u64) - 9: StLoc[5](loc4: u64) - 10: MoveLoc[0](Arg0: &S) - 11: MoveLoc[5](loc4: u64) - 12: MoveLoc[4](loc3: u64) - 13: MoveLoc[3](loc2: u64) - 14: MoveLoc[2](loc1: u64) - 15: MoveLoc[1](loc0: u64) - 16: Call consume1(&S, u64, u64, u64, u64, u64) - 17: Ret + 0: MoveLoc[0](Arg0: &S) + 1: LdU64(1) + 2: LdU64(2) + 3: LdU64(3) + 4: LdU64(4) + 5: LdU64(5) + 6: Call consume1(&S, u64, u64, u64, u64, u64) + 7: Ret } public test02(Arg0: &S) /* def_idx: 4 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 B0: - 0: LdU64(1) - 1: LdU64(2) - 2: LdU64(4) - 3: LdU64(5) - 4: StLoc[1](loc0: u64) - 5: StLoc[2](loc1: u64) - 6: StLoc[3](loc2: u64) - 7: StLoc[4](loc3: u64) - 8: CopyLoc[0](Arg0: &S) - 9: MoveLoc[4](loc3: u64) - 10: MoveLoc[3](loc2: u64) - 11: MoveLoc[0](Arg0: &S) - 12: MoveLoc[2](loc1: u64) - 13: MoveLoc[1](loc0: u64) - 14: Call consume2(&S, u64, u64, &S, u64, u64) - 15: Ret + 0: CopyLoc[0](Arg0: &S) + 1: LdU64(1) + 2: LdU64(2) + 3: MoveLoc[0](Arg0: &S) + 4: LdU64(4) + 5: LdU64(5) + 6: Call consume2(&S, u64, u64, &S, u64, u64) + 7: Ret } public test03(Arg0: &S) /* def_idx: 5 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 -L6: loc5: u64 -L7: loc6: u64 -L8: loc7: u64 -L9: loc8: u64 -L10: loc9: u64 B0: - 0: LdU64(1) - 1: LdU64(2) - 2: LdU64(3) - 3: LdU64(4) - 4: LdU64(5) - 5: StLoc[1](loc0: u64) - 6: StLoc[2](loc1: u64) - 7: StLoc[3](loc2: u64) - 8: StLoc[4](loc3: u64) - 9: StLoc[5](loc4: u64) - 10: CopyLoc[0](Arg0: &S) - 11: MoveLoc[5](loc4: u64) - 12: MoveLoc[4](loc3: u64) - 13: MoveLoc[3](loc2: u64) - 14: MoveLoc[2](loc1: u64) - 15: MoveLoc[1](loc0: u64) - 16: Call consume1(&S, u64, u64, u64, u64, u64) - 17: LdU64(1) - 18: LdU64(2) - 19: LdU64(3) - 20: LdU64(4) - 21: LdU64(5) - 22: StLoc[6](loc5: u64) - 23: StLoc[7](loc6: u64) - 24: StLoc[8](loc7: u64) - 25: StLoc[9](loc8: u64) - 26: StLoc[10](loc9: u64) - 27: MoveLoc[0](Arg0: &S) - 28: MoveLoc[10](loc9: u64) - 29: MoveLoc[9](loc8: u64) - 30: MoveLoc[8](loc7: u64) - 31: MoveLoc[7](loc6: u64) - 32: MoveLoc[6](loc5: u64) - 33: Call consume1(&S, u64, u64, u64, u64, u64) - 34: Ret + 0: CopyLoc[0](Arg0: &S) + 1: LdU64(1) + 2: LdU64(2) + 3: LdU64(3) + 4: LdU64(4) + 5: LdU64(5) + 6: Call consume1(&S, u64, u64, u64, u64, u64) + 7: MoveLoc[0](Arg0: &S) + 8: LdU64(1) + 9: LdU64(2) + 10: LdU64(3) + 11: LdU64(4) + 12: LdU64(5) + 13: Call consume1(&S, u64, u64, u64, u64, u64) + 14: Ret } public test04(Arg0: &S) /* def_idx: 6 */ { -L1: loc0: u64 -L2: loc1: &u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 -L6: loc5: u64 -L7: loc6: u64 -L8: loc7: u64 -L9: loc8: u64 -L10: loc9: u64 B0: - 0: LdU64(1) - 1: LdU64(2) - 2: LdU64(3) - 3: CopyLoc[0](Arg0: &S) - 4: ImmBorrowField[0](S.x: u64) - 5: LdU64(5) - 6: StLoc[1](loc0: u64) - 7: StLoc[2](loc1: &u64) - 8: StLoc[3](loc2: u64) - 9: StLoc[4](loc3: u64) - 10: StLoc[5](loc4: u64) - 11: CopyLoc[0](Arg0: &S) - 12: MoveLoc[5](loc4: u64) - 13: MoveLoc[4](loc3: u64) - 14: MoveLoc[3](loc2: u64) - 15: MoveLoc[2](loc1: &u64) - 16: MoveLoc[1](loc0: u64) - 17: Call consume3(&S, u64, u64, u64, &u64, u64) - 18: LdU64(1) - 19: LdU64(2) - 20: LdU64(3) - 21: CopyLoc[0](Arg0: &S) - 22: ImmBorrowField[0](S.x: u64) - 23: ReadRef - 24: LdU64(5) - 25: StLoc[6](loc5: u64) - 26: StLoc[7](loc6: u64) - 27: StLoc[8](loc7: u64) - 28: StLoc[9](loc8: u64) - 29: StLoc[10](loc9: u64) - 30: MoveLoc[0](Arg0: &S) - 31: MoveLoc[10](loc9: u64) - 32: MoveLoc[9](loc8: u64) - 33: MoveLoc[8](loc7: u64) - 34: MoveLoc[7](loc6: u64) - 35: MoveLoc[6](loc5: u64) - 36: Call consume1(&S, u64, u64, u64, u64, u64) - 37: Ret + 0: CopyLoc[0](Arg0: &S) + 1: LdU64(1) + 2: LdU64(2) + 3: LdU64(3) + 4: CopyLoc[0](Arg0: &S) + 5: ImmBorrowField[0](S.x: u64) + 6: LdU64(5) + 7: Call consume3(&S, u64, u64, u64, &u64, u64) + 8: CopyLoc[0](Arg0: &S) + 9: LdU64(1) + 10: LdU64(2) + 11: LdU64(3) + 12: MoveLoc[0](Arg0: &S) + 13: ImmBorrowField[0](S.x: u64) + 14: ReadRef + 15: LdU64(5) + 16: Call consume1(&S, u64, u64, u64, u64, u64) + 17: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_02.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_02.opt.exp index 790b06577f4a9..ffe373d4103a1 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_02.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_02.opt.exp @@ -29,11 +29,6 @@ B0: 4: Ret } public test01(Arg0: &S) /* def_idx: 3 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: 0: MoveLoc[0](Arg0: &S) 1: LdU64(1) @@ -45,10 +40,6 @@ B0: 7: Ret } public test02(Arg0: &S) /* def_idx: 4 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 B0: 0: CopyLoc[0](Arg0: &S) 1: LdU64(1) @@ -60,11 +51,6 @@ B0: 7: Ret } public test03(Arg0: &S) /* def_idx: 5 */ { -L1: loc0: u64 -L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 B0: 0: CopyLoc[0](Arg0: &S) 1: LdU64(1) @@ -83,47 +69,25 @@ B0: 14: Ret } public test04(Arg0: &S) /* def_idx: 6 */ { -L1: loc0: u64 -L2: loc1: &u64 -L3: loc2: u64 -L4: loc3: u64 -L5: loc4: u64 -L6: loc5: u64 B0: - 0: LdU64(1) - 1: LdU64(2) - 2: LdU64(3) - 3: CopyLoc[0](Arg0: &S) - 4: ImmBorrowField[0](S.x: u64) - 5: StLoc[2](loc1: &u64) - 6: StLoc[3](loc2: u64) - 7: StLoc[4](loc3: u64) - 8: StLoc[5](loc4: u64) - 9: CopyLoc[0](Arg0: &S) - 10: MoveLoc[5](loc4: u64) - 11: MoveLoc[4](loc3: u64) - 12: MoveLoc[3](loc2: u64) - 13: MoveLoc[2](loc1: &u64) - 14: LdU64(5) - 15: Call consume3(&S, u64, u64, u64, &u64, u64) - 16: LdU64(1) - 17: LdU64(2) - 18: LdU64(3) - 19: CopyLoc[0](Arg0: &S) - 20: ImmBorrowField[0](S.x: u64) - 21: ReadRef - 22: StLoc[1](loc0: u64) - 23: StLoc[3](loc2: u64) - 24: StLoc[4](loc3: u64) - 25: StLoc[5](loc4: u64) - 26: MoveLoc[0](Arg0: &S) - 27: MoveLoc[5](loc4: u64) - 28: MoveLoc[4](loc3: u64) - 29: MoveLoc[3](loc2: u64) - 30: MoveLoc[1](loc0: u64) - 31: LdU64(5) - 32: Call consume1(&S, u64, u64, u64, u64, u64) - 33: Ret + 0: CopyLoc[0](Arg0: &S) + 1: LdU64(1) + 2: LdU64(2) + 3: LdU64(3) + 4: CopyLoc[0](Arg0: &S) + 5: ImmBorrowField[0](S.x: u64) + 6: LdU64(5) + 7: Call consume3(&S, u64, u64, u64, &u64, u64) + 8: CopyLoc[0](Arg0: &S) + 9: LdU64(1) + 10: LdU64(2) + 11: LdU64(3) + 12: MoveLoc[0](Arg0: &S) + 13: ImmBorrowField[0](S.x: u64) + 14: ReadRef + 15: LdU64(5) + 16: Call consume1(&S, u64, u64, u64, u64, u64) + 17: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_04.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_04.exp index 42e76e110a911..8b175afa80b86 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_04.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_04.exp @@ -15,20 +15,14 @@ B0: 0: Ret } public foo(Arg0: u64) /* def_idx: 2 */ { -L1: loc0: u64 -L2: loc1: u64 B0: 0: MutBorrowLoc[0](Arg0: u64) 1: Call bar(&mut u64) - 2: LdU64(1) - 3: LdU64(2) - 4: StLoc[1](loc0: u64) - 5: StLoc[2](loc1: u64) - 6: MoveLoc[0](Arg0: u64) - 7: MoveLoc[2](loc1: u64) - 8: MoveLoc[1](loc0: u64) - 9: Call baz(u64, u64, u64) - 10: Ret + 2: MoveLoc[0](Arg0: u64) + 3: LdU64(1) + 4: LdU64(2) + 5: Call baz(u64, u64, u64) + 6: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_04.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_04.opt.exp index 33b1f294dc099..8b175afa80b86 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_04.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_04.opt.exp @@ -15,8 +15,6 @@ B0: 0: Ret } public foo(Arg0: u64) /* def_idx: 2 */ { -L1: loc0: u64 -L2: loc1: u64 B0: 0: MutBorrowLoc[0](Arg0: u64) 1: Call bar(&mut u64) diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_05.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_05.exp index 3afc5c9ca65d3..baaf060b97b15 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_05.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_05.exp @@ -14,43 +14,40 @@ B0: 1: Ret } public test1(Arg0: u64) /* def_idx: 2 */ { -L1: loc0: u64 B0: - 0: LdU64(1) - 1: StLoc[1](loc0: u64) - 2: CopyLoc[0](Arg0: u64) - 3: MoveLoc[0](Arg0: u64) - 4: MoveLoc[1](loc0: u64) - 5: Call consume1(u64, u64, u64) - 6: Ret + 0: CopyLoc[0](Arg0: u64) + 1: MoveLoc[0](Arg0: u64) + 2: LdU64(1) + 3: Call consume1(u64, u64, u64) + 4: Ret } public test2(Arg0: u64) /* def_idx: 3 */ { -L1: loc0: u64 -L2: loc1: u64 B0: 0: Call one(): u64 - 1: LdU64(2) - 2: StLoc[1](loc0: u64) - 3: StLoc[2](loc1: u64) - 4: MoveLoc[2](loc1: u64) - 5: MoveLoc[0](Arg0: u64) - 6: MoveLoc[1](loc0: u64) - 7: Call consume1(u64, u64, u64) - 8: Ret + 1: MoveLoc[0](Arg0: u64) + 2: LdU64(2) + 3: Call consume1(u64, u64, u64) + 4: Ret } public test3(Arg0: u64) /* def_idx: 4 */ { L1: loc0: u64 L2: loc1: u64 +L3: loc2: u64 +L4: loc3: u64 B0: 0: Call one(): u64 - 1: LdU64(3) + 1: MoveLoc[0](Arg0: u64) 2: StLoc[1](loc0: u64) 3: StLoc[2](loc1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: MoveLoc[2](loc1: u64) - 6: MoveLoc[1](loc0: u64) - 7: Call consume1(u64, u64, u64) - 8: Ret + 4: MoveLoc[2](loc1: u64) + 5: LdU64(3) + 6: StLoc[3](loc2: u64) + 7: StLoc[4](loc3: u64) + 8: MoveLoc[1](loc0: u64) + 9: MoveLoc[4](loc3: u64) + 10: MoveLoc[3](loc2: u64) + 11: Call consume1(u64, u64, u64) + 12: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_05.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_05.opt.exp index 56cc7a5deab9c..14e6070b12992 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_05.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/opt_load_05.opt.exp @@ -14,7 +14,6 @@ B0: 1: Ret } public test1(Arg0: u64) /* def_idx: 2 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: MoveLoc[0](Arg0: u64) @@ -23,8 +22,6 @@ B0: 4: Ret } public test2(Arg0: u64) /* def_idx: 3 */ { -L1: loc0: u64 -L2: loc1: u64 B0: 0: Call one(): u64 1: MoveLoc[0](Arg0: u64) @@ -37,9 +34,9 @@ L1: loc0: u64 L2: loc1: u64 B0: 0: Call one(): u64 - 1: StLoc[2](loc1: u64) + 1: StLoc[1](loc0: u64) 2: MoveLoc[0](Arg0: u64) - 3: MoveLoc[2](loc1: u64) + 3: MoveLoc[1](loc0: u64) 4: LdU64(3) 5: Call consume1(u64, u64, u64) 6: Ret diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/pack_order.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/pack_order.exp index de87792e4d59d..c0000ffe2f26a 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/pack_order.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/pack_order.exp @@ -21,64 +21,88 @@ L3: loc0: u8 L4: loc1: u8 B0: 0: MoveLoc[0](Arg0: u8) - 1: StLoc[3](loc0: u8) - 2: MoveLoc[1](Arg1: u8) + 1: MoveLoc[1](Arg1: u8) + 2: StLoc[3](loc0: u8) 3: StLoc[4](loc1: u8) - 4: MoveLoc[3](loc0: u8) + 4: MoveLoc[4](loc1: u8) 5: MoveLoc[2](Arg2: u8) - 6: MoveLoc[4](loc1: u8) + 6: MoveLoc[3](loc0: u8) 7: Pack[0](S) 8: Ret } pack3(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 2 */ { L3: loc0: u8 +L4: loc1: u8 +L5: loc2: u8 B0: 0: MoveLoc[0](Arg0: u8) - 1: StLoc[3](loc0: u8) - 2: MoveLoc[1](Arg1: u8) - 3: MoveLoc[3](loc0: u8) - 4: MoveLoc[2](Arg2: u8) - 5: Pack[0](S) - 6: Ret + 1: MoveLoc[1](Arg1: u8) + 2: StLoc[3](loc0: u8) + 3: StLoc[4](loc1: u8) + 4: MoveLoc[4](loc1: u8) + 5: StLoc[5](loc2: u8) + 6: MoveLoc[3](loc0: u8) + 7: MoveLoc[5](loc2: u8) + 8: MoveLoc[2](Arg2: u8) + 9: Pack[0](S) + 10: Ret } pack4(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 3 */ { L3: loc0: u8 L4: loc1: u8 +L5: loc2: u8 +L6: loc3: u8 B0: 0: MoveLoc[0](Arg0: u8) - 1: StLoc[3](loc0: u8) - 2: MoveLoc[1](Arg1: u8) - 3: StLoc[4](loc1: u8) - 4: MoveLoc[2](Arg2: u8) - 5: MoveLoc[3](loc0: u8) - 6: MoveLoc[4](loc1: u8) - 7: Pack[0](S) - 8: Ret + 1: MoveLoc[1](Arg1: u8) + 2: MoveLoc[2](Arg2: u8) + 3: StLoc[3](loc0: u8) + 4: StLoc[4](loc1: u8) + 5: StLoc[5](loc2: u8) + 6: MoveLoc[5](loc2: u8) + 7: StLoc[6](loc3: u8) + 8: MoveLoc[3](loc0: u8) + 9: MoveLoc[6](loc3: u8) + 10: MoveLoc[4](loc1: u8) + 11: Pack[0](S) + 12: Ret } pack5(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 4 */ { L3: loc0: u8 +L4: loc1: u8 +L5: loc2: u8 B0: 0: MoveLoc[0](Arg0: u8) - 1: StLoc[3](loc0: u8) - 2: MoveLoc[1](Arg1: u8) - 3: MoveLoc[2](Arg2: u8) - 4: MoveLoc[3](loc0: u8) - 5: Pack[0](S) - 6: Ret + 1: MoveLoc[1](Arg1: u8) + 2: MoveLoc[2](Arg2: u8) + 3: StLoc[3](loc0: u8) + 4: StLoc[4](loc1: u8) + 5: StLoc[5](loc2: u8) + 6: MoveLoc[4](loc1: u8) + 7: MoveLoc[3](loc0: u8) + 8: MoveLoc[5](loc2: u8) + 9: Pack[0](S) + 10: Ret } pack6(Arg0: u8, Arg1: u8, Arg2: u8): S /* def_idx: 5 */ { L3: loc0: u8 L4: loc1: u8 +L5: loc2: u8 +L6: loc3: u8 B0: 0: MoveLoc[0](Arg0: u8) - 1: StLoc[3](loc0: u8) - 2: MoveLoc[1](Arg1: u8) - 3: StLoc[4](loc1: u8) - 4: MoveLoc[2](Arg2: u8) + 1: MoveLoc[1](Arg1: u8) + 2: MoveLoc[2](Arg2: u8) + 3: StLoc[3](loc0: u8) + 4: StLoc[4](loc1: u8) 5: MoveLoc[4](loc1: u8) - 6: MoveLoc[3](loc0: u8) - 7: Pack[0](S) - 8: Ret + 6: StLoc[5](loc2: u8) + 7: StLoc[6](loc3: u8) + 8: MoveLoc[3](loc0: u8) + 9: MoveLoc[5](loc2: u8) + 10: MoveLoc[6](loc3: u8) + 11: Pack[0](S) + 12: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack.exp index 7e765c50bc3cb..5ddae932e6e0d 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack.exp @@ -11,21 +11,16 @@ struct S { } pack(Arg0: u64, Arg1: u64): S /* def_idx: 0 */ { -L2: loc0: T B0: - 0: MoveLoc[1](Arg1: u64) - 1: Pack[0](T) - 2: StLoc[2](loc0: T) - 3: MoveLoc[0](Arg0: u64) - 4: MoveLoc[2](loc0: T) - 5: Pack[1](S) - 6: Ret + 0: MoveLoc[0](Arg0: u64) + 1: MoveLoc[1](Arg1: u64) + 2: Pack[0](T) + 3: Pack[1](S) + 4: Ret } unpack(Arg0: S): u64 * u64 /* def_idx: 1 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 -L4: loc3: u64 B0: 0: MoveLoc[0](Arg0: S) 1: Unpack[1](S) @@ -33,12 +28,8 @@ B0: 3: StLoc[1](loc0: u64) 4: StLoc[2](loc1: u64) 5: MoveLoc[2](loc1: u64) - 6: StLoc[3](loc2: u64) - 7: MoveLoc[1](loc0: u64) - 8: StLoc[4](loc3: u64) - 9: MoveLoc[3](loc2: u64) - 10: MoveLoc[4](loc3: u64) - 11: Ret + 6: MoveLoc[1](loc0: u64) + 7: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack.opt.exp index 814b21a7d843e..478176a41191f 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack.opt.exp @@ -11,15 +11,12 @@ struct S { } pack(Arg0: u64, Arg1: u64): S /* def_idx: 0 */ { -L2: loc0: T B0: - 0: MoveLoc[1](Arg1: u64) - 1: Pack[0](T) - 2: StLoc[2](loc0: T) - 3: MoveLoc[0](Arg0: u64) - 4: MoveLoc[2](loc0: T) - 5: Pack[1](S) - 6: Ret + 0: MoveLoc[0](Arg0: u64) + 1: MoveLoc[1](Arg1: u64) + 2: Pack[0](T) + 3: Pack[1](S) + 4: Ret } unpack(Arg0: S): u64 * u64 /* def_idx: 1 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack_ref.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack_ref.opt.exp index 50897b5e6a239..ceb4c3c0a03a1 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack_ref.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/pack_unpack_ref.opt.exp @@ -14,7 +14,6 @@ struct S { unpack_mut_ref(Arg0: &mut S): u64 * u64 /* def_idx: 0 */ { L1: loc0: &mut u64 -L2: loc1: &mut u64 B0: 0: CopyLoc[0](Arg0: &mut S) 1: MutBorrowField[0](S.f: u64) @@ -28,7 +27,6 @@ B0: } unpack_ref(Arg0: &S): u64 * u64 /* def_idx: 1 */ { L1: loc0: &u64 -L2: loc1: &u64 B0: 0: CopyLoc[0](Arg0: &S) 1: ImmBorrowField[0](S.f: u64) @@ -41,32 +39,31 @@ B0: 8: Ret } unpack_ref_G(Arg0: &G): u64 * u64 * u64 * u64 /* def_idx: 2 */ { -L1: loc0: &S -L2: loc1: &u64 +L1: loc0: &u64 +L2: loc1: &S L3: loc2: &u64 L4: loc3: &u64 -L5: loc4: &u64 B0: 0: CopyLoc[0](Arg0: &G) 1: ImmBorrowField[2](G.x1: u64) 2: CopyLoc[0](Arg0: &G) 3: ImmBorrowField[3](G.x2: u64) - 4: MoveLoc[0](Arg0: &G) - 5: ImmBorrowField[4](G.s: S) - 6: StLoc[1](loc0: &S) - 7: CopyLoc[1](loc0: &S) - 8: ImmBorrowField[0](S.f: u64) - 9: MoveLoc[1](loc0: &S) - 10: ImmBorrowField[1](S.g: u64) - 11: StLoc[2](loc1: &u64) - 12: StLoc[3](loc2: &u64) + 4: StLoc[1](loc0: &u64) + 5: MoveLoc[0](Arg0: &G) + 6: ImmBorrowField[4](G.s: S) + 7: StLoc[2](loc1: &S) + 8: CopyLoc[2](loc1: &S) + 9: ImmBorrowField[0](S.f: u64) + 10: StLoc[3](loc2: &u64) + 11: MoveLoc[2](loc1: &S) + 12: ImmBorrowField[1](S.g: u64) 13: StLoc[4](loc3: &u64) 14: ReadRef - 15: MoveLoc[4](loc3: &u64) + 15: MoveLoc[1](loc0: &u64) 16: ReadRef 17: MoveLoc[3](loc2: &u64) 18: ReadRef - 19: MoveLoc[2](loc1: &u64) + 19: MoveLoc[4](loc3: &u64) 20: ReadRef 21: Ret } diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/struct_variants.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/struct_variants.exp index 84c3ab844270c..fee04f8b946f4 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/struct_variants.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/struct_variants.exp @@ -65,6 +65,8 @@ enum Outer { public inner_value(Arg0: Inner): u64 /* def_idx: 0 */ { L1: loc0: &Inner L2: loc1: u64 +L3: loc2: u64 +L4: loc3: u64 B0: 0: ImmBorrowLoc[0](Arg0: Inner) 1: StLoc[1](loc0: &Inner) @@ -77,23 +79,27 @@ B1: 7: MoveLoc[0](Arg0: Inner) 8: UnpackVariant[0](Inner/Inner1) 9: StLoc[2](loc1: u64) - 10: Branch(21) + 10: Branch(25) B2: 11: MoveLoc[1](loc0: &Inner) 12: TestVariant[1](Inner/Inner2) - 13: BrFalse(19) + 13: BrFalse(23) B3: 14: MoveLoc[0](Arg0: Inner) 15: UnpackVariant[1](Inner/Inner2) - 16: Add - 17: StLoc[2](loc1: u64) - 18: Branch(21) + 16: StLoc[3](loc2: u64) + 17: StLoc[4](loc3: u64) + 18: MoveLoc[4](loc3: u64) + 19: MoveLoc[3](loc2: u64) + 20: Add + 21: StLoc[2](loc1: u64) + 22: Branch(25) B4: - 19: LdU64(14566554180833181697) - 20: Abort + 23: LdU64(14566554180833181697) + 24: Abort B5: - 21: MoveLoc[2](loc1: u64) - 22: Ret + 25: MoveLoc[2](loc1: u64) + 26: Ret } public is_inner1(Arg0: &Inner): bool /* def_idx: 1 */ { L1: loc0: bool @@ -152,7 +158,6 @@ B5: } public is_some_dropped(Arg0: Option): bool /* def_idx: 3 */ { L1: loc0: bool -L2: loc1: Option B0: 0: ImmBorrowLoc[0](Arg0: Option) 1: TestVariantGeneric[0](Option/None) @@ -165,9 +170,9 @@ B1: 7: Branch(15) B2: 8: MoveLoc[0](Arg0: Option) - 9: StLoc[2](loc1: Option) - 10: LdTrue - 11: StLoc[1](loc0: bool) + 9: LdTrue + 10: StLoc[1](loc0: bool) + 11: Pop 12: Branch(15) B3: 13: LdU64(14566554180833181697) @@ -361,8 +366,7 @@ B12: public outer_value_with_cond(Arg0: Outer): u64 /* def_idx: 7 */ { L1: loc0: &Outer L2: loc1: u64 -L3: loc2: &Inner -L4: loc3: Box +L3: loc2: Box B0: 0: ImmBorrowLoc[0](Arg0: Outer) 1: StLoc[1](loc0: &Outer) @@ -376,65 +380,63 @@ B1: 8: UnpackVariant[4](Outer/None) 9: LdU64(0) 10: StLoc[2](loc1: u64) - 11: Branch(57) + 11: Branch(55) B2: 12: CopyLoc[1](loc0: &Outer) 13: TestVariant[5](Outer/One) 14: BrTrue(16) B3: - 15: Branch(32) + 15: Branch(30) B4: 16: CopyLoc[1](loc0: &Outer) 17: ImmBorrowVariantField[1](One.i: Inner) - 18: StLoc[3](loc2: &Inner) - 19: MoveLoc[3](loc2: &Inner) - 20: Call is_inner1(&Inner): bool - 21: BrTrue(23) + 18: Call is_inner1(&Inner): bool + 19: BrTrue(21) B5: - 22: Branch(32) + 20: Branch(30) B6: - 23: MoveLoc[1](loc0: &Outer) - 24: Pop - 25: MoveLoc[0](Arg0: Outer) - 26: UnpackVariant[5](Outer/One) - 27: Call inner_value(Inner): u64 - 28: LdU64(2) - 29: Mod - 30: StLoc[2](loc1: u64) - 31: Branch(57) + 21: MoveLoc[1](loc0: &Outer) + 22: Pop + 23: MoveLoc[0](Arg0: Outer) + 24: UnpackVariant[5](Outer/One) + 25: Call inner_value(Inner): u64 + 26: LdU64(2) + 27: Mod + 28: StLoc[2](loc1: u64) + 29: Branch(55) B7: - 32: CopyLoc[1](loc0: &Outer) - 33: TestVariant[5](Outer/One) - 34: BrFalse(42) + 30: CopyLoc[1](loc0: &Outer) + 31: TestVariant[5](Outer/One) + 32: BrFalse(40) B8: - 35: MoveLoc[1](loc0: &Outer) - 36: Pop - 37: MoveLoc[0](Arg0: Outer) - 38: UnpackVariant[5](Outer/One) - 39: Call inner_value(Inner): u64 - 40: StLoc[2](loc1: u64) - 41: Branch(57) + 33: MoveLoc[1](loc0: &Outer) + 34: Pop + 35: MoveLoc[0](Arg0: Outer) + 36: UnpackVariant[5](Outer/One) + 37: Call inner_value(Inner): u64 + 38: StLoc[2](loc1: u64) + 39: Branch(55) B9: - 42: MoveLoc[1](loc0: &Outer) - 43: TestVariant[6](Outer/Two) - 44: BrFalse(55) + 40: MoveLoc[1](loc0: &Outer) + 41: TestVariant[6](Outer/Two) + 42: BrFalse(53) B10: - 45: MoveLoc[0](Arg0: Outer) - 46: UnpackVariant[6](Outer/Two) - 47: StLoc[4](loc3: Box) - 48: Call inner_value(Inner): u64 - 49: ImmBorrowLoc[4](loc3: Box) - 50: ImmBorrowField[0](Box.x: u64) - 51: ReadRef - 52: Add - 53: StLoc[2](loc1: u64) - 54: Branch(57) + 43: MoveLoc[0](Arg0: Outer) + 44: UnpackVariant[6](Outer/Two) + 45: StLoc[3](loc2: Box) + 46: Call inner_value(Inner): u64 + 47: ImmBorrowLoc[3](loc2: Box) + 48: ImmBorrowField[0](Box.x: u64) + 49: ReadRef + 50: Add + 51: StLoc[2](loc1: u64) + 52: Branch(55) B11: - 55: LdU64(14566554180833181697) - 56: Abort + 53: LdU64(14566554180833181697) + 54: Abort B12: - 57: MoveLoc[2](loc1: u64) - 58: Ret + 55: MoveLoc[2](loc1: u64) + 56: Ret } public outer_value_with_cond_ref(Arg0: &Outer): bool /* def_idx: 8 */ { L1: loc0: bool diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/unpack_generic_struct.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/unpack_generic_struct.exp index efb4cdee84f64..a2257aaa12612 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/unpack_generic_struct.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/unpack_generic_struct.exp @@ -29,29 +29,19 @@ B3: 9: Ret } public foo(Arg0: E, Arg1: &mut Ty0) /* def_idx: 1 */ { -L2: loc0: E -L3: loc1: Ty0 -L4: loc2: E -L5: loc3: E -L6: loc4: u64 +L2: loc0: Ty0 B0: 0: MoveLoc[0](Arg0: E) - 1: StLoc[2](loc0: E) - 2: MoveLoc[2](loc0: E) + 1: UnpackGeneric[1](E) + 2: PackGeneric[1](E) 3: UnpackGeneric[1](E) - 4: StLoc[3](loc1: Ty0) - 5: MoveLoc[3](loc1: Ty0) - 6: PackGeneric[1](E) - 7: StLoc[4](loc2: E) - 8: MoveLoc[4](loc2: E) - 9: StLoc[5](loc3: E) - 10: MoveLoc[5](loc3: E) - 11: UnpackGeneric[1](E) - 12: LdU64(3) - 13: StLoc[6](loc4: u64) - 14: MoveLoc[1](Arg1: &mut Ty0) - 15: WriteRef - 16: Ret + 4: LdU64(3) + 5: Pop + 6: StLoc[2](loc0: Ty0) + 7: MoveLoc[2](loc0: Ty0) + 8: MoveLoc[1](Arg1: &mut Ty0) + 9: WriteRef + 10: Ret } public is_none(Arg0: &Option): bool /* def_idx: 2 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/unpack_generic_struct_typed.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/unpack_generic_struct_typed.exp index efb4cdee84f64..a2257aaa12612 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/unpack_generic_struct_typed.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/unpack_generic_struct_typed.exp @@ -29,29 +29,19 @@ B3: 9: Ret } public foo(Arg0: E, Arg1: &mut Ty0) /* def_idx: 1 */ { -L2: loc0: E -L3: loc1: Ty0 -L4: loc2: E -L5: loc3: E -L6: loc4: u64 +L2: loc0: Ty0 B0: 0: MoveLoc[0](Arg0: E) - 1: StLoc[2](loc0: E) - 2: MoveLoc[2](loc0: E) + 1: UnpackGeneric[1](E) + 2: PackGeneric[1](E) 3: UnpackGeneric[1](E) - 4: StLoc[3](loc1: Ty0) - 5: MoveLoc[3](loc1: Ty0) - 6: PackGeneric[1](E) - 7: StLoc[4](loc2: E) - 8: MoveLoc[4](loc2: E) - 9: StLoc[5](loc3: E) - 10: MoveLoc[5](loc3: E) - 11: UnpackGeneric[1](E) - 12: LdU64(3) - 13: StLoc[6](loc4: u64) - 14: MoveLoc[1](Arg1: &mut Ty0) - 15: WriteRef - 16: Ret + 4: LdU64(3) + 5: Pop + 6: StLoc[2](loc0: Ty0) + 7: MoveLoc[2](loc0: Ty0) + 8: MoveLoc[1](Arg1: &mut Ty0) + 9: WriteRef + 10: Ret } public is_none(Arg0: &Option): bool /* def_idx: 2 */ { B0: diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/vector.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/vector.exp index 5a8df708ab8b8..40b822e92a9a0 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/vector.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/vector.exp @@ -10,64 +10,52 @@ use 0000000000000000000000000000000000000000000000000000000000000001::vector as public remove(Arg0: &mut vector, Arg1: u64): Ty0 /* def_idx: 0 */ { L2: loc0: u64 L3: loc1: u64 -L4: loc2: &mut vector -L5: loc3: u64 -L6: loc4: u64 -L7: loc5: u64 B0: 0: CopyLoc[0](Arg0: &mut vector) 1: FreezeRef 2: VecLen(1) - 3: StLoc[2](loc0: u64) - 4: CopyLoc[1](Arg1: u64) - 5: CopyLoc[2](loc0: u64) - 6: Ge - 7: BrFalse(13) + 3: CopyLoc[1](Arg1: u64) + 4: StLoc[2](loc0: u64) + 5: StLoc[3](loc1: u64) + 6: MoveLoc[2](loc0: u64) + 7: CopyLoc[3](loc1: u64) + 8: Ge + 9: BrFalse(15) B1: - 8: MoveLoc[0](Arg0: &mut vector) - 9: Pop - 10: LdU64(1) - 11: Abort + 10: MoveLoc[0](Arg0: &mut vector) + 11: Pop + 12: LdU64(1) + 13: Abort B2: - 12: Branch(13) + 14: Branch(15) B3: - 13: LdU64(1) - 14: StLoc[3](loc1: u64) - 15: MoveLoc[2](loc0: u64) - 16: MoveLoc[3](loc1: u64) + 15: MoveLoc[3](loc1: u64) + 16: LdU64(1) 17: Sub - 18: StLoc[2](loc0: u64) + 18: StLoc[3](loc1: u64) B4: 19: CopyLoc[1](Arg1: u64) - 20: CopyLoc[2](loc0: u64) + 20: CopyLoc[3](loc1: u64) 21: Lt - 22: BrFalse(40) + 22: BrFalse(32) B5: 23: CopyLoc[0](Arg0: &mut vector) - 24: StLoc[4](loc2: &mut vector) - 25: CopyLoc[1](Arg1: u64) - 26: StLoc[5](loc3: u64) - 27: LdU64(1) - 28: StLoc[6](loc4: u64) - 29: MoveLoc[1](Arg1: u64) - 30: MoveLoc[6](loc4: u64) - 31: Add - 32: StLoc[1](Arg1: u64) - 33: CopyLoc[1](Arg1: u64) - 34: StLoc[7](loc5: u64) - 35: MoveLoc[4](loc2: &mut vector) - 36: MoveLoc[5](loc3: u64) - 37: MoveLoc[7](loc5: u64) - 38: VecSwap(1) - 39: Branch(41) + 24: CopyLoc[1](Arg1: u64) + 25: MoveLoc[1](Arg1: u64) + 26: LdU64(1) + 27: Add + 28: StLoc[1](Arg1: u64) + 29: CopyLoc[1](Arg1: u64) + 30: VecSwap(1) + 31: Branch(33) B6: - 40: Branch(42) + 32: Branch(34) B7: - 41: Branch(19) + 33: Branch(19) B8: - 42: MoveLoc[0](Arg0: &mut vector) - 43: VecPopBack(1) - 44: Ret + 34: MoveLoc[0](Arg0: &mut vector) + 35: VecPopBack(1) + 36: Ret } create(): vector /* def_idx: 1 */ { B0: @@ -78,10 +66,6 @@ test_fold() /* def_idx: 2 */ { L0: loc0: vector L1: loc1: u64 L2: loc2: u64 -L3: loc3: u64 -L4: loc4: u64 -L5: loc5: u64 -L6: loc6: u64 B0: 0: LdU64(0) 1: LdConst[1](Vector(U64): [1, 1, 0, 0, 0, 0, 0, 0, 0]) @@ -97,13 +81,13 @@ B1: B2: 10: MutBorrowLoc[0](loc0: vector) 11: VecPopBack(5) - 12: StLoc[2](loc2: u64) - 13: MoveLoc[1](loc1: u64) - 14: StLoc[3](loc3: u64) + 12: MoveLoc[1](loc1: u64) + 13: Pop + 14: StLoc[2](loc2: u64) 15: MoveLoc[2](loc2: u64) - 16: StLoc[4](loc4: u64) - 17: LdU64(0) - 18: StLoc[1](loc1: u64) + 16: LdU64(0) + 17: StLoc[1](loc1: u64) + 18: Pop 19: Branch(21) B3: 20: Branch(22) @@ -111,20 +95,16 @@ B4: 21: Branch(6) B5: 22: MoveLoc[1](loc1: u64) - 23: StLoc[5](loc5: u64) - 24: LdU64(0) - 25: StLoc[6](loc6: u64) - 26: MoveLoc[5](loc5: u64) - 27: MoveLoc[6](loc6: u64) - 28: Eq - 29: BrFalse(31) + 23: LdU64(0) + 24: Eq + 25: BrFalse(27) B6: - 30: Branch(33) + 26: Branch(29) B7: - 31: LdU64(0) - 32: Abort + 27: LdU64(0) + 28: Abort B8: - 33: Ret + 29: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/vector.opt.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/vector.opt.exp index 59b0000ee2d3c..f334510d33d10 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/vector.opt.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/vector.opt.exp @@ -9,8 +9,6 @@ use 0000000000000000000000000000000000000000000000000000000000000001::vector as public remove(Arg0: &mut vector, Arg1: u64): Ty0 /* def_idx: 0 */ { L2: loc0: u64 -L3: loc1: u64 -L4: loc2: u64 B0: 0: CopyLoc[0](Arg0: &mut vector) 1: FreezeRef @@ -58,7 +56,6 @@ B0: test_fold() /* def_idx: 2 */ { L0: loc0: u64 L1: loc1: vector -L2: loc2: u64 B0: 0: LdU64(0) 1: StLoc[0](loc0: u64) @@ -72,7 +69,7 @@ B1: 8: BrTrue(15) B2: 9: MutBorrowLoc[1](loc1: vector) - 10: VecPopBack(5) + 10: VecPopBack(2) 11: Pop 12: LdU64(0) 13: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_01.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_01.on.exp index 0870224a85ec2..a98457b592311 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_01.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_01.on.exp @@ -31,6 +31,7 @@ fun m::take2($t0: u64, $t1: u64) { public fun m::test() { var $t0: u64 var $t1: u64 + var $t2: u64 [unused] # flush: $t1 # live vars: 0: ($t0, $t1) := m::one_one() diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_02.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_02.on.exp index c2a870c8c44d0..cf1b28b1c904d 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_02.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_02.on.exp @@ -31,6 +31,7 @@ fun m::take2($t0: u64, $t1: u64) { public fun m::test() { var $t0: u64 var $t1: u64 + var $t2: u64 [unused] # flush: $t0, $t1 # live vars: 0: ($t0, $t1) := m::one_one() diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_03.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_03.on.exp index 86d9781822945..f7d24cf2808cd 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_03.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_03.on.exp @@ -31,15 +31,18 @@ fun m::take2($t0: u64, $t1: u64) { public fun m::test() { var $t0: u64 var $t1: u64 + var $t2: u64 [unused] # flush: $t0 # live vars: 0: ($t0, $t1) := m::one_one() # live vars: $t0, $t1 1: m::take1($t1) # live vars: $t0 - 2: m::take2($t0, $t0) + 2: $t1 := copy($t0) + # live vars: $t0, $t1 + 3: m::take2($t1, $t0) # live vars: - 3: return () + 4: return () } diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_04.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_04.on.exp index a13bdd44923af..ff806c7c0db02 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_04.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_04.on.exp @@ -31,15 +31,18 @@ fun m::take2($t0: u64, $t1: u64) { public fun m::test() { var $t0: u64 var $t1: u64 + var $t2: u64 [unused] # flush: $t1 # live vars: 0: ($t0, $t1) := m::one_one() # live vars: $t0, $t1 1: m::take1($t0) # live vars: $t1 - 2: m::take2($t1, $t1) + 2: $t0 := copy($t1) + # live vars: $t0, $t1 + 3: m::take2($t0, $t1) # live vars: - 3: return () + 4: return () } diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_05.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_05.on.exp index 4410c4d801505..a31d5538a0d1f 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_05.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_05.on.exp @@ -31,6 +31,7 @@ fun m::take2($t0: u64, $t1: u64) { public fun m::test() { var $t0: u64 var $t1: u64 + # flush: $t0 # live vars: 0: ($t0, $t1) := m::one_one() # live vars: $t0, $t1 diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_06.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_06.on.exp index 33a814454b8a5..96861d4e1c3bc 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_06.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_06.on.exp @@ -20,12 +20,16 @@ fun m::take2($t0: u64, $t1: u64) { [variant baseline] public fun m::test($t0: u64) { var $t1: u64 + var $t2: u64 [unused] + # flush: $t1 # live vars: $t0 0: $t1 := m::one() # live vars: $t0, $t1 - 1: m::take2($t0, $t1) + 1: $t0 := move($t0) + # live vars: $t0, $t1 + 2: m::take2($t0, $t1) # live vars: - 2: return () + 3: return () } diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.off.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.off.exp index da91b1fbdbafc..9de43d650013d 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.off.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.off.exp @@ -5,7 +5,6 @@ module c0ffee.m { foo(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) 1: LdU64(1) diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.on.exp index e30fa68798f35..e7ce2ad25d5c3 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_07.on.exp @@ -3,13 +3,16 @@ [variant baseline] fun m::foo($t0: u64): u64 { var $t1: u64 [unused] - var $t2: u64 + var $t2: u64 [unused] + var $t3: u64 + # live vars: $t0 + 0: $t0 := move($t0) # live vars: $t0 - 0: $t2 := 1 - # live vars: $t0, $t2 - 1: $t0 := +($t0, $t2) + 1: $t3 := 1 + # live vars: $t0, $t3 + 2: $t0 := +($t0, $t3) # live vars: $t0 - 2: return $t0 + 3: return $t0 } @@ -45,7 +48,6 @@ module c0ffee.m { foo(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) 1: LdU64(1) diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_08.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_08.on.exp index 9bd6d2de130fc..4d2c4ea40228b 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/def_use_08.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/def_use_08.on.exp @@ -32,6 +32,9 @@ public fun m::test() { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 [unused] + var $t5: u64 [unused] + var $t6: u64 [unused] # flush: $t0 # live vars: 0: ($t0, $t1, $t2, $t3) := m::foo() diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.move b/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.move new file mode 100644 index 0000000000000..81da626809a08 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.move @@ -0,0 +1,26 @@ +module 0xc0ffee::m { + public fun one(): u64 { + 1 + } + + public fun consume( + _a: u64, + _b: u64, + _c: u64, + _d: u64, + _e: u64, + _f: u64, + _g: u64 + ) {} + + public fun test() { + let a = one(); + let b = one(); + let c = one(); + let d = one(); + let e = one(); + let f = one(); + let g = one(); + consume(a, b, c, d, e, f, g); + } +} diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.off.exp b/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.off.exp new file mode 100644 index 0000000000000..83f331d38c8cd --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.off.exp @@ -0,0 +1,29 @@ + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +public consume(Arg0: u64, Arg1: u64, Arg2: u64, Arg3: u64, Arg4: u64, Arg5: u64, Arg6: u64) /* def_idx: 0 */ { +B0: + 0: Ret +} +public one(): u64 /* def_idx: 1 */ { +B0: + 0: LdU64(1) + 1: Ret +} +public test() /* def_idx: 2 */ { +B0: + 0: Call one(): u64 + 1: Call one(): u64 + 2: Call one(): u64 + 3: Call one(): u64 + 4: Call one(): u64 + 5: Call one(): u64 + 6: Call one(): u64 + 7: Call consume(u64, u64, u64, u64, u64, u64, u64) + 8: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.on.exp new file mode 100644 index 0000000000000..aaa2e97210b77 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/flush-writes/in_order_use_01.on.exp @@ -0,0 +1,83 @@ +============ after FlushWritesProcessor: ================ + +[variant baseline] +public fun m::consume($t0: u64, $t1: u64, $t2: u64, $t3: u64, $t4: u64, $t5: u64, $t6: u64) { + # live vars: $t0, $t1, $t2, $t3, $t4, $t5, $t6 + 0: return () +} + + +[variant baseline] +public fun m::one(): u64 { + var $t0: u64 + # live vars: + 0: $t0 := 1 + # live vars: $t0 + 1: return $t0 +} + + +[variant baseline] +public fun m::test() { + var $t0: u64 + var $t1: u64 + var $t2: u64 + var $t3: u64 + var $t4: u64 + var $t5: u64 + var $t6: u64 + var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] + var $t12: u64 [unused] + # live vars: + 0: $t0 := m::one() + # live vars: $t0 + 1: $t1 := m::one() + # live vars: $t0, $t1 + 2: $t2 := m::one() + # live vars: $t0, $t1, $t2 + 3: $t3 := m::one() + # live vars: $t0, $t1, $t2, $t3 + 4: $t4 := m::one() + # live vars: $t0, $t1, $t2, $t3, $t4 + 5: $t5 := m::one() + # live vars: $t0, $t1, $t2, $t3, $t4, $t5 + 6: $t6 := m::one() + # live vars: $t0, $t1, $t2, $t3, $t4, $t5, $t6 + 7: m::consume($t0, $t1, $t2, $t3, $t4, $t5, $t6) + # live vars: + 8: return () +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +public consume(Arg0: u64, Arg1: u64, Arg2: u64, Arg3: u64, Arg4: u64, Arg5: u64, Arg6: u64) /* def_idx: 0 */ { +B0: + 0: Ret +} +public one(): u64 /* def_idx: 1 */ { +B0: + 0: LdU64(1) + 1: Ret +} +public test() /* def_idx: 2 */ { +B0: + 0: Call one(): u64 + 1: Call one(): u64 + 2: Call one(): u64 + 3: Call one(): u64 + 4: Call one(): u64 + 5: Call one(): u64 + 6: Call one(): u64 + 7: Call consume(u64, u64, u64, u64, u64, u64, u64) + 8: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.off.exp b/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.off.exp index 9c907cf1b4e38..611c59a093878 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.off.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.off.exp @@ -5,7 +5,6 @@ module c0ffee.m { foo(Arg0: u64): u64 * u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: MoveLoc[0](Arg0: u64) diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.on.exp index 4640def1c25d2..8a73dad251497 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/loop_01.on.exp @@ -4,15 +4,18 @@ fun m::foo($t0: u64): (u64, u64) { var $t1: u64 var $t2: u64 [unused] - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 # live vars: $t0 0: $t1 := copy($t0) # live vars: $t0, $t1 - 1: $t3 := 1 - # live vars: $t0, $t1, $t3 - 2: $t0 := -($t0, $t3) + 1: $t0 := move($t0) # live vars: $t0, $t1 - 3: return ($t1, $t0) + 2: $t4 := 1 + # live vars: $t0, $t1, $t4 + 3: $t0 := -($t0, $t4) + # live vars: $t0, $t1 + 4: return ($t1, $t0) } @@ -20,16 +23,17 @@ fun m::foo($t0: u64): (u64, u64) { public fun m::test1($t0: u64) { var $t1: u64 var $t2: bool - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 # live vars: $t0 0: label L0 # flush: $t0 # live vars: $t0 1: ($t1, $t0) := m::foo($t0) # live vars: $t0, $t1 - 2: $t3 := 0 - # live vars: $t0, $t1, $t3 - 3: $t2 := ==($t1, $t3) + 2: $t4 := 0 + # live vars: $t0, $t1, $t4 + 3: $t2 := ==($t1, $t4) # live vars: $t0, $t2 4: if ($t2) goto 5 else goto 0 # live vars: $t0 @@ -43,16 +47,17 @@ public fun m::test1($t0: u64) { public fun m::test2($t0: u64) { var $t1: u64 var $t2: bool - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 # live vars: $t0 0: label L0 # flush: $t0 # live vars: $t0 1: ($t0, $t1) := m::foo($t0) # live vars: $t0, $t1 - 2: $t3 := 0 - # live vars: $t0, $t1, $t3 - 3: $t2 := ==($t1, $t3) + 2: $t4 := 0 + # live vars: $t0, $t1, $t4 + 3: $t2 := ==($t1, $t4) # live vars: $t0, $t2 4: if ($t2) goto 5 else goto 0 # live vars: $t0 @@ -68,7 +73,6 @@ module c0ffee.m { foo(Arg0: u64): u64 * u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: MoveLoc[0](Arg0: u64) diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/loop_02.off.exp b/third_party/move/move-compiler-v2/tests/flush-writes/loop_02.off.exp index 690a6f78c649f..665c8ba795cbe 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/loop_02.off.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/loop_02.off.exp @@ -5,7 +5,6 @@ module c0ffee.m { inc(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) 1: LdU64(1) @@ -14,7 +13,6 @@ B0: } public test() /* def_idx: 1 */ { L0: loc0: u64 -L1: loc1: u64 B0: 0: LdU64(0) 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/loop_02.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/loop_02.on.exp index 55dca74a4e2ef..70a98721f5664 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/loop_02.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/loop_02.on.exp @@ -3,13 +3,16 @@ [variant baseline] fun m::inc($t0: u64): u64 { var $t1: u64 [unused] - var $t2: u64 + var $t2: u64 [unused] + var $t3: u64 # live vars: $t0 - 0: $t2 := 1 - # live vars: $t0, $t2 - 1: $t0 := +($t0, $t2) + 0: $t0 := move($t0) + # live vars: $t0 + 1: $t3 := 1 + # live vars: $t0, $t3 + 2: $t0 := +($t0, $t3) # live vars: $t0 - 2: return $t0 + 3: return $t0 } @@ -19,6 +22,7 @@ public fun m::test() { var $t1: u64 var $t2: bool var $t3: u64 [unused] + var $t4: u64 # flush: $t0 # live vars: 0: $t0 := 0 @@ -26,22 +30,25 @@ public fun m::test() { 1: label L0 # live vars: $t0 2: $t1 := m::inc($t0) + # flush: $t0 # live vars: $t1 3: $t0 := move($t1) # live vars: $t0 - 4: $t1 := 10 + 4: $t1 := copy($t0) # live vars: $t0, $t1 - 5: $t2 := >($t0, $t1) + 5: $t4 := 10 + # live vars: $t0, $t1, $t4 + 6: $t2 := >($t1, $t4) # live vars: $t0, $t2 - 6: if ($t2) goto 9 else goto 7 + 7: if ($t2) goto 10 else goto 8 # live vars: $t0 - 7: label L3 + 8: label L3 # live vars: $t0 - 8: goto 1 + 9: goto 1 # live vars: $t0 - 9: label L2 + 10: label L2 # live vars: - 10: return () + 11: return () } @@ -51,7 +58,6 @@ module c0ffee.m { inc(Arg0: u64): u64 /* def_idx: 0 */ { -L1: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) 1: LdU64(1) @@ -60,7 +66,6 @@ B0: } public test() /* def_idx: 1 */ { L0: loc0: u64 -L1: loc1: u64 B0: 0: LdU64(0) 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_01.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_01.on.exp index 7e0a55544f30a..8fabfb3efeb16 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_01.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_01.on.exp @@ -26,6 +26,12 @@ public fun m::test() { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] + var $t12: u64 [unused] # flush: $t0 # live vars: 0: $t0 := m::one() diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_02.off.exp b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_02.off.exp index 95adc98b1fb92..c0ceec5e952f7 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_02.off.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_02.off.exp @@ -16,16 +16,19 @@ B0: public test() /* def_idx: 2 */ { L0: loc0: u64 L1: loc1: u64 +L2: loc2: u64 B0: 0: Call one(): u64 1: Call one(): u64 2: StLoc[0](loc0: u64) 3: StLoc[1](loc1: u64) - 4: MoveLoc[0](loc0: u64) - 5: CopyLoc[1](loc1: u64) - 6: MoveLoc[1](loc1: u64) - 7: Call consume(u64, u64, u64) - 8: Ret + 4: CopyLoc[1](loc1: u64) + 5: StLoc[2](loc2: u64) + 6: MoveLoc[0](loc0: u64) + 7: MoveLoc[2](loc2: u64) + 8: MoveLoc[1](loc1: u64) + 9: Call consume(u64, u64, u64) + 10: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_02.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_02.on.exp index eeee9aeca8865..1c11b62be1e43 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_02.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_02.on.exp @@ -21,15 +21,19 @@ fun m::one(): u64 { public fun m::test() { var $t0: u64 var $t1: u64 + var $t2: u64 [unused] + var $t3: u64 # flush: $t0 # live vars: 0: $t0 := m::one() # live vars: $t0 1: $t1 := m::one() # live vars: $t0, $t1 - 2: m::consume($t1, $t0, $t0) + 2: $t3 := copy($t0) + # live vars: $t0, $t1, $t3 + 3: m::consume($t1, $t3, $t0) # live vars: - 3: return () + 4: return () } diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_03.off.exp b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_03.off.exp index 4b7e692da0d00..434e4c65aa790 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_03.off.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_03.off.exp @@ -17,15 +17,18 @@ B0: public test() /* def_idx: 2 */ { L0: loc0: u64 L1: loc1: u64 +L2: loc2: u64 B0: 0: Call one_one(): u64 * u64 1: StLoc[0](loc0: u64) 2: StLoc[1](loc1: u64) - 3: MoveLoc[0](loc0: u64) - 4: CopyLoc[1](loc1: u64) - 5: MoveLoc[1](loc1: u64) - 6: Call consume(u64, u64, u64) - 7: Ret + 3: CopyLoc[1](loc1: u64) + 4: StLoc[2](loc2: u64) + 5: MoveLoc[0](loc0: u64) + 6: MoveLoc[2](loc2: u64) + 7: MoveLoc[1](loc1: u64) + 8: Call consume(u64, u64, u64) + 9: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_03.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_03.on.exp index 788166f87ed53..857902c6a6fa5 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_03.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_03.on.exp @@ -24,13 +24,17 @@ fun m::one_one(): (u64, u64) { public fun m::test() { var $t0: u64 var $t1: u64 + var $t2: u64 [unused] + var $t3: u64 # flush: $t0 # live vars: 0: ($t0, $t1) := m::one_one() # live vars: $t0, $t1 - 1: m::consume($t1, $t0, $t0) + 1: $t3 := copy($t0) + # live vars: $t0, $t1, $t3 + 2: m::consume($t1, $t3, $t0) # live vars: - 2: return () + 3: return () } @@ -52,15 +56,18 @@ B0: public test() /* def_idx: 2 */ { L0: loc0: u64 L1: loc1: u64 +L2: loc2: u64 B0: 0: Call one_one(): u64 * u64 1: StLoc[0](loc0: u64) 2: StLoc[1](loc1: u64) - 3: MoveLoc[0](loc0: u64) - 4: CopyLoc[1](loc1: u64) - 5: MoveLoc[1](loc1: u64) - 6: Call consume(u64, u64, u64) - 7: Ret + 3: CopyLoc[1](loc1: u64) + 4: StLoc[2](loc2: u64) + 5: MoveLoc[0](loc0: u64) + 6: MoveLoc[2](loc2: u64) + 7: MoveLoc[1](loc1: u64) + 8: Call consume(u64, u64, u64) + 9: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_04.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_04.on.exp index e709922e98925..9d129dc3ef425 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_04.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/out_of_order_use_04.on.exp @@ -21,15 +21,20 @@ fun m::one(): u64 { public fun m::test() { var $t0: u64 var $t1: u64 + var $t2: u64 + var $t3: u64 [unused] # flush: $t0 # live vars: 0: $t0 := m::one() + # flush: $t1 # live vars: $t0 1: $t1 := m::one() # live vars: $t0, $t1 - 2: m::consume($t0, $t1, $t0) + 2: $t2 := copy($t0) + # live vars: $t0, $t1, $t2 + 3: m::consume($t2, $t1, $t0) # live vars: - 3: return () + 4: return () } diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/unused_flush_early_02.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/unused_flush_early_02.on.exp index cd5b039374e09..df0b8aa411527 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/unused_flush_early_02.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/unused_flush_early_02.on.exp @@ -25,7 +25,8 @@ public fun m::test(): (u64, u64) { var $t3: u64 var $t4: u64 var $t5: bool - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 # flush: $t2 # live vars: 0: $t2 := m::one() @@ -35,9 +36,9 @@ public fun m::test(): (u64, u64) { # live vars: $t2, $t3 2: $t4 := m::one() # live vars: $t2, $t3, $t4 - 3: $t6 := 0 - # live vars: $t2, $t3, $t4, $t6 - 4: $t5 := ==($t3, $t6) + 3: $t7 := 0 + # live vars: $t2, $t3, $t4, $t7 + 4: $t5 := ==($t3, $t7) # live vars: $t2, $t4, $t5 5: if ($t5) goto 8 else goto 6 # live vars: $t2, $t4 @@ -51,7 +52,11 @@ public fun m::test(): (u64, u64) { # live vars: $t2, $t4 10: label L2 # live vars: $t2, $t4 - 11: return ($t2, $t4) + 11: $t2 := move($t2) + # live vars: $t2, $t4 + 12: $t4 := move($t4) + # live vars: $t2, $t4 + 13: return ($t2, $t4) } diff --git a/third_party/move/move-compiler-v2/tests/flush-writes/unused_flush_early_03.on.exp b/third_party/move/move-compiler-v2/tests/flush-writes/unused_flush_early_03.on.exp index 9af909489ad96..faae5c17d09e4 100644 --- a/third_party/move/move-compiler-v2/tests/flush-writes/unused_flush_early_03.on.exp +++ b/third_party/move/move-compiler-v2/tests/flush-writes/unused_flush_early_03.on.exp @@ -29,18 +29,21 @@ public fun m::test1() { var $t1: u64 var $t2: u64 var $t3: bool - var $t4: u64 - var $t5: bool [unused] - var $t6: u64 [unused] - var $t7: bool [unused] + var $t4: u64 [unused] + var $t5: u64 + var $t6: bool [unused] + var $t7: u64 [unused] var $t8: u64 [unused] + var $t9: bool [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] # flush: $t1, $t2 # live vars: 0: ($t0, $t1, $t2) := m::foo() # live vars: $t0, $t1, $t2 - 1: $t4 := 0 - # live vars: $t0, $t1, $t2, $t4 - 2: $t3 := ==($t0, $t4) + 1: $t5 := 0 + # live vars: $t0, $t1, $t2, $t5 + 2: $t3 := ==($t0, $t5) # live vars: $t1, $t2, $t3 3: if ($t3) goto 6 else goto 4 # live vars: $t1, $t2 @@ -54,39 +57,43 @@ public fun m::test1() { # live vars: $t1, $t2 8: label L2 # live vars: $t1, $t2 - 9: $t0 := 0 + 9: $t1 := move($t1) + # live vars: $t1, $t2 + 10: $t0 := 0 # live vars: $t0, $t1, $t2 - 10: $t3 := ==($t1, $t0) + 11: $t3 := ==($t1, $t0) # live vars: $t2, $t3 - 11: if ($t3) goto 14 else goto 12 + 12: if ($t3) goto 15 else goto 13 + # live vars: $t2 + 13: label L10 # live vars: $t2 - 12: label L10 + 14: goto 17 # live vars: $t2 - 13: goto 16 + 15: label L3 # live vars: $t2 - 14: label L3 + 16: m::bar() # live vars: $t2 - 15: m::bar() + 17: label L5 # live vars: $t2 - 16: label L5 + 18: $t2 := move($t2) # live vars: $t2 - 17: $t0 := 0 + 19: $t0 := 0 # live vars: $t0, $t2 - 18: $t3 := ==($t2, $t0) + 20: $t3 := ==($t2, $t0) # live vars: $t3 - 19: if ($t3) goto 22 else goto 20 + 21: if ($t3) goto 24 else goto 22 # live vars: - 20: label L11 + 22: label L11 # live vars: - 21: goto 24 + 23: goto 26 # live vars: - 22: label L6 + 24: label L6 # live vars: - 23: m::bar() + 25: m::bar() # live vars: - 24: label L8 + 26: label L8 # live vars: - 25: return () + 27: return () } @@ -109,7 +116,6 @@ B0: public test1() /* def_idx: 2 */ { L0: loc0: u64 L1: loc1: u64 -L2: loc2: u64 B0: 0: Call foo(): u64 * u64 * u64 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/non_lambda_arg.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/non_lambda_arg.lambda.exp index 2f733050cb6bd..afb55300b662d 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/inline-parity/non_lambda_arg.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/inline-parity/non_lambda_arg.lambda.exp @@ -354,16 +354,20 @@ module 0x42::sort { public fun sort::incorrect_sort<#0>($t0: &mut vector<#0>, $t1: |(#0, #0)|bool) { var $t2: u64 var $t3: &vector<#0> - var $t4: u64 + var $t4: &mut vector<#0> var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t3 := freeze_ref(implicit)($t0) 1: $t2 := vector::length<#0>($t3) - 2: $t4 := 0 - 3: $t6 := 1 - 4: $t5 := -($t2, $t6) - 5: sort::incorrect_sort_recursive<#0>($t0, $t4, $t5, $t1) - 6: return () + 2: $t4 := infer($t0) + 3: $t5 := 0 + 4: $t7 := infer($t2) + 5: $t8 := 1 + 6: $t6 := -($t7, $t8) + 7: sort::incorrect_sort_recursive<#0>($t4, $t5, $t6, $t1) + 8: return () } @@ -376,23 +380,41 @@ public fun sort::incorrect_sort_recursive<#0>($t0: &mut vector<#0>, $t1: u64, $t var $t8: u64 var $t9: u64 var $t10: u64 - var $t11: u64 - 0: $t4 := <($t1, $t2) - 1: if ($t4) goto 2 else goto 13 - 2: label L0 - 3: $t7 := 2 - 4: $t6 := /($t2, $t7) - 5: $t5 := +($t1, $t6) - 6: $t9 := 1 - 7: $t8 := -($t5, $t9) - 8: sort::incorrect_sort_recursive<#0>($t0, $t1, $t8, $t3) - 9: $t11 := 1 - 10: $t10 := +($t5, $t11) - 11: sort::incorrect_sort_recursive<#0>($t0, $t10, $t2, $t3) - 12: goto 14 - 13: label L1 - 14: label L2 - 15: return () + var $t11: &mut vector<#0> + var $t12: u64 + var $t13: u64 + var $t14: u64 + var $t15: u64 + var $t16: &mut vector<#0> + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + 0: $t5 := infer($t1) + 1: $t4 := <($t5, $t2) + 2: if ($t4) goto 3 else goto 22 + 3: label L0 + 4: $t7 := infer($t1) + 5: $t9 := infer($t2) + 6: $t10 := 2 + 7: $t8 := /($t9, $t10) + 8: $t6 := +($t7, $t8) + 9: $t11 := infer($t0) + 10: $t12 := infer($t1) + 11: $t14 := infer($t6) + 12: $t15 := 1 + 13: $t13 := -($t14, $t15) + 14: sort::incorrect_sort_recursive<#0>($t11, $t12, $t13, $t3) + 15: $t16 := infer($t0) + 16: $t18 := infer($t6) + 17: $t19 := 1 + 18: $t17 := +($t18, $t19) + 19: $t20 := infer($t2) + 20: sort::incorrect_sort_recursive<#0>($t16, $t17, $t20, $t3) + 21: goto 23 + 22: label L1 + 23: label L2 + 24: return () } diff --git a/third_party/move/move-compiler-v2/tests/lambda/non_lambda_arg.lambda.exp b/third_party/move/move-compiler-v2/tests/lambda/non_lambda_arg.lambda.exp index 8949035e6a9d3..5925804dec97c 100644 --- a/third_party/move/move-compiler-v2/tests/lambda/non_lambda_arg.lambda.exp +++ b/third_party/move/move-compiler-v2/tests/lambda/non_lambda_arg.lambda.exp @@ -354,16 +354,20 @@ module 0x42::sort { public fun sort::incorrect_sort<#0>($t0: &mut vector<#0>, $t1: |(#0, #0)|bool) { var $t2: u64 var $t3: &vector<#0> - var $t4: u64 + var $t4: &mut vector<#0> var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t3 := freeze_ref(implicit)($t0) 1: $t2 := vector::length<#0>($t3) - 2: $t4 := 0 - 3: $t6 := 1 - 4: $t5 := -($t2, $t6) - 5: sort::incorrect_sort_recursive<#0>($t0, $t4, $t5, $t1) - 6: return () + 2: $t4 := infer($t0) + 3: $t5 := 0 + 4: $t7 := infer($t2) + 5: $t8 := 1 + 6: $t6 := -($t7, $t8) + 7: sort::incorrect_sort_recursive<#0>($t4, $t5, $t6, $t1) + 8: return () } @@ -376,23 +380,41 @@ public fun sort::incorrect_sort_recursive<#0>($t0: &mut vector<#0>, $t1: u64, $t var $t8: u64 var $t9: u64 var $t10: u64 - var $t11: u64 - 0: $t4 := <($t1, $t2) - 1: if ($t4) goto 2 else goto 13 - 2: label L0 - 3: $t7 := 2 - 4: $t6 := /($t2, $t7) - 5: $t5 := +($t1, $t6) - 6: $t9 := 1 - 7: $t8 := -($t5, $t9) - 8: sort::incorrect_sort_recursive<#0>($t0, $t1, $t8, $t3) - 9: $t11 := 1 - 10: $t10 := +($t5, $t11) - 11: sort::incorrect_sort_recursive<#0>($t0, $t10, $t2, $t3) - 12: goto 14 - 13: label L1 - 14: label L2 - 15: return () + var $t11: &mut vector<#0> + var $t12: u64 + var $t13: u64 + var $t14: u64 + var $t15: u64 + var $t16: &mut vector<#0> + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + 0: $t5 := infer($t1) + 1: $t4 := <($t5, $t2) + 2: if ($t4) goto 3 else goto 22 + 3: label L0 + 4: $t7 := infer($t1) + 5: $t9 := infer($t2) + 6: $t10 := 2 + 7: $t8 := /($t9, $t10) + 8: $t6 := +($t7, $t8) + 9: $t11 := infer($t0) + 10: $t12 := infer($t1) + 11: $t14 := infer($t6) + 12: $t15 := 1 + 13: $t13 := -($t14, $t15) + 14: sort::incorrect_sort_recursive<#0>($t11, $t12, $t13, $t3) + 15: $t16 := infer($t0) + 16: $t18 := infer($t6) + 17: $t19 := 1 + 18: $t17 := +($t18, $t19) + 19: $t20 := infer($t2) + 20: sort::incorrect_sort_recursive<#0>($t16, $t17, $t20, $t3) + 21: goto 23 + 22: label L1 + 23: label L2 + 24: return () } diff --git a/third_party/move/move-compiler-v2/tests/live-var/bug_9717_looponly.exp b/third_party/move/move-compiler-v2/tests/live-var/bug_9717_looponly.exp index e7aa75eab4159..6e8dc21ffe57c 100644 --- a/third_party/move/move-compiler-v2/tests/live-var/bug_9717_looponly.exp +++ b/third_party/move/move-compiler-v2/tests/live-var/bug_9717_looponly.exp @@ -11,58 +11,64 @@ public fun vectors::guess_flips_break2($t0: vector): u64 { var $t7: bool var $t8: u8 var $t9: &u8 - var $t10: u8 - var $t11: u64 + var $t10: &vector + var $t11: u8 var $t12: u64 - var $t13: bool - var $t14: u8 - var $t15: &u8 + var $t13: u64 + var $t14: u64 + var $t15: bool var $t16: u8 - var $t17: vector - var $t18: vector - var $t19: &vector + var $t17: &u8 + var $t18: &vector + var $t19: u8 + var $t20: vector + var $t21: vector + var $t22: &vector 0: $t2 := 0 1: $t3 := borrow_local($t0) 2: label L0 3: $t5 := infer($t2) 4: $t6 := vector::length($t3) 5: $t4 := <($t5, $t6) - 6: if ($t4) goto 7 else goto 32 + 6: if ($t4) goto 7 else goto 35 7: label L2 - 8: $t9 := vector::borrow($t3, $t2) - 9: $t8 := read_ref($t9) - 10: $t10 := 0 - 11: $t7 := !=($t8, $t10) - 12: if ($t7) goto 13 else goto 16 - 13: label L5 - 14: goto 36 - 15: goto 17 - 16: label L6 - 17: label L7 - 18: $t12 := 1 - 19: $t11 := +($t2, $t12) - 20: $t2 := infer($t11) - 21: $t15 := vector::borrow($t3, $t2) - 22: $t14 := read_ref($t15) - 23: $t16 := 5 - 24: $t13 := ==($t14, $t16) - 25: if ($t13) goto 26 else goto 29 - 26: label L8 - 27: goto 36 - 28: goto 30 - 29: label L9 - 30: label L10 - 31: goto 34 - 32: label L3 - 33: goto 36 - 34: label L4 - 35: goto 2 - 36: label L1 - 37: $t17 := copy($t0) - 38: $t18 := infer($t0) - 39: $t19 := infer($t3) - 40: $t1 := vector::length($t19) - 41: return $t1 + 8: $t10 := infer($t3) + 9: $t9 := vector::borrow($t10, $t2) + 10: $t8 := read_ref($t9) + 11: $t11 := 0 + 12: $t7 := !=($t8, $t11) + 13: if ($t7) goto 14 else goto 17 + 14: label L5 + 15: goto 39 + 16: goto 18 + 17: label L6 + 18: label L7 + 19: $t13 := infer($t2) + 20: $t14 := 1 + 21: $t12 := +($t13, $t14) + 22: $t2 := infer($t12) + 23: $t18 := infer($t3) + 24: $t17 := vector::borrow($t18, $t2) + 25: $t16 := read_ref($t17) + 26: $t19 := 5 + 27: $t15 := ==($t16, $t19) + 28: if ($t15) goto 29 else goto 32 + 29: label L8 + 30: goto 39 + 31: goto 33 + 32: label L9 + 33: label L10 + 34: goto 37 + 35: label L3 + 36: goto 39 + 37: label L4 + 38: goto 2 + 39: label L1 + 40: $t20 := copy($t0) + 41: $t21 := infer($t0) + 42: $t22 := infer($t3) + 43: $t1 := vector::length($t22) + 44: return $t1 } ============ after LiveVarAnalysisProcessor: ================ @@ -78,16 +84,19 @@ public fun vectors::guess_flips_break2($t0: vector): u64 { var $t7: bool var $t8: u8 var $t9: &u8 - var $t10: u8 - var $t11: u64 + var $t10: &vector + var $t11: u8 var $t12: u64 - var $t13: bool - var $t14: u8 - var $t15: &u8 + var $t13: u64 + var $t14: u64 + var $t15: bool var $t16: u8 - var $t17: vector - var $t18: vector - var $t19: &vector + var $t17: &u8 + var $t18: &vector + var $t19: u8 + var $t20: vector + var $t21: vector + var $t22: &vector # live vars: $t0 0: $t2 := 0 # live vars: $t0, $t2 @@ -101,75 +110,667 @@ public fun vectors::guess_flips_break2($t0: vector): u64 { # live vars: $t0, $t2, $t3, $t5, $t6 5: $t4 := <($t5, $t6) # live vars: $t0, $t2, $t3, $t4 - 6: if ($t4) goto 7 else goto 32 + 6: if ($t4) goto 7 else goto 35 # live vars: $t0, $t2, $t3 7: label L2 # live vars: $t0, $t2, $t3 - 8: $t9 := vector::borrow($t3, $t2) + 8: $t10 := infer($t3) + # live vars: $t0, $t2, $t3, $t10 + 9: $t9 := vector::borrow($t10, $t2) # live vars: $t0, $t2, $t3, $t9 - 9: $t8 := read_ref($t9) + 10: $t8 := read_ref($t9) # live vars: $t0, $t2, $t3, $t8 - 10: $t10 := 0 - # live vars: $t0, $t2, $t3, $t8, $t10 - 11: $t7 := !=($t8, $t10) + 11: $t11 := 0 + # live vars: $t0, $t2, $t3, $t8, $t11 + 12: $t7 := !=($t8, $t11) # live vars: $t0, $t2, $t3, $t7 - 12: if ($t7) goto 13 else goto 16 + 13: if ($t7) goto 14 else goto 17 # live vars: $t0, $t2, $t3 - 13: label L5 + 14: label L5 # live vars: $t0, $t3 - 14: goto 36 + 15: goto 39 # live vars: $t0, $t2, $t3 - 15: goto 17 + 16: goto 18 # live vars: $t0, $t2, $t3 - 16: label L6 + 17: label L6 # live vars: $t0, $t2, $t3 - 17: label L7 + 18: label L7 # live vars: $t0, $t2, $t3 - 18: $t12 := 1 - # live vars: $t0, $t2, $t3, $t12 - 19: $t11 := +($t2, $t12) - # live vars: $t0, $t3, $t11 - 20: $t2 := infer($t11) + 19: $t13 := infer($t2) + # live vars: $t0, $t3, $t13 + 20: $t14 := 1 + # live vars: $t0, $t3, $t13, $t14 + 21: $t12 := +($t13, $t14) + # live vars: $t0, $t3, $t12 + 22: $t2 := infer($t12) # live vars: $t0, $t2, $t3 - 21: $t15 := vector::borrow($t3, $t2) + 23: $t18 := infer($t3) + # live vars: $t0, $t2, $t3, $t18 + 24: $t17 := vector::borrow($t18, $t2) + # live vars: $t0, $t2, $t3, $t17 + 25: $t16 := read_ref($t17) + # live vars: $t0, $t2, $t3, $t16 + 26: $t19 := 5 + # live vars: $t0, $t2, $t3, $t16, $t19 + 27: $t15 := ==($t16, $t19) # live vars: $t0, $t2, $t3, $t15 - 22: $t14 := read_ref($t15) - # live vars: $t0, $t2, $t3, $t14 - 23: $t16 := 5 - # live vars: $t0, $t2, $t3, $t14, $t16 - 24: $t13 := ==($t14, $t16) - # live vars: $t0, $t2, $t3, $t13 - 25: if ($t13) goto 26 else goto 29 + 28: if ($t15) goto 29 else goto 32 # live vars: $t0, $t2, $t3 - 26: label L8 + 29: label L8 # live vars: $t0, $t3 - 27: goto 36 + 30: goto 39 # live vars: $t0, $t2, $t3 - 28: goto 30 + 31: goto 33 # live vars: $t0, $t2, $t3 - 29: label L9 + 32: label L9 # live vars: $t0, $t2, $t3 - 30: label L10 + 33: label L10 # live vars: $t0, $t2, $t3 - 31: goto 34 + 34: goto 37 # live vars: $t0, $t2, $t3 - 32: label L3 + 35: label L3 # live vars: $t0, $t3 - 33: goto 36 + 36: goto 39 # live vars: $t0, $t2, $t3 - 34: label L4 + 37: label L4 # live vars: $t0, $t2, $t3 - 35: goto 2 + 38: goto 2 # live vars: $t0, $t3 - 36: label L1 + 39: label L1 # live vars: $t0, $t3 - 37: $t17 := copy($t0) + 40: $t20 := copy($t0) # live vars: $t0, $t3 - 38: $t18 := infer($t0) + 41: $t21 := infer($t0) # live vars: $t3 - 39: $t19 := infer($t3) - # live vars: $t19 - 40: $t1 := vector::length($t19) + 42: $t22 := infer($t3) + # live vars: $t22 + 43: $t1 := vector::length($t22) # live vars: $t1 - 41: return $t1 + 44: return $t1 } + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun vectors::guess_flips_break2($t0: vector): u64 { + var $t1: u64 + var $t2: u64 + var $t3: &vector + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: bool + var $t8: u8 + var $t9: &u8 + var $t10: &vector + var $t11: u8 + var $t12: u64 + var $t13: u64 + var $t14: u64 + var $t15: bool + var $t16: u8 + var $t17: &u8 + var $t18: &vector + var $t19: u8 + var $t20: vector + var $t21: vector + var $t22: &vector + # live vars: $t0 + 0: $t2 := 0 + # live vars: $t0, $t2 + 1: $t3 := borrow_local($t0) + # live vars: $t0, $t2, $t3 + 2: label L0 + # live vars: $t0, $t2, $t3 + 3: $t5 := infer($t2) + # live vars: $t0, $t2, $t3, $t5 + 4: $t6 := vector::length($t3) + # live vars: $t0, $t2, $t3, $t5, $t6 + 5: $t4 := <($t5, $t6) + # live vars: $t0, $t2, $t3, $t4 + 6: if ($t4) goto 7 else goto 35 + # live vars: $t0, $t2, $t3 + 7: label L2 + # live vars: $t0, $t2, $t3 + 8: $t10 := infer($t3) + # live vars: $t0, $t2, $t3, $t10 + 9: $t9 := vector::borrow($t10, $t2) + # live vars: $t0, $t2, $t3, $t9 + 10: $t8 := read_ref($t9) + # live vars: $t0, $t2, $t3, $t8 + 11: $t11 := 0 + # live vars: $t0, $t2, $t3, $t8, $t11 + 12: $t7 := !=($t8, $t11) + # live vars: $t0, $t2, $t3, $t7 + 13: if ($t7) goto 14 else goto 17 + # live vars: $t0, $t2, $t3 + 14: label L5 + # live vars: $t0, $t3 + 15: goto 39 + # live vars: $t0, $t2, $t3 + 16: goto 18 + # live vars: $t0, $t2, $t3 + 17: label L6 + # live vars: $t0, $t2, $t3 + 18: label L7 + # live vars: $t0, $t2, $t3 + 19: $t13 := infer($t2) + # live vars: $t0, $t3, $t13 + 20: $t14 := 1 + # live vars: $t0, $t3, $t13, $t14 + 21: $t12 := +($t13, $t14) + # live vars: $t0, $t3, $t12 + 22: $t2 := infer($t12) + # live vars: $t0, $t2, $t3 + 23: $t18 := infer($t3) + # live vars: $t0, $t2, $t3, $t18 + 24: $t17 := vector::borrow($t18, $t2) + # live vars: $t0, $t2, $t3, $t17 + 25: $t16 := read_ref($t17) + # live vars: $t0, $t2, $t3, $t16 + 26: $t19 := 5 + # live vars: $t0, $t2, $t3, $t16, $t19 + 27: $t15 := ==($t16, $t19) + # live vars: $t0, $t2, $t3, $t15 + 28: if ($t15) goto 29 else goto 32 + # live vars: $t0, $t2, $t3 + 29: label L8 + # live vars: $t0, $t3 + 30: goto 39 + # live vars: $t0, $t2, $t3 + 31: goto 33 + # live vars: $t0, $t2, $t3 + 32: label L9 + # live vars: $t0, $t2, $t3 + 33: label L10 + # live vars: $t0, $t2, $t3 + 34: goto 37 + # live vars: $t0, $t2, $t3 + 35: label L3 + # live vars: $t0, $t3 + 36: goto 39 + # live vars: $t0, $t2, $t3 + 37: label L4 + # live vars: $t0, $t2, $t3 + 38: goto 2 + # live vars: $t0, $t3 + 39: label L1 + # live vars: $t0, $t3 + 40: $t20 := copy($t0) + # live vars: $t0, $t3 + 41: $t21 := infer($t0) + # live vars: $t3 + 42: $t22 := infer($t3) + # live vars: $t22 + 43: $t1 := vector::length($t22) + # live vars: $t1 + 44: return $t1 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun vectors::guess_flips_break2($t0: vector): u64 { + var $t1: u64 + var $t2: u64 + var $t3: &vector + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: bool + var $t8: u8 + var $t9: &u8 + var $t10: &vector + var $t11: u8 + var $t12: u64 + var $t13: u64 + var $t14: u64 + var $t15: bool + var $t16: u8 + var $t17: &u8 + var $t18: &vector + var $t19: u8 + var $t20: vector + var $t21: vector + var $t22: &vector + # live vars: $t0 + 0: $t2 := 0 + # live vars: $t0, $t2 + 1: $t3 := borrow_local($t0) + # live vars: $t0, $t2, $t3 + 2: label L0 + # live vars: $t0, $t2, $t3 + 3: $t5 := copy($t2) + # live vars: $t0, $t2, $t3, $t5 + 4: $t6 := vector::length($t3) + # live vars: $t0, $t2, $t3, $t5, $t6 + 5: $t4 := <($t5, $t6) + # live vars: $t0, $t2, $t3, $t4 + 6: if ($t4) goto 9 else goto 7 + # live vars: $t0, $t2, $t3 + 7: label L8 + # live vars: $t0, $t3 + 8: goto 18 + # live vars: $t0, $t2, $t3 + 9: label L2 + # live vars: $t0, $t2, $t3 + 10: $t10 := copy($t3) + # live vars: $t0, $t2, $t3, $t10 + 11: $t9 := vector::borrow($t10, $t2) + # live vars: $t0, $t2, $t3, $t9 + 12: $t8 := read_ref($t9) + # live vars: $t0, $t2, $t3, $t8 + 13: $t11 := 0 + # live vars: $t0, $t2, $t3, $t8, $t11 + 14: $t7 := !=($t8, $t11) + # live vars: $t0, $t2, $t3, $t7 + 15: if ($t7) goto 16 else goto 24 + # live vars: $t0, $t2, $t3 + 16: label L9 + # live vars: $t0, $t3 + 17: goto 18 + # live vars: $t0, $t3 + 18: label L1 + # live vars: $t0, $t3 + 19: $t20 := copy($t0) + # live vars: $t0, $t3 + 20: $t21 := copy($t0) + # live vars: $t3 + 21: $t22 := move($t3) + # live vars: $t22 + 22: $t1 := vector::length($t22) + # live vars: $t1 + 23: return $t1 + # live vars: $t0, $t2, $t3 + 24: label L7 + # live vars: $t0, $t2, $t3 + 25: $t13 := move($t2) + # live vars: $t0, $t3, $t13 + 26: $t14 := 1 + # live vars: $t0, $t3, $t13, $t14 + 27: $t12 := +($t13, $t14) + # live vars: $t0, $t3, $t12 + 28: $t2 := move($t12) + # live vars: $t0, $t2, $t3 + 29: $t18 := copy($t3) + # live vars: $t0, $t2, $t3, $t18 + 30: $t17 := vector::borrow($t18, $t2) + # live vars: $t0, $t2, $t3, $t17 + 31: $t16 := read_ref($t17) + # live vars: $t0, $t2, $t3, $t16 + 32: $t19 := 5 + # live vars: $t0, $t2, $t3, $t16, $t19 + 33: $t15 := ==($t16, $t19) + # live vars: $t0, $t2, $t3, $t15 + 34: if ($t15) goto 35 else goto 37 + # live vars: $t0, $t2, $t3 + 35: label L10 + # live vars: $t0, $t3 + 36: goto 18 + # live vars: $t0, $t2, $t3 + 37: label L11 + # live vars: $t0, $t2, $t3 + 38: goto 2 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun vectors::guess_flips_break2($t0: vector): u64 { + var $t1: u64 + var $t2: u64 + var $t3: &vector + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: bool + var $t8: u8 + var $t9: &u8 + var $t10: &vector + var $t11: u8 + var $t12: u64 + var $t13: u64 + var $t14: u64 + var $t15: bool + var $t16: u8 + var $t17: &u8 + var $t18: &vector + var $t19: u8 + var $t20: vector [unused] + var $t21: vector [unused] + var $t22: &vector + # live vars: $t0 + 0: $t2 := 0 + # live vars: $t0, $t2 + 1: $t3 := borrow_local($t0) + # live vars: $t2, $t3 + 2: label L0 + # live vars: $t2, $t3 + 3: $t5 := copy($t2) + # live vars: $t2, $t3, $t5 + 4: $t6 := vector::length($t3) + # live vars: $t2, $t3, $t5, $t6 + 5: $t4 := <($t5, $t6) + # live vars: $t2, $t3, $t4 + 6: if ($t4) goto 9 else goto 7 + # live vars: $t2, $t3 + 7: label L8 + # live vars: $t3 + 8: goto 18 + # live vars: $t2, $t3 + 9: label L2 + # live vars: $t2, $t3 + 10: $t10 := copy($t3) + # live vars: $t2, $t3, $t10 + 11: $t9 := vector::borrow($t10, $t2) + # live vars: $t2, $t3, $t9 + 12: $t8 := read_ref($t9) + # live vars: $t2, $t3, $t8 + 13: $t11 := 0 + # live vars: $t2, $t3, $t8, $t11 + 14: $t7 := !=($t8, $t11) + # live vars: $t2, $t3, $t7 + 15: if ($t7) goto 16 else goto 22 + # live vars: $t2, $t3 + 16: label L9 + # live vars: $t3 + 17: goto 18 + # live vars: $t3 + 18: label L1 + # live vars: $t3 + 19: $t22 := move($t3) + # live vars: $t22 + 20: $t1 := vector::length($t22) + # live vars: $t1 + 21: return $t1 + # live vars: $t2, $t3 + 22: label L7 + # live vars: $t2, $t3 + 23: $t13 := move($t2) + # live vars: $t3, $t13 + 24: $t14 := 1 + # live vars: $t3, $t13, $t14 + 25: $t12 := +($t13, $t14) + # live vars: $t3, $t12 + 26: $t2 := move($t12) + # live vars: $t2, $t3 + 27: $t18 := copy($t3) + # live vars: $t2, $t3, $t18 + 28: $t17 := vector::borrow($t18, $t2) + # live vars: $t2, $t3, $t17 + 29: $t16 := read_ref($t17) + # live vars: $t2, $t3, $t16 + 30: $t19 := 5 + # live vars: $t2, $t3, $t16, $t19 + 31: $t15 := ==($t16, $t19) + # live vars: $t2, $t3, $t15 + 32: if ($t15) goto 33 else goto 35 + # live vars: $t2, $t3 + 33: label L10 + # live vars: $t3 + 34: goto 18 + # live vars: $t2, $t3 + 35: label L11 + # live vars: $t2, $t3 + 36: goto 2 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun vectors::guess_flips_break2($t0: vector): u64 { + var $t1: u64 [unused] + var $t2: u64 + var $t3: &vector + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: bool [unused] + var $t8: u8 + var $t9: &u8 + var $t10: &vector + var $t11: u8 + var $t12: u64 [unused] + var $t13: u64 [unused] + var $t14: u64 [unused] + var $t15: bool [unused] + var $t16: u8 [unused] + var $t17: &u8 [unused] + var $t18: &vector [unused] + var $t19: u8 [unused] + var $t20: vector [unused] + var $t21: vector [unused] + var $t22: &vector [unused] + # live vars: $t0 + 0: $t2 := 0 + # live vars: $t0, $t2 + 1: $t3 := borrow_local($t0) + # live vars: $t2, $t3 + 2: label L0 + # live vars: $t2, $t3 + 3: $t5 := copy($t2) + # live vars: $t2, $t3, $t5 + 4: $t6 := vector::length($t3) + # live vars: $t2, $t3, $t5, $t6 + 5: $t4 := <($t5, $t6) + # live vars: $t2, $t3, $t4 + 6: if ($t4) goto 9 else goto 7 + # live vars: $t2, $t3 + 7: label L8 + # live vars: $t3 + 8: goto 18 + # live vars: $t2, $t3 + 9: label L2 + # live vars: $t2, $t3 + 10: $t10 := copy($t3) + # live vars: $t2, $t3, $t10 + 11: $t9 := vector::borrow($t10, $t2) + # live vars: $t2, $t3, $t9 + 12: $t8 := read_ref($t9) + # live vars: $t2, $t3, $t8 + 13: $t11 := 0 + # live vars: $t2, $t3, $t8, $t11 + 14: $t4 := !=($t8, $t11) + # live vars: $t2, $t3, $t4 + 15: if ($t4) goto 16 else goto 22 + # live vars: $t2, $t3 + 16: label L9 + # live vars: $t3 + 17: goto 18 + # live vars: $t3 + 18: label L1 + # live vars: $t3 + 19: $t10 := move($t3) + # live vars: $t10 + 20: $t5 := vector::length($t10) + # live vars: $t5 + 21: return $t5 + # live vars: $t2, $t3 + 22: label L7 + # live vars: $t2, $t3 + 23: $t5 := move($t2) + # live vars: $t3, $t5 + 24: $t6 := 1 + # live vars: $t3, $t5, $t6 + 25: $t5 := +($t5, $t6) + # live vars: $t3, $t5 + 26: $t2 := move($t5) + # live vars: $t2, $t3 + 27: $t10 := copy($t3) + # live vars: $t2, $t3, $t10 + 28: $t9 := vector::borrow($t10, $t2) + # live vars: $t2, $t3, $t9 + 29: $t8 := read_ref($t9) + # live vars: $t2, $t3, $t8 + 30: $t11 := 5 + # live vars: $t2, $t3, $t8, $t11 + 31: $t4 := ==($t8, $t11) + # live vars: $t2, $t3, $t4 + 32: if ($t4) goto 33 else goto 35 + # live vars: $t2, $t3 + 33: label L10 + # live vars: $t3 + 34: goto 18 + # live vars: $t2, $t3 + 35: label L11 + # live vars: $t2, $t3 + 36: goto 2 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +public fun vectors::guess_flips_break2($t0: vector): u64 { + var $t1: u64 [unused] + var $t2: u64 + var $t3: &vector + var $t4: bool + var $t5: u64 + var $t6: u64 + var $t7: bool [unused] + var $t8: u8 + var $t9: &u8 + var $t10: &vector + var $t11: u8 + var $t12: u64 [unused] + var $t13: u64 [unused] + var $t14: u64 [unused] + var $t15: bool [unused] + var $t16: u8 [unused] + var $t17: &u8 [unused] + var $t18: &vector [unused] + var $t19: u8 [unused] + var $t20: vector [unused] + var $t21: vector [unused] + var $t22: &vector [unused] + # live vars: $t0 + 0: $t2 := 0 + # live vars: $t0, $t2 + 1: $t3 := borrow_local($t0) + # live vars: $t2, $t3 + 2: label L0 + # live vars: $t2, $t3 + 3: $t5 := copy($t2) + # live vars: $t2, $t3, $t5 + 4: $t6 := vector::length($t3) + # live vars: $t2, $t3, $t5, $t6 + 5: $t4 := <($t5, $t6) + # live vars: $t2, $t3, $t4 + 6: if ($t4) goto 9 else goto 7 + # live vars: $t2, $t3 + 7: label L8 + # live vars: $t3 + 8: goto 18 + # live vars: $t2, $t3 + 9: label L2 + # live vars: $t2, $t3 + 10: $t10 := copy($t3) + # live vars: $t2, $t3, $t10 + 11: $t9 := vector::borrow($t10, $t2) + # live vars: $t2, $t3, $t9 + 12: $t8 := read_ref($t9) + # live vars: $t2, $t3, $t8 + 13: $t11 := 0 + # live vars: $t2, $t3, $t8, $t11 + 14: $t4 := !=($t8, $t11) + # live vars: $t2, $t3, $t4 + 15: if ($t4) goto 16 else goto 22 + # live vars: $t2, $t3 + 16: label L9 + # live vars: $t3 + 17: goto 18 + # live vars: $t3 + 18: label L1 + # live vars: $t3 + 19: $t10 := move($t3) + # live vars: $t10 + 20: $t5 := vector::length($t10) + # live vars: $t5 + 21: return $t5 + # live vars: $t2, $t3 + 22: label L7 + # live vars: $t2, $t3 + 23: $t5 := move($t2) + # live vars: $t3, $t5 + 24: $t6 := 1 + # live vars: $t3, $t5, $t6 + 25: $t5 := +($t5, $t6) + # live vars: $t3, $t5 + 26: $t2 := move($t5) + # live vars: $t2, $t3 + 27: $t10 := copy($t3) + # live vars: $t2, $t3, $t10 + 28: $t9 := vector::borrow($t10, $t2) + # live vars: $t2, $t3, $t9 + 29: $t8 := read_ref($t9) + # live vars: $t2, $t3, $t8 + 30: $t11 := 5 + # live vars: $t2, $t3, $t8, $t11 + 31: $t4 := ==($t8, $t11) + # live vars: $t2, $t3, $t4 + 32: if ($t4) goto 33 else goto 35 + # live vars: $t2, $t3 + 33: label L10 + # live vars: $t3 + 34: goto 18 + # live vars: $t2, $t3 + 35: label L11 + # live vars: $t2, $t3 + 36: goto 2 +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module cafe.vectors { + + +entry public guess_flips_break2(Arg0: vector): u64 /* def_idx: 0 */ { +L1: loc0: u64 +L2: loc1: &vector +B0: + 0: LdU64(0) + 1: StLoc[1](loc0: u64) + 2: ImmBorrowLoc[0](Arg0: vector) + 3: StLoc[2](loc1: &vector) +B1: + 4: CopyLoc[1](loc0: u64) + 5: CopyLoc[2](loc1: &vector) + 6: VecLen(2) + 7: Lt + 8: BrTrue(10) +B2: + 9: Branch(18) +B3: + 10: CopyLoc[2](loc1: &vector) + 11: CopyLoc[1](loc0: u64) + 12: VecImmBorrow(2) + 13: ReadRef + 14: LdU8(0) + 15: Neq + 16: BrFalse(21) +B4: + 17: Branch(18) +B5: + 18: MoveLoc[2](loc1: &vector) + 19: VecLen(2) + 20: Ret +B6: + 21: MoveLoc[1](loc0: u64) + 22: LdU64(1) + 23: Add + 24: StLoc[1](loc0: u64) + 25: CopyLoc[2](loc1: &vector) + 26: CopyLoc[1](loc0: u64) + 27: VecImmBorrow(2) + 28: ReadRef + 29: LdU8(5) + 30: Eq + 31: BrFalse(33) +B7: + 32: Branch(18) +B8: + 33: Branch(4) +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/live-var/mut_inline.exp b/third_party/move/move-compiler-v2/tests/live-var/mut_inline.exp index 294f89be7fbf0..e6e9ffce3b0ea 100644 --- a/third_party/move/move-compiler-v2/tests/live-var/mut_inline.exp +++ b/third_party/move/move-compiler-v2/tests/live-var/mut_inline.exp @@ -11,32 +11,40 @@ fun m::foo(): u64 { var $t6: u64 var $t7: &vector var $t8: bool - var $t9: bool + var $t9: u64 var $t10: bool - var $t11: &u64 + var $t11: bool var $t12: &u64 - var $t13: &vector - var $t14: u64 + var $t13: &u64 + var $t14: &vector var $t15: u64 var $t16: u64 var $t17: u64 var $t18: u64 var $t19: u64 var $t20: u64 - var $t21: bool - var $t22: bool - var $t23: &u64 - var $t24: &u64 - var $t25: &vector - var $t26: u64 - var $t27: u64 - var $t28: u64 - var $t29: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector var $t30: u64 var $t31: u64 - var $t32: &u64 - var $t33: &vector + var $t32: &mut vector + var $t33: u64 var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 0: $t1 := ["1", "2", "3"] 1: $t2 := borrow_local($t1) 2: $t4 := infer($t2) @@ -44,69 +52,77 @@ fun m::foo(): u64 { 4: $t7 := freeze_ref(implicit)($t4) 5: $t6 := vector::length($t7) 6: label L0 - 7: $t8 := <($t5, $t6) - 8: if ($t8) goto 9 else goto 27 - 9: label L2 - 10: $t13 := freeze_ref(implicit)($t4) - 11: $t12 := vector::borrow($t13, $t5) - 12: $t11 := infer($t12) - 13: $t14 := read_ref($t11) - 14: $t15 := 1 - 15: $t10 := >($t14, $t15) - 16: $t9 := !($t10) - 17: if ($t9) goto 18 else goto 21 - 18: label L5 - 19: goto 31 - 20: goto 22 - 21: label L6 - 22: label L7 - 23: $t17 := 1 - 24: $t16 := +($t5, $t17) - 25: $t5 := infer($t16) - 26: goto 29 - 27: label L3 + 7: $t9 := infer($t5) + 8: $t8 := <($t9, $t6) + 9: if ($t8) goto 10 else goto 29 + 10: label L2 + 11: $t14 := freeze_ref(implicit)($t4) + 12: $t13 := vector::borrow($t14, $t5) + 13: $t12 := infer($t13) + 14: $t15 := read_ref($t12) + 15: $t16 := 1 + 16: $t11 := >($t15, $t16) + 17: $t10 := !($t11) + 18: if ($t10) goto 19 else goto 22 + 19: label L5 + 20: goto 33 + 21: goto 23 + 22: label L6 + 23: label L7 + 24: $t18 := infer($t5) + 25: $t19 := 1 + 26: $t17 := +($t18, $t19) + 27: $t5 := infer($t17) 28: goto 31 - 29: label L4 - 30: goto 6 - 31: label L1 - 32: $t18 := infer($t5) - 33: $t20 := 1 - 34: $t19 := +($t5, $t20) - 35: $t5 := infer($t19) - 36: label L8 - 37: $t21 := <($t5, $t6) - 38: if ($t21) goto 39 else goto 59 - 39: label L10 - 40: $t25 := freeze_ref(implicit)($t4) - 41: $t24 := vector::borrow($t25, $t5) - 42: $t23 := infer($t24) - 43: $t26 := read_ref($t23) - 44: $t27 := 1 - 45: $t22 := >($t26, $t27) - 46: if ($t22) goto 47 else goto 53 - 47: label L13 - 48: vector::swap($t4, $t18, $t5) - 49: $t29 := 1 - 50: $t28 := +($t18, $t29) - 51: $t18 := infer($t28) - 52: goto 54 - 53: label L14 - 54: label L15 - 55: $t31 := 1 - 56: $t30 := +($t5, $t31) - 57: $t5 := infer($t30) - 58: goto 61 - 59: label L11 - 60: goto 63 - 61: label L12 - 62: goto 36 - 63: label L9 - 64: $t3 := infer($t18) - 65: $t33 := freeze_ref(implicit)($t2) - 66: $t34 := 0 - 67: $t32 := vector::borrow($t33, $t34) - 68: $t0 := read_ref($t32) - 69: return $t0 + 29: label L3 + 30: goto 33 + 31: label L4 + 32: goto 6 + 33: label L1 + 34: $t20 := infer($t5) + 35: $t22 := infer($t5) + 36: $t23 := 1 + 37: $t21 := +($t22, $t23) + 38: $t5 := infer($t21) + 39: label L8 + 40: $t25 := infer($t5) + 41: $t24 := <($t25, $t6) + 42: if ($t24) goto 43 else goto 67 + 43: label L10 + 44: $t29 := freeze_ref(implicit)($t4) + 45: $t28 := vector::borrow($t29, $t5) + 46: $t27 := infer($t28) + 47: $t30 := read_ref($t27) + 48: $t31 := 1 + 49: $t26 := >($t30, $t31) + 50: if ($t26) goto 51 else goto 60 + 51: label L13 + 52: $t32 := infer($t4) + 53: $t33 := infer($t20) + 54: vector::swap($t32, $t33, $t5) + 55: $t35 := infer($t20) + 56: $t36 := 1 + 57: $t34 := +($t35, $t36) + 58: $t20 := infer($t34) + 59: goto 61 + 60: label L14 + 61: label L15 + 62: $t38 := infer($t5) + 63: $t39 := 1 + 64: $t37 := +($t38, $t39) + 65: $t5 := infer($t37) + 66: goto 69 + 67: label L11 + 68: goto 71 + 69: label L12 + 70: goto 39 + 71: label L9 + 72: $t3 := infer($t20) + 73: $t41 := freeze_ref(implicit)($t2) + 74: $t42 := 0 + 75: $t40 := vector::borrow($t41, $t42) + 76: $t0 := read_ref($t40) + 77: return $t0 } ============ after LiveVarAnalysisProcessor: ================ @@ -122,32 +138,40 @@ fun m::foo(): u64 { var $t6: u64 var $t7: &vector var $t8: bool - var $t9: bool + var $t9: u64 var $t10: bool - var $t11: &u64 + var $t11: bool var $t12: &u64 - var $t13: &vector - var $t14: u64 + var $t13: &u64 + var $t14: &vector var $t15: u64 var $t16: u64 var $t17: u64 var $t18: u64 var $t19: u64 var $t20: u64 - var $t21: bool - var $t22: bool - var $t23: &u64 - var $t24: &u64 - var $t25: &vector - var $t26: u64 - var $t27: u64 - var $t28: u64 - var $t29: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector var $t30: u64 var $t31: u64 - var $t32: &u64 - var $t33: &vector + var $t32: &mut vector + var $t33: u64 var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 # live vars: 0: $t1 := ["1", "2", "3"] # live vars: $t1 @@ -163,129 +187,1205 @@ fun m::foo(): u64 { # live vars: $t2, $t4, $t5, $t6 6: label L0 # live vars: $t2, $t4, $t5, $t6 - 7: $t8 := <($t5, $t6) + 7: $t9 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) # live vars: $t2, $t4, $t5, $t6, $t8 - 8: if ($t8) goto 9 else goto 27 + 9: if ($t8) goto 10 else goto 29 # live vars: $t2, $t4, $t5, $t6 - 9: label L2 + 10: label L2 # live vars: $t2, $t4, $t5, $t6 - 10: $t13 := freeze_ref(implicit)($t4) + 11: $t14 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t14 + 12: $t13 := vector::borrow($t14, $t5) # live vars: $t2, $t4, $t5, $t6, $t13 - 11: $t12 := vector::borrow($t13, $t5) + 13: $t12 := infer($t13) # live vars: $t2, $t4, $t5, $t6, $t12 - 12: $t11 := infer($t12) + 14: $t15 := read_ref($t12) + # live vars: $t2, $t4, $t5, $t6, $t15 + 15: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t15, $t16 + 16: $t11 := >($t15, $t16) # live vars: $t2, $t4, $t5, $t6, $t11 - 13: $t14 := read_ref($t11) - # live vars: $t2, $t4, $t5, $t6, $t14 - 14: $t15 := 1 - # live vars: $t2, $t4, $t5, $t6, $t14, $t15 - 15: $t10 := >($t14, $t15) + 17: $t10 := !($t11) # live vars: $t2, $t4, $t5, $t6, $t10 - 16: $t9 := !($t10) + 18: if ($t10) goto 19 else goto 22 + # live vars: $t2, $t4, $t5, $t6 + 19: label L5 + # live vars: $t2, $t4, $t5, $t6 + 20: goto 33 + # live vars: $t2, $t4, $t5, $t6 + 21: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 22: label L6 + # live vars: $t2, $t4, $t5, $t6 + 23: label L7 + # live vars: $t2, $t4, $t5, $t6 + 24: $t18 := infer($t5) + # live vars: $t2, $t4, $t6, $t18 + 25: $t19 := 1 + # live vars: $t2, $t4, $t6, $t18, $t19 + 26: $t17 := +($t18, $t19) + # live vars: $t2, $t4, $t6, $t17 + 27: $t5 := infer($t17) + # live vars: $t2, $t4, $t5, $t6 + 28: goto 31 + # live vars: $t2, $t4, $t5, $t6 + 29: label L3 + # live vars: $t2, $t4, $t5, $t6 + 30: goto 33 + # live vars: $t2, $t4, $t5, $t6 + 31: label L4 + # live vars: $t2, $t4, $t5, $t6 + 32: goto 6 + # live vars: $t2, $t4, $t5, $t6 + 33: label L1 + # live vars: $t2, $t4, $t5, $t6 + 34: $t20 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 35: $t22 := infer($t5) + # live vars: $t2, $t4, $t6, $t20, $t22 + 36: $t23 := 1 + # live vars: $t2, $t4, $t6, $t20, $t22, $t23 + 37: $t21 := +($t22, $t23) + # live vars: $t2, $t4, $t6, $t20, $t21 + 38: $t5 := infer($t21) + # live vars: $t2, $t4, $t5, $t6, $t20 + 39: label L8 + # live vars: $t2, $t4, $t5, $t6, $t20 + 40: $t25 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t25 + 41: $t24 := <($t25, $t6) + # live vars: $t2, $t4, $t5, $t6, $t20, $t24 + 42: if ($t24) goto 43 else goto 67 + # live vars: $t2, $t4, $t5, $t6, $t20 + 43: label L10 + # live vars: $t2, $t4, $t5, $t6, $t20 + 44: $t29 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t29 + 45: $t28 := vector::borrow($t29, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t28 + 46: $t27 := infer($t28) + # live vars: $t2, $t4, $t5, $t6, $t20, $t27 + 47: $t30 := read_ref($t27) + # live vars: $t2, $t4, $t5, $t6, $t20, $t30 + 48: $t31 := 1 + # live vars: $t2, $t4, $t5, $t6, $t20, $t30, $t31 + 49: $t26 := >($t30, $t31) + # live vars: $t2, $t4, $t5, $t6, $t20, $t26 + 50: if ($t26) goto 51 else goto 60 + # live vars: $t2, $t4, $t5, $t6, $t20 + 51: label L13 + # live vars: $t2, $t4, $t5, $t6, $t20 + 52: $t32 := infer($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32 + 53: $t33 := infer($t20) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32, $t33 + 54: vector::swap($t32, $t33, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 55: $t35 := infer($t20) + # live vars: $t2, $t4, $t5, $t6, $t35 + 56: $t36 := 1 + # live vars: $t2, $t4, $t5, $t6, $t35, $t36 + 57: $t34 := +($t35, $t36) + # live vars: $t2, $t4, $t5, $t6, $t34 + 58: $t20 := infer($t34) + # live vars: $t2, $t4, $t5, $t6, $t20 + 59: goto 61 + # live vars: $t2, $t4, $t5, $t6, $t20 + 60: label L14 + # live vars: $t2, $t4, $t5, $t6, $t20 + 61: label L15 + # live vars: $t2, $t4, $t5, $t6, $t20 + 62: $t38 := infer($t5) + # live vars: $t2, $t4, $t6, $t20, $t38 + 63: $t39 := 1 + # live vars: $t2, $t4, $t6, $t20, $t38, $t39 + 64: $t37 := +($t38, $t39) + # live vars: $t2, $t4, $t6, $t20, $t37 + 65: $t5 := infer($t37) + # live vars: $t2, $t4, $t5, $t6, $t20 + 66: goto 69 + # live vars: $t2, $t4, $t5, $t6, $t20 + 67: label L11 + # live vars: $t2, $t20 + 68: goto 71 + # live vars: $t2, $t4, $t5, $t6, $t20 + 69: label L12 + # live vars: $t2, $t4, $t5, $t6, $t20 + 70: goto 39 + # live vars: $t2, $t20 + 71: label L9 + # live vars: $t2, $t20 + 72: $t3 := infer($t20) + # live vars: $t2 + 73: $t41 := freeze_ref(implicit)($t2) + # live vars: $t41 + 74: $t42 := 0 + # live vars: $t41, $t42 + 75: $t40 := vector::borrow($t41, $t42) + # live vars: $t40 + 76: $t0 := read_ref($t40) + # live vars: $t0 + 77: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 + var $t1: vector + var $t2: &mut vector + var $t3: u64 + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool + var $t11: bool + var $t12: &u64 + var $t13: &u64 + var $t14: &vector + var $t15: u64 + var $t16: u64 + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector + var $t30: u64 + var $t31: u64 + var $t32: &mut vector + var $t33: u64 + var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := infer($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := infer($t5) # live vars: $t2, $t4, $t5, $t6, $t9 - 17: if ($t9) goto 18 else goto 21 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 10 else goto 29 # live vars: $t2, $t4, $t5, $t6 - 18: label L5 + 10: label L2 # live vars: $t2, $t4, $t5, $t6 - 19: goto 31 + 11: $t14 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t14 + 12: $t13 := vector::borrow($t14, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 13: $t12 := infer($t13) + # live vars: $t2, $t4, $t5, $t6, $t12 + 14: $t15 := read_ref($t12) + # live vars: $t2, $t4, $t5, $t6, $t15 + 15: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t15, $t16 + 16: $t11 := >($t15, $t16) + # live vars: $t2, $t4, $t5, $t6, $t11 + 17: $t10 := !($t11) + # live vars: $t2, $t4, $t5, $t6, $t10 + 18: if ($t10) goto 19 else goto 22 # live vars: $t2, $t4, $t5, $t6 - 20: goto 22 + 19: label L5 # live vars: $t2, $t4, $t5, $t6 - 21: label L6 + 20: goto 33 # live vars: $t2, $t4, $t5, $t6 - 22: label L7 + 21: goto 23 # live vars: $t2, $t4, $t5, $t6 - 23: $t17 := 1 - # live vars: $t2, $t4, $t5, $t6, $t17 - 24: $t16 := +($t5, $t17) - # live vars: $t2, $t4, $t6, $t16 - 25: $t5 := infer($t16) + 22: label L6 # live vars: $t2, $t4, $t5, $t6 - 26: goto 29 + 23: label L7 # live vars: $t2, $t4, $t5, $t6 - 27: label L3 + 24: $t18 := infer($t5) + # live vars: $t2, $t4, $t6, $t18 + 25: $t19 := 1 + # live vars: $t2, $t4, $t6, $t18, $t19 + 26: $t17 := +($t18, $t19) + # live vars: $t2, $t4, $t6, $t17 + 27: $t5 := infer($t17) # live vars: $t2, $t4, $t5, $t6 28: goto 31 # live vars: $t2, $t4, $t5, $t6 - 29: label L4 + 29: label L3 + # live vars: $t2, $t4, $t5, $t6 + 30: goto 33 + # live vars: $t2, $t4, $t5, $t6 + 31: label L4 + # live vars: $t2, $t4, $t5, $t6 + 32: goto 6 + # live vars: $t2, $t4, $t5, $t6 + 33: label L1 + # live vars: $t2, $t4, $t5, $t6 + 34: $t20 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 35: $t22 := infer($t5) + # live vars: $t2, $t4, $t6, $t20, $t22 + 36: $t23 := 1 + # live vars: $t2, $t4, $t6, $t20, $t22, $t23 + 37: $t21 := +($t22, $t23) + # live vars: $t2, $t4, $t6, $t20, $t21 + 38: $t5 := infer($t21) + # live vars: $t2, $t4, $t5, $t6, $t20 + 39: label L8 + # live vars: $t2, $t4, $t5, $t6, $t20 + 40: $t25 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t25 + 41: $t24 := <($t25, $t6) + # live vars: $t2, $t4, $t5, $t6, $t20, $t24 + 42: if ($t24) goto 43 else goto 67 + # live vars: $t2, $t4, $t5, $t6, $t20 + 43: label L10 + # live vars: $t2, $t4, $t5, $t6, $t20 + 44: $t29 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t29 + 45: $t28 := vector::borrow($t29, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t28 + 46: $t27 := infer($t28) + # live vars: $t2, $t4, $t5, $t6, $t20, $t27 + 47: $t30 := read_ref($t27) + # live vars: $t2, $t4, $t5, $t6, $t20, $t30 + 48: $t31 := 1 + # live vars: $t2, $t4, $t5, $t6, $t20, $t30, $t31 + 49: $t26 := >($t30, $t31) + # live vars: $t2, $t4, $t5, $t6, $t20, $t26 + 50: if ($t26) goto 51 else goto 60 + # live vars: $t2, $t4, $t5, $t6, $t20 + 51: label L13 + # live vars: $t2, $t4, $t5, $t6, $t20 + 52: $t32 := infer($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32 + 53: $t33 := infer($t20) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32, $t33 + 54: vector::swap($t32, $t33, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 55: $t35 := infer($t20) + # live vars: $t2, $t4, $t5, $t6, $t35 + 56: $t36 := 1 + # live vars: $t2, $t4, $t5, $t6, $t35, $t36 + 57: $t34 := +($t35, $t36) + # live vars: $t2, $t4, $t5, $t6, $t34 + 58: $t20 := infer($t34) + # live vars: $t2, $t4, $t5, $t6, $t20 + 59: goto 61 + # live vars: $t2, $t4, $t5, $t6, $t20 + 60: label L14 + # live vars: $t2, $t4, $t5, $t6, $t20 + 61: label L15 + # live vars: $t2, $t4, $t5, $t6, $t20 + 62: $t38 := infer($t5) + # live vars: $t2, $t4, $t6, $t20, $t38 + 63: $t39 := 1 + # live vars: $t2, $t4, $t6, $t20, $t38, $t39 + 64: $t37 := +($t38, $t39) + # live vars: $t2, $t4, $t6, $t20, $t37 + 65: $t5 := infer($t37) + # live vars: $t2, $t4, $t5, $t6, $t20 + 66: goto 69 + # live vars: $t2, $t4, $t5, $t6, $t20 + 67: label L11 + # live vars: $t2, $t20 + 68: goto 71 + # live vars: $t2, $t4, $t5, $t6, $t20 + 69: label L12 + # live vars: $t2, $t4, $t5, $t6, $t20 + 70: goto 39 + # live vars: $t2, $t20 + 71: label L9 + # live vars: $t2, $t20 + 72: $t3 := infer($t20) + # live vars: $t2 + 73: $t41 := freeze_ref(implicit)($t2) + # live vars: $t41 + 74: $t42 := 0 + # live vars: $t41, $t42 + 75: $t40 := vector::borrow($t41, $t42) + # live vars: $t40 + 76: $t0 := read_ref($t40) + # live vars: $t0 + 77: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 + var $t1: vector + var $t2: &mut vector + var $t3: u64 + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool + var $t11: bool + var $t12: &u64 + var $t13: &u64 + var $t14: &vector + var $t15: u64 + var $t16: u64 + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector + var $t30: u64 + var $t31: u64 + var $t32: &mut vector + var $t33: u64 + var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := copy($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 12 else goto 10 + # live vars: $t2, $t4, $t5, $t6 + 10: label L16 + # live vars: $t2, $t4, $t5, $t6 + 11: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 12: label L2 # live vars: $t2, $t4, $t5, $t6 - 30: goto 6 + 13: $t14 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t14 + 14: $t13 := vector::borrow($t14, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 15: $t12 := move($t13) + # live vars: $t2, $t4, $t5, $t6, $t12 + 16: $t15 := read_ref($t12) + # live vars: $t2, $t4, $t5, $t6, $t15 + 17: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t15, $t16 + 18: $t11 := >($t15, $t16) + # live vars: $t2, $t4, $t5, $t6, $t11 + 19: $t10 := !($t11) + # live vars: $t2, $t4, $t5, $t6, $t10 + 20: if ($t10) goto 21 else goto 65 + # live vars: $t2, $t4, $t5, $t6 + 21: label L17 + # live vars: $t2, $t4, $t5, $t6 + 22: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 23: label L1 + # live vars: $t2, $t4, $t5, $t6 + 24: $t20 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 25: $t22 := move($t5) + # live vars: $t2, $t4, $t6, $t20, $t22 + 26: $t23 := 1 + # live vars: $t2, $t4, $t6, $t20, $t22, $t23 + 27: $t21 := +($t22, $t23) + # live vars: $t2, $t4, $t6, $t20, $t21 + 28: $t5 := move($t21) + # live vars: $t2, $t4, $t5, $t6, $t20 + 29: label L8 + # live vars: $t2, $t4, $t5, $t6, $t20 + 30: $t25 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t25 + 31: $t24 := <($t25, $t6) + # live vars: $t2, $t4, $t5, $t6, $t20, $t24 + 32: if ($t24) goto 33 else goto 57 + # live vars: $t2, $t4, $t5, $t6, $t20 + 33: label L10 + # live vars: $t2, $t4, $t5, $t6, $t20 + 34: $t29 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t29 + 35: $t28 := vector::borrow($t29, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t28 + 36: $t27 := move($t28) + # live vars: $t2, $t4, $t5, $t6, $t20, $t27 + 37: $t30 := read_ref($t27) + # live vars: $t2, $t4, $t5, $t6, $t20, $t30 + 38: $t31 := 1 + # live vars: $t2, $t4, $t5, $t6, $t20, $t30, $t31 + 39: $t26 := >($t30, $t31) + # live vars: $t2, $t4, $t5, $t6, $t20, $t26 + 40: if ($t26) goto 43 else goto 41 + # live vars: $t2, $t4, $t5, $t6, $t20 + 41: label L18 + # live vars: $t2, $t4, $t5, $t6, $t20 + 42: goto 51 + # live vars: $t2, $t4, $t5, $t6, $t20 + 43: label L13 + # live vars: $t2, $t4, $t5, $t6, $t20 + 44: $t32 := copy($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32 + 45: $t33 := copy($t20) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32, $t33 + 46: vector::swap($t32, $t33, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 47: $t35 := move($t20) + # live vars: $t2, $t4, $t5, $t6, $t35 + 48: $t36 := 1 + # live vars: $t2, $t4, $t5, $t6, $t35, $t36 + 49: $t34 := +($t35, $t36) + # live vars: $t2, $t4, $t5, $t6, $t34 + 50: $t20 := move($t34) + # live vars: $t2, $t4, $t5, $t6, $t20 + 51: label L15 + # live vars: $t2, $t4, $t5, $t6, $t20 + 52: $t38 := move($t5) + # live vars: $t2, $t4, $t6, $t20, $t38 + 53: $t39 := 1 + # live vars: $t2, $t4, $t6, $t20, $t38, $t39 + 54: $t37 := +($t38, $t39) + # live vars: $t2, $t4, $t6, $t20, $t37 + 55: $t5 := move($t37) + # live vars: $t2, $t4, $t5, $t6, $t20 + 56: goto 29 + # live vars: $t2, $t4, $t5, $t6, $t20 + 57: label L11 + # live vars: $t2, $t4, $t20 + 58: drop($t4) + # live vars: $t2, $t20 + 59: $t3 := move($t20) + # live vars: $t2 + 60: $t41 := freeze_ref(implicit)($t2) + # live vars: $t41 + 61: $t42 := 0 + # live vars: $t41, $t42 + 62: $t40 := vector::borrow($t41, $t42) + # live vars: $t40 + 63: $t0 := read_ref($t40) + # live vars: $t0 + 64: return $t0 # live vars: $t2, $t4, $t5, $t6 - 31: label L1 + 65: label L7 # live vars: $t2, $t4, $t5, $t6 - 32: $t18 := infer($t5) - # live vars: $t2, $t4, $t5, $t6, $t18 - 33: $t20 := 1 - # live vars: $t2, $t4, $t5, $t6, $t18, $t20 - 34: $t19 := +($t5, $t20) + 66: $t18 := move($t5) + # live vars: $t2, $t4, $t6, $t18 + 67: $t19 := 1 # live vars: $t2, $t4, $t6, $t18, $t19 - 35: $t5 := infer($t19) - # live vars: $t2, $t4, $t5, $t6, $t18 - 36: label L8 - # live vars: $t2, $t4, $t5, $t6, $t18 - 37: $t21 := <($t5, $t6) - # live vars: $t2, $t4, $t5, $t6, $t18, $t21 - 38: if ($t21) goto 39 else goto 59 - # live vars: $t2, $t4, $t5, $t6, $t18 - 39: label L10 - # live vars: $t2, $t4, $t5, $t6, $t18 - 40: $t25 := freeze_ref(implicit)($t4) - # live vars: $t2, $t4, $t5, $t6, $t18, $t25 - 41: $t24 := vector::borrow($t25, $t5) - # live vars: $t2, $t4, $t5, $t6, $t18, $t24 - 42: $t23 := infer($t24) - # live vars: $t2, $t4, $t5, $t6, $t18, $t23 - 43: $t26 := read_ref($t23) - # live vars: $t2, $t4, $t5, $t6, $t18, $t26 - 44: $t27 := 1 - # live vars: $t2, $t4, $t5, $t6, $t18, $t26, $t27 - 45: $t22 := >($t26, $t27) - # live vars: $t2, $t4, $t5, $t6, $t18, $t22 - 46: if ($t22) goto 47 else goto 53 - # live vars: $t2, $t4, $t5, $t6, $t18 - 47: label L13 - # live vars: $t2, $t4, $t5, $t6, $t18 - 48: vector::swap($t4, $t18, $t5) - # live vars: $t2, $t4, $t5, $t6, $t18 - 49: $t29 := 1 - # live vars: $t2, $t4, $t5, $t6, $t18, $t29 - 50: $t28 := +($t18, $t29) - # live vars: $t2, $t4, $t5, $t6, $t28 - 51: $t18 := infer($t28) - # live vars: $t2, $t4, $t5, $t6, $t18 - 52: goto 54 - # live vars: $t2, $t4, $t5, $t6, $t18 - 53: label L14 - # live vars: $t2, $t4, $t5, $t6, $t18 - 54: label L15 - # live vars: $t2, $t4, $t5, $t6, $t18 - 55: $t31 := 1 - # live vars: $t2, $t4, $t5, $t6, $t18, $t31 - 56: $t30 := +($t5, $t31) - # live vars: $t2, $t4, $t6, $t18, $t30 - 57: $t5 := infer($t30) - # live vars: $t2, $t4, $t5, $t6, $t18 - 58: goto 61 - # live vars: $t2, $t4, $t5, $t6, $t18 - 59: label L11 - # live vars: $t2, $t18 - 60: goto 63 - # live vars: $t2, $t4, $t5, $t6, $t18 - 61: label L12 - # live vars: $t2, $t4, $t5, $t6, $t18 - 62: goto 36 - # live vars: $t2, $t18 - 63: label L9 - # live vars: $t2, $t18 - 64: $t3 := infer($t18) + 68: $t17 := +($t18, $t19) + # live vars: $t2, $t4, $t6, $t17 + 69: $t5 := move($t17) + # live vars: $t2, $t4, $t5, $t6 + 70: goto 6 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 + var $t1: vector + var $t2: &mut vector + var $t3: u64 [unused] + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool + var $t11: bool + var $t12: &u64 + var $t13: &u64 + var $t14: &vector + var $t15: u64 + var $t16: u64 + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector + var $t30: u64 + var $t31: u64 + var $t32: &mut vector + var $t33: u64 + var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := copy($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 12 else goto 10 + # live vars: $t2, $t4, $t5, $t6 + 10: label L16 + # live vars: $t2, $t4, $t5, $t6 + 11: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 12: label L2 + # live vars: $t2, $t4, $t5, $t6 + 13: $t14 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t14 + 14: $t13 := vector::borrow($t14, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 15: $t12 := move($t13) + # live vars: $t2, $t4, $t5, $t6, $t12 + 16: $t15 := read_ref($t12) + # live vars: $t2, $t4, $t5, $t6, $t15 + 17: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t15, $t16 + 18: $t11 := >($t15, $t16) + # live vars: $t2, $t4, $t5, $t6, $t11 + 19: $t10 := !($t11) + # live vars: $t2, $t4, $t5, $t6, $t10 + 20: if ($t10) goto 21 else goto 64 + # live vars: $t2, $t4, $t5, $t6 + 21: label L17 + # live vars: $t2, $t4, $t5, $t6 + 22: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 23: label L1 + # live vars: $t2, $t4, $t5, $t6 + 24: $t20 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 25: $t22 := move($t5) + # live vars: $t2, $t4, $t6, $t20, $t22 + 26: $t23 := 1 + # live vars: $t2, $t4, $t6, $t20, $t22, $t23 + 27: $t21 := +($t22, $t23) + # live vars: $t2, $t4, $t6, $t20, $t21 + 28: $t5 := move($t21) + # live vars: $t2, $t4, $t5, $t6, $t20 + 29: label L8 + # live vars: $t2, $t4, $t5, $t6, $t20 + 30: $t25 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t25 + 31: $t24 := <($t25, $t6) + # live vars: $t2, $t4, $t5, $t6, $t20, $t24 + 32: if ($t24) goto 33 else goto 57 + # live vars: $t2, $t4, $t5, $t6, $t20 + 33: label L10 + # live vars: $t2, $t4, $t5, $t6, $t20 + 34: $t29 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t29 + 35: $t28 := vector::borrow($t29, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t28 + 36: $t27 := move($t28) + # live vars: $t2, $t4, $t5, $t6, $t20, $t27 + 37: $t30 := read_ref($t27) + # live vars: $t2, $t4, $t5, $t6, $t20, $t30 + 38: $t31 := 1 + # live vars: $t2, $t4, $t5, $t6, $t20, $t30, $t31 + 39: $t26 := >($t30, $t31) + # live vars: $t2, $t4, $t5, $t6, $t20, $t26 + 40: if ($t26) goto 43 else goto 41 + # live vars: $t2, $t4, $t5, $t6, $t20 + 41: label L18 + # live vars: $t2, $t4, $t5, $t6, $t20 + 42: goto 51 + # live vars: $t2, $t4, $t5, $t6, $t20 + 43: label L13 + # live vars: $t2, $t4, $t5, $t6, $t20 + 44: $t32 := copy($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32 + 45: $t33 := copy($t20) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32, $t33 + 46: vector::swap($t32, $t33, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 47: $t35 := move($t20) + # live vars: $t2, $t4, $t5, $t6, $t35 + 48: $t36 := 1 + # live vars: $t2, $t4, $t5, $t6, $t35, $t36 + 49: $t34 := +($t35, $t36) + # live vars: $t2, $t4, $t5, $t6, $t34 + 50: $t20 := move($t34) + # live vars: $t2, $t4, $t5, $t6, $t20 + 51: label L15 + # live vars: $t2, $t4, $t5, $t6, $t20 + 52: $t38 := move($t5) + # live vars: $t2, $t4, $t6, $t20, $t38 + 53: $t39 := 1 + # live vars: $t2, $t4, $t6, $t20, $t38, $t39 + 54: $t37 := +($t38, $t39) + # live vars: $t2, $t4, $t6, $t20, $t37 + 55: $t5 := move($t37) + # live vars: $t2, $t4, $t5, $t6, $t20 + 56: goto 29 + # live vars: $t2, $t4, $t5, $t6, $t20 + 57: label L11 + # live vars: $t2, $t4 + 58: drop($t4) # live vars: $t2 - 65: $t33 := freeze_ref(implicit)($t2) - # live vars: $t33 - 66: $t34 := 0 - # live vars: $t33, $t34 - 67: $t32 := vector::borrow($t33, $t34) - # live vars: $t32 - 68: $t0 := read_ref($t32) + 59: $t41 := freeze_ref(implicit)($t2) + # live vars: $t41 + 60: $t42 := 0 + # live vars: $t41, $t42 + 61: $t40 := vector::borrow($t41, $t42) + # live vars: $t40 + 62: $t0 := read_ref($t40) # live vars: $t0 - 69: return $t0 + 63: return $t0 + # live vars: $t2, $t4, $t5, $t6 + 64: label L7 + # live vars: $t2, $t4, $t5, $t6 + 65: $t18 := move($t5) + # live vars: $t2, $t4, $t6, $t18 + 66: $t19 := 1 + # live vars: $t2, $t4, $t6, $t18, $t19 + 67: $t17 := +($t18, $t19) + # live vars: $t2, $t4, $t6, $t17 + 68: $t5 := move($t17) + # live vars: $t2, $t4, $t5, $t6 + 69: goto 6 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 [unused] + var $t1: vector + var $t2: &mut vector + var $t3: u64 [unused] + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool [unused] + var $t11: bool [unused] + var $t12: &u64 [unused] + var $t13: &u64 + var $t14: &vector [unused] + var $t15: u64 [unused] + var $t16: u64 + var $t17: u64 [unused] + var $t18: u64 [unused] + var $t19: u64 [unused] + var $t20: u64 [unused] + var $t21: u64 [unused] + var $t22: u64 [unused] + var $t23: u64 + var $t24: bool [unused] + var $t25: u64 [unused] + var $t26: bool [unused] + var $t27: &u64 [unused] + var $t28: &u64 [unused] + var $t29: &vector [unused] + var $t30: u64 [unused] + var $t31: u64 [unused] + var $t32: &mut vector + var $t33: u64 [unused] + var $t34: u64 [unused] + var $t35: u64 [unused] + var $t36: u64 [unused] + var $t37: u64 [unused] + var $t38: u64 [unused] + var $t39: u64 [unused] + var $t40: &u64 [unused] + var $t41: &vector [unused] + var $t42: u64 [unused] + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := copy($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 12 else goto 10 + # live vars: $t2, $t4, $t5, $t6 + 10: label L16 + # live vars: $t2, $t4, $t5, $t6 + 11: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 12: label L2 + # live vars: $t2, $t4, $t5, $t6 + 13: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t7 + 14: $t13 := vector::borrow($t7, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 15: $t13 := move($t13) + # live vars: $t2, $t4, $t5, $t6, $t13 + 16: $t9 := read_ref($t13) + # live vars: $t2, $t4, $t5, $t6, $t9 + 17: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 18: $t8 := >($t9, $t16) + # live vars: $t2, $t4, $t5, $t6, $t8 + 19: $t8 := !($t8) + # live vars: $t2, $t4, $t5, $t6, $t8 + 20: if ($t8) goto 21 else goto 64 + # live vars: $t2, $t4, $t5, $t6 + 21: label L17 + # live vars: $t2, $t4, $t5, $t6 + 22: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 23: label L1 + # live vars: $t2, $t4, $t5, $t6 + 24: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 25: $t16 := move($t5) + # live vars: $t2, $t4, $t6, $t9, $t16 + 26: $t23 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16, $t23 + 27: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t6, $t9, $t16 + 28: $t5 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 29: label L8 + # live vars: $t2, $t4, $t5, $t6, $t9 + 30: $t16 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 31: $t8 := <($t16, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8, $t9 + 32: if ($t8) goto 33 else goto 57 + # live vars: $t2, $t4, $t5, $t6, $t9 + 33: label L10 + # live vars: $t2, $t4, $t5, $t6, $t9 + 34: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t7, $t9 + 35: $t13 := vector::borrow($t7, $t5) + # live vars: $t2, $t4, $t5, $t6, $t9, $t13 + 36: $t13 := move($t13) + # live vars: $t2, $t4, $t5, $t6, $t9, $t13 + 37: $t16 := read_ref($t13) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 38: $t23 := 1 + # live vars: $t2, $t4, $t5, $t6, $t9, $t16, $t23 + 39: $t8 := >($t16, $t23) + # live vars: $t2, $t4, $t5, $t6, $t8, $t9 + 40: if ($t8) goto 43 else goto 41 + # live vars: $t2, $t4, $t5, $t6, $t9 + 41: label L18 + # live vars: $t2, $t4, $t5, $t6, $t9 + 42: goto 51 + # live vars: $t2, $t4, $t5, $t6, $t9 + 43: label L13 + # live vars: $t2, $t4, $t5, $t6, $t9 + 44: $t32 := copy($t4) + # live vars: $t2, $t4, $t5, $t6, $t9, $t32 + 45: $t16 := copy($t9) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16, $t32 + 46: vector::swap($t32, $t16, $t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 47: $t16 := move($t9) + # live vars: $t2, $t4, $t5, $t6, $t16 + 48: $t23 := 1 + # live vars: $t2, $t4, $t5, $t6, $t16, $t23 + 49: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t5, $t6, $t16 + 50: $t9 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 51: label L15 + # live vars: $t2, $t4, $t5, $t6, $t9 + 52: $t16 := move($t5) + # live vars: $t2, $t4, $t6, $t9, $t16 + 53: $t23 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16, $t23 + 54: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t6, $t9, $t16 + 55: $t5 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 56: goto 29 + # live vars: $t2, $t4, $t5, $t6, $t9 + 57: label L11 + # live vars: $t2, $t4 + 58: drop($t4) + # live vars: $t2 + 59: $t7 := freeze_ref(implicit)($t2) + # live vars: $t7 + 60: $t9 := 0 + # live vars: $t7, $t9 + 61: $t13 := vector::borrow($t7, $t9) + # live vars: $t13 + 62: $t9 := read_ref($t13) + # live vars: $t9 + 63: return $t9 + # live vars: $t2, $t4, $t5, $t6 + 64: label L7 + # live vars: $t2, $t4, $t5, $t6 + 65: $t9 := move($t5) + # live vars: $t2, $t4, $t6, $t9 + 66: $t16 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16 + 67: $t9 := +($t9, $t16) + # live vars: $t2, $t4, $t6, $t9 + 68: $t5 := move($t9) + # live vars: $t2, $t4, $t5, $t6 + 69: goto 6 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 [unused] + var $t1: vector + var $t2: &mut vector + var $t3: u64 [unused] + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool [unused] + var $t11: bool [unused] + var $t12: &u64 [unused] + var $t13: &u64 + var $t14: &vector [unused] + var $t15: u64 [unused] + var $t16: u64 + var $t17: u64 [unused] + var $t18: u64 [unused] + var $t19: u64 [unused] + var $t20: u64 [unused] + var $t21: u64 [unused] + var $t22: u64 [unused] + var $t23: u64 + var $t24: bool [unused] + var $t25: u64 [unused] + var $t26: bool [unused] + var $t27: &u64 [unused] + var $t28: &u64 [unused] + var $t29: &vector [unused] + var $t30: u64 [unused] + var $t31: u64 [unused] + var $t32: &mut vector + var $t33: u64 [unused] + var $t34: u64 [unused] + var $t35: u64 [unused] + var $t36: u64 [unused] + var $t37: u64 [unused] + var $t38: u64 [unused] + var $t39: u64 [unused] + var $t40: &u64 [unused] + var $t41: &vector [unused] + var $t42: u64 [unused] + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := copy($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 12 else goto 10 + # live vars: $t2, $t4, $t5, $t6 + 10: label L16 + # live vars: $t2, $t4, $t5, $t6 + 11: goto 22 + # live vars: $t2, $t4, $t5, $t6 + 12: label L2 + # live vars: $t2, $t4, $t5, $t6 + 13: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t7 + 14: $t13 := vector::borrow($t7, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 15: $t9 := read_ref($t13) + # live vars: $t2, $t4, $t5, $t6, $t9 + 16: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 17: $t8 := >($t9, $t16) + # live vars: $t2, $t4, $t5, $t6, $t8 + 18: $t8 := !($t8) + # live vars: $t2, $t4, $t5, $t6, $t8 + 19: if ($t8) goto 20 else goto 62 + # live vars: $t2, $t4, $t5, $t6 + 20: label L17 + # live vars: $t2, $t4, $t5, $t6 + 21: goto 22 + # live vars: $t2, $t4, $t5, $t6 + 22: label L1 + # live vars: $t2, $t4, $t5, $t6 + 23: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 24: $t16 := move($t5) + # live vars: $t2, $t4, $t6, $t9, $t16 + 25: $t23 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16, $t23 + 26: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t6, $t9, $t16 + 27: $t5 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 28: label L8 + # live vars: $t2, $t4, $t5, $t6, $t9 + 29: $t16 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 30: $t8 := <($t16, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8, $t9 + 31: if ($t8) goto 32 else goto 55 + # live vars: $t2, $t4, $t5, $t6, $t9 + 32: label L10 + # live vars: $t2, $t4, $t5, $t6, $t9 + 33: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t7, $t9 + 34: $t13 := vector::borrow($t7, $t5) + # live vars: $t2, $t4, $t5, $t6, $t9, $t13 + 35: $t16 := read_ref($t13) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 36: $t23 := 1 + # live vars: $t2, $t4, $t5, $t6, $t9, $t16, $t23 + 37: $t8 := >($t16, $t23) + # live vars: $t2, $t4, $t5, $t6, $t8, $t9 + 38: if ($t8) goto 41 else goto 39 + # live vars: $t2, $t4, $t5, $t6, $t9 + 39: label L18 + # live vars: $t2, $t4, $t5, $t6, $t9 + 40: goto 49 + # live vars: $t2, $t4, $t5, $t6, $t9 + 41: label L13 + # live vars: $t2, $t4, $t5, $t6, $t9 + 42: $t32 := copy($t4) + # live vars: $t2, $t4, $t5, $t6, $t9, $t32 + 43: $t16 := copy($t9) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16, $t32 + 44: vector::swap($t32, $t16, $t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 45: $t16 := move($t9) + # live vars: $t2, $t4, $t5, $t6, $t16 + 46: $t23 := 1 + # live vars: $t2, $t4, $t5, $t6, $t16, $t23 + 47: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t5, $t6, $t16 + 48: $t9 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 49: label L15 + # live vars: $t2, $t4, $t5, $t6, $t9 + 50: $t16 := move($t5) + # live vars: $t2, $t4, $t6, $t9, $t16 + 51: $t23 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16, $t23 + 52: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t6, $t9, $t16 + 53: $t5 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 54: goto 28 + # live vars: $t2, $t4, $t5, $t6, $t9 + 55: label L11 + # live vars: $t2, $t4 + 56: drop($t4) + # live vars: $t2 + 57: $t7 := freeze_ref(implicit)($t2) + # live vars: $t7 + 58: $t9 := 0 + # live vars: $t7, $t9 + 59: $t13 := vector::borrow($t7, $t9) + # live vars: $t13 + 60: $t9 := read_ref($t13) + # live vars: $t9 + 61: return $t9 + # live vars: $t2, $t4, $t5, $t6 + 62: label L7 + # live vars: $t2, $t4, $t5, $t6 + 63: $t9 := move($t5) + # live vars: $t2, $t4, $t6, $t9 + 64: $t16 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16 + 65: $t9 := +($t9, $t16) + # live vars: $t2, $t4, $t6, $t9 + 66: $t5 := move($t9) + # live vars: $t2, $t4, $t5, $t6 + 67: goto 6 +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { + + +foo(): u64 /* def_idx: 0 */ { +L0: loc0: vector +L1: loc1: &mut vector +L2: loc2: &mut vector +L3: loc3: u64 +L4: loc4: u64 +L5: loc5: u64 +B0: + 0: LdConst[0](Vector(U64): [3, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](loc0: vector) + 2: MutBorrowLoc[0](loc0: vector) + 3: StLoc[1](loc1: &mut vector) + 4: CopyLoc[1](loc1: &mut vector) + 5: StLoc[2](loc2: &mut vector) + 6: LdU64(0) + 7: StLoc[3](loc3: u64) + 8: CopyLoc[2](loc2: &mut vector) + 9: FreezeRef + 10: VecLen(1) + 11: StLoc[4](loc4: u64) +B1: + 12: CopyLoc[3](loc3: u64) + 13: CopyLoc[4](loc4: u64) + 14: Lt + 15: BrTrue(17) +B2: + 16: Branch(26) +B3: + 17: CopyLoc[2](loc2: &mut vector) + 18: FreezeRef + 19: CopyLoc[3](loc3: u64) + 20: VecImmBorrow(1) + 21: ReadRef + 22: LdU64(1) + 23: Gt + 24: BrTrue(66) +B4: + 25: Branch(26) +B5: + 26: CopyLoc[3](loc3: u64) + 27: StLoc[5](loc5: u64) + 28: MoveLoc[3](loc3: u64) + 29: LdU64(1) + 30: Add + 31: StLoc[3](loc3: u64) +B6: + 32: CopyLoc[3](loc3: u64) + 33: CopyLoc[4](loc4: u64) + 34: Lt + 35: BrFalse(58) +B7: + 36: CopyLoc[2](loc2: &mut vector) + 37: FreezeRef + 38: CopyLoc[3](loc3: u64) + 39: VecImmBorrow(1) + 40: ReadRef + 41: LdU64(1) + 42: Gt + 43: BrTrue(45) +B8: + 44: Branch(53) +B9: + 45: CopyLoc[2](loc2: &mut vector) + 46: CopyLoc[5](loc5: u64) + 47: CopyLoc[3](loc3: u64) + 48: VecSwap(1) + 49: MoveLoc[5](loc5: u64) + 50: LdU64(1) + 51: Add + 52: StLoc[5](loc5: u64) +B10: + 53: MoveLoc[3](loc3: u64) + 54: LdU64(1) + 55: Add + 56: StLoc[3](loc3: u64) + 57: Branch(32) +B11: + 58: MoveLoc[2](loc2: &mut vector) + 59: Pop + 60: MoveLoc[1](loc1: &mut vector) + 61: FreezeRef + 62: LdU64(0) + 63: VecImmBorrow(1) + 64: ReadRef + 65: Ret +B12: + 66: MoveLoc[3](loc3: u64) + 67: LdU64(1) + 68: Add + 69: StLoc[3](loc3: u64) + 70: Branch(12) +} } +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/live-var/mut_inline_typed.exp b/third_party/move/move-compiler-v2/tests/live-var/mut_inline_typed.exp index 294f89be7fbf0..e6e9ffce3b0ea 100644 --- a/third_party/move/move-compiler-v2/tests/live-var/mut_inline_typed.exp +++ b/third_party/move/move-compiler-v2/tests/live-var/mut_inline_typed.exp @@ -11,32 +11,40 @@ fun m::foo(): u64 { var $t6: u64 var $t7: &vector var $t8: bool - var $t9: bool + var $t9: u64 var $t10: bool - var $t11: &u64 + var $t11: bool var $t12: &u64 - var $t13: &vector - var $t14: u64 + var $t13: &u64 + var $t14: &vector var $t15: u64 var $t16: u64 var $t17: u64 var $t18: u64 var $t19: u64 var $t20: u64 - var $t21: bool - var $t22: bool - var $t23: &u64 - var $t24: &u64 - var $t25: &vector - var $t26: u64 - var $t27: u64 - var $t28: u64 - var $t29: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector var $t30: u64 var $t31: u64 - var $t32: &u64 - var $t33: &vector + var $t32: &mut vector + var $t33: u64 var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 0: $t1 := ["1", "2", "3"] 1: $t2 := borrow_local($t1) 2: $t4 := infer($t2) @@ -44,69 +52,77 @@ fun m::foo(): u64 { 4: $t7 := freeze_ref(implicit)($t4) 5: $t6 := vector::length($t7) 6: label L0 - 7: $t8 := <($t5, $t6) - 8: if ($t8) goto 9 else goto 27 - 9: label L2 - 10: $t13 := freeze_ref(implicit)($t4) - 11: $t12 := vector::borrow($t13, $t5) - 12: $t11 := infer($t12) - 13: $t14 := read_ref($t11) - 14: $t15 := 1 - 15: $t10 := >($t14, $t15) - 16: $t9 := !($t10) - 17: if ($t9) goto 18 else goto 21 - 18: label L5 - 19: goto 31 - 20: goto 22 - 21: label L6 - 22: label L7 - 23: $t17 := 1 - 24: $t16 := +($t5, $t17) - 25: $t5 := infer($t16) - 26: goto 29 - 27: label L3 + 7: $t9 := infer($t5) + 8: $t8 := <($t9, $t6) + 9: if ($t8) goto 10 else goto 29 + 10: label L2 + 11: $t14 := freeze_ref(implicit)($t4) + 12: $t13 := vector::borrow($t14, $t5) + 13: $t12 := infer($t13) + 14: $t15 := read_ref($t12) + 15: $t16 := 1 + 16: $t11 := >($t15, $t16) + 17: $t10 := !($t11) + 18: if ($t10) goto 19 else goto 22 + 19: label L5 + 20: goto 33 + 21: goto 23 + 22: label L6 + 23: label L7 + 24: $t18 := infer($t5) + 25: $t19 := 1 + 26: $t17 := +($t18, $t19) + 27: $t5 := infer($t17) 28: goto 31 - 29: label L4 - 30: goto 6 - 31: label L1 - 32: $t18 := infer($t5) - 33: $t20 := 1 - 34: $t19 := +($t5, $t20) - 35: $t5 := infer($t19) - 36: label L8 - 37: $t21 := <($t5, $t6) - 38: if ($t21) goto 39 else goto 59 - 39: label L10 - 40: $t25 := freeze_ref(implicit)($t4) - 41: $t24 := vector::borrow($t25, $t5) - 42: $t23 := infer($t24) - 43: $t26 := read_ref($t23) - 44: $t27 := 1 - 45: $t22 := >($t26, $t27) - 46: if ($t22) goto 47 else goto 53 - 47: label L13 - 48: vector::swap($t4, $t18, $t5) - 49: $t29 := 1 - 50: $t28 := +($t18, $t29) - 51: $t18 := infer($t28) - 52: goto 54 - 53: label L14 - 54: label L15 - 55: $t31 := 1 - 56: $t30 := +($t5, $t31) - 57: $t5 := infer($t30) - 58: goto 61 - 59: label L11 - 60: goto 63 - 61: label L12 - 62: goto 36 - 63: label L9 - 64: $t3 := infer($t18) - 65: $t33 := freeze_ref(implicit)($t2) - 66: $t34 := 0 - 67: $t32 := vector::borrow($t33, $t34) - 68: $t0 := read_ref($t32) - 69: return $t0 + 29: label L3 + 30: goto 33 + 31: label L4 + 32: goto 6 + 33: label L1 + 34: $t20 := infer($t5) + 35: $t22 := infer($t5) + 36: $t23 := 1 + 37: $t21 := +($t22, $t23) + 38: $t5 := infer($t21) + 39: label L8 + 40: $t25 := infer($t5) + 41: $t24 := <($t25, $t6) + 42: if ($t24) goto 43 else goto 67 + 43: label L10 + 44: $t29 := freeze_ref(implicit)($t4) + 45: $t28 := vector::borrow($t29, $t5) + 46: $t27 := infer($t28) + 47: $t30 := read_ref($t27) + 48: $t31 := 1 + 49: $t26 := >($t30, $t31) + 50: if ($t26) goto 51 else goto 60 + 51: label L13 + 52: $t32 := infer($t4) + 53: $t33 := infer($t20) + 54: vector::swap($t32, $t33, $t5) + 55: $t35 := infer($t20) + 56: $t36 := 1 + 57: $t34 := +($t35, $t36) + 58: $t20 := infer($t34) + 59: goto 61 + 60: label L14 + 61: label L15 + 62: $t38 := infer($t5) + 63: $t39 := 1 + 64: $t37 := +($t38, $t39) + 65: $t5 := infer($t37) + 66: goto 69 + 67: label L11 + 68: goto 71 + 69: label L12 + 70: goto 39 + 71: label L9 + 72: $t3 := infer($t20) + 73: $t41 := freeze_ref(implicit)($t2) + 74: $t42 := 0 + 75: $t40 := vector::borrow($t41, $t42) + 76: $t0 := read_ref($t40) + 77: return $t0 } ============ after LiveVarAnalysisProcessor: ================ @@ -122,32 +138,40 @@ fun m::foo(): u64 { var $t6: u64 var $t7: &vector var $t8: bool - var $t9: bool + var $t9: u64 var $t10: bool - var $t11: &u64 + var $t11: bool var $t12: &u64 - var $t13: &vector - var $t14: u64 + var $t13: &u64 + var $t14: &vector var $t15: u64 var $t16: u64 var $t17: u64 var $t18: u64 var $t19: u64 var $t20: u64 - var $t21: bool - var $t22: bool - var $t23: &u64 - var $t24: &u64 - var $t25: &vector - var $t26: u64 - var $t27: u64 - var $t28: u64 - var $t29: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector var $t30: u64 var $t31: u64 - var $t32: &u64 - var $t33: &vector + var $t32: &mut vector + var $t33: u64 var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 # live vars: 0: $t1 := ["1", "2", "3"] # live vars: $t1 @@ -163,129 +187,1205 @@ fun m::foo(): u64 { # live vars: $t2, $t4, $t5, $t6 6: label L0 # live vars: $t2, $t4, $t5, $t6 - 7: $t8 := <($t5, $t6) + 7: $t9 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) # live vars: $t2, $t4, $t5, $t6, $t8 - 8: if ($t8) goto 9 else goto 27 + 9: if ($t8) goto 10 else goto 29 # live vars: $t2, $t4, $t5, $t6 - 9: label L2 + 10: label L2 # live vars: $t2, $t4, $t5, $t6 - 10: $t13 := freeze_ref(implicit)($t4) + 11: $t14 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t14 + 12: $t13 := vector::borrow($t14, $t5) # live vars: $t2, $t4, $t5, $t6, $t13 - 11: $t12 := vector::borrow($t13, $t5) + 13: $t12 := infer($t13) # live vars: $t2, $t4, $t5, $t6, $t12 - 12: $t11 := infer($t12) + 14: $t15 := read_ref($t12) + # live vars: $t2, $t4, $t5, $t6, $t15 + 15: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t15, $t16 + 16: $t11 := >($t15, $t16) # live vars: $t2, $t4, $t5, $t6, $t11 - 13: $t14 := read_ref($t11) - # live vars: $t2, $t4, $t5, $t6, $t14 - 14: $t15 := 1 - # live vars: $t2, $t4, $t5, $t6, $t14, $t15 - 15: $t10 := >($t14, $t15) + 17: $t10 := !($t11) # live vars: $t2, $t4, $t5, $t6, $t10 - 16: $t9 := !($t10) + 18: if ($t10) goto 19 else goto 22 + # live vars: $t2, $t4, $t5, $t6 + 19: label L5 + # live vars: $t2, $t4, $t5, $t6 + 20: goto 33 + # live vars: $t2, $t4, $t5, $t6 + 21: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 22: label L6 + # live vars: $t2, $t4, $t5, $t6 + 23: label L7 + # live vars: $t2, $t4, $t5, $t6 + 24: $t18 := infer($t5) + # live vars: $t2, $t4, $t6, $t18 + 25: $t19 := 1 + # live vars: $t2, $t4, $t6, $t18, $t19 + 26: $t17 := +($t18, $t19) + # live vars: $t2, $t4, $t6, $t17 + 27: $t5 := infer($t17) + # live vars: $t2, $t4, $t5, $t6 + 28: goto 31 + # live vars: $t2, $t4, $t5, $t6 + 29: label L3 + # live vars: $t2, $t4, $t5, $t6 + 30: goto 33 + # live vars: $t2, $t4, $t5, $t6 + 31: label L4 + # live vars: $t2, $t4, $t5, $t6 + 32: goto 6 + # live vars: $t2, $t4, $t5, $t6 + 33: label L1 + # live vars: $t2, $t4, $t5, $t6 + 34: $t20 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 35: $t22 := infer($t5) + # live vars: $t2, $t4, $t6, $t20, $t22 + 36: $t23 := 1 + # live vars: $t2, $t4, $t6, $t20, $t22, $t23 + 37: $t21 := +($t22, $t23) + # live vars: $t2, $t4, $t6, $t20, $t21 + 38: $t5 := infer($t21) + # live vars: $t2, $t4, $t5, $t6, $t20 + 39: label L8 + # live vars: $t2, $t4, $t5, $t6, $t20 + 40: $t25 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t25 + 41: $t24 := <($t25, $t6) + # live vars: $t2, $t4, $t5, $t6, $t20, $t24 + 42: if ($t24) goto 43 else goto 67 + # live vars: $t2, $t4, $t5, $t6, $t20 + 43: label L10 + # live vars: $t2, $t4, $t5, $t6, $t20 + 44: $t29 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t29 + 45: $t28 := vector::borrow($t29, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t28 + 46: $t27 := infer($t28) + # live vars: $t2, $t4, $t5, $t6, $t20, $t27 + 47: $t30 := read_ref($t27) + # live vars: $t2, $t4, $t5, $t6, $t20, $t30 + 48: $t31 := 1 + # live vars: $t2, $t4, $t5, $t6, $t20, $t30, $t31 + 49: $t26 := >($t30, $t31) + # live vars: $t2, $t4, $t5, $t6, $t20, $t26 + 50: if ($t26) goto 51 else goto 60 + # live vars: $t2, $t4, $t5, $t6, $t20 + 51: label L13 + # live vars: $t2, $t4, $t5, $t6, $t20 + 52: $t32 := infer($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32 + 53: $t33 := infer($t20) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32, $t33 + 54: vector::swap($t32, $t33, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 55: $t35 := infer($t20) + # live vars: $t2, $t4, $t5, $t6, $t35 + 56: $t36 := 1 + # live vars: $t2, $t4, $t5, $t6, $t35, $t36 + 57: $t34 := +($t35, $t36) + # live vars: $t2, $t4, $t5, $t6, $t34 + 58: $t20 := infer($t34) + # live vars: $t2, $t4, $t5, $t6, $t20 + 59: goto 61 + # live vars: $t2, $t4, $t5, $t6, $t20 + 60: label L14 + # live vars: $t2, $t4, $t5, $t6, $t20 + 61: label L15 + # live vars: $t2, $t4, $t5, $t6, $t20 + 62: $t38 := infer($t5) + # live vars: $t2, $t4, $t6, $t20, $t38 + 63: $t39 := 1 + # live vars: $t2, $t4, $t6, $t20, $t38, $t39 + 64: $t37 := +($t38, $t39) + # live vars: $t2, $t4, $t6, $t20, $t37 + 65: $t5 := infer($t37) + # live vars: $t2, $t4, $t5, $t6, $t20 + 66: goto 69 + # live vars: $t2, $t4, $t5, $t6, $t20 + 67: label L11 + # live vars: $t2, $t20 + 68: goto 71 + # live vars: $t2, $t4, $t5, $t6, $t20 + 69: label L12 + # live vars: $t2, $t4, $t5, $t6, $t20 + 70: goto 39 + # live vars: $t2, $t20 + 71: label L9 + # live vars: $t2, $t20 + 72: $t3 := infer($t20) + # live vars: $t2 + 73: $t41 := freeze_ref(implicit)($t2) + # live vars: $t41 + 74: $t42 := 0 + # live vars: $t41, $t42 + 75: $t40 := vector::borrow($t41, $t42) + # live vars: $t40 + 76: $t0 := read_ref($t40) + # live vars: $t0 + 77: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 + var $t1: vector + var $t2: &mut vector + var $t3: u64 + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool + var $t11: bool + var $t12: &u64 + var $t13: &u64 + var $t14: &vector + var $t15: u64 + var $t16: u64 + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector + var $t30: u64 + var $t31: u64 + var $t32: &mut vector + var $t33: u64 + var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := infer($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := infer($t5) # live vars: $t2, $t4, $t5, $t6, $t9 - 17: if ($t9) goto 18 else goto 21 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 10 else goto 29 # live vars: $t2, $t4, $t5, $t6 - 18: label L5 + 10: label L2 # live vars: $t2, $t4, $t5, $t6 - 19: goto 31 + 11: $t14 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t14 + 12: $t13 := vector::borrow($t14, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 13: $t12 := infer($t13) + # live vars: $t2, $t4, $t5, $t6, $t12 + 14: $t15 := read_ref($t12) + # live vars: $t2, $t4, $t5, $t6, $t15 + 15: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t15, $t16 + 16: $t11 := >($t15, $t16) + # live vars: $t2, $t4, $t5, $t6, $t11 + 17: $t10 := !($t11) + # live vars: $t2, $t4, $t5, $t6, $t10 + 18: if ($t10) goto 19 else goto 22 # live vars: $t2, $t4, $t5, $t6 - 20: goto 22 + 19: label L5 # live vars: $t2, $t4, $t5, $t6 - 21: label L6 + 20: goto 33 # live vars: $t2, $t4, $t5, $t6 - 22: label L7 + 21: goto 23 # live vars: $t2, $t4, $t5, $t6 - 23: $t17 := 1 - # live vars: $t2, $t4, $t5, $t6, $t17 - 24: $t16 := +($t5, $t17) - # live vars: $t2, $t4, $t6, $t16 - 25: $t5 := infer($t16) + 22: label L6 # live vars: $t2, $t4, $t5, $t6 - 26: goto 29 + 23: label L7 # live vars: $t2, $t4, $t5, $t6 - 27: label L3 + 24: $t18 := infer($t5) + # live vars: $t2, $t4, $t6, $t18 + 25: $t19 := 1 + # live vars: $t2, $t4, $t6, $t18, $t19 + 26: $t17 := +($t18, $t19) + # live vars: $t2, $t4, $t6, $t17 + 27: $t5 := infer($t17) # live vars: $t2, $t4, $t5, $t6 28: goto 31 # live vars: $t2, $t4, $t5, $t6 - 29: label L4 + 29: label L3 + # live vars: $t2, $t4, $t5, $t6 + 30: goto 33 + # live vars: $t2, $t4, $t5, $t6 + 31: label L4 + # live vars: $t2, $t4, $t5, $t6 + 32: goto 6 + # live vars: $t2, $t4, $t5, $t6 + 33: label L1 + # live vars: $t2, $t4, $t5, $t6 + 34: $t20 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 35: $t22 := infer($t5) + # live vars: $t2, $t4, $t6, $t20, $t22 + 36: $t23 := 1 + # live vars: $t2, $t4, $t6, $t20, $t22, $t23 + 37: $t21 := +($t22, $t23) + # live vars: $t2, $t4, $t6, $t20, $t21 + 38: $t5 := infer($t21) + # live vars: $t2, $t4, $t5, $t6, $t20 + 39: label L8 + # live vars: $t2, $t4, $t5, $t6, $t20 + 40: $t25 := infer($t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t25 + 41: $t24 := <($t25, $t6) + # live vars: $t2, $t4, $t5, $t6, $t20, $t24 + 42: if ($t24) goto 43 else goto 67 + # live vars: $t2, $t4, $t5, $t6, $t20 + 43: label L10 + # live vars: $t2, $t4, $t5, $t6, $t20 + 44: $t29 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t29 + 45: $t28 := vector::borrow($t29, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t28 + 46: $t27 := infer($t28) + # live vars: $t2, $t4, $t5, $t6, $t20, $t27 + 47: $t30 := read_ref($t27) + # live vars: $t2, $t4, $t5, $t6, $t20, $t30 + 48: $t31 := 1 + # live vars: $t2, $t4, $t5, $t6, $t20, $t30, $t31 + 49: $t26 := >($t30, $t31) + # live vars: $t2, $t4, $t5, $t6, $t20, $t26 + 50: if ($t26) goto 51 else goto 60 + # live vars: $t2, $t4, $t5, $t6, $t20 + 51: label L13 + # live vars: $t2, $t4, $t5, $t6, $t20 + 52: $t32 := infer($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32 + 53: $t33 := infer($t20) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32, $t33 + 54: vector::swap($t32, $t33, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 55: $t35 := infer($t20) + # live vars: $t2, $t4, $t5, $t6, $t35 + 56: $t36 := 1 + # live vars: $t2, $t4, $t5, $t6, $t35, $t36 + 57: $t34 := +($t35, $t36) + # live vars: $t2, $t4, $t5, $t6, $t34 + 58: $t20 := infer($t34) + # live vars: $t2, $t4, $t5, $t6, $t20 + 59: goto 61 + # live vars: $t2, $t4, $t5, $t6, $t20 + 60: label L14 + # live vars: $t2, $t4, $t5, $t6, $t20 + 61: label L15 + # live vars: $t2, $t4, $t5, $t6, $t20 + 62: $t38 := infer($t5) + # live vars: $t2, $t4, $t6, $t20, $t38 + 63: $t39 := 1 + # live vars: $t2, $t4, $t6, $t20, $t38, $t39 + 64: $t37 := +($t38, $t39) + # live vars: $t2, $t4, $t6, $t20, $t37 + 65: $t5 := infer($t37) + # live vars: $t2, $t4, $t5, $t6, $t20 + 66: goto 69 + # live vars: $t2, $t4, $t5, $t6, $t20 + 67: label L11 + # live vars: $t2, $t20 + 68: goto 71 + # live vars: $t2, $t4, $t5, $t6, $t20 + 69: label L12 + # live vars: $t2, $t4, $t5, $t6, $t20 + 70: goto 39 + # live vars: $t2, $t20 + 71: label L9 + # live vars: $t2, $t20 + 72: $t3 := infer($t20) + # live vars: $t2 + 73: $t41 := freeze_ref(implicit)($t2) + # live vars: $t41 + 74: $t42 := 0 + # live vars: $t41, $t42 + 75: $t40 := vector::borrow($t41, $t42) + # live vars: $t40 + 76: $t0 := read_ref($t40) + # live vars: $t0 + 77: return $t0 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 + var $t1: vector + var $t2: &mut vector + var $t3: u64 + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool + var $t11: bool + var $t12: &u64 + var $t13: &u64 + var $t14: &vector + var $t15: u64 + var $t16: u64 + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector + var $t30: u64 + var $t31: u64 + var $t32: &mut vector + var $t33: u64 + var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := copy($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 12 else goto 10 + # live vars: $t2, $t4, $t5, $t6 + 10: label L16 + # live vars: $t2, $t4, $t5, $t6 + 11: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 12: label L2 # live vars: $t2, $t4, $t5, $t6 - 30: goto 6 + 13: $t14 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t14 + 14: $t13 := vector::borrow($t14, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 15: $t12 := move($t13) + # live vars: $t2, $t4, $t5, $t6, $t12 + 16: $t15 := read_ref($t12) + # live vars: $t2, $t4, $t5, $t6, $t15 + 17: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t15, $t16 + 18: $t11 := >($t15, $t16) + # live vars: $t2, $t4, $t5, $t6, $t11 + 19: $t10 := !($t11) + # live vars: $t2, $t4, $t5, $t6, $t10 + 20: if ($t10) goto 21 else goto 65 + # live vars: $t2, $t4, $t5, $t6 + 21: label L17 + # live vars: $t2, $t4, $t5, $t6 + 22: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 23: label L1 + # live vars: $t2, $t4, $t5, $t6 + 24: $t20 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 25: $t22 := move($t5) + # live vars: $t2, $t4, $t6, $t20, $t22 + 26: $t23 := 1 + # live vars: $t2, $t4, $t6, $t20, $t22, $t23 + 27: $t21 := +($t22, $t23) + # live vars: $t2, $t4, $t6, $t20, $t21 + 28: $t5 := move($t21) + # live vars: $t2, $t4, $t5, $t6, $t20 + 29: label L8 + # live vars: $t2, $t4, $t5, $t6, $t20 + 30: $t25 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t25 + 31: $t24 := <($t25, $t6) + # live vars: $t2, $t4, $t5, $t6, $t20, $t24 + 32: if ($t24) goto 33 else goto 57 + # live vars: $t2, $t4, $t5, $t6, $t20 + 33: label L10 + # live vars: $t2, $t4, $t5, $t6, $t20 + 34: $t29 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t29 + 35: $t28 := vector::borrow($t29, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t28 + 36: $t27 := move($t28) + # live vars: $t2, $t4, $t5, $t6, $t20, $t27 + 37: $t30 := read_ref($t27) + # live vars: $t2, $t4, $t5, $t6, $t20, $t30 + 38: $t31 := 1 + # live vars: $t2, $t4, $t5, $t6, $t20, $t30, $t31 + 39: $t26 := >($t30, $t31) + # live vars: $t2, $t4, $t5, $t6, $t20, $t26 + 40: if ($t26) goto 43 else goto 41 + # live vars: $t2, $t4, $t5, $t6, $t20 + 41: label L18 + # live vars: $t2, $t4, $t5, $t6, $t20 + 42: goto 51 + # live vars: $t2, $t4, $t5, $t6, $t20 + 43: label L13 + # live vars: $t2, $t4, $t5, $t6, $t20 + 44: $t32 := copy($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32 + 45: $t33 := copy($t20) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32, $t33 + 46: vector::swap($t32, $t33, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 47: $t35 := move($t20) + # live vars: $t2, $t4, $t5, $t6, $t35 + 48: $t36 := 1 + # live vars: $t2, $t4, $t5, $t6, $t35, $t36 + 49: $t34 := +($t35, $t36) + # live vars: $t2, $t4, $t5, $t6, $t34 + 50: $t20 := move($t34) + # live vars: $t2, $t4, $t5, $t6, $t20 + 51: label L15 + # live vars: $t2, $t4, $t5, $t6, $t20 + 52: $t38 := move($t5) + # live vars: $t2, $t4, $t6, $t20, $t38 + 53: $t39 := 1 + # live vars: $t2, $t4, $t6, $t20, $t38, $t39 + 54: $t37 := +($t38, $t39) + # live vars: $t2, $t4, $t6, $t20, $t37 + 55: $t5 := move($t37) + # live vars: $t2, $t4, $t5, $t6, $t20 + 56: goto 29 + # live vars: $t2, $t4, $t5, $t6, $t20 + 57: label L11 + # live vars: $t2, $t4, $t20 + 58: drop($t4) + # live vars: $t2, $t20 + 59: $t3 := move($t20) + # live vars: $t2 + 60: $t41 := freeze_ref(implicit)($t2) + # live vars: $t41 + 61: $t42 := 0 + # live vars: $t41, $t42 + 62: $t40 := vector::borrow($t41, $t42) + # live vars: $t40 + 63: $t0 := read_ref($t40) + # live vars: $t0 + 64: return $t0 # live vars: $t2, $t4, $t5, $t6 - 31: label L1 + 65: label L7 # live vars: $t2, $t4, $t5, $t6 - 32: $t18 := infer($t5) - # live vars: $t2, $t4, $t5, $t6, $t18 - 33: $t20 := 1 - # live vars: $t2, $t4, $t5, $t6, $t18, $t20 - 34: $t19 := +($t5, $t20) + 66: $t18 := move($t5) + # live vars: $t2, $t4, $t6, $t18 + 67: $t19 := 1 # live vars: $t2, $t4, $t6, $t18, $t19 - 35: $t5 := infer($t19) - # live vars: $t2, $t4, $t5, $t6, $t18 - 36: label L8 - # live vars: $t2, $t4, $t5, $t6, $t18 - 37: $t21 := <($t5, $t6) - # live vars: $t2, $t4, $t5, $t6, $t18, $t21 - 38: if ($t21) goto 39 else goto 59 - # live vars: $t2, $t4, $t5, $t6, $t18 - 39: label L10 - # live vars: $t2, $t4, $t5, $t6, $t18 - 40: $t25 := freeze_ref(implicit)($t4) - # live vars: $t2, $t4, $t5, $t6, $t18, $t25 - 41: $t24 := vector::borrow($t25, $t5) - # live vars: $t2, $t4, $t5, $t6, $t18, $t24 - 42: $t23 := infer($t24) - # live vars: $t2, $t4, $t5, $t6, $t18, $t23 - 43: $t26 := read_ref($t23) - # live vars: $t2, $t4, $t5, $t6, $t18, $t26 - 44: $t27 := 1 - # live vars: $t2, $t4, $t5, $t6, $t18, $t26, $t27 - 45: $t22 := >($t26, $t27) - # live vars: $t2, $t4, $t5, $t6, $t18, $t22 - 46: if ($t22) goto 47 else goto 53 - # live vars: $t2, $t4, $t5, $t6, $t18 - 47: label L13 - # live vars: $t2, $t4, $t5, $t6, $t18 - 48: vector::swap($t4, $t18, $t5) - # live vars: $t2, $t4, $t5, $t6, $t18 - 49: $t29 := 1 - # live vars: $t2, $t4, $t5, $t6, $t18, $t29 - 50: $t28 := +($t18, $t29) - # live vars: $t2, $t4, $t5, $t6, $t28 - 51: $t18 := infer($t28) - # live vars: $t2, $t4, $t5, $t6, $t18 - 52: goto 54 - # live vars: $t2, $t4, $t5, $t6, $t18 - 53: label L14 - # live vars: $t2, $t4, $t5, $t6, $t18 - 54: label L15 - # live vars: $t2, $t4, $t5, $t6, $t18 - 55: $t31 := 1 - # live vars: $t2, $t4, $t5, $t6, $t18, $t31 - 56: $t30 := +($t5, $t31) - # live vars: $t2, $t4, $t6, $t18, $t30 - 57: $t5 := infer($t30) - # live vars: $t2, $t4, $t5, $t6, $t18 - 58: goto 61 - # live vars: $t2, $t4, $t5, $t6, $t18 - 59: label L11 - # live vars: $t2, $t18 - 60: goto 63 - # live vars: $t2, $t4, $t5, $t6, $t18 - 61: label L12 - # live vars: $t2, $t4, $t5, $t6, $t18 - 62: goto 36 - # live vars: $t2, $t18 - 63: label L9 - # live vars: $t2, $t18 - 64: $t3 := infer($t18) + 68: $t17 := +($t18, $t19) + # live vars: $t2, $t4, $t6, $t17 + 69: $t5 := move($t17) + # live vars: $t2, $t4, $t5, $t6 + 70: goto 6 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 + var $t1: vector + var $t2: &mut vector + var $t3: u64 [unused] + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool + var $t11: bool + var $t12: &u64 + var $t13: &u64 + var $t14: &vector + var $t15: u64 + var $t16: u64 + var $t17: u64 + var $t18: u64 + var $t19: u64 + var $t20: u64 + var $t21: u64 + var $t22: u64 + var $t23: u64 + var $t24: bool + var $t25: u64 + var $t26: bool + var $t27: &u64 + var $t28: &u64 + var $t29: &vector + var $t30: u64 + var $t31: u64 + var $t32: &mut vector + var $t33: u64 + var $t34: u64 + var $t35: u64 + var $t36: u64 + var $t37: u64 + var $t38: u64 + var $t39: u64 + var $t40: &u64 + var $t41: &vector + var $t42: u64 + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := copy($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 12 else goto 10 + # live vars: $t2, $t4, $t5, $t6 + 10: label L16 + # live vars: $t2, $t4, $t5, $t6 + 11: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 12: label L2 + # live vars: $t2, $t4, $t5, $t6 + 13: $t14 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t14 + 14: $t13 := vector::borrow($t14, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 15: $t12 := move($t13) + # live vars: $t2, $t4, $t5, $t6, $t12 + 16: $t15 := read_ref($t12) + # live vars: $t2, $t4, $t5, $t6, $t15 + 17: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t15, $t16 + 18: $t11 := >($t15, $t16) + # live vars: $t2, $t4, $t5, $t6, $t11 + 19: $t10 := !($t11) + # live vars: $t2, $t4, $t5, $t6, $t10 + 20: if ($t10) goto 21 else goto 64 + # live vars: $t2, $t4, $t5, $t6 + 21: label L17 + # live vars: $t2, $t4, $t5, $t6 + 22: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 23: label L1 + # live vars: $t2, $t4, $t5, $t6 + 24: $t20 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 25: $t22 := move($t5) + # live vars: $t2, $t4, $t6, $t20, $t22 + 26: $t23 := 1 + # live vars: $t2, $t4, $t6, $t20, $t22, $t23 + 27: $t21 := +($t22, $t23) + # live vars: $t2, $t4, $t6, $t20, $t21 + 28: $t5 := move($t21) + # live vars: $t2, $t4, $t5, $t6, $t20 + 29: label L8 + # live vars: $t2, $t4, $t5, $t6, $t20 + 30: $t25 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t25 + 31: $t24 := <($t25, $t6) + # live vars: $t2, $t4, $t5, $t6, $t20, $t24 + 32: if ($t24) goto 33 else goto 57 + # live vars: $t2, $t4, $t5, $t6, $t20 + 33: label L10 + # live vars: $t2, $t4, $t5, $t6, $t20 + 34: $t29 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t29 + 35: $t28 := vector::borrow($t29, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20, $t28 + 36: $t27 := move($t28) + # live vars: $t2, $t4, $t5, $t6, $t20, $t27 + 37: $t30 := read_ref($t27) + # live vars: $t2, $t4, $t5, $t6, $t20, $t30 + 38: $t31 := 1 + # live vars: $t2, $t4, $t5, $t6, $t20, $t30, $t31 + 39: $t26 := >($t30, $t31) + # live vars: $t2, $t4, $t5, $t6, $t20, $t26 + 40: if ($t26) goto 43 else goto 41 + # live vars: $t2, $t4, $t5, $t6, $t20 + 41: label L18 + # live vars: $t2, $t4, $t5, $t6, $t20 + 42: goto 51 + # live vars: $t2, $t4, $t5, $t6, $t20 + 43: label L13 + # live vars: $t2, $t4, $t5, $t6, $t20 + 44: $t32 := copy($t4) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32 + 45: $t33 := copy($t20) + # live vars: $t2, $t4, $t5, $t6, $t20, $t32, $t33 + 46: vector::swap($t32, $t33, $t5) + # live vars: $t2, $t4, $t5, $t6, $t20 + 47: $t35 := move($t20) + # live vars: $t2, $t4, $t5, $t6, $t35 + 48: $t36 := 1 + # live vars: $t2, $t4, $t5, $t6, $t35, $t36 + 49: $t34 := +($t35, $t36) + # live vars: $t2, $t4, $t5, $t6, $t34 + 50: $t20 := move($t34) + # live vars: $t2, $t4, $t5, $t6, $t20 + 51: label L15 + # live vars: $t2, $t4, $t5, $t6, $t20 + 52: $t38 := move($t5) + # live vars: $t2, $t4, $t6, $t20, $t38 + 53: $t39 := 1 + # live vars: $t2, $t4, $t6, $t20, $t38, $t39 + 54: $t37 := +($t38, $t39) + # live vars: $t2, $t4, $t6, $t20, $t37 + 55: $t5 := move($t37) + # live vars: $t2, $t4, $t5, $t6, $t20 + 56: goto 29 + # live vars: $t2, $t4, $t5, $t6, $t20 + 57: label L11 + # live vars: $t2, $t4 + 58: drop($t4) # live vars: $t2 - 65: $t33 := freeze_ref(implicit)($t2) - # live vars: $t33 - 66: $t34 := 0 - # live vars: $t33, $t34 - 67: $t32 := vector::borrow($t33, $t34) - # live vars: $t32 - 68: $t0 := read_ref($t32) + 59: $t41 := freeze_ref(implicit)($t2) + # live vars: $t41 + 60: $t42 := 0 + # live vars: $t41, $t42 + 61: $t40 := vector::borrow($t41, $t42) + # live vars: $t40 + 62: $t0 := read_ref($t40) # live vars: $t0 - 69: return $t0 + 63: return $t0 + # live vars: $t2, $t4, $t5, $t6 + 64: label L7 + # live vars: $t2, $t4, $t5, $t6 + 65: $t18 := move($t5) + # live vars: $t2, $t4, $t6, $t18 + 66: $t19 := 1 + # live vars: $t2, $t4, $t6, $t18, $t19 + 67: $t17 := +($t18, $t19) + # live vars: $t2, $t4, $t6, $t17 + 68: $t5 := move($t17) + # live vars: $t2, $t4, $t5, $t6 + 69: goto 6 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 [unused] + var $t1: vector + var $t2: &mut vector + var $t3: u64 [unused] + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool [unused] + var $t11: bool [unused] + var $t12: &u64 [unused] + var $t13: &u64 + var $t14: &vector [unused] + var $t15: u64 [unused] + var $t16: u64 + var $t17: u64 [unused] + var $t18: u64 [unused] + var $t19: u64 [unused] + var $t20: u64 [unused] + var $t21: u64 [unused] + var $t22: u64 [unused] + var $t23: u64 + var $t24: bool [unused] + var $t25: u64 [unused] + var $t26: bool [unused] + var $t27: &u64 [unused] + var $t28: &u64 [unused] + var $t29: &vector [unused] + var $t30: u64 [unused] + var $t31: u64 [unused] + var $t32: &mut vector + var $t33: u64 [unused] + var $t34: u64 [unused] + var $t35: u64 [unused] + var $t36: u64 [unused] + var $t37: u64 [unused] + var $t38: u64 [unused] + var $t39: u64 [unused] + var $t40: &u64 [unused] + var $t41: &vector [unused] + var $t42: u64 [unused] + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := copy($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 12 else goto 10 + # live vars: $t2, $t4, $t5, $t6 + 10: label L16 + # live vars: $t2, $t4, $t5, $t6 + 11: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 12: label L2 + # live vars: $t2, $t4, $t5, $t6 + 13: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t7 + 14: $t13 := vector::borrow($t7, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 15: $t13 := move($t13) + # live vars: $t2, $t4, $t5, $t6, $t13 + 16: $t9 := read_ref($t13) + # live vars: $t2, $t4, $t5, $t6, $t9 + 17: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 18: $t8 := >($t9, $t16) + # live vars: $t2, $t4, $t5, $t6, $t8 + 19: $t8 := !($t8) + # live vars: $t2, $t4, $t5, $t6, $t8 + 20: if ($t8) goto 21 else goto 64 + # live vars: $t2, $t4, $t5, $t6 + 21: label L17 + # live vars: $t2, $t4, $t5, $t6 + 22: goto 23 + # live vars: $t2, $t4, $t5, $t6 + 23: label L1 + # live vars: $t2, $t4, $t5, $t6 + 24: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 25: $t16 := move($t5) + # live vars: $t2, $t4, $t6, $t9, $t16 + 26: $t23 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16, $t23 + 27: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t6, $t9, $t16 + 28: $t5 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 29: label L8 + # live vars: $t2, $t4, $t5, $t6, $t9 + 30: $t16 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 31: $t8 := <($t16, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8, $t9 + 32: if ($t8) goto 33 else goto 57 + # live vars: $t2, $t4, $t5, $t6, $t9 + 33: label L10 + # live vars: $t2, $t4, $t5, $t6, $t9 + 34: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t7, $t9 + 35: $t13 := vector::borrow($t7, $t5) + # live vars: $t2, $t4, $t5, $t6, $t9, $t13 + 36: $t13 := move($t13) + # live vars: $t2, $t4, $t5, $t6, $t9, $t13 + 37: $t16 := read_ref($t13) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 38: $t23 := 1 + # live vars: $t2, $t4, $t5, $t6, $t9, $t16, $t23 + 39: $t8 := >($t16, $t23) + # live vars: $t2, $t4, $t5, $t6, $t8, $t9 + 40: if ($t8) goto 43 else goto 41 + # live vars: $t2, $t4, $t5, $t6, $t9 + 41: label L18 + # live vars: $t2, $t4, $t5, $t6, $t9 + 42: goto 51 + # live vars: $t2, $t4, $t5, $t6, $t9 + 43: label L13 + # live vars: $t2, $t4, $t5, $t6, $t9 + 44: $t32 := copy($t4) + # live vars: $t2, $t4, $t5, $t6, $t9, $t32 + 45: $t16 := copy($t9) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16, $t32 + 46: vector::swap($t32, $t16, $t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 47: $t16 := move($t9) + # live vars: $t2, $t4, $t5, $t6, $t16 + 48: $t23 := 1 + # live vars: $t2, $t4, $t5, $t6, $t16, $t23 + 49: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t5, $t6, $t16 + 50: $t9 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 51: label L15 + # live vars: $t2, $t4, $t5, $t6, $t9 + 52: $t16 := move($t5) + # live vars: $t2, $t4, $t6, $t9, $t16 + 53: $t23 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16, $t23 + 54: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t6, $t9, $t16 + 55: $t5 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 56: goto 29 + # live vars: $t2, $t4, $t5, $t6, $t9 + 57: label L11 + # live vars: $t2, $t4 + 58: drop($t4) + # live vars: $t2 + 59: $t7 := freeze_ref(implicit)($t2) + # live vars: $t7 + 60: $t9 := 0 + # live vars: $t7, $t9 + 61: $t13 := vector::borrow($t7, $t9) + # live vars: $t13 + 62: $t9 := read_ref($t13) + # live vars: $t9 + 63: return $t9 + # live vars: $t2, $t4, $t5, $t6 + 64: label L7 + # live vars: $t2, $t4, $t5, $t6 + 65: $t9 := move($t5) + # live vars: $t2, $t4, $t6, $t9 + 66: $t16 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16 + 67: $t9 := +($t9, $t16) + # live vars: $t2, $t4, $t6, $t9 + 68: $t5 := move($t9) + # live vars: $t2, $t4, $t5, $t6 + 69: goto 6 +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::foo(): u64 { + var $t0: u64 [unused] + var $t1: vector + var $t2: &mut vector + var $t3: u64 [unused] + var $t4: &mut vector + var $t5: u64 + var $t6: u64 + var $t7: &vector + var $t8: bool + var $t9: u64 + var $t10: bool [unused] + var $t11: bool [unused] + var $t12: &u64 [unused] + var $t13: &u64 + var $t14: &vector [unused] + var $t15: u64 [unused] + var $t16: u64 + var $t17: u64 [unused] + var $t18: u64 [unused] + var $t19: u64 [unused] + var $t20: u64 [unused] + var $t21: u64 [unused] + var $t22: u64 [unused] + var $t23: u64 + var $t24: bool [unused] + var $t25: u64 [unused] + var $t26: bool [unused] + var $t27: &u64 [unused] + var $t28: &u64 [unused] + var $t29: &vector [unused] + var $t30: u64 [unused] + var $t31: u64 [unused] + var $t32: &mut vector + var $t33: u64 [unused] + var $t34: u64 [unused] + var $t35: u64 [unused] + var $t36: u64 [unused] + var $t37: u64 [unused] + var $t38: u64 [unused] + var $t39: u64 [unused] + var $t40: &u64 [unused] + var $t41: &vector [unused] + var $t42: u64 [unused] + # live vars: + 0: $t1 := ["1", "2", "3"] + # live vars: $t1 + 1: $t2 := borrow_local($t1) + # live vars: $t2 + 2: $t4 := copy($t2) + # live vars: $t2, $t4 + 3: $t5 := 0 + # live vars: $t2, $t4, $t5 + 4: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t7 + 5: $t6 := vector::length($t7) + # live vars: $t2, $t4, $t5, $t6 + 6: label L0 + # live vars: $t2, $t4, $t5, $t6 + 7: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 8: $t8 := <($t9, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8 + 9: if ($t8) goto 12 else goto 10 + # live vars: $t2, $t4, $t5, $t6 + 10: label L16 + # live vars: $t2, $t4, $t5, $t6 + 11: goto 22 + # live vars: $t2, $t4, $t5, $t6 + 12: label L2 + # live vars: $t2, $t4, $t5, $t6 + 13: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t7 + 14: $t13 := vector::borrow($t7, $t5) + # live vars: $t2, $t4, $t5, $t6, $t13 + 15: $t9 := read_ref($t13) + # live vars: $t2, $t4, $t5, $t6, $t9 + 16: $t16 := 1 + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 17: $t8 := >($t9, $t16) + # live vars: $t2, $t4, $t5, $t6, $t8 + 18: $t8 := !($t8) + # live vars: $t2, $t4, $t5, $t6, $t8 + 19: if ($t8) goto 20 else goto 62 + # live vars: $t2, $t4, $t5, $t6 + 20: label L17 + # live vars: $t2, $t4, $t5, $t6 + 21: goto 22 + # live vars: $t2, $t4, $t5, $t6 + 22: label L1 + # live vars: $t2, $t4, $t5, $t6 + 23: $t9 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 24: $t16 := move($t5) + # live vars: $t2, $t4, $t6, $t9, $t16 + 25: $t23 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16, $t23 + 26: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t6, $t9, $t16 + 27: $t5 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 28: label L8 + # live vars: $t2, $t4, $t5, $t6, $t9 + 29: $t16 := copy($t5) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 30: $t8 := <($t16, $t6) + # live vars: $t2, $t4, $t5, $t6, $t8, $t9 + 31: if ($t8) goto 32 else goto 55 + # live vars: $t2, $t4, $t5, $t6, $t9 + 32: label L10 + # live vars: $t2, $t4, $t5, $t6, $t9 + 33: $t7 := freeze_ref(implicit)($t4) + # live vars: $t2, $t4, $t5, $t6, $t7, $t9 + 34: $t13 := vector::borrow($t7, $t5) + # live vars: $t2, $t4, $t5, $t6, $t9, $t13 + 35: $t16 := read_ref($t13) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16 + 36: $t23 := 1 + # live vars: $t2, $t4, $t5, $t6, $t9, $t16, $t23 + 37: $t8 := >($t16, $t23) + # live vars: $t2, $t4, $t5, $t6, $t8, $t9 + 38: if ($t8) goto 41 else goto 39 + # live vars: $t2, $t4, $t5, $t6, $t9 + 39: label L18 + # live vars: $t2, $t4, $t5, $t6, $t9 + 40: goto 49 + # live vars: $t2, $t4, $t5, $t6, $t9 + 41: label L13 + # live vars: $t2, $t4, $t5, $t6, $t9 + 42: $t32 := copy($t4) + # live vars: $t2, $t4, $t5, $t6, $t9, $t32 + 43: $t16 := copy($t9) + # live vars: $t2, $t4, $t5, $t6, $t9, $t16, $t32 + 44: vector::swap($t32, $t16, $t5) + # live vars: $t2, $t4, $t5, $t6, $t9 + 45: $t16 := move($t9) + # live vars: $t2, $t4, $t5, $t6, $t16 + 46: $t23 := 1 + # live vars: $t2, $t4, $t5, $t6, $t16, $t23 + 47: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t5, $t6, $t16 + 48: $t9 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 49: label L15 + # live vars: $t2, $t4, $t5, $t6, $t9 + 50: $t16 := move($t5) + # live vars: $t2, $t4, $t6, $t9, $t16 + 51: $t23 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16, $t23 + 52: $t16 := +($t16, $t23) + # live vars: $t2, $t4, $t6, $t9, $t16 + 53: $t5 := move($t16) + # live vars: $t2, $t4, $t5, $t6, $t9 + 54: goto 28 + # live vars: $t2, $t4, $t5, $t6, $t9 + 55: label L11 + # live vars: $t2, $t4 + 56: drop($t4) + # live vars: $t2 + 57: $t7 := freeze_ref(implicit)($t2) + # live vars: $t7 + 58: $t9 := 0 + # live vars: $t7, $t9 + 59: $t13 := vector::borrow($t7, $t9) + # live vars: $t13 + 60: $t9 := read_ref($t13) + # live vars: $t9 + 61: return $t9 + # live vars: $t2, $t4, $t5, $t6 + 62: label L7 + # live vars: $t2, $t4, $t5, $t6 + 63: $t9 := move($t5) + # live vars: $t2, $t4, $t6, $t9 + 64: $t16 := 1 + # live vars: $t2, $t4, $t6, $t9, $t16 + 65: $t9 := +($t9, $t16) + # live vars: $t2, $t4, $t6, $t9 + 66: $t5 := move($t9) + # live vars: $t2, $t4, $t5, $t6 + 67: goto 6 +} + + +============ disassembled file-format ================== +// Move bytecode v7 +module 42.m { + + +foo(): u64 /* def_idx: 0 */ { +L0: loc0: vector +L1: loc1: &mut vector +L2: loc2: &mut vector +L3: loc3: u64 +L4: loc4: u64 +L5: loc5: u64 +B0: + 0: LdConst[0](Vector(U64): [3, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0]) + 1: StLoc[0](loc0: vector) + 2: MutBorrowLoc[0](loc0: vector) + 3: StLoc[1](loc1: &mut vector) + 4: CopyLoc[1](loc1: &mut vector) + 5: StLoc[2](loc2: &mut vector) + 6: LdU64(0) + 7: StLoc[3](loc3: u64) + 8: CopyLoc[2](loc2: &mut vector) + 9: FreezeRef + 10: VecLen(1) + 11: StLoc[4](loc4: u64) +B1: + 12: CopyLoc[3](loc3: u64) + 13: CopyLoc[4](loc4: u64) + 14: Lt + 15: BrTrue(17) +B2: + 16: Branch(26) +B3: + 17: CopyLoc[2](loc2: &mut vector) + 18: FreezeRef + 19: CopyLoc[3](loc3: u64) + 20: VecImmBorrow(1) + 21: ReadRef + 22: LdU64(1) + 23: Gt + 24: BrTrue(66) +B4: + 25: Branch(26) +B5: + 26: CopyLoc[3](loc3: u64) + 27: StLoc[5](loc5: u64) + 28: MoveLoc[3](loc3: u64) + 29: LdU64(1) + 30: Add + 31: StLoc[3](loc3: u64) +B6: + 32: CopyLoc[3](loc3: u64) + 33: CopyLoc[4](loc4: u64) + 34: Lt + 35: BrFalse(58) +B7: + 36: CopyLoc[2](loc2: &mut vector) + 37: FreezeRef + 38: CopyLoc[3](loc3: u64) + 39: VecImmBorrow(1) + 40: ReadRef + 41: LdU64(1) + 42: Gt + 43: BrTrue(45) +B8: + 44: Branch(53) +B9: + 45: CopyLoc[2](loc2: &mut vector) + 46: CopyLoc[5](loc5: u64) + 47: CopyLoc[3](loc3: u64) + 48: VecSwap(1) + 49: MoveLoc[5](loc5: u64) + 50: LdU64(1) + 51: Add + 52: StLoc[5](loc5: u64) +B10: + 53: MoveLoc[3](loc3: u64) + 54: LdU64(1) + 55: Add + 56: StLoc[3](loc3: u64) + 57: Branch(32) +B11: + 58: MoveLoc[2](loc2: &mut vector) + 59: Pop + 60: MoveLoc[1](loc1: &mut vector) + 61: FreezeRef + 62: LdU64(0) + 63: VecImmBorrow(1) + 64: ReadRef + 65: Ret +B12: + 66: MoveLoc[3](loc3: u64) + 67: LdU64(1) + 68: Add + 69: StLoc[3](loc3: u64) + 70: Branch(12) +} } +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/live-var/mut_ref.exp b/third_party/move/move-compiler-v2/tests/live-var/mut_ref.exp index b2dabe6d743a4..e97e63f51a045 100644 --- a/third_party/move/move-compiler-v2/tests/live-var/mut_ref.exp +++ b/third_party/move/move-compiler-v2/tests/live-var/mut_ref.exp @@ -51,11 +51,177 @@ fun m::f2_fail() { var $t0: 0x42::m::R var $t1: u64 var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R + 0: $t1 := 0 + 1: $t0 := pack 0x42::m::R($t1) + 2: $t2 := borrow_local($t0) + 3: $t3 := infer($t2) + 4: m::some2($t3, $t2) + 5: return () +} + + +[variant baseline] +fun m::f3_ok() { + var $t0: 0x42::m::R + var $t1: u64 + var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R + 0: $t1 := 0 + 1: $t0 := pack 0x42::m::R($t1) + 2: $t2 := borrow_local($t0) + 3: m::some($t2) + 4: $t3 := borrow_local($t0) + 5: $t2 := infer($t3) + 6: m::some($t2) + 7: return () +} + + +[variant baseline] +fun m::f4_ok() { + var $t0: 0x42::m::R + var $t1: u64 + var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R + 0: $t1 := 0 + 1: $t0 := pack 0x42::m::R($t1) + 2: $t2 := borrow_local($t0) + 3: $t3 := m::id($t2) + 4: $t2 := infer($t3) + 5: m::some($t2) + 6: return () +} + + +[variant baseline] +fun m::f5_fail($t0: bool) { + var $t1: 0x42::m::R + var $t2: u64 + var $t3: &mut 0x42::m::R + var $t4: &mut 0x42::m::R + 0: $t2 := 0 + 1: $t1 := pack 0x42::m::R($t2) + 2: $t3 := borrow_local($t1) + 3: $t4 := infer($t3) + 4: if ($t0) goto 5 else goto 9 + 5: label L0 + 6: m::some($t3) + 7: m::some($t4) + 8: goto 12 + 9: label L1 + 10: m::some($t4) + 11: m::some($t3) + 12: label L2 + 13: return () +} + + +[variant baseline] +fun m::id($t0: &mut 0x42::m::R): &mut 0x42::m::R { + var $t1: &mut 0x42::m::R + 0: $t1 := infer($t0) + 1: return $t1 +} + + +[variant baseline] +fun m::some($t0: &mut 0x42::m::R) { + 0: return () +} + + +[variant baseline] +fun m::some2($t0: &mut 0x42::m::R, $t1: &mut 0x42::m::R) { + 0: return () +} + +============ after LiveVarAnalysisProcessor: ================ + +[variant baseline] +fun m::f1_ok() { + var $t0: 0x42::m::R + var $t1: u64 + var $t2: &mut 0x42::m::R + # live vars: + 0: $t1 := 0 + # live vars: $t1 + 1: $t0 := pack 0x42::m::R($t1) + # live vars: $t0 + 2: $t2 := borrow_local($t0) + # live vars: $t2 + 3: m::some($t2) + # live vars: $t2 + 4: m::some($t2) + # live vars: + 5: return () +} + + +[variant baseline] +fun m::f1a_ok() { + var $t0: 0x42::m::R + var $t1: u64 + var $t2: &mut 0x42::m::R + var $t3: 0x42::m::R + # live vars: + 0: $t1 := 0 + # live vars: $t1 + 1: $t0 := pack 0x42::m::R($t1) + # live vars: $t0 + 2: $t2 := borrow_local($t0) + # live vars: $t2 + 3: $t3 := read_ref($t2) + # live vars: $t2 + 4: m::some($t2) + # live vars: $t2 + 5: m::some($t2) + # live vars: + 6: return () +} + + +[variant baseline] +fun m::f1b_ok() { + var $t0: 0x42::m::R + var $t1: u64 + var $t2: &mut 0x42::m::R + var $t3: 0x42::m::R + # live vars: + 0: $t1 := 0 + # live vars: $t1 + 1: $t0 := pack 0x42::m::R($t1) + # live vars: $t0 + 2: $t2 := borrow_local($t0) + # live vars: $t2 + 3: m::some($t2) + # live vars: $t2 + 4: $t3 := read_ref($t2) + # live vars: $t2 + 5: m::some($t2) + # live vars: + 6: return () +} + + +[variant baseline] +fun m::f2_fail() { + var $t0: 0x42::m::R + var $t1: u64 + var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R + # live vars: 0: $t1 := 0 + # live vars: $t1 1: $t0 := pack 0x42::m::R($t1) + # live vars: $t0 2: $t2 := borrow_local($t0) - 3: m::some2($t2, $t2) - 4: return () + # live vars: $t2 + 3: $t3 := infer($t2) + # live vars: $t2, $t3 + 4: m::some2($t3, $t2) + # live vars: + 5: return () } @@ -65,13 +231,21 @@ fun m::f3_ok() { var $t1: u64 var $t2: &mut 0x42::m::R var $t3: &mut 0x42::m::R + # live vars: 0: $t1 := 0 + # live vars: $t1 1: $t0 := pack 0x42::m::R($t1) + # live vars: $t0 2: $t2 := borrow_local($t0) + # live vars: $t0, $t2 3: m::some($t2) + # live vars: $t0 4: $t3 := borrow_local($t0) + # live vars: $t3 5: $t2 := infer($t3) + # live vars: $t2 6: m::some($t2) + # live vars: 7: return () } @@ -82,12 +256,19 @@ fun m::f4_ok() { var $t1: u64 var $t2: &mut 0x42::m::R var $t3: &mut 0x42::m::R + # live vars: 0: $t1 := 0 + # live vars: $t1 1: $t0 := pack 0x42::m::R($t1) + # live vars: $t0 2: $t2 := borrow_local($t0) + # live vars: $t2 3: $t3 := m::id($t2) + # live vars: $t3 4: $t2 := infer($t3) + # live vars: $t2 5: m::some($t2) + # live vars: 6: return () } @@ -98,19 +279,33 @@ fun m::f5_fail($t0: bool) { var $t2: u64 var $t3: &mut 0x42::m::R var $t4: &mut 0x42::m::R + # live vars: $t0 0: $t2 := 0 + # live vars: $t0, $t2 1: $t1 := pack 0x42::m::R($t2) + # live vars: $t0, $t1 2: $t3 := borrow_local($t1) + # live vars: $t0, $t3 3: $t4 := infer($t3) + # live vars: $t0, $t3, $t4 4: if ($t0) goto 5 else goto 9 + # live vars: $t3, $t4 5: label L0 + # live vars: $t3, $t4 6: m::some($t3) + # live vars: $t4 7: m::some($t4) + # live vars: 8: goto 12 + # live vars: $t3, $t4 9: label L1 + # live vars: $t3, $t4 10: m::some($t4) + # live vars: $t3 11: m::some($t3) + # live vars: 12: label L2 + # live vars: 13: return () } @@ -118,19 +313,23 @@ fun m::f5_fail($t0: bool) { [variant baseline] fun m::id($t0: &mut 0x42::m::R): &mut 0x42::m::R { var $t1: &mut 0x42::m::R + # live vars: $t0 0: $t1 := infer($t0) + # live vars: $t1 1: return $t1 } [variant baseline] fun m::some($t0: &mut 0x42::m::R) { + # live vars: $t0 0: return () } [variant baseline] fun m::some2($t0: &mut 0x42::m::R, $t1: &mut 0x42::m::R) { + # live vars: $t0, $t1 0: return () } @@ -207,6 +406,7 @@ fun m::f2_fail() { var $t0: 0x42::m::R var $t1: u64 var $t2: &mut 0x42::m::R + var $t3: &mut 0x42::m::R # live vars: 0: $t1 := 0 # live vars: $t1 @@ -214,9 +414,11 @@ fun m::f2_fail() { # live vars: $t0 2: $t2 := borrow_local($t0) # live vars: $t2 - 3: m::some2($t2, $t2) + 3: $t3 := infer($t2) + # live vars: $t2, $t3 + 4: m::some2($t3, $t2) # live vars: - 4: return () + 5: return () } @@ -327,3 +529,25 @@ fun m::some2($t0: &mut 0x42::m::R, $t1: &mut 0x42::m::R) { # live vars: $t0, $t1 0: return () } + + +Diagnostics: +error: cannot transfer mutable local `x` since it is borrowed + ┌─ tests/live-var/mut_ref.move:41:9 + │ +41 │ some2(x, x); // expected error because multiple use + │ ^^^^^^^^^^^ + │ │ │ + │ │ previously mutably borrowed here + │ transfer attempted here + +error: cannot transfer mutable local `x` since it is borrowed + ┌─ tests/live-var/mut_ref.move:64:13 + │ +62 │ let y = x; // expected error because of implicit copy + │ - previously mutably borrowed here +63 │ if (cond) { +64 │ some(x); + │ ^^^^^^^ transfer attempted here +65 │ some(y) + │ ------- conflicting reference `y` used here diff --git a/third_party/move/move-compiler-v2/tests/more-v1/liveness/mut_ref.exp b/third_party/move/move-compiler-v2/tests/more-v1/liveness/mut_ref.exp index c4ecdd80bca73..56becb529d04b 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/liveness/mut_ref.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/liveness/mut_ref.exp @@ -5,9 +5,9 @@ error: cannot transfer mutable local `x` since it is borrowed │ 41 │ some2(x, x); // expected error because multiple use │ ^^^^^^^^^^^ - │ │ + │ │ │ + │ │ previously mutably borrowed here │ transfer attempted here - │ previously mutably borrowed here error: cannot transfer mutable local `x` since it is borrowed ┌─ tests/more-v1/liveness/mut_ref.move:64:13 diff --git a/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_if.exp b/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_if.exp index e99dac5a1a2b9..a98b47563fdad 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_if.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_if.exp @@ -14,7 +14,7 @@ error: cannot move local `x` since it is still in use 10 │ if (cond) { _ = move x }; │ ^^^^^^ attempted to move here 11 │ let _ = x + 1; - │ ----- used here + │ - used here error: cannot move local `x` since it is still in use ┌─ tests/more-v1/locals/use_after_move_if.move:16:25 diff --git a/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_if_else.exp b/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_if_else.exp index 6d3f341daa7d9..21d402916e2bd 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_if_else.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_if_else.exp @@ -30,7 +30,7 @@ error: cannot move local `x` since it is still in use 16 │ if (cond) { _ = move x } else { _ = move x }; │ ^^^^^^ attempted to move here 17 │ let _ = x + 1; - │ ----- used here + │ - used here error: cannot move local `x` since it is still in use ┌─ tests/more-v1/locals/use_after_move_if_else.move:16:45 @@ -38,7 +38,7 @@ error: cannot move local `x` since it is still in use 16 │ if (cond) { _ = move x } else { _ = move x }; │ ^^^^^^ attempted to move here 17 │ let _ = x + 1; - │ ----- used here + │ - used here error: cannot move local `x` since it is still in use ┌─ tests/more-v1/locals/use_after_move_if_else.move:23:25 @@ -46,7 +46,7 @@ error: cannot move local `x` since it is still in use 23 │ if (cond) { _ = move x } else { _ = x }; │ ^^^^^^ attempted to move here 24 │ let _ = x + 1; - │ ----- used here + │ - used here error: cannot move local `x` since it is still in use ┌─ tests/more-v1/locals/use_after_move_if_else.move:29:25 diff --git a/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_simple.exp b/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_simple.exp index 696c6dd3054de..47b693faaaa49 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_simple.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/locals/use_after_move_simple.exp @@ -14,7 +14,7 @@ error: cannot move local `x` since it is still in use 16 │ move x; │ ^^^^^^ attempted to move here 17 │ let _ = x + 1; - │ ----- used here + │ - used here error: cannot move local `x` since it is still in use ┌─ tests/more-v1/locals/use_after_move_simple.move:26:9 diff --git a/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/branch_assigns_then_moves.exp b/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/branch_assigns_then_moves.exp index 4362ea3b66639..f0ef889fadf51 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/branch_assigns_then_moves.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/branch_assigns_then_moves.exp @@ -7,4 +7,4 @@ error: cannot move local `x` since it is still in use │ ^^^^^^ attempted to move here · 12 │ assert!(x == 5, 42); - │ ------ used here + │ - used here diff --git a/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/else_moves_if_doesnt.exp b/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/else_moves_if_doesnt.exp index c598f2de532cf..592859bd15e0e 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/else_moves_if_doesnt.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/else_moves_if_doesnt.exp @@ -6,4 +6,4 @@ error: cannot move local `x` since it is still in use 4 │ let y = if (true) 0 else move x; y; │ ^^^^^^ attempted to move here 5 │ assert!(x == 0, 42); - │ ------ used here + │ - used here diff --git a/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/if_moves_else_doesnt.exp b/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/if_moves_else_doesnt.exp index b2ffe2bcdfd57..c7a85d1a17fb2 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/if_moves_else_doesnt.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/if_moves_else_doesnt.exp @@ -7,4 +7,4 @@ error: cannot move local `x` since it is still in use │ ^^^^^^ attempted to move here 5 │ y; 6 │ assert!(x == 0, 42); - │ ------ used here + │ - used here diff --git a/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/if_moves_no_else.exp b/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/if_moves_no_else.exp index aacd970467d78..03059adfe2626 100644 --- a/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/if_moves_no_else.exp +++ b/third_party/move/move-compiler-v2/tests/more-v1/translated_ir_tests/move/commands/if_moves_no_else.exp @@ -7,4 +7,4 @@ error: cannot move local `x` since it is still in use │ ^^^^^^ attempted to move here · 8 │ assert!(x == 0, 42); - │ ------ used here + │ - used here diff --git a/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified.exp b/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified.exp index 0ed31e88c7ef1..0114c974e14c4 100644 --- a/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified.exp +++ b/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified.exp @@ -28,4 +28,4 @@ error: cannot move local `x` since it is still in use 4 │ let y = move x; │ ^^^^^^ attempted to move here 5 │ x + y - │ ----- used here + │ - used here diff --git a/third_party/move/move-compiler-v2/tests/op-equal/eval_order.exp b/third_party/move/move-compiler-v2/tests/op-equal/eval_order.exp index 8d0574ecb6ed7..1710e30cb9de9 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/eval_order.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/eval_order.exp @@ -171,18 +171,24 @@ public fun m::test0(): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 + var $t10: u64 0: $t1 := 1 - 1: $t5 := 2 - 2: $t4 := +($t1, $t5) - 3: $t1 := infer($t4) - 4: $t3 := infer($t1) - 5: $t6 := +($t1, $t3) - 6: $t1 := infer($t6) - 7: $t2 := infer($t1) - 8: $t7 := +($t1, $t2) - 9: $t1 := infer($t7) - 10: $t0 := infer($t1) - 11: return $t0 + 1: $t5 := infer($t1) + 2: $t6 := 2 + 3: $t4 := +($t5, $t6) + 4: $t1 := infer($t4) + 5: $t3 := infer($t1) + 6: $t8 := infer($t1) + 7: $t7 := +($t8, $t3) + 8: $t1 := infer($t7) + 9: $t2 := infer($t1) + 10: $t10 := infer($t1) + 11: $t9 := +($t10, $t2) + 12: $t1 := infer($t9) + 13: $t0 := infer($t1) + 14: return $t0 } @@ -194,15 +200,19 @@ public fun m::test1(): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t1 := 1 - 1: $t4 := 2 - 2: $t3 := +($t1, $t4) - 3: $t1 := infer($t3) - 4: $t2 := infer($t1) - 5: $t5 := +($t1, $t2) - 6: $t1 := infer($t5) - 7: $t0 := infer($t1) - 8: return $t0 + 1: $t4 := infer($t1) + 2: $t5 := 2 + 3: $t3 := +($t4, $t5) + 4: $t1 := infer($t3) + 5: $t2 := infer($t1) + 6: $t7 := infer($t1) + 7: $t6 := +($t7, $t2) + 8: $t1 := infer($t6) + 9: $t0 := infer($t1) + 10: return $t0 } @@ -213,14 +223,16 @@ public fun m::test2(): u64 { var $t2: u64 var $t3: &mut u64 var $t4: u64 + var $t5: u64 0: $t1 := 1 1: $t3 := borrow_local($t1) 2: m::mod1($t3) 3: $t2 := infer($t1) - 4: $t4 := +($t1, $t2) - 5: $t1 := infer($t4) - 6: $t0 := infer($t1) - 7: return $t0 + 4: $t5 := infer($t1) + 5: $t4 := +($t5, $t2) + 6: $t1 := infer($t4) + 7: $t0 := infer($t1) + 8: return $t0 } @@ -231,13 +243,15 @@ public fun m::test3(): u64 { var $t2: u64 var $t3: &mut u64 var $t4: u64 + var $t5: u64 0: $t1 := 1 1: $t3 := borrow_local($t1) 2: $t2 := m::mod2($t3) - 3: $t4 := +($t1, $t2) - 4: $t1 := infer($t4) - 5: $t0 := infer($t1) - 6: return $t0 + 3: $t5 := infer($t1) + 4: $t4 := +($t5, $t2) + 5: $t1 := infer($t4) + 6: $t0 := infer($t1) + 7: return $t0 } ============ after LiveVarAnalysisProcessor: ================ @@ -249,15 +263,17 @@ fun m::mod1($t0: &mut u64) { var $t3: u64 var $t4: u64 # live vars: $t0 - 0: $t3 := read_ref($t0) + 0: $t0 := move($t0) + # live vars: $t0 + 1: $t3 := read_ref($t0) # live vars: $t0, $t3 - 1: $t4 := 2 + 2: $t4 := 2 # live vars: $t0, $t3, $t4 - 2: $t3 := +($t3, $t4) + 3: $t3 := +($t3, $t4) # live vars: $t0, $t3 - 3: write_ref($t0, $t3) + 4: write_ref($t0, $t3) # live vars: - 4: return () + 5: return () } @@ -293,30 +309,39 @@ public fun m::test0(): u64 { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] + var $t10: u64 [unused] # live vars: 0: $t1 := 1 # live vars: $t1 - 1: $t5 := 2 - # live vars: $t1, $t5 - 2: $t5 := +($t1, $t5) + 1: $t5 := move($t1) + # live vars: $t5 + 2: $t6 := 2 + # live vars: $t5, $t6 + 3: $t5 := +($t5, $t6) # live vars: $t5 - 3: $t1 := move($t5) + 4: $t1 := move($t5) # live vars: $t1 - 4: $t5 := copy($t1) + 5: $t5 := copy($t1) # live vars: $t1, $t5 - 5: $t5 := +($t1, $t5) + 6: $t6 := move($t1) + # live vars: $t5, $t6 + 7: $t5 := +($t6, $t5) # live vars: $t5 - 6: $t1 := move($t5) + 8: $t1 := move($t5) # live vars: $t1 - 7: $t5 := copy($t1) + 9: $t5 := copy($t1) # live vars: $t1, $t5 - 8: $t5 := +($t1, $t5) + 10: $t6 := move($t1) + # live vars: $t5, $t6 + 11: $t5 := +($t6, $t5) # live vars: $t5 - 9: $t1 := move($t5) + 12: $t1 := move($t5) # live vars: $t1 - 10: return $t1 + 13: return $t1 } @@ -327,23 +352,29 @@ public fun m::test1(): u64 { var $t2: u64 [unused] var $t3: u64 [unused] var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 + var $t6: u64 [unused] + var $t7: u64 [unused] # live vars: 0: $t1 := 1 # live vars: $t1 - 1: $t4 := 2 - # live vars: $t1, $t4 - 2: $t4 := +($t1, $t4) + 1: $t4 := move($t1) + # live vars: $t4 + 2: $t5 := 2 + # live vars: $t4, $t5 + 3: $t4 := +($t4, $t5) # live vars: $t4 - 3: $t1 := move($t4) + 4: $t1 := move($t4) # live vars: $t1 - 4: $t4 := copy($t1) + 5: $t4 := copy($t1) # live vars: $t1, $t4 - 5: $t4 := +($t1, $t4) + 6: $t5 := move($t1) + # live vars: $t4, $t5 + 7: $t4 := +($t5, $t4) # live vars: $t4 - 6: $t1 := move($t4) + 8: $t1 := move($t4) # live vars: $t1 - 7: return $t1 + 9: return $t1 } @@ -354,6 +385,7 @@ public fun m::test2(): u64 { var $t2: u64 var $t3: &mut u64 var $t4: u64 [unused] + var $t5: u64 # live vars: 0: $t1 := 1 # live vars: $t1 @@ -363,13 +395,15 @@ public fun m::test2(): u64 { # live vars: $t1 3: $t2 := copy($t1) # live vars: $t1, $t2 - 4: $t2 := +($t1, $t2) + 4: $t5 := move($t1) + # live vars: $t2, $t5 + 5: $t2 := +($t5, $t2) # live vars: $t2 - 5: $t1 := move($t2) + 6: $t1 := move($t2) # live vars: $t1 - 6: $t2 := move($t1) + 7: $t2 := move($t1) # live vars: $t2 - 7: return $t2 + 8: return $t2 } @@ -380,6 +414,7 @@ public fun m::test3(): u64 { var $t2: u64 var $t3: &mut u64 var $t4: u64 [unused] + var $t5: u64 # live vars: 0: $t1 := 1 # live vars: $t1 @@ -387,13 +422,15 @@ public fun m::test3(): u64 { # live vars: $t1, $t3 2: $t2 := m::mod2($t3) # live vars: $t1, $t2 - 3: $t2 := +($t1, $t2) + 3: $t5 := move($t1) + # live vars: $t2, $t5 + 4: $t2 := +($t5, $t2) # live vars: $t2 - 4: $t1 := move($t2) + 5: $t1 := move($t2) # live vars: $t1 - 5: $t2 := move($t1) + 6: $t2 := move($t1) # live vars: $t2 - 6: return $t2 + 7: return $t2 } diff --git a/third_party/move/move-compiler-v2/tests/op-equal/invalid1.exp b/third_party/move/move-compiler-v2/tests/op-equal/invalid1.exp index e615879b5173c..bd9894740abeb 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/invalid1.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/invalid1.exp @@ -39,23 +39,25 @@ fun test::test() { var $t1: &mut u64 var $t2: u64 var $t3: u64 - var $t4: &mut u64 - var $t5: u64 + var $t4: u64 + var $t5: &mut u64 var $t6: u64 var $t7: u64 var $t8: u64 + var $t9: u64 0: $t0 := 42 1: $t1 := borrow_local($t0) - 2: $t3 := 1 - 3: $t2 := +($t0, $t3) - 4: $t0 := infer($t2) - 5: $t4 := infer($t1) - 6: $t6 := read_ref($t4) - 7: $t7 := 1 - 8: $t5 := +($t6, $t7) - 9: write_ref($t4, $t5) - 10: $t8 := infer($t0) - 11: return () + 2: $t3 := infer($t0) + 3: $t4 := 1 + 4: $t2 := +($t3, $t4) + 5: $t0 := infer($t2) + 6: $t5 := infer($t1) + 7: $t7 := read_ref($t5) + 8: $t8 := 1 + 9: $t6 := +($t7, $t8) + 10: write_ref($t5, $t6) + 11: $t9 := infer($t0) + 12: return () } @@ -66,7 +68,7 @@ error: cannot copy local `x` which is still mutably borrowed 4 │ let p = &mut x; │ ------ local `x` previously mutably borrowed here 5 │ x += 1; - │ ^^^^^^ copy attempted here + │ ^ copy attempted here 6 │ *p += 1; │ - conflicting reference `p` used here diff --git a/third_party/move/move-compiler-v2/tests/op-equal/valid0.exp b/third_party/move/move-compiler-v2/tests/op-equal/valid0.exp index e3a00fa6e9edf..66ed1975916a0 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/valid0.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/valid0.exp @@ -204,11 +204,13 @@ fun test::add1_new($t0: u256): u256 { var $t1: u256 var $t2: u256 var $t3: u256 - 0: $t3 := 1 - 1: $t2 := +($t0, $t3) - 2: $t0 := infer($t2) - 3: $t1 := infer($t0) - 4: return $t1 + var $t4: u256 + 0: $t3 := infer($t0) + 1: $t4 := 1 + 2: $t2 := +($t3, $t4) + 3: $t0 := infer($t2) + 4: $t1 := infer($t0) + 5: return $t1 } @@ -217,11 +219,13 @@ fun test::add1_old($t0: u256): u256 { var $t1: u256 var $t2: u256 var $t3: u256 - 0: $t3 := 1 - 1: $t2 := +($t0, $t3) - 2: $t0 := infer($t2) - 3: $t1 := infer($t0) - 4: return $t1 + var $t4: u256 + 0: $t3 := infer($t0) + 1: $t4 := 1 + 2: $t2 := +($t3, $t4) + 3: $t0 := infer($t2) + 4: $t1 := infer($t0) + 5: return $t1 } @@ -379,15 +383,17 @@ fun test::inc_vec_coin_old($t0: vector<0x42::test::Coin>, $t1: u64) { [variant baseline] fun test::inc_vec_new($t0: &mut vector, $t1: u64) { var $t2: &mut u256 - var $t3: u256 + var $t3: &mut vector var $t4: u256 var $t5: u256 - 0: $t2 := vector::borrow_mut($t0, $t1) - 1: $t4 := read_ref($t2) - 2: $t5 := 1 - 3: $t3 := +($t4, $t5) - 4: write_ref($t2, $t3) - 5: return () + var $t6: u256 + 0: $t3 := infer($t0) + 1: $t2 := vector::borrow_mut($t3, $t1) + 2: $t5 := read_ref($t2) + 3: $t6 := 1 + 4: $t4 := +($t5, $t6) + 5: write_ref($t2, $t4) + 6: return () } @@ -506,14 +512,17 @@ fun test::add1_new($t0: u256): u256 { var $t1: u256 [unused] var $t2: u256 [unused] var $t3: u256 + var $t4: u256 # live vars: $t0 - 0: $t3 := 1 - # live vars: $t0, $t3 - 1: $t3 := +($t0, $t3) + 0: $t3 := move($t0) + # live vars: $t3 + 1: $t4 := 1 + # live vars: $t3, $t4 + 2: $t3 := +($t3, $t4) # live vars: $t3 - 2: $t0 := move($t3) + 3: $t0 := move($t3) # live vars: $t0 - 3: return $t0 + 4: return $t0 } @@ -522,14 +531,17 @@ fun test::add1_old($t0: u256): u256 { var $t1: u256 [unused] var $t2: u256 [unused] var $t3: u256 + var $t4: u256 # live vars: $t0 - 0: $t3 := 1 - # live vars: $t0, $t3 - 1: $t3 := +($t0, $t3) + 0: $t3 := move($t0) + # live vars: $t3 + 1: $t4 := 1 + # live vars: $t3, $t4 + 2: $t3 := +($t3, $t4) # live vars: $t3 - 2: $t0 := move($t3) + 3: $t0 := move($t3) # live vars: $t0 - 3: return $t0 + 4: return $t0 } @@ -651,15 +663,17 @@ fun test::inc_new($t0: &mut u256) { var $t3: u256 var $t4: u256 # live vars: $t0 - 0: $t3 := read_ref($t0) + 0: $t0 := move($t0) + # live vars: $t0 + 1: $t3 := read_ref($t0) # live vars: $t0, $t3 - 1: $t4 := 1 + 2: $t4 := 1 # live vars: $t0, $t3, $t4 - 2: $t3 := +($t3, $t4) + 3: $t3 := +($t3, $t4) # live vars: $t0, $t3 - 3: write_ref($t0, $t3) + 4: write_ref($t0, $t3) # live vars: - 4: return () + 5: return () } @@ -747,21 +761,24 @@ fun test::inc_vec_coin_old($t0: vector<0x42::test::Coin>, $t1: u64) { [variant baseline] fun test::inc_vec_new($t0: &mut vector, $t1: u64) { var $t2: &mut u256 - var $t3: u256 [unused] - var $t4: u256 + var $t3: &mut vector [unused] + var $t4: u256 [unused] var $t5: u256 + var $t6: u256 # live vars: $t0, $t1 - 0: $t2 := vector::borrow_mut($t0, $t1) + 0: $t0 := move($t0) + # live vars: $t0, $t1 + 1: $t2 := vector::borrow_mut($t0, $t1) # live vars: $t2 - 1: $t4 := read_ref($t2) - # live vars: $t2, $t4 - 2: $t5 := 1 - # live vars: $t2, $t4, $t5 - 3: $t4 := +($t4, $t5) - # live vars: $t2, $t4 - 4: write_ref($t2, $t4) + 2: $t5 := read_ref($t2) + # live vars: $t2, $t5 + 3: $t6 := 1 + # live vars: $t2, $t5, $t6 + 4: $t5 := +($t5, $t6) + # live vars: $t2, $t5 + 5: write_ref($t2, $t5) # live vars: - 5: return () + 6: return () } @@ -932,7 +949,6 @@ struct Wrapper has drop, key { } add1_new(Arg0: u256): u256 /* def_idx: 0 */ { -L1: loc0: u256 B0: 0: MoveLoc[0](Arg0: u256) 1: LdU256(1) @@ -940,7 +956,6 @@ B0: 3: Ret } add1_old(Arg0: u256): u256 /* def_idx: 1 */ { -L1: loc0: u256 B0: 0: MoveLoc[0](Arg0: u256) 1: LdU256(1) diff --git a/third_party/move/move-compiler-v2/tests/op-equal/valid1.exp b/third_party/move/move-compiler-v2/tests/op-equal/valid1.exp index d75c575a32c78..4687235280fae 100644 --- a/third_party/move/move-compiler-v2/tests/op-equal/valid1.exp +++ b/third_party/move/move-compiler-v2/tests/op-equal/valid1.exp @@ -167,15 +167,17 @@ fun test::bitand_vec_coin_new($t0: vector<0x42::test::Coin>, $t1: u64) { [variant baseline] fun test::bitor_vec_new($t0: &mut vector, $t1: u64) { var $t2: &mut u256 - var $t3: u256 + var $t3: &mut vector var $t4: u256 var $t5: u256 - 0: $t2 := vector::borrow_mut($t0, $t1) - 1: $t4 := read_ref($t2) - 2: $t5 := 42 - 3: $t3 := |($t4, $t5) - 4: write_ref($t2, $t3) - 5: return () + var $t6: u256 + 0: $t3 := infer($t0) + 1: $t2 := vector::borrow_mut($t3, $t1) + 2: $t5 := read_ref($t2) + 3: $t6 := 42 + 4: $t4 := |($t5, $t6) + 5: write_ref($t2, $t4) + 6: return () } @@ -331,21 +333,24 @@ fun test::bitand_vec_coin_new($t0: vector<0x42::test::Coin>, $t1: u64) { [variant baseline] fun test::bitor_vec_new($t0: &mut vector, $t1: u64) { var $t2: &mut u256 - var $t3: u256 [unused] - var $t4: u256 + var $t3: &mut vector [unused] + var $t4: u256 [unused] var $t5: u256 + var $t6: u256 + # live vars: $t0, $t1 + 0: $t0 := move($t0) # live vars: $t0, $t1 - 0: $t2 := vector::borrow_mut($t0, $t1) + 1: $t2 := vector::borrow_mut($t0, $t1) # live vars: $t2 - 1: $t4 := read_ref($t2) - # live vars: $t2, $t4 - 2: $t5 := 42 - # live vars: $t2, $t4, $t5 - 3: $t4 := |($t4, $t5) - # live vars: $t2, $t4 - 4: write_ref($t2, $t4) + 2: $t5 := read_ref($t2) + # live vars: $t2, $t5 + 3: $t6 := 42 + # live vars: $t2, $t5, $t6 + 4: $t5 := |($t5, $t6) + # live vars: $t2, $t5 + 5: write_ref($t2, $t5) # live vars: - 5: return () + 6: return () } @@ -476,15 +481,17 @@ fun test::sub1($t0: &mut u256) { var $t3: u256 var $t4: u256 # live vars: $t0 - 0: $t3 := read_ref($t0) + 0: $t0 := move($t0) + # live vars: $t0 + 1: $t3 := read_ref($t0) # live vars: $t0, $t3 - 1: $t4 := 1 + 2: $t4 := 1 # live vars: $t0, $t3, $t4 - 2: $t3 := -($t3, $t4) + 3: $t3 := -($t3, $t4) # live vars: $t0, $t3 - 3: write_ref($t0, $t3) + 4: write_ref($t0, $t3) # live vars: - 4: return () + 5: return () } diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.exp b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.exp index f41849f78bc59..8410c0cfc90a9 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.exp @@ -5,6 +5,6 @@ error: cannot transfer mutable local `x` since it is borrowed │ 8 │ mut_ref(x, x) │ ^^^^^^^^^^^^^ - │ │ + │ │ │ + │ │ previously mutably borrowed here │ transfer attempted here - │ previously mutably borrowed here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.no-opt.exp b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.no-opt.exp index f41849f78bc59..8410c0cfc90a9 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.no-opt.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.no-opt.exp @@ -5,6 +5,6 @@ error: cannot transfer mutable local `x` since it is borrowed │ 8 │ mut_ref(x, x) │ ^^^^^^^^^^^^^ - │ │ + │ │ │ + │ │ previously mutably borrowed here │ transfer attempted here - │ previously mutably borrowed here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.old.exp index fca6dfb9b9abc..89a3a9cca1859 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/duplicate_use.old.exp @@ -1,7 +1,9 @@ Diagnostics: -error: same mutable reference in local `x` is used again in argument list +error: same mutable reference in local `x` is also used in other value in argument list ┌─ tests/reference-safety/duplicate_use.move:8:9 │ +7 │ fun fail(x: &mut u64) { + │ - previous mutable local borrow 8 │ mut_ref(x, x) │ ^^^^^^^^^^^^^ requirement enforced here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/freeze.exp b/third_party/move/move-compiler-v2/tests/reference-safety/freeze.exp index 773015d0f9c65..8167877ca429b 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/freeze.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/freeze.exp @@ -5,9 +5,9 @@ error: cannot transfer mutable local `r` since it is borrowed │ 18 │ ref_mut_mut(r, r); // error │ ^^^^^^^^^^^^^^^^^ - │ │ + │ │ │ + │ │ previously mutably borrowed here │ transfer attempted here - │ previously mutably borrowed here error: cannot transfer mutable local `r` since it is borrowed ┌─ tests/reference-safety/freeze.move:24:9 diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/freeze.no-opt.exp b/third_party/move/move-compiler-v2/tests/reference-safety/freeze.no-opt.exp index 773015d0f9c65..8167877ca429b 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/freeze.no-opt.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/freeze.no-opt.exp @@ -5,9 +5,9 @@ error: cannot transfer mutable local `r` since it is borrowed │ 18 │ ref_mut_mut(r, r); // error │ ^^^^^^^^^^^^^^^^^ - │ │ + │ │ │ + │ │ previously mutably borrowed here │ transfer attempted here - │ previously mutably borrowed here error: cannot transfer mutable local `r` since it is borrowed ┌─ tests/reference-safety/freeze.move:24:9 diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/freeze.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/freeze.old.exp index e56e055336711..62117e58091fc 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/freeze.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/freeze.old.exp @@ -1,8 +1,10 @@ Diagnostics: -error: same mutable reference in local `r` is used again in argument list +error: same mutable reference in local `r` is also used in other value in argument list ┌─ tests/reference-safety/freeze.move:18:9 │ +17 │ let r = &mut x; + │ ------ previous mutable local borrow 18 │ ref_mut_mut(r, r); // error │ ^^^^^^^^^^^^^^^^^ requirement enforced here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.exp b/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.exp index 56d76e7207b0b..22155231434e2 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.exp @@ -9,7 +9,7 @@ error: cannot transfer mutable value since it is borrowed │ │ previously mutably borrowed here │ transfer attempted here -error: cannot transfer mutable local `r` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/multiple_use_invalid.move:11:9 │ 10 │ let x = r; diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.no-opt.exp b/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.no-opt.exp index 56d76e7207b0b..22155231434e2 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.no-opt.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.no-opt.exp @@ -9,7 +9,7 @@ error: cannot transfer mutable value since it is borrowed │ │ previously mutably borrowed here │ transfer attempted here -error: cannot transfer mutable local `r` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/multiple_use_invalid.move:11:9 │ 10 │ let x = r; diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.old.exp index fcfc05f5dda14..bf55b27743b0a 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/multiple_use_invalid.old.exp @@ -10,7 +10,16 @@ error: same mutable reference in value is also used in other value in argument l │ │ previous mutable field borrow │ requirement enforced here -error: same mutable reference in local `r` is also used in other local `x` in argument list +error: mutable reference in local `r` requires exclusive access but is borrowed + ┌─ tests/reference-safety/multiple_use_invalid.move:11:11 + │ +11 │ s(r, x) + │ --^---- + │ │ │ + │ │ requirement enforced here + │ conflicting reference `x` used here + +error: same mutable reference in local `x` is also used in other value in argument list ┌─ tests/reference-safety/multiple_use_invalid.move:11:9 │ 9 │ let r = &mut s.x; @@ -19,7 +28,7 @@ error: same mutable reference in local `r` is also used in other local `x` in ar 11 │ s(r, x) │ ^^^^^^^ requirement enforced here -error: same mutable reference in local `r1` is also used in other local `r2` in argument list +error: same mutable reference in local `r2` is also used in other value in argument list ┌─ tests/reference-safety/multiple_use_invalid.move:20:9 │ 18 │ let r1 = &mut x; diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.exp index a37612c579b63..56f4e5f2d3b21 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.exp @@ -9,7 +9,7 @@ error: cannot transfer mutable local `f` since it is borrowed 12 │ foo(f_g, f); │ ^^^^^^^^^^^ transfer attempted here -error: cannot transfer mutable local `f` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-borrow-tests/factor_invalid_1.move:22:9 │ 19 │ let f_g = &mut f.g; diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.no-opt.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.no-opt.exp index a37612c579b63..56f4e5f2d3b21 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.no-opt.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.no-opt.exp @@ -9,7 +9,7 @@ error: cannot transfer mutable local `f` since it is borrowed 12 │ foo(f_g, f); │ ^^^^^^^^^^^ transfer attempted here -error: cannot transfer mutable local `f` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-borrow-tests/factor_invalid_1.move:22:9 │ 19 │ let f_g = &mut f.g; diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.old.exp index 8a1e25a9340bd..b1846d1919b64 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/factor_invalid_1.old.exp @@ -10,6 +10,18 @@ error: mutable reference in local `f` requires exclusive access but is borrowed │ ^^^^^^^^^^^ requirement enforced here error: mutable reference in local `f` requires exclusive access but is borrowed + ┌─ tests/reference-safety/v1-borrow-tests/factor_invalid_1.move:22:13 + │ +19 │ let f_g = &mut f.g; + │ -------- previous mutable field borrow + · +22 │ bar(f, f_g); + │ ----^------ + │ │ │ + │ │ requirement enforced here + │ conflicting reference `f_g` used here + +error: mutable reference in value requires exclusive access but is borrowed ┌─ tests/reference-safety/v1-borrow-tests/factor_invalid_1.move:22:9 │ 19 │ let f_g = &mut f.g; diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.exp index e9543d2bd3ac1..27c3fd7b6be3a 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.exp @@ -18,7 +18,7 @@ error: cannot mutably borrow `Tester::Pair` since it is already borrowed 36 │ let p2 = freeze(borrow_global_mut(addr2)); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow attempted here 37 │ p1 == p2 - │ -------- conflicting reference `p1` used here + │ -- conflicting reference `p1` used here error: cannot mutably borrow `Tester::Pair` since it is already borrowed ┌─ tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.move:42:19 @@ -28,4 +28,4 @@ error: cannot mutably borrow `Tester::Pair` since it is already borrowed 42 │ let c2 = &borrow_global_mut(addr2).x; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow attempted here 43 │ c1 == c2 - │ -------- conflicting reference `c1` used here + │ -- conflicting reference `c1` used here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.no-opt.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.no-opt.exp index e9543d2bd3ac1..27c3fd7b6be3a 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.no-opt.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.no-opt.exp @@ -18,7 +18,7 @@ error: cannot mutably borrow `Tester::Pair` since it is already borrowed 36 │ let p2 = freeze(borrow_global_mut(addr2)); │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow attempted here 37 │ p1 == p2 - │ -------- conflicting reference `p1` used here + │ -- conflicting reference `p1` used here error: cannot mutably borrow `Tester::Pair` since it is already borrowed ┌─ tests/reference-safety/v1-borrow-tests/imm_borrow_global_invalid.move:42:19 @@ -28,4 +28,4 @@ error: cannot mutably borrow `Tester::Pair` since it is already borrowed 42 │ let c2 = &borrow_global_mut(addr2).x; │ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow attempted here 43 │ c1 == c2 - │ -------- conflicting reference `c1` used here + │ -- conflicting reference `c1` used here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_loc.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_loc.old.exp index ec38e8b177d8a..46735fe0e42ea 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_loc.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_loc.old.exp @@ -16,7 +16,7 @@ error: cannot immutably borrow since mutable references exist │ immutable borrow attempted here 28 │ assert!(b2.f != 0, 42); 29 │ assert!((returned_ref == &b1.f) != (returned_ref == &b2.f), 42); - │ ----------------------- conflicting reference `returned_ref` used here + │ ------------ conflicting reference `returned_ref` used here error: cannot immutably borrow since mutable references exist ┌─ tests/reference-safety/v1-borrow-tests/imm_borrow_loc.move:28:17 @@ -33,7 +33,7 @@ error: cannot immutably borrow since mutable references exist │ requirement enforced here │ immutable borrow attempted here 29 │ assert!((returned_ref == &b1.f) != (returned_ref == &b2.f), 42); - │ ----------------------- conflicting reference `returned_ref` used here + │ ------------ conflicting reference `returned_ref` used here error: cannot immutably borrow since mutable references exist ┌─ tests/reference-safety/v1-borrow-tests/imm_borrow_loc.move:29:35 @@ -45,7 +45,7 @@ error: cannot immutably borrow since mutable references exist │ used by call result · 29 │ assert!((returned_ref == &b1.f) != (returned_ref == &b2.f), 42); - │ ------------------^^--- ----------------------- conflicting reference `returned_ref` used here + │ ------------------^^--- ------------ conflicting reference `returned_ref` used here │ │ │ │ │ immutable borrow attempted here │ requirement enforced here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_loc_valid.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_loc_valid.old.exp index 6709295ee1f47..b1d84511b940b 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_loc_valid.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-borrow-tests/imm_borrow_loc_valid.old.exp @@ -16,7 +16,7 @@ error: cannot immutably borrow since mutable references exist │ immutable borrow attempted here · 30 │ (returned_ref == &(&mut b1).f) != (returned_ref == &(&mut b2).f), - │ ------------------------------ conflicting reference `returned_ref` used here + │ ------------ conflicting reference `returned_ref` used here error: cannot immutably borrow since mutable references exist ┌─ tests/reference-safety/v1-borrow-tests/imm_borrow_loc_valid.move:28:17 @@ -34,4 +34,4 @@ error: cannot immutably borrow since mutable references exist │ immutable borrow attempted here 29 │ assert!( 30 │ (returned_ref == &(&mut b1).f) != (returned_ref == &(&mut b2).f), - │ ------------------------------ conflicting reference `returned_ref` used here + │ ------------ conflicting reference `returned_ref` used here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.exp index 3c2747e18e2d0..6cf64ef5cb91c 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.exp @@ -1,6 +1,6 @@ Diagnostics: -error: cannot transfer mutable local `s1` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:15:9 │ 14 │ let f = freeze(s1); @@ -8,7 +8,7 @@ error: cannot transfer mutable local `s1` since it is borrowed 15 │ mut_imm(s1, f); │ ^^^^^^^^^^^^^^ transfer attempted here -error: cannot transfer mutable local `s1` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:17:9 │ 16 │ let f = &s1.f; @@ -39,11 +39,11 @@ error: cannot transfer mutable local `s1` since it is borrowed │ 23 │ mut_mut(s1, s1); │ ^^^^^^^^^^^^^^^ - │ │ + │ │ │ + │ │ previously mutably borrowed here │ transfer attempted here - │ previously mutably borrowed here -error: cannot transfer mutable local `s1` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:25:9 │ 24 │ let f = &mut s1.f; @@ -70,7 +70,7 @@ error: cannot transfer mutable local `s1` since it is borrowed 29 │ *s; │ -- conflicting reference `s` used here -error: cannot transfer mutable local `s1` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:31:9 │ 30 │ let f = id_mut(&mut s1.f); diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.no-opt.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.no-opt.exp index 3c2747e18e2d0..6cf64ef5cb91c 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.no-opt.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.no-opt.exp @@ -1,6 +1,6 @@ Diagnostics: -error: cannot transfer mutable local `s1` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:15:9 │ 14 │ let f = freeze(s1); @@ -8,7 +8,7 @@ error: cannot transfer mutable local `s1` since it is borrowed 15 │ mut_imm(s1, f); │ ^^^^^^^^^^^^^^ transfer attempted here -error: cannot transfer mutable local `s1` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:17:9 │ 16 │ let f = &s1.f; @@ -39,11 +39,11 @@ error: cannot transfer mutable local `s1` since it is borrowed │ 23 │ mut_mut(s1, s1); │ ^^^^^^^^^^^^^^^ - │ │ + │ │ │ + │ │ previously mutably borrowed here │ transfer attempted here - │ previously mutably borrowed here -error: cannot transfer mutable local `s1` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:25:9 │ 24 │ let f = &mut s1.f; @@ -70,7 +70,7 @@ error: cannot transfer mutable local `s1` since it is borrowed 29 │ *s; │ -- conflicting reference `s` used here -error: cannot transfer mutable local `s1` since it is borrowed +error: cannot transfer mutable value since it is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:31:9 │ 30 │ let f = id_mut(&mut s1.f); diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.old.exp index 36f592249a698..a1925cca1e95f 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/call_mutual_borrows_invalid.old.exp @@ -1,20 +1,46 @@ Diagnostics: error: mutable reference in local `s1` requires exclusive access but is borrowed + ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:15:17 + │ +14 │ let f = freeze(s1); + │ ---------- previous freeze +15 │ mut_imm(s1, f); + │ --------^^---- + │ │ │ + │ │ requirement enforced here + │ conflicting reference `f` used here + +error: mutable reference in value requires exclusive access but is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:15:9 │ 14 │ let f = freeze(s1); │ ---------- previous freeze 15 │ mut_imm(s1, f); │ ^^^^^^^^^^^^^^ requirement enforced here +16 │ let f = &s1.f; + │ ----- conflicting reference `s1` used here error: mutable reference in local `s1` requires exclusive access but is borrowed + ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:17:17 + │ +16 │ let f = &s1.f; + │ ----- previous field borrow +17 │ mut_imm(s1, f); + │ --------^^---- + │ │ │ + │ │ requirement enforced here + │ conflicting reference `f` used here + +error: mutable reference in value requires exclusive access but is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:17:9 │ 16 │ let f = &s1.f; │ ----- previous field borrow 17 │ mut_imm(s1, f); │ ^^^^^^^^^^^^^^ requirement enforced here +18 │ let f = &s1.f; + │ ----- conflicting reference `s1` used here error: cannot mutably borrow since immutable references exist ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:19:17 @@ -43,19 +69,35 @@ error: cannot mutably borrow since immutable references exist │ │ mutable borrow attempted here │ requirement enforced here -error: same mutable reference in local `s1` is used again in argument list +error: same mutable reference in local `s1` is also used in other value in argument list ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:23:9 │ +13 │ fun t0(s1: &mut S, _s2: &mut S) { + │ -- previous mutable local borrow + · 23 │ mut_mut(s1, s1); │ ^^^^^^^^^^^^^^^ requirement enforced here error: mutable reference in local `s1` requires exclusive access but is borrowed + ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:25:17 + │ +24 │ let f = &mut s1.f; + │ --------- previous mutable field borrow +25 │ mut_mut(s1, f); + │ --------^^---- + │ │ │ + │ │ requirement enforced here + │ conflicting reference `f` used here + +error: mutable reference in value requires exclusive access but is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:25:9 │ 24 │ let f = &mut s1.f; │ --------- previous mutable field borrow 25 │ mut_mut(s1, f); │ ^^^^^^^^^^^^^^ requirement enforced here +26 │ mut_mut(&mut s1.f, s1); + │ --------- conflicting reference `s1` used here error: mutable reference in local `s1` requires exclusive access but is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:26:9 @@ -77,6 +119,20 @@ error: mutable reference in local `s1` requires exclusive access but is borrowed │ -- conflicting reference `s` used here error: mutable reference in local `s1` requires exclusive access but is borrowed + ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:31:17 + │ +30 │ let f = id_mut(&mut s1.f); + │ ----------------- + │ │ │ + │ │ previous mutable field borrow + │ used by mutable call result +31 │ mut_mut(s1, f); + │ --------^^---- + │ │ │ + │ │ requirement enforced here + │ conflicting reference `f` used here + +error: mutable reference in value requires exclusive access but is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:31:9 │ 30 │ let f = id_mut(&mut s1.f); @@ -86,6 +142,8 @@ error: mutable reference in local `s1` requires exclusive access but is borrowed │ used by mutable call result 31 │ mut_mut(s1, f); │ ^^^^^^^^^^^^^^ requirement enforced here +32 │ mut_mut(id_mut(&mut s1.f), s1); + │ --------- conflicting reference `s1` used here error: mutable reference in local `s1` requires exclusive access but is borrowed ┌─ tests/reference-safety/v1-tests/call_mutual_borrows_invalid.move:32:9 diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.exp index e5fbce1d21b8d..cce03ec82b236 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.exp @@ -6,7 +6,7 @@ error: cannot copy local `x` which is still mutably borrowed 12 │ let f = &mut x; │ ------ local `x` previously mutably borrowed here 13 │ x + 0; - │ ^^^^^ copy attempted here + │ ^ copy attempted here 14 │ *f; │ -- conflicting reference `f` used here @@ -16,6 +16,6 @@ error: cannot copy local `x` which is still mutably borrowed 18 │ let f = id_mut(&mut x); │ -------------- local `x` previously mutably borrowed here 19 │ x + 0; - │ ^^^^^ copy attempted here + │ ^ copy attempted here 20 │ *f; │ -- conflicting reference `f` used here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.no-opt.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.no-opt.exp index e5fbce1d21b8d..cce03ec82b236 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.no-opt.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.no-opt.exp @@ -6,7 +6,7 @@ error: cannot copy local `x` which is still mutably borrowed 12 │ let f = &mut x; │ ------ local `x` previously mutably borrowed here 13 │ x + 0; - │ ^^^^^ copy attempted here + │ ^ copy attempted here 14 │ *f; │ -- conflicting reference `f` used here @@ -16,6 +16,6 @@ error: cannot copy local `x` which is still mutably borrowed 18 │ let f = id_mut(&mut x); │ -------------- local `x` previously mutably borrowed here 19 │ x + 0; - │ ^^^^^ copy attempted here + │ ^ copy attempted here 20 │ *f; │ -- conflicting reference `f` used here diff --git a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.old.exp b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.old.exp index 8a5582cc2b73c..1c2c1073f3736 100644 --- a/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.old.exp +++ b/third_party/move/move-compiler-v2/tests/reference-safety/v1-tests/copy_full_invalid.old.exp @@ -1,16 +1,16 @@ Diagnostics: -error: cannot pass local `x` which is still mutably borrowed as function argument +error: cannot copy local `x` which is still mutably borrowed ┌─ tests/reference-safety/v1-tests/copy_full_invalid.move:13:9 │ 12 │ let f = &mut x; │ ------ previous mutable local borrow 13 │ x + 0; - │ ^^^^^ passed here + │ ^ copied here 14 │ *f; │ -- conflicting reference `f` used here -error: cannot pass local `x` which is still mutably borrowed as function argument +error: cannot copy local `x` which is still mutably borrowed ┌─ tests/reference-safety/v1-tests/copy_full_invalid.move:19:9 │ 18 │ let f = id_mut(&mut x); @@ -19,6 +19,6 @@ error: cannot pass local `x` which is still mutably borrowed as function argumen │ │ previous mutable local borrow │ used by mutable call result 19 │ x + 0; - │ ^^^^^ passed here + │ ^ copied here 20 │ *f; │ -- conflicting reference `f` used here diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/else_assigns_if_doesnt.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/else_assigns_if_doesnt.exp index dc7f6f24d283d..c8fb66932a341 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/else_assigns_if_doesnt.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/else_assigns_if_doesnt.exp @@ -45,4 +45,4 @@ error: use of possibly unassigned local `y` ┌─ tests/simplifier-elimination/else_assigns_if_doesnt.move:11:13 │ 11 │ assert!(y == 0, 42); - │ ^^^^^^ + │ ^ diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_else_doesnt.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_else_doesnt.exp index 5c7d031f7cbe2..a1a6e7c1f0c7e 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_else_doesnt.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/if_assigns_else_doesnt.exp @@ -45,4 +45,4 @@ error: use of possibly unassigned local `x` ┌─ tests/simplifier-elimination/if_assigns_else_doesnt.move:11:13 │ 11 │ assert!(x == 42, 42); - │ ^^^^^^^ + │ ^ diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified.exp index 5993472addce0..e4bf54017e179 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/moved_var_not_simplified.exp @@ -28,4 +28,4 @@ error: cannot move local `x` since it is still in use 4 │ let y = move x; │ ^^^^^^ attempted to move here 5 │ x + y - │ ----- used here + │ - used here diff --git a/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_loop.exp b/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_loop.exp index 549cc95c615c2..f61681833eb12 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_loop.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier-elimination/use_before_assign_loop.exp @@ -115,7 +115,7 @@ error: use of possibly unassigned local `x` ┌─ tests/simplifier-elimination/use_before_assign_loop.move:9:24 │ 9 │ loop { let y = x + 1; if (cond) { continue }; x = 0; y; } - │ ^^^^^ + │ ^ error: use of possibly unassigned local `x` ┌─ tests/simplifier-elimination/use_before_assign_loop.move:14:24 diff --git a/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified.exp b/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified.exp index bba70e2914393..d01240bac1cc4 100644 --- a/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified.exp +++ b/third_party/move/move-compiler-v2/tests/simplifier/moved_var_not_simplified.exp @@ -28,4 +28,4 @@ error: cannot move local `x` since it is still in use 4 │ let y = move x; │ ^^^^^^ attempted to move here 5 │ x + y - │ ----- used here + │ - used here diff --git a/third_party/move/move-compiler-v2/tests/testsuite.rs b/third_party/move/move-compiler-v2/tests/testsuite.rs index eff9be3737cf6..a5e6ef2322d8d 100644 --- a/third_party/move/move-compiler-v2/tests/testsuite.rs +++ b/third_party/move/move-compiler-v2/tests/testsuite.rs @@ -265,7 +265,7 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { stop_after: StopAfter::FileFormat, dump_ast: DumpLevel::EndStage, dump_bytecode: DumpLevel::EndStage, - dump_bytecode_filter: Some(vec![INITIAL_BYTECODE_STAGE]), + dump_bytecode_filter: Some(vec![INITIAL_BYTECODE_STAGE, FILE_FORMAT_STAGE]), }, // -- Tests for stages in the bytecode pipeline // Live-var tests @@ -276,10 +276,15 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { exclude: vec![], exp_suffix: None, options: opts.clone(), - stop_after: StopAfter::BytecodePipeline(Some("LiveVarAnalysisProcessor")), + // Run the entire compiler pipeline to double-check the result + stop_after: StopAfter::FileFormat, dump_ast: DumpLevel::None, dump_bytecode: DumpLevel::AllStages, - dump_bytecode_filter: Some(vec![INITIAL_BYTECODE_STAGE, "LiveVarAnalysisProcessor"]), + dump_bytecode_filter: Some(vec![ + INITIAL_BYTECODE_STAGE, + "LiveVarAnalysisProcessor", + FILE_FORMAT_STAGE, + ]), }, // Reference safety tests, old version (with optimizations on) TestConfig { @@ -386,7 +391,8 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { exclude: vec![], exp_suffix: None, options: opts.clone(), - stop_after: StopAfter::BytecodePipeline(Some("AbilityProcessor")), + // Run the entire compiler pipeline to double-check the result + stop_after: StopAfter::FileFormat, dump_ast: DumpLevel::None, dump_bytecode: DumpLevel::AllStages, dump_bytecode_filter: Some(vec![ @@ -395,6 +401,7 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { "LiveVarAnalysisProcessor", "ReferenceSafetyProcessor", "AbilityProcessor", + FILE_FORMAT_STAGE, ]), }, TestConfig { @@ -541,6 +548,7 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { INITIAL_BYTECODE_STAGE, "UnreachableCodeProcessor", "UnreachableCodeRemover", + FILE_FORMAT_STAGE, ]), }, // Uninitialized use checker @@ -553,10 +561,15 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { options: opts .clone() .set_experiment(Experiment::KEEP_UNINIT_ANNOTATIONS, true), - stop_after: StopAfter::BytecodePipeline(Some("uninitialized_use_checker")), + // Run the entire compiler pipeline to double-check the result + stop_after: StopAfter::FileFormat, dump_ast: DumpLevel::None, dump_bytecode: DumpLevel::AllStages, - dump_bytecode_filter: Some(vec![INITIAL_BYTECODE_STAGE, "uninitialized_use_checker"]), + dump_bytecode_filter: Some(vec![ + INITIAL_BYTECODE_STAGE, + "uninitialized_use_checker", + FILE_FORMAT_STAGE, + ]), }, // -- File Format Generation // Test without bytecode optimizations enabled diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_both_branch.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_both_branch.exp index fa135c53f0cc4..d8ee05d270a80 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_both_branch.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_both_branch.exp @@ -50,3 +50,28 @@ fun m::test($t0: bool): u64 { # before: { maybe: $t3, $t4 }, after: { maybe: $t3, $t4 } 10: return $t1 } + + +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test(Arg0: bool): u64 /* def_idx: 0 */ { +L1: loc0: u64 +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrFalse(6) +B1: + 2: LdU64(1) + 3: StLoc[1](loc0: u64) +B2: + 4: MoveLoc[1](loc0: u64) + 5: Ret +B3: + 6: LdU64(2) + 7: StLoc[1](loc0: u64) + 8: Branch(4) +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_in_one_if_branch_unfoldable.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_in_one_if_branch_unfoldable.exp index acfac3d8089ec..f67534e1f57b6 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_in_one_if_branch_unfoldable.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_in_one_if_branch_unfoldable.exp @@ -7,6 +7,7 @@ fun _0::main($t0: bool, $t1: bool) { var $t4: u64 var $t5: u64 var $t6: bool + var $t7: u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t4 := 5 @@ -21,8 +22,9 @@ fun _0::main($t0: bool, $t1: bool) { 11: goto 13 12: label L4 13: label L5 - 14: $t6 := ==($t2, $t3) - 15: return () + 14: $t7 := infer($t2) + 15: $t6 := ==($t7, $t3) + 16: return () } @@ -31,7 +33,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/assign_in_one_if_branch_unfoldable.move:7:5 │ 7 │ x == y; - │ ^^^^^^ + │ ^ error: use of possibly unassigned local `y` ┌─ tests/uninit-use-checker/assign_in_one_if_branch_unfoldable.move:7:5 @@ -48,36 +50,39 @@ fun _0::main($t0: bool, $t1: bool) { var $t4: u64 var $t5: u64 var $t6: bool - # before: { no: $t2, $t3, $t4, $t5, $t6 }, after: { no: $t2, $t3, $t4, $t5, $t6 } + var $t7: u64 + # before: { no: $t2, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t2, $t3, $t4, $t5, $t6, $t7 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t2, $t3, $t4, $t5, $t6 }, after: { no: $t2, $t3, $t4, $t5, $t6 } + # before: { no: $t2, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t2, $t3, $t4, $t5, $t6, $t7 } 1: label L0 - # before: { no: $t2, $t3, $t4, $t5, $t6 }, after: { no: $t2, $t3, $t5, $t6 } + # before: { no: $t2, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t2, $t3, $t5, $t6, $t7 } 2: $t4 := 5 - # before: { no: $t2, $t3, $t5, $t6 }, after: { no: $t3, $t5, $t6 } + # before: { no: $t2, $t3, $t5, $t6, $t7 }, after: { no: $t3, $t5, $t6, $t7 } 3: $t2 := infer($t4) - # before: { no: $t3, $t5, $t6 }, after: { no: $t3, $t5, $t6 } + # before: { no: $t3, $t5, $t6, $t7 }, after: { no: $t3, $t5, $t6, $t7 } 4: goto 6 - # before: { no: $t2, $t3, $t4, $t5, $t6 }, after: { no: $t2, $t3, $t4, $t5, $t6 } + # before: { no: $t2, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t2, $t3, $t4, $t5, $t6, $t7 } 5: label L1 - # before: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 }, after: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 } + # before: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 }, after: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 } 6: label L2 - # before: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 }, after: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 } + # before: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 }, after: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 } 7: if ($t1) goto 8 else goto 12 - # before: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 }, after: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 } + # before: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 }, after: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 } 8: label L3 - # before: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 }, after: { no: $t3, $t6 }{ maybe: $t2, $t4 } + # before: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 }, after: { no: $t3, $t6, $t7 }{ maybe: $t2, $t4 } 9: $t5 := 5 - # before: { no: $t3, $t6 }{ maybe: $t2, $t4 }, after: { no: $t6 }{ maybe: $t2, $t4 } + # before: { no: $t3, $t6, $t7 }{ maybe: $t2, $t4 }, after: { no: $t6, $t7 }{ maybe: $t2, $t4 } 10: $t3 := infer($t5) - # before: { no: $t6 }{ maybe: $t2, $t4 }, after: { no: $t6 }{ maybe: $t2, $t4 } + # before: { no: $t6, $t7 }{ maybe: $t2, $t4 }, after: { no: $t6, $t7 }{ maybe: $t2, $t4 } 11: goto 13 - # before: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 }, after: { no: $t3, $t5, $t6 }{ maybe: $t2, $t4 } + # before: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 }, after: { no: $t3, $t5, $t6, $t7 }{ maybe: $t2, $t4 } 12: label L4 - # before: { no: $t6 }{ maybe: $t2, $t3, $t4, $t5 }, after: { no: $t6 }{ maybe: $t2, $t3, $t4, $t5 } + # before: { no: $t6, $t7 }{ maybe: $t2, $t3, $t4, $t5 }, after: { no: $t6, $t7 }{ maybe: $t2, $t3, $t4, $t5 } 13: label L5 + # before: { no: $t6, $t7 }{ maybe: $t2, $t3, $t4, $t5 }, after: { no: $t6 }{ maybe: $t2, $t3, $t4, $t5 } + 14: $t7 := infer($t2) # before: { no: $t6 }{ maybe: $t2, $t3, $t4, $t5 }, after: { maybe: $t2, $t3, $t4, $t5 } - 14: $t6 := ==($t2, $t3) + 15: $t6 := ==($t7, $t3) # before: { maybe: $t2, $t3, $t4, $t5 }, after: { maybe: $t2, $t3, $t4, $t5 } - 15: return () + 16: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_wrong_if_branch_no_else_unfoldable.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_wrong_if_branch_no_else_unfoldable.exp index 8abdd013b22da..bf4b77e716272 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_wrong_if_branch_no_else_unfoldable.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_wrong_if_branch_no_else_unfoldable.exp @@ -7,6 +7,7 @@ fun _0::main($t0: bool) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t2 := 100 @@ -14,16 +15,17 @@ fun _0::main($t0: bool) { 4: goto 6 5: label L1 6: label L2 - 7: $t4 := 100 - 8: $t3 := ==($t1, $t4) - 9: if ($t3) goto 10 else goto 12 - 10: label L3 - 11: goto 15 - 12: label L4 - 13: $t5 := 42 - 14: abort($t5) - 15: label L5 - 16: return () + 7: $t4 := infer($t1) + 8: $t5 := 100 + 9: $t3 := ==($t4, $t5) + 10: if ($t3) goto 11 else goto 13 + 11: label L3 + 12: goto 16 + 13: label L4 + 14: $t6 := 42 + 15: abort($t6) + 16: label L5 + 17: return () } @@ -32,7 +34,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/assign_wrong_if_branch_no_else_unfoldable.move:5:13 │ 5 │ assert!(x == 100, 42); - │ ^^^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -43,38 +45,41 @@ fun _0::main($t0: bool) { var $t3: bool var $t4: u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 2: $t2 := 100 - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 3: $t1 := infer($t2) - # before: { no: $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 4: goto 6 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 5: label L1 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } - 7: $t4 := 100 - # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 8: $t3 := ==($t1, $t4) - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 9: if ($t3) goto 10 else goto 12 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 10: label L3 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 11: goto 15 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 12: label L4 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 13: $t5 := 42 + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 } + 7: $t4 := infer($t1) + # before: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t6 }{ maybe: $t1, $t2 } + 8: $t5 := 100 + # before: { no: $t3, $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 9: $t3 := ==($t4, $t5) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 10: if ($t3) goto 11 else goto 13 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 11: label L3 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 12: goto 16 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 13: label L4 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 14: $t6 := 42 # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 14: abort($t5) - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 15: label L5 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 16: return () + 15: abort($t6) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 16: label L5 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 17: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_wrong_if_branch_unfoldable.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_wrong_if_branch_unfoldable.exp index 4e388d37bbc54..4b5851bb39079 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_wrong_if_branch_unfoldable.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/assign_wrong_if_branch_unfoldable.exp @@ -7,6 +7,7 @@ fun _0::main($t0: bool) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 0: if ($t0) goto 1 else goto 3 1: label L0 2: goto 6 @@ -14,16 +15,17 @@ fun _0::main($t0: bool) { 4: $t2 := 100 5: $t1 := infer($t2) 6: label L2 - 7: $t4 := 100 - 8: $t3 := ==($t1, $t4) - 9: if ($t3) goto 10 else goto 12 - 10: label L3 - 11: goto 15 - 12: label L4 - 13: $t5 := 42 - 14: abort($t5) - 15: label L5 - 16: return () + 7: $t4 := infer($t1) + 8: $t5 := 100 + 9: $t3 := ==($t4, $t5) + 10: if ($t3) goto 11 else goto 13 + 11: label L3 + 12: goto 16 + 13: label L4 + 14: $t6 := 42 + 15: abort($t6) + 16: label L5 + 17: return () } @@ -32,7 +34,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/assign_wrong_if_branch_unfoldable.move:5:13 │ 5 │ assert!(x == 100, 42); - │ ^^^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -43,38 +45,41 @@ fun _0::main($t0: bool) { var $t3: bool var $t4: u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: if ($t0) goto 1 else goto 3 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 2: goto 6 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 3: label L1 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 4: $t2 := 100 - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 5: $t1 := infer($t2) - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } - 7: $t4 := 100 - # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 8: $t3 := ==($t1, $t4) - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 9: if ($t3) goto 10 else goto 12 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 10: label L3 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 11: goto 15 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 12: label L4 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 13: $t5 := 42 + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 } + 7: $t4 := infer($t1) + # before: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t6 }{ maybe: $t1, $t2 } + 8: $t5 := 100 + # before: { no: $t3, $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 9: $t3 := ==($t4, $t5) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 10: if ($t3) goto 11 else goto 13 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 11: label L3 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 12: goto 16 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 13: label L4 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 14: $t6 := 42 # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 14: abort($t5) - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 15: label L5 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 16: return () + 15: abort($t6) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 16: label L5 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 17: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/else_assigns_if_doesnt_unfoldable.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/else_assigns_if_doesnt_unfoldable.exp index e3361d8af67e3..e9001f34e133d 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/else_assigns_if_doesnt_unfoldable.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/else_assigns_if_doesnt_unfoldable.exp @@ -10,6 +10,7 @@ fun _0::main($t0: bool) { var $t6: bool var $t7: u64 var $t8: u64 + var $t9: u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t3 := 0 @@ -20,16 +21,17 @@ fun _0::main($t0: bool) { 7: $t1 := infer($t4) 8: $t5 := infer($t1) 9: label L2 - 10: $t7 := 0 - 11: $t6 := ==($t2, $t7) - 12: if ($t6) goto 13 else goto 15 - 13: label L3 - 14: goto 18 - 15: label L4 - 16: $t8 := 42 - 17: abort($t8) - 18: label L5 - 19: return () + 10: $t7 := infer($t2) + 11: $t8 := 0 + 12: $t6 := ==($t7, $t8) + 13: if ($t6) goto 14 else goto 16 + 14: label L3 + 15: goto 19 + 16: label L4 + 17: $t9 := 42 + 18: abort($t9) + 19: label L5 + 20: return () } @@ -38,7 +40,7 @@ error: use of possibly unassigned local `y` ┌─ tests/uninit-use-checker/else_assigns_if_doesnt_unfoldable.move:11:13 │ 11 │ assert!(y == 0, 42); - │ ^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -52,44 +54,47 @@ fun _0::main($t0: bool) { var $t6: bool var $t7: u64 var $t8: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 } + var $t9: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t4, $t5, $t6, $t7, $t8, $t9 } 2: $t3 := 0 - # before: { no: $t1, $t2, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t4, $t5, $t6, $t7, $t8, $t9 } 3: $t2 := infer($t3) - # before: { no: $t1, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t4, $t5, $t6, $t7, $t8, $t9 } 4: goto 9 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 5: label L1 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t3, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t3, $t5, $t6, $t7, $t8, $t9 } 6: $t4 := 42 - # before: { no: $t1, $t2, $t3, $t5, $t6, $t7, $t8 }, after: { no: $t2, $t3, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t2, $t3, $t5, $t6, $t7, $t8, $t9 } 7: $t1 := infer($t4) - # before: { no: $t2, $t3, $t5, $t6, $t7, $t8 }, after: { no: $t2, $t3, $t6, $t7, $t8 } + # before: { no: $t2, $t3, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t2, $t3, $t6, $t7, $t8, $t9 } 8: $t5 := infer($t1) - # before: { no: $t6, $t7, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t7, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t6, $t7, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t7, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } 9: label L2 - # before: { no: $t6, $t7, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 10: $t7 := 0 - # before: { no: $t6, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 11: $t6 := ==($t2, $t7) - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 12: if ($t6) goto 13 else goto 15 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 13: label L3 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 14: goto 18 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 15: label L4 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } - 16: $t8 := 42 + # before: { no: $t6, $t7, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 10: $t7 := infer($t2) + # before: { no: $t6, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 11: $t8 := 0 + # before: { no: $t6, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 12: $t6 := ==($t7, $t8) + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 13: if ($t6) goto 14 else goto 16 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 14: label L3 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 15: goto 19 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 16: label L4 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 17: $t9 := 42 # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } - 17: abort($t8) - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 18: label L5 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 19: return () + 18: abort($t9) + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 19: label L5 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 20: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/if_assigns_else_doesnt_unfoldable.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/if_assigns_else_doesnt_unfoldable.exp index b00b8cdb1eca5..e98a531fe81d2 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/if_assigns_else_doesnt_unfoldable.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/if_assigns_else_doesnt_unfoldable.exp @@ -10,6 +10,7 @@ fun _0::main($t0: bool) { var $t6: bool var $t7: u64 var $t8: u64 + var $t9: u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t3 := 42 @@ -20,16 +21,17 @@ fun _0::main($t0: bool) { 7: $t2 := infer($t4) 8: $t5 := infer($t2) 9: label L2 - 10: $t7 := 42 - 11: $t6 := ==($t1, $t7) - 12: if ($t6) goto 13 else goto 15 - 13: label L3 - 14: goto 18 - 15: label L4 - 16: $t8 := 42 - 17: abort($t8) - 18: label L5 - 19: return () + 10: $t7 := infer($t1) + 11: $t8 := 42 + 12: $t6 := ==($t7, $t8) + 13: if ($t6) goto 14 else goto 16 + 14: label L3 + 15: goto 19 + 16: label L4 + 17: $t9 := 42 + 18: abort($t9) + 19: label L5 + 20: return () } @@ -38,7 +40,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/if_assigns_else_doesnt_unfoldable.move:11:13 │ 11 │ assert!(x == 42, 42); - │ ^^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -52,44 +54,47 @@ fun _0::main($t0: bool) { var $t6: bool var $t7: u64 var $t8: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 } + var $t9: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t4, $t5, $t6, $t7, $t8, $t9 } 2: $t3 := 42 - # before: { no: $t1, $t2, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t2, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t2, $t4, $t5, $t6, $t7, $t8, $t9 } 3: $t1 := infer($t3) - # before: { no: $t2, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t2, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t2, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t2, $t4, $t5, $t6, $t7, $t8, $t9 } 4: goto 9 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 5: label L1 - # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t2, $t3, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t2, $t3, $t5, $t6, $t7, $t8, $t9 } 6: $t4 := 0 - # before: { no: $t1, $t2, $t3, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t3, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t2, $t3, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t3, $t5, $t6, $t7, $t8, $t9 } 7: $t2 := infer($t4) - # before: { no: $t1, $t3, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t3, $t6, $t7, $t8 } + # before: { no: $t1, $t3, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t3, $t6, $t7, $t8, $t9 } 8: $t5 := infer($t2) - # before: { no: $t6, $t7, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t7, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t6, $t7, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t7, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } 9: label L2 - # before: { no: $t6, $t7, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 10: $t7 := 42 - # before: { no: $t6, $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 11: $t6 := ==($t1, $t7) - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 12: if ($t6) goto 13 else goto 15 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 13: label L3 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 14: goto 18 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 15: label L4 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } - 16: $t8 := 42 + # before: { no: $t6, $t7, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 10: $t7 := infer($t1) + # before: { no: $t6, $t8, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t6, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 11: $t8 := 42 + # before: { no: $t6, $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 12: $t6 := ==($t7, $t8) + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 13: if ($t6) goto 14 else goto 16 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 14: label L3 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 15: goto 19 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 16: label L4 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 17: $t9 := 42 # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } - 17: abort($t8) - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 18: label L5 - # before: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t1, $t2, $t3, $t4, $t5 } - 19: return () + 18: abort($t9) + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 19: label L5 + # before: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t1, $t2, $t3, $t4, $t5 } + 20: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/if_assigns_no_else_unfoldable.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/if_assigns_no_else_unfoldable.exp index f47080df23cb0..197cc81858eb9 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/if_assigns_no_else_unfoldable.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/if_assigns_no_else_unfoldable.exp @@ -7,6 +7,7 @@ fun _0::main($t0: bool) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t2 := 42 @@ -14,16 +15,17 @@ fun _0::main($t0: bool) { 4: goto 6 5: label L1 6: label L2 - 7: $t4 := 42 - 8: $t3 := ==($t1, $t4) - 9: if ($t3) goto 10 else goto 12 - 10: label L3 - 11: goto 15 - 12: label L4 - 13: $t5 := 42 - 14: abort($t5) - 15: label L5 - 16: return () + 7: $t4 := infer($t1) + 8: $t5 := 42 + 9: $t3 := ==($t4, $t5) + 10: if ($t3) goto 11 else goto 13 + 11: label L3 + 12: goto 16 + 13: label L4 + 14: $t6 := 42 + 15: abort($t6) + 16: label L5 + 17: return () } @@ -32,7 +34,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/if_assigns_no_else_unfoldable.move:5:13 │ 5 │ assert!(x == 42, 42); - │ ^^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -43,38 +45,41 @@ fun _0::main($t0: bool) { var $t3: bool var $t4: u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 2: $t2 := 42 - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 3: $t1 := infer($t2) - # before: { no: $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 4: goto 6 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 5: label L1 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } - 7: $t4 := 42 - # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 8: $t3 := ==($t1, $t4) - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 9: if ($t3) goto 10 else goto 12 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 10: label L3 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 11: goto 15 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 12: label L4 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 13: $t5 := 42 + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 } + 7: $t4 := infer($t1) + # before: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t6 }{ maybe: $t1, $t2 } + 8: $t5 := 42 + # before: { no: $t3, $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 9: $t3 := ==($t4, $t5) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 10: if ($t3) goto 11 else goto 13 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 11: label L3 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 12: goto 16 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 13: label L4 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 14: $t6 := 42 # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 14: abort($t5) - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 15: label L5 - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 16: return () + 15: abort($t6) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 16: label L5 + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 17: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/no_error.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/no_error.exp index 607fec561177c..72ecdcfd22bea 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/no_error.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/no_error.exp @@ -8,13 +8,19 @@ fun m::foo($t0: u64, $t1: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 - 0: $t3 := +($t0, $t1) - 1: $t5 := 1 - 2: $t4 := +($t3, $t5) + var $t8: u64 + var $t9: u64 + var $t10: u64 + 0: $t4 := infer($t0) + 1: $t3 := +($t4, $t1) + 2: $t6 := infer($t3) 3: $t7 := 1 - 4: $t6 := +($t4, $t7) - 5: $t2 := infer($t6) - 6: return $t2 + 4: $t5 := +($t6, $t7) + 5: $t9 := infer($t5) + 6: $t10 := 1 + 7: $t8 := +($t9, $t10) + 8: $t2 := infer($t8) + 9: return $t2 } ============ after uninitialized_use_checker: ================ @@ -27,18 +33,47 @@ fun m::foo($t0: u64, $t1: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 - # before: { no: $t2, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t2, $t4, $t5, $t6, $t7 } - 0: $t3 := +($t0, $t1) - # before: { no: $t2, $t4, $t5, $t6, $t7 }, after: { no: $t2, $t4, $t6, $t7 } - 1: $t5 := 1 - # before: { no: $t2, $t4, $t6, $t7 }, after: { no: $t2, $t6, $t7 } - 2: $t4 := +($t3, $t5) - # before: { no: $t2, $t6, $t7 }, after: { no: $t2, $t6 } + var $t8: u64 + var $t9: u64 + var $t10: u64 + # before: { no: $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9, $t10 }, after: { no: $t2, $t3, $t5, $t6, $t7, $t8, $t9, $t10 } + 0: $t4 := infer($t0) + # before: { no: $t2, $t3, $t5, $t6, $t7, $t8, $t9, $t10 }, after: { no: $t2, $t5, $t6, $t7, $t8, $t9, $t10 } + 1: $t3 := +($t4, $t1) + # before: { no: $t2, $t5, $t6, $t7, $t8, $t9, $t10 }, after: { no: $t2, $t5, $t7, $t8, $t9, $t10 } + 2: $t6 := infer($t3) + # before: { no: $t2, $t5, $t7, $t8, $t9, $t10 }, after: { no: $t2, $t5, $t8, $t9, $t10 } 3: $t7 := 1 - # before: { no: $t2, $t6 }, after: { no: $t2 } - 4: $t6 := +($t4, $t7) + # before: { no: $t2, $t5, $t8, $t9, $t10 }, after: { no: $t2, $t8, $t9, $t10 } + 4: $t5 := +($t6, $t7) + # before: { no: $t2, $t8, $t9, $t10 }, after: { no: $t2, $t8, $t10 } + 5: $t9 := infer($t5) + # before: { no: $t2, $t8, $t10 }, after: { no: $t2, $t8 } + 6: $t10 := 1 + # before: { no: $t2, $t8 }, after: { no: $t2 } + 7: $t8 := +($t9, $t10) # before: { no: $t2 }, after: all initialized - 5: $t2 := infer($t6) + 8: $t2 := infer($t8) # before: all initialized, after: all initialized - 6: return $t2 + 9: return $t2 } + + +============ disassembled file-format ================== +// Move bytecode v7 +module c0.m { + + +foo(Arg0: u64, Arg1: u64): u64 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: u64) + 1: MoveLoc[1](Arg1: u64) + 2: Add + 3: LdU64(1) + 4: Add + 5: LdU64(1) + 6: Add + 7: Ret +} +} +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/use_twice_before_assign.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/use_twice_before_assign.exp index c8037ab3914d8..ed183b0159ca1 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/use_twice_before_assign.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/use_twice_before_assign.exp @@ -12,12 +12,20 @@ warning: Unused local variable `y`. Consider removing or prefixing with an under fun _0::main() { var $t0: u64 var $t1: u64 - 0: $t1 := +($t0, $t0) - 1: return () + var $t2: u64 + 0: $t2 := infer($t0) + 1: $t1 := +($t2, $t0) + 2: return () } Diagnostics: +error: use of unassigned local `x` + ┌─ tests/uninit-use-checker/use_twice_before_assign.move:4:13 + │ +4 │ let y = x + x; + │ ^ + error: use of unassigned local `x` ┌─ tests/uninit-use-checker/use_twice_before_assign.move:4:13 │ @@ -30,8 +38,11 @@ error: use of unassigned local `x` fun _0::main() { var $t0: u64 var $t1: u64 + var $t2: u64 + # before: { no: $t0, $t1, $t2 }, after: { no: $t0, $t1 } + 0: $t2 := infer($t0) # before: { no: $t0, $t1 }, after: { no: $t0 } - 0: $t1 := +($t0, $t0) + 1: $t1 := +($t2, $t0) # before: { no: $t0 }, after: { no: $t0 } - 1: return () + 2: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/uses_before_assign.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/uses_before_assign.exp index d3801de716820..a3d2e93a5c211 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/uses_before_assign.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/uses_before_assign.exp @@ -13,8 +13,10 @@ fun _0::main() { var $t0: u64 var $t1: u64 var $t2: u64 - 0: $t2 := +($t0, $t1) - 1: return () + var $t3: u64 + 0: $t3 := infer($t0) + 1: $t2 := +($t3, $t1) + 2: return () } @@ -23,7 +25,7 @@ error: use of unassigned local `x` ┌─ tests/uninit-use-checker/uses_before_assign.move:5:13 │ 5 │ let z = x + y; - │ ^^^^^ + │ ^ error: use of unassigned local `y` ┌─ tests/uninit-use-checker/uses_before_assign.move:5:13 @@ -38,8 +40,11 @@ fun _0::main() { var $t0: u64 var $t1: u64 var $t2: u64 + var $t3: u64 + # before: { no: $t0, $t1, $t2, $t3 }, after: { no: $t0, $t1, $t2 } + 0: $t3 := infer($t0) # before: { no: $t0, $t1, $t2 }, after: { no: $t0, $t1 } - 0: $t2 := +($t0, $t1) + 1: $t2 := +($t3, $t1) # before: { no: $t0, $t1 }, after: { no: $t0, $t1 } - 1: return () + 2: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-borrows/eq_unassigned_local.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-borrows/eq_unassigned_local.exp index 20bf8e77052d9..12641727eb50c 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-borrows/eq_unassigned_local.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-borrows/eq_unassigned_local.exp @@ -5,11 +5,13 @@ fun _0::main() { var $t0: &u64 var $t1: bool var $t2: &u64 - var $t3: u64 - 0: $t3 := 5 - 1: $t2 := borrow_local($t3) - 2: $t1 := ==($t0, $t2) - 3: return () + var $t3: &u64 + var $t4: u64 + 0: $t2 := infer($t0) + 1: $t4 := 5 + 2: $t3 := borrow_local($t4) + 3: $t1 := ==($t2, $t3) + 4: return () } @@ -18,7 +20,7 @@ error: use of unassigned local `ref` ┌─ tests/uninit-use-checker/v1-borrows/eq_unassigned_local.move:5:9 │ 5 │ ref == &x; - │ ^^^^^^^^^ + │ ^^^ ============ after uninitialized_use_checker: ================ @@ -27,13 +29,16 @@ fun _0::main() { var $t0: &u64 var $t1: bool var $t2: &u64 - var $t3: u64 - # before: { no: $t0, $t1, $t2, $t3 }, after: { no: $t0, $t1, $t2 } - 0: $t3 := 5 - # before: { no: $t0, $t1, $t2 }, after: { no: $t0, $t1 } - 1: $t2 := borrow_local($t3) + var $t3: &u64 + var $t4: u64 + # before: { no: $t0, $t1, $t2, $t3, $t4 }, after: { no: $t0, $t1, $t3, $t4 } + 0: $t2 := infer($t0) + # before: { no: $t0, $t1, $t3, $t4 }, after: { no: $t0, $t1, $t3 } + 1: $t4 := 5 + # before: { no: $t0, $t1, $t3 }, after: { no: $t0, $t1 } + 2: $t3 := borrow_local($t4) # before: { no: $t0, $t1 }, after: { no: $t0 } - 2: $t1 := ==($t0, $t2) + 3: $t1 := ==($t2, $t3) # before: { no: $t0 }, after: { no: $t0 } - 3: return () + 4: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_in_one_if_branch.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_in_one_if_branch.exp index a31e27277d3fd..cfd1b431a9941 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_in_one_if_branch.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_in_one_if_branch.exp @@ -9,6 +9,7 @@ fun _0::main() { var $t4: bool var $t5: u64 var $t6: bool + var $t7: u64 0: $t2 := true 1: if ($t2) goto 2 else goto 6 2: label L0 @@ -25,8 +26,9 @@ fun _0::main() { 13: goto 15 14: label L4 15: label L5 - 16: $t6 := ==($t0, $t1) - 17: return () + 16: $t7 := infer($t0) + 17: $t6 := ==($t7, $t1) + 18: return () } @@ -35,7 +37,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-commands/assign_in_one_if_branch.move:7:5 │ 7 │ x == y; - │ ^^^^^^ + │ ^ error: use of possibly unassigned local `y` ┌─ tests/uninit-use-checker/v1-commands/assign_in_one_if_branch.move:7:5 @@ -54,40 +56,43 @@ fun _0::main() { var $t4: bool var $t5: u64 var $t6: bool - # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } + var $t7: u64 + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7 } 0: $t2 := true - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7 } 1: if ($t2) goto 2 else goto 6 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7 } 2: label L0 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t4, $t5, $t6 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t0, $t1, $t4, $t5, $t6, $t7 } 3: $t3 := 5 - # before: { no: $t0, $t1, $t4, $t5, $t6 }, after: { no: $t1, $t4, $t5, $t6 } + # before: { no: $t0, $t1, $t4, $t5, $t6, $t7 }, after: { no: $t1, $t4, $t5, $t6, $t7 } 4: $t0 := infer($t3) - # before: { no: $t1, $t4, $t5, $t6 }, after: { no: $t1, $t4, $t5, $t6 } + # before: { no: $t1, $t4, $t5, $t6, $t7 }, after: { no: $t1, $t4, $t5, $t6, $t7 } 5: goto 7 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7 } 6: label L1 - # before: { no: $t1, $t4, $t5, $t6 }{ maybe: $t0, $t3 }, after: { no: $t1, $t4, $t5, $t6 }{ maybe: $t0, $t3 } + # before: { no: $t1, $t4, $t5, $t6, $t7 }{ maybe: $t0, $t3 }, after: { no: $t1, $t4, $t5, $t6, $t7 }{ maybe: $t0, $t3 } 7: label L2 - # before: { no: $t1, $t4, $t5, $t6 }{ maybe: $t0, $t3 }, after: { no: $t1, $t5, $t6 }{ maybe: $t0, $t3 } + # before: { no: $t1, $t4, $t5, $t6, $t7 }{ maybe: $t0, $t3 }, after: { no: $t1, $t5, $t6, $t7 }{ maybe: $t0, $t3 } 8: $t4 := true - # before: { no: $t1, $t5, $t6 }{ maybe: $t0, $t3 }, after: { no: $t1, $t5, $t6 }{ maybe: $t0, $t3 } + # before: { no: $t1, $t5, $t6, $t7 }{ maybe: $t0, $t3 }, after: { no: $t1, $t5, $t6, $t7 }{ maybe: $t0, $t3 } 9: if ($t4) goto 10 else goto 14 - # before: { no: $t1, $t5, $t6 }{ maybe: $t0, $t3 }, after: { no: $t1, $t5, $t6 }{ maybe: $t0, $t3 } + # before: { no: $t1, $t5, $t6, $t7 }{ maybe: $t0, $t3 }, after: { no: $t1, $t5, $t6, $t7 }{ maybe: $t0, $t3 } 10: label L3 - # before: { no: $t1, $t5, $t6 }{ maybe: $t0, $t3 }, after: { no: $t1, $t6 }{ maybe: $t0, $t3 } + # before: { no: $t1, $t5, $t6, $t7 }{ maybe: $t0, $t3 }, after: { no: $t1, $t6, $t7 }{ maybe: $t0, $t3 } 11: $t5 := 5 - # before: { no: $t1, $t6 }{ maybe: $t0, $t3 }, after: { no: $t6 }{ maybe: $t0, $t3 } + # before: { no: $t1, $t6, $t7 }{ maybe: $t0, $t3 }, after: { no: $t6, $t7 }{ maybe: $t0, $t3 } 12: $t1 := infer($t5) - # before: { no: $t6 }{ maybe: $t0, $t3 }, after: { no: $t6 }{ maybe: $t0, $t3 } + # before: { no: $t6, $t7 }{ maybe: $t0, $t3 }, after: { no: $t6, $t7 }{ maybe: $t0, $t3 } 13: goto 15 - # before: { no: $t1, $t5, $t6 }{ maybe: $t0, $t3 }, after: { no: $t1, $t5, $t6 }{ maybe: $t0, $t3 } + # before: { no: $t1, $t5, $t6, $t7 }{ maybe: $t0, $t3 }, after: { no: $t1, $t5, $t6, $t7 }{ maybe: $t0, $t3 } 14: label L4 - # before: { no: $t6 }{ maybe: $t0, $t1, $t3, $t5 }, after: { no: $t6 }{ maybe: $t0, $t1, $t3, $t5 } + # before: { no: $t6, $t7 }{ maybe: $t0, $t1, $t3, $t5 }, after: { no: $t6, $t7 }{ maybe: $t0, $t1, $t3, $t5 } 15: label L5 + # before: { no: $t6, $t7 }{ maybe: $t0, $t1, $t3, $t5 }, after: { no: $t6 }{ maybe: $t0, $t1, $t3, $t5 } + 16: $t7 := infer($t0) # before: { no: $t6 }{ maybe: $t0, $t1, $t3, $t5 }, after: { maybe: $t0, $t1, $t3, $t5 } - 16: $t6 := ==($t0, $t1) + 17: $t6 := ==($t7, $t1) # before: { maybe: $t0, $t1, $t3, $t5 }, after: { maybe: $t0, $t1, $t3, $t5 } - 17: return () + 18: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch.exp index 7598b364f73bd..c363492dc9e81 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch.exp @@ -8,6 +8,7 @@ fun _0::main() { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 0: $t1 := true 1: if ($t1) goto 2 else goto 4 2: label L0 @@ -16,16 +17,17 @@ fun _0::main() { 5: $t2 := 100 6: $t0 := infer($t2) 7: label L2 - 8: $t4 := 100 - 9: $t3 := ==($t0, $t4) - 10: if ($t3) goto 11 else goto 13 - 11: label L3 - 12: goto 16 - 13: label L4 - 14: $t5 := 42 - 15: abort($t5) - 16: label L5 - 17: return () + 8: $t4 := infer($t0) + 9: $t5 := 100 + 10: $t3 := ==($t4, $t5) + 11: if ($t3) goto 12 else goto 14 + 12: label L3 + 13: goto 17 + 14: label L4 + 15: $t6 := 42 + 16: abort($t6) + 17: label L5 + 18: return () } @@ -34,7 +36,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-commands/assign_wrong_if_branch.move:5:13 │ 5 │ assert!(x == 100, 42); - │ ^^^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -46,40 +48,43 @@ fun _0::main() { var $t3: bool var $t4: u64 var $t5: u64 - # before: { no: $t0, $t1, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 0: $t1 := true - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 1: if ($t1) goto 2 else goto 4 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 2: label L0 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 3: goto 7 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 4: label L1 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t3, $t4, $t5, $t6 } 5: $t2 := 100 - # before: { no: $t0, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t0, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 6: $t0 := infer($t2) - # before: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 } 7: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 }, after: { no: $t3, $t5 }{ maybe: $t0, $t2 } - 8: $t4 := 100 - # before: { no: $t3, $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 9: $t3 := ==($t0, $t4) - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 10: if ($t3) goto 11 else goto 13 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 11: label L3 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 12: goto 16 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 13: label L4 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } - 14: $t5 := 42 + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t0, $t2 } + 8: $t4 := infer($t0) + # before: { no: $t3, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t6 }{ maybe: $t0, $t2 } + 9: $t5 := 100 + # before: { no: $t3, $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 10: $t3 := ==($t4, $t5) + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 11: if ($t3) goto 12 else goto 14 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 12: label L3 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 13: goto 17 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 14: label L4 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } + 15: $t6 := 42 # before: { maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } - 15: abort($t5) - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 16: label L5 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 17: return () + 16: abort($t6) + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 17: label L5 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 18: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch_no_else.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch_no_else.exp index 9cf7420d46e5e..f68e7034cd275 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch_no_else.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch_no_else.exp @@ -8,6 +8,7 @@ fun _0::main() { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 0: $t1 := false 1: if ($t1) goto 2 else goto 6 2: label L0 @@ -16,16 +17,17 @@ fun _0::main() { 5: goto 7 6: label L1 7: label L2 - 8: $t4 := 100 - 9: $t3 := ==($t0, $t4) - 10: if ($t3) goto 11 else goto 13 - 11: label L3 - 12: goto 16 - 13: label L4 - 14: $t5 := 42 - 15: abort($t5) - 16: label L5 - 17: return () + 8: $t4 := infer($t0) + 9: $t5 := 100 + 10: $t3 := ==($t4, $t5) + 11: if ($t3) goto 12 else goto 14 + 12: label L3 + 13: goto 17 + 14: label L4 + 15: $t6 := 42 + 16: abort($t6) + 17: label L5 + 18: return () } @@ -34,7 +36,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-commands/assign_wrong_if_branch_no_else.move:5:13 │ 5 │ assert!(x == 100, 42); - │ ^^^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -46,40 +48,43 @@ fun _0::main() { var $t3: bool var $t4: u64 var $t5: u64 - # before: { no: $t0, $t1, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 0: $t1 := false - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 1: if ($t1) goto 2 else goto 6 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 2: label L0 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t3, $t4, $t5, $t6 } 3: $t2 := 100 - # before: { no: $t0, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t0, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 4: $t0 := infer($t2) - # before: { no: $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 5: goto 7 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 6: label L1 - # before: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 } 7: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 }, after: { no: $t3, $t5 }{ maybe: $t0, $t2 } - 8: $t4 := 100 - # before: { no: $t3, $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 9: $t3 := ==($t0, $t4) - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 10: if ($t3) goto 11 else goto 13 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 11: label L3 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 12: goto 16 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 13: label L4 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } - 14: $t5 := 42 + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t0, $t2 } + 8: $t4 := infer($t0) + # before: { no: $t3, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t6 }{ maybe: $t0, $t2 } + 9: $t5 := 100 + # before: { no: $t3, $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 10: $t3 := ==($t4, $t5) + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 11: if ($t3) goto 12 else goto 14 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 12: label L3 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 13: goto 17 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 14: label L4 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } + 15: $t6 := 42 # before: { maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } - 15: abort($t5) - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 16: label L5 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 17: return () + 16: abort($t6) + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 17: label L5 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 18: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/else_assigns_if_doesnt.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/else_assigns_if_doesnt.exp index b375052acabc4..fec11953f82aa 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/else_assigns_if_doesnt.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/else_assigns_if_doesnt.exp @@ -11,6 +11,7 @@ fun _0::main() { var $t6: bool var $t7: u64 var $t8: u64 + var $t9: u64 0: $t2 := true 1: if ($t2) goto 2 else goto 6 2: label L0 @@ -22,16 +23,17 @@ fun _0::main() { 8: $t0 := infer($t4) 9: $t5 := infer($t0) 10: label L2 - 11: $t7 := 0 - 12: $t6 := ==($t1, $t7) - 13: if ($t6) goto 14 else goto 16 - 14: label L3 - 15: goto 19 - 16: label L4 - 17: $t8 := 42 - 18: abort($t8) - 19: label L5 - 20: return () + 11: $t7 := infer($t1) + 12: $t8 := 0 + 13: $t6 := ==($t7, $t8) + 14: if ($t6) goto 15 else goto 17 + 15: label L3 + 16: goto 20 + 17: label L4 + 18: $t9 := 42 + 19: abort($t9) + 20: label L5 + 21: return () } @@ -40,7 +42,7 @@ error: use of possibly unassigned local `y` ┌─ tests/uninit-use-checker/v1-commands/else_assigns_if_doesnt.move:11:13 │ 11 │ assert!(y == 0, 42); - │ ^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -55,46 +57,49 @@ fun _0::main() { var $t6: bool var $t7: u64 var $t8: u64 - # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 } + var $t9: u64 + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 0: $t2 := true - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 1: if ($t2) goto 2 else goto 6 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 2: label L0 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t4, $t5, $t6, $t7, $t8, $t9 } 3: $t3 := 0 - # before: { no: $t0, $t1, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t4, $t5, $t6, $t7, $t8, $t9 } 4: $t1 := infer($t3) - # before: { no: $t0, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t4, $t5, $t6, $t7, $t8, $t9 } 5: goto 10 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 6: label L1 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t5, $t6, $t7, $t8, $t9 } 7: $t4 := 42 - # before: { no: $t0, $t1, $t3, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t3, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t3, $t5, $t6, $t7, $t8, $t9 } 8: $t0 := infer($t4) - # before: { no: $t1, $t3, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t3, $t6, $t7, $t8 } + # before: { no: $t1, $t3, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t3, $t6, $t7, $t8, $t9 } 9: $t5 := infer($t0) - # before: { no: $t6, $t7, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t7, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + # before: { no: $t6, $t7, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t7, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } 10: label L2 - # before: { no: $t6, $t7, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 11: $t7 := 0 - # before: { no: $t6, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 12: $t6 := ==($t1, $t7) - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 13: if ($t6) goto 14 else goto 16 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 14: label L3 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 15: goto 19 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 16: label L4 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { maybe: $t0, $t1, $t3, $t4, $t5 } - 17: $t8 := 42 + # before: { no: $t6, $t7, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 11: $t7 := infer($t1) + # before: { no: $t6, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 12: $t8 := 0 + # before: { no: $t6, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 13: $t6 := ==($t7, $t8) + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 14: if ($t6) goto 15 else goto 17 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 15: label L3 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 16: goto 20 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 17: label L4 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { maybe: $t0, $t1, $t3, $t4, $t5 } + 18: $t9 := 42 # before: { maybe: $t0, $t1, $t3, $t4, $t5 }, after: { maybe: $t0, $t1, $t3, $t4, $t5 } - 18: abort($t8) - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 19: label L5 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 20: return () + 19: abort($t9) + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 20: label L5 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 21: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_else_doesnt.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_else_doesnt.exp index 2d71e8e6d40b9..2188845b73cd3 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_else_doesnt.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_else_doesnt.exp @@ -11,6 +11,7 @@ fun _0::main() { var $t6: bool var $t7: u64 var $t8: u64 + var $t9: u64 0: $t2 := true 1: if ($t2) goto 2 else goto 6 2: label L0 @@ -22,16 +23,17 @@ fun _0::main() { 8: $t1 := infer($t4) 9: $t5 := infer($t1) 10: label L2 - 11: $t7 := 42 - 12: $t6 := ==($t0, $t7) - 13: if ($t6) goto 14 else goto 16 - 14: label L3 - 15: goto 19 - 16: label L4 - 17: $t8 := 42 - 18: abort($t8) - 19: label L5 - 20: return () + 11: $t7 := infer($t0) + 12: $t8 := 42 + 13: $t6 := ==($t7, $t8) + 14: if ($t6) goto 15 else goto 17 + 15: label L3 + 16: goto 20 + 17: label L4 + 18: $t9 := 42 + 19: abort($t9) + 20: label L5 + 21: return () } @@ -40,7 +42,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-commands/if_assigns_else_doesnt.move:11:13 │ 11 │ assert!(x == 42, 42); - │ ^^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -55,46 +57,49 @@ fun _0::main() { var $t6: bool var $t7: u64 var $t8: u64 - # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 } + var $t9: u64 + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 0: $t2 := true - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 1: if ($t2) goto 2 else goto 6 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 2: label L0 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t4, $t5, $t6, $t7, $t8, $t9 } 3: $t3 := 42 - # before: { no: $t0, $t1, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t4, $t5, $t6, $t7, $t8, $t9 } 4: $t0 := infer($t3) - # before: { no: $t1, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t1, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t1, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t1, $t4, $t5, $t6, $t7, $t8, $t9 } 5: goto 10 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 } 6: label L1 - # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t1, $t3, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t1, $t3, $t5, $t6, $t7, $t8, $t9 } 7: $t4 := 0 - # before: { no: $t0, $t1, $t3, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t3, $t5, $t6, $t7, $t8 } + # before: { no: $t0, $t1, $t3, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t3, $t5, $t6, $t7, $t8, $t9 } 8: $t1 := infer($t4) - # before: { no: $t0, $t3, $t5, $t6, $t7, $t8 }, after: { no: $t0, $t3, $t6, $t7, $t8 } + # before: { no: $t0, $t3, $t5, $t6, $t7, $t8, $t9 }, after: { no: $t0, $t3, $t6, $t7, $t8, $t9 } 9: $t5 := infer($t1) - # before: { no: $t6, $t7, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t7, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + # before: { no: $t6, $t7, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t7, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } 10: label L2 - # before: { no: $t6, $t7, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 11: $t7 := 42 - # before: { no: $t6, $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 12: $t6 := ==($t0, $t7) - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 13: if ($t6) goto 14 else goto 16 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 14: label L3 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 15: goto 19 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 16: label L4 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { maybe: $t0, $t1, $t3, $t4, $t5 } - 17: $t8 := 42 + # before: { no: $t6, $t7, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 11: $t7 := infer($t0) + # before: { no: $t6, $t8, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t6, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 12: $t8 := 42 + # before: { no: $t6, $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 13: $t6 := ==($t7, $t8) + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 14: if ($t6) goto 15 else goto 17 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 15: label L3 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 16: goto 20 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 17: label L4 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { maybe: $t0, $t1, $t3, $t4, $t5 } + 18: $t9 := 42 # before: { maybe: $t0, $t1, $t3, $t4, $t5 }, after: { maybe: $t0, $t1, $t3, $t4, $t5 } - 18: abort($t8) - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 19: label L5 - # before: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t8 }{ maybe: $t0, $t1, $t3, $t4, $t5 } - 20: return () + 19: abort($t9) + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 20: label L5 + # before: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t9 }{ maybe: $t0, $t1, $t3, $t4, $t5 } + 21: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_no_else.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_no_else.exp index c5764f1e874d2..070230c7b04e9 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_no_else.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-commands/if_assigns_no_else.exp @@ -8,6 +8,7 @@ fun _0::main() { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 0: $t1 := true 1: if ($t1) goto 2 else goto 6 2: label L0 @@ -16,16 +17,17 @@ fun _0::main() { 5: goto 7 6: label L1 7: label L2 - 8: $t4 := 42 - 9: $t3 := ==($t0, $t4) - 10: if ($t3) goto 11 else goto 13 - 11: label L3 - 12: goto 16 - 13: label L4 - 14: $t5 := 42 - 15: abort($t5) - 16: label L5 - 17: return () + 8: $t4 := infer($t0) + 9: $t5 := 42 + 10: $t3 := ==($t4, $t5) + 11: if ($t3) goto 12 else goto 14 + 12: label L3 + 13: goto 17 + 14: label L4 + 15: $t6 := 42 + 16: abort($t6) + 17: label L5 + 18: return () } @@ -34,7 +36,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-commands/if_assigns_no_else.move:5:13 │ 5 │ assert!(x == 42, 42); - │ ^^^^^^^ + │ ^ ============ after uninitialized_use_checker: ================ @@ -46,40 +48,43 @@ fun _0::main() { var $t3: bool var $t4: u64 var $t5: u64 - # before: { no: $t0, $t1, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 0: $t1 := true - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 1: if ($t1) goto 2 else goto 6 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 2: label L0 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t3, $t4, $t5, $t6 } 3: $t2 := 42 - # before: { no: $t0, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t0, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 4: $t0 := infer($t2) - # before: { no: $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 5: goto 7 - # before: { no: $t0, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t2, $t3, $t4, $t5 } + # before: { no: $t0, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t2, $t3, $t4, $t5, $t6 } 6: label L1 - # before: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 } 7: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t0, $t2 }, after: { no: $t3, $t5 }{ maybe: $t0, $t2 } - 8: $t4 := 42 - # before: { no: $t3, $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 9: $t3 := ==($t0, $t4) - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 10: if ($t3) goto 11 else goto 13 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 11: label L3 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 12: goto 16 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 13: label L4 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } - 14: $t5 := 42 + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t0, $t2 } + 8: $t4 := infer($t0) + # before: { no: $t3, $t5, $t6 }{ maybe: $t0, $t2 }, after: { no: $t3, $t6 }{ maybe: $t0, $t2 } + 9: $t5 := 42 + # before: { no: $t3, $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 10: $t3 := ==($t4, $t5) + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 11: if ($t3) goto 12 else goto 14 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 12: label L3 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 13: goto 17 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 14: label L4 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } + 15: $t6 := 42 # before: { maybe: $t0, $t2 }, after: { maybe: $t0, $t2 } - 15: abort($t5) - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 16: label L5 - # before: { no: $t5 }{ maybe: $t0, $t2 }, after: { no: $t5 }{ maybe: $t0, $t2 } - 17: return () + 16: abort($t6) + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 17: label L5 + # before: { no: $t6 }{ maybe: $t0, $t2 }, after: { no: $t6 }{ maybe: $t0, $t2 } + 18: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if.exp index f6fb5c095e8a0..82e094bc6ca5a 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if.exp @@ -26,6 +26,7 @@ fun M::tcopy($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t2 := 0 @@ -33,10 +34,11 @@ fun M::tcopy($t0: bool) { 4: goto 6 5: label L1 6: label L2 - 7: $t4 := 1 - 8: $t3 := +($t1, $t4) - 9: $t5 := infer($t3) - 10: return () + 7: $t4 := infer($t1) + 8: $t5 := 1 + 9: $t3 := +($t4, $t5) + 10: $t6 := infer($t3) + 11: return () } @@ -74,7 +76,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-locals/use_before_assign_if.move:11:17 │ 11 │ let _ = x + 1; - │ ^^^^^ + │ ^ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-locals/use_before_assign_if.move:17:17 @@ -120,28 +122,31 @@ fun M::tcopy($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 2: $t2 := 0 - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 3: $t1 := infer($t2) - # before: { no: $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 4: goto 6 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 5: label L1 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } - 7: $t4 := 1 - # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } - 8: $t3 := +($t1, $t4) - # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 9: $t5 := infer($t3) + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 } + 7: $t4 := infer($t1) + # before: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t6 }{ maybe: $t1, $t2 } + 8: $t5 := 1 + # before: { no: $t3, $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } + 9: $t3 := +($t4, $t5) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 10: $t6 := infer($t3) # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 10: return () + 11: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_loop.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_loop.exp index 175d7515003fb..0e1218f0287c9 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_loop.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_loop.exp @@ -53,21 +53,23 @@ fun M::tcopy($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: label L0 - 1: $t3 := 1 - 2: $t2 := +($t1, $t3) - 3: if ($t0) goto 4 else goto 7 - 4: label L2 - 5: goto 0 - 6: goto 8 - 7: label L3 - 8: label L4 - 9: $t4 := 0 - 10: $t1 := infer($t4) - 11: $t5 := infer($t2) - 12: goto 0 - 13: label L1 - 14: return () + 1: $t3 := infer($t1) + 2: $t4 := 1 + 3: $t2 := +($t3, $t4) + 4: if ($t0) goto 5 else goto 8 + 5: label L2 + 6: goto 0 + 7: goto 9 + 8: label L3 + 9: label L4 + 10: $t5 := 0 + 11: $t1 := infer($t5) + 12: $t6 := infer($t2) + 13: goto 0 + 14: label L1 + 15: return () } @@ -103,7 +105,7 @@ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-locals/use_before_assign_loop.move:9:24 │ 9 │ loop { let y = x + 1; if (cond) { continue }; x = 0; y; } - │ ^^^^^ + │ ^ error: use of possibly unassigned local `x` ┌─ tests/uninit-use-checker/v1-locals/use_before_assign_loop.move:14:24 @@ -200,33 +202,36 @@ fun M::tcopy($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 - # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { maybe: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { maybe: $t1, $t2, $t3, $t4, $t5, $t6 } 0: label L0 - # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t4, $t5 } - 1: $t3 := 1 - # before: { maybe: $t1, $t2, $t4, $t5 }, after: { maybe: $t1, $t4, $t5 } - 2: $t2 := +($t1, $t3) - # before: { maybe: $t1, $t4, $t5 }, after: { maybe: $t1, $t4, $t5 } - 3: if ($t0) goto 4 else goto 7 - # before: { maybe: $t1, $t4, $t5 }, after: { maybe: $t1, $t4, $t5 } - 4: label L2 - # before: { maybe: $t1, $t4, $t5 }, after: { maybe: $t1, $t4, $t5 } - 5: goto 0 - 6: goto 8 - # before: { maybe: $t1, $t4, $t5 }, after: { maybe: $t1, $t4, $t5 } - 7: label L3 - # before: { maybe: $t1, $t4, $t5 }, after: { maybe: $t1, $t4, $t5 } - 8: label L4 - # before: { maybe: $t1, $t4, $t5 }, after: { maybe: $t1, $t5 } - 9: $t4 := 0 - # before: { maybe: $t1, $t5 }, after: { maybe: $t5 } - 10: $t1 := infer($t4) - # before: { maybe: $t5 }, after: all initialized - 11: $t5 := infer($t2) + # before: { maybe: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { maybe: $t1, $t2, $t4, $t5, $t6 } + 1: $t3 := infer($t1) + # before: { maybe: $t1, $t2, $t4, $t5, $t6 }, after: { maybe: $t1, $t2, $t5, $t6 } + 2: $t4 := 1 + # before: { maybe: $t1, $t2, $t5, $t6 }, after: { maybe: $t1, $t5, $t6 } + 3: $t2 := +($t3, $t4) + # before: { maybe: $t1, $t5, $t6 }, after: { maybe: $t1, $t5, $t6 } + 4: if ($t0) goto 5 else goto 8 + # before: { maybe: $t1, $t5, $t6 }, after: { maybe: $t1, $t5, $t6 } + 5: label L2 + # before: { maybe: $t1, $t5, $t6 }, after: { maybe: $t1, $t5, $t6 } + 6: goto 0 + 7: goto 9 + # before: { maybe: $t1, $t5, $t6 }, after: { maybe: $t1, $t5, $t6 } + 8: label L3 + # before: { maybe: $t1, $t5, $t6 }, after: { maybe: $t1, $t5, $t6 } + 9: label L4 + # before: { maybe: $t1, $t5, $t6 }, after: { maybe: $t1, $t6 } + 10: $t5 := 0 + # before: { maybe: $t1, $t6 }, after: { maybe: $t6 } + 11: $t1 := infer($t5) + # before: { maybe: $t6 }, after: all initialized + 12: $t6 := infer($t2) # before: all initialized, after: all initialized - 12: goto 0 - 13: label L1 - 14: return () + 13: goto 0 + 14: label L1 + 15: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp index 46ecf613deaa7..8292b77e67716 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp @@ -20,13 +20,15 @@ fun M::tcopy() { var $t1: u64 var $t2: u64 var $t3: u64 - var $t4: 0x8675309::M::S + var $t4: u64 var $t5: 0x8675309::M::S - 0: $t2 := 1 - 1: $t1 := +($t0, $t2) - 2: $t3 := infer($t1) - 3: $t5 := copy($t4) - 4: return () + var $t6: 0x8675309::M::S + 0: $t2 := infer($t0) + 1: $t3 := 1 + 2: $t1 := +($t2, $t3) + 3: $t4 := infer($t1) + 4: $t6 := copy($t5) + 5: return () } @@ -65,7 +67,7 @@ error: use of unassigned local `x` ┌─ tests/uninit-use-checker/v1-locals/use_before_assign_simple.move:14:17 │ 14 │ let _ = x + 1; - │ ^^^^^ + │ ^ error: use of unassigned local `s` ┌─ tests/uninit-use-checker/v1-locals/use_before_assign_simple.move:17:19 @@ -111,18 +113,21 @@ fun M::tcopy() { var $t1: u64 var $t2: u64 var $t3: u64 - var $t4: 0x8675309::M::S + var $t4: u64 var $t5: 0x8675309::M::S - # before: { no: $t0, $t1, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t1, $t3, $t4, $t5 } - 0: $t2 := 1 - # before: { no: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t0, $t3, $t4, $t5 } - 1: $t1 := +($t0, $t2) - # before: { no: $t0, $t3, $t4, $t5 }, after: { no: $t0, $t4, $t5 } - 2: $t3 := infer($t1) - # before: { no: $t0, $t4, $t5 }, after: { no: $t0, $t4 } - 3: $t5 := copy($t4) - # before: { no: $t0, $t4 }, after: { no: $t0, $t4 } - 4: return () + var $t6: 0x8675309::M::S + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } + 0: $t2 := infer($t0) + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t4, $t5, $t6 } + 1: $t3 := 1 + # before: { no: $t0, $t1, $t4, $t5, $t6 }, after: { no: $t0, $t4, $t5, $t6 } + 2: $t1 := +($t2, $t3) + # before: { no: $t0, $t4, $t5, $t6 }, after: { no: $t0, $t5, $t6 } + 3: $t4 := infer($t1) + # before: { no: $t0, $t5, $t6 }, after: { no: $t0, $t5 } + 4: $t6 := copy($t5) + # before: { no: $t0, $t5 }, after: { no: $t0, $t5 } + 5: return () } diff --git a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/abort_only.exp b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/abort_only.exp index e4b4fd0c62559..323a655777f9e 100644 --- a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/abort_only.exp +++ b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/abort_only.exp @@ -29,4 +29,15 @@ fun m::test() { } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test() /* def_idx: 0 */ { +B0: + 0: LdU64(0) + 1: Abort +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/abort_or_return_always.exp b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/abort_or_return_always.exp index 6d7f7215ad4f4..2fe6829f1dd67 100644 --- a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/abort_or_return_always.exp +++ b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/abort_or_return_always.exp @@ -55,4 +55,21 @@ fun m::test($t0: bool): u64 { } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test(Arg0: bool): u64 /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrFalse(4) +B1: + 2: LdU64(0) + 3: Abort +B2: + 4: LdU64(1) + 5: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/always_false_branch.exp b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/always_false_branch.exp index 99e0aca193630..287eed0c9630d 100644 --- a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/always_false_branch.exp +++ b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/always_false_branch.exp @@ -7,20 +7,22 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 0: $t1 := false - 1: if ($t1) goto 2 else goto 10 + 1: if ($t1) goto 2 else goto 11 2: label L0 3: $t2 := 0 - 4: $t4 := 1 - 5: $t3 := +($t2, $t4) - 6: $t2 := infer($t3) - 7: $t0 := infer($t2) - 8: return $t0 - 9: goto 11 - 10: label L1 - 11: label L2 - 12: $t0 := 0 - 13: return $t0 + 4: $t4 := infer($t2) + 5: $t5 := 1 + 6: $t3 := +($t4, $t5) + 7: $t2 := infer($t3) + 8: $t0 := infer($t2) + 9: return $t0 + 10: goto 12 + 11: label L1 + 12: label L2 + 13: $t0 := 0 + 14: return $t0 } ============ after UnreachableCodeProcessor: ================ @@ -32,30 +34,33 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 # maybe 0: $t1 := false # maybe - 1: if ($t1) goto 2 else goto 9 + 1: if ($t1) goto 2 else goto 10 # maybe 2: label L0 # maybe 3: $t2 := 0 # maybe - 4: $t4 := 1 + 4: $t4 := move($t2) # maybe - 5: $t3 := +($t2, $t4) + 5: $t5 := 1 # maybe - 6: $t2 := move($t3) + 6: $t3 := +($t4, $t5) # maybe - 7: $t0 := move($t2) + 7: $t2 := move($t3) # maybe - 8: return $t0 + 8: $t0 := move($t2) # maybe - 9: label L2 + 9: return $t0 # maybe - 10: $t0 := 0 + 10: label L2 # maybe - 11: return $t0 + 11: $t0 := 0 + # maybe + 12: return $t0 } ============ after UnreachableCodeRemover: ================ @@ -67,19 +72,39 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 0: $t1 := false - 1: if ($t1) goto 2 else goto 9 + 1: if ($t1) goto 2 else goto 10 2: label L0 3: $t2 := 0 - 4: $t4 := 1 - 5: $t3 := +($t2, $t4) - 6: $t2 := move($t3) - 7: $t0 := move($t2) - 8: return $t0 - 9: label L2 - 10: $t0 := 0 - 11: return $t0 + 4: $t4 := move($t2) + 5: $t5 := 1 + 6: $t3 := +($t4, $t5) + 7: $t2 := move($t3) + 8: $t0 := move($t2) + 9: return $t0 + 10: label L2 + 11: $t0 := 0 + 12: return $t0 } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test(): u64 /* def_idx: 0 */ { +B0: + 0: Branch(5) +B1: + 1: LdU64(0) + 2: LdU64(1) + 3: Add + 4: Ret +B2: + 5: LdU64(0) + 6: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/break_unreachable.exp b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/break_unreachable.exp index ca5f7519139aa..44e712f41be8b 100644 --- a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/break_unreachable.exp +++ b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/break_unreachable.exp @@ -5,40 +5,50 @@ fun m::test() { var $t0: u64 var $t1: u64 var $t2: u64 - var $t3: bool - var $t4: u64 + var $t3: u64 + var $t4: bool var $t5: u64 var $t6: u64 var $t7: u64 var $t8: u64 var $t9: u64 var $t10: u64 + var $t11: u64 + var $t12: u64 + var $t13: u64 + var $t14: u64 + var $t15: u64 0: $t0 := 0 1: label L0 - 2: $t2 := 1 - 3: $t1 := +($t0, $t2) - 4: $t0 := infer($t1) - 5: $t4 := 10 - 6: $t3 := ==($t0, $t4) - 7: if ($t3) goto 8 else goto 14 - 8: label L2 - 9: goto 24 - 10: $t6 := 1 - 11: $t5 := +($t0, $t6) - 12: $t0 := infer($t5) - 13: goto 19 - 14: label L3 - 15: goto 1 - 16: $t8 := 1 - 17: $t7 := +($t0, $t8) - 18: $t0 := infer($t7) - 19: label L4 - 20: $t10 := 1 - 21: $t9 := +($t0, $t10) - 22: $t0 := infer($t9) - 23: goto 1 - 24: label L1 - 25: return () + 2: $t2 := infer($t0) + 3: $t3 := 1 + 4: $t1 := +($t2, $t3) + 5: $t0 := infer($t1) + 6: $t5 := infer($t0) + 7: $t6 := 10 + 8: $t4 := ==($t5, $t6) + 9: if ($t4) goto 10 else goto 17 + 10: label L2 + 11: goto 29 + 12: $t8 := infer($t0) + 13: $t9 := 1 + 14: $t7 := +($t8, $t9) + 15: $t0 := infer($t7) + 16: goto 23 + 17: label L3 + 18: goto 1 + 19: $t11 := infer($t0) + 20: $t12 := 1 + 21: $t10 := +($t11, $t12) + 22: $t0 := infer($t10) + 23: label L4 + 24: $t14 := infer($t0) + 25: $t15 := 1 + 26: $t13 := +($t14, $t15) + 27: $t0 := infer($t13) + 28: goto 1 + 29: label L1 + 30: return () } ============ after UnreachableCodeProcessor: ================ @@ -48,38 +58,47 @@ fun m::test() { var $t0: u64 var $t1: u64 var $t2: u64 - var $t3: bool - var $t4: u64 - var $t5: u64 [unused] - var $t6: u64 [unused] + var $t3: u64 + var $t4: bool + var $t5: u64 + var $t6: u64 var $t7: u64 [unused] var $t8: u64 [unused] var $t9: u64 [unused] var $t10: u64 [unused] + var $t11: u64 [unused] + var $t12: u64 [unused] + var $t13: u64 [unused] + var $t14: u64 [unused] + var $t15: u64 [unused] # maybe 0: $t0 := 0 # maybe 1: label L0 # maybe - 2: $t2 := 1 + 2: $t2 := move($t0) # maybe - 3: $t1 := +($t0, $t2) + 3: $t3 := 1 # maybe - 4: $t0 := move($t1) + 4: $t1 := +($t2, $t3) # maybe - 5: $t4 := 10 + 5: $t0 := move($t1) # maybe - 6: $t3 := ==($t0, $t4) + 6: $t5 := copy($t0) # maybe - 7: if ($t3) goto 10 else goto 8 + 7: $t6 := 10 # maybe - 8: label L3 + 8: $t4 := ==($t5, $t6) # maybe - 9: goto 1 + 9: if ($t4) goto 12 else goto 10 # maybe - 10: label L2 + 10: label L3 # maybe - 11: return () + 11: goto 1 + # maybe + 12: label L2 + # maybe + 13: return () } ============ after UnreachableCodeRemover: ================ @@ -89,27 +108,59 @@ fun m::test() { var $t0: u64 var $t1: u64 var $t2: u64 - var $t3: bool - var $t4: u64 - var $t5: u64 [unused] - var $t6: u64 [unused] + var $t3: u64 + var $t4: bool + var $t5: u64 + var $t6: u64 var $t7: u64 [unused] var $t8: u64 [unused] var $t9: u64 [unused] var $t10: u64 [unused] + var $t11: u64 [unused] + var $t12: u64 [unused] + var $t13: u64 [unused] + var $t14: u64 [unused] + var $t15: u64 [unused] 0: $t0 := 0 1: label L0 - 2: $t2 := 1 - 3: $t1 := +($t0, $t2) - 4: $t0 := move($t1) - 5: $t4 := 10 - 6: $t3 := ==($t0, $t4) - 7: if ($t3) goto 10 else goto 8 - 8: label L3 - 9: goto 1 - 10: label L2 - 11: return () + 2: $t2 := move($t0) + 3: $t3 := 1 + 4: $t1 := +($t2, $t3) + 5: $t0 := move($t1) + 6: $t5 := copy($t0) + 7: $t6 := 10 + 8: $t4 := ==($t5, $t6) + 9: if ($t4) goto 12 else goto 10 + 10: label L3 + 11: goto 1 + 12: label L2 + 13: return () } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test() /* def_idx: 0 */ { +L0: loc0: u64 +B0: + 0: LdU64(0) + 1: StLoc[0](loc0: u64) +B1: + 2: MoveLoc[0](loc0: u64) + 3: LdU64(1) + 4: Add + 5: StLoc[0](loc0: u64) + 6: CopyLoc[0](loc0: u64) + 7: LdU64(10) + 8: Eq + 9: BrTrue(11) +B2: + 10: Branch(2) +B3: + 11: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/conditional_loop_unreachable.exp b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/conditional_loop_unreachable.exp index 39b915dd1b386..2a1a4be89f909 100644 --- a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/conditional_loop_unreachable.exp +++ b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/conditional_loop_unreachable.exp @@ -8,33 +8,37 @@ fun m::test($t0: bool, $t1: bool) { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: label L0 - 1: if ($t0) goto 2 else goto 21 + 1: if ($t0) goto 2 else goto 23 2: label L2 - 3: if ($t1) goto 4 else goto 13 + 3: if ($t1) goto 4 else goto 14 4: label L5 5: label L8 6: goto 5 7: label L9 8: $t2 := 0 - 9: $t4 := 1 - 10: $t3 := +($t2, $t4) - 11: $t2 := infer($t3) - 12: goto 15 - 13: label L6 - 14: goto 25 - 15: label L7 - 16: $t5 := 0 - 17: $t7 := 1 - 18: $t6 := +($t5, $t7) - 19: $t5 := infer($t6) - 20: goto 23 - 21: label L3 + 9: $t4 := infer($t2) + 10: $t5 := 1 + 11: $t3 := +($t4, $t5) + 12: $t2 := infer($t3) + 13: goto 16 + 14: label L6 + 15: goto 27 + 16: label L7 + 17: $t6 := 0 + 18: $t8 := infer($t6) + 19: $t9 := 1 + 20: $t7 := +($t8, $t9) + 21: $t6 := infer($t7) 22: goto 25 - 23: label L4 - 24: goto 0 - 25: label L1 - 26: return () + 23: label L3 + 24: goto 27 + 25: label L4 + 26: goto 0 + 27: label L1 + 28: return () } @@ -61,6 +65,8 @@ fun m::test($t0: bool, $t1: bool) { var $t5: u64 [unused] var $t6: u64 [unused] var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] # maybe 0: if ($t0) goto 3 else goto 1 # maybe @@ -99,6 +105,8 @@ fun m::test($t0: bool, $t1: bool) { var $t5: u64 [unused] var $t6: u64 [unused] var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: if ($t0) goto 3 else goto 1 1: label L9 2: goto 11 @@ -115,4 +123,28 @@ fun m::test($t0: bool, $t1: bool) { } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test(Arg0: bool, Arg1: bool) /* def_idx: 0 */ { +B0: + 0: MoveLoc[0](Arg0: bool) + 1: BrTrue(3) +B1: + 2: Branch(8) +B2: + 3: MoveLoc[1](Arg1: bool) + 4: BrFalse(6) +B3: + 5: Branch(7) +B4: + 6: Branch(8) +B5: + 7: Branch(7) +B6: + 8: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/inter_procedural_abort.exp b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/inter_procedural_abort.exp index 1eebd76b31354..c9682f28384ef 100644 --- a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/inter_procedural_abort.exp +++ b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/inter_procedural_abort.exp @@ -15,13 +15,15 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: m::always_abort() 1: $t1 := 0 - 2: $t3 := 1 - 3: $t2 := +($t1, $t3) - 4: $t1 := infer($t2) - 5: $t0 := infer($t1) - 6: return $t0 + 2: $t3 := infer($t1) + 3: $t4 := 1 + 4: $t2 := +($t3, $t4) + 5: $t1 := infer($t2) + 6: $t0 := infer($t1) + 7: return $t0 } ============ after UnreachableCodeProcessor: ================ @@ -42,20 +44,23 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 # maybe 0: m::always_abort() # maybe 1: $t1 := 0 # maybe - 2: $t3 := 1 + 2: $t3 := move($t1) # maybe - 3: $t2 := +($t1, $t3) + 3: $t4 := 1 # maybe - 4: $t1 := move($t2) + 4: $t2 := +($t3, $t4) # maybe - 5: $t0 := move($t1) + 5: $t1 := move($t2) # maybe - 6: return $t0 + 6: $t0 := move($t1) + # maybe + 7: return $t0 } ============ after UnreachableCodeRemover: ================ @@ -74,14 +79,35 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: m::always_abort() 1: $t1 := 0 - 2: $t3 := 1 - 3: $t2 := +($t1, $t3) - 4: $t1 := move($t2) - 5: $t0 := move($t1) - 6: return $t0 + 2: $t3 := move($t1) + 3: $t4 := 1 + 4: $t2 := +($t3, $t4) + 5: $t1 := move($t2) + 6: $t0 := move($t1) + 7: return $t0 } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +always_abort() /* def_idx: 0 */ { +B0: + 0: LdU64(0) + 1: Abort +} +test(): u64 /* def_idx: 1 */ { +B0: + 0: Call always_abort() + 1: LdU64(0) + 2: LdU64(1) + 3: Add + 4: Ret +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/loop_unreachable.exp b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/loop_unreachable.exp index 1c8c37a0a5415..249ad2a47c0ba 100644 --- a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/loop_unreachable.exp +++ b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/loop_unreachable.exp @@ -31,4 +31,14 @@ fun m::test(): u64 { } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test(): u64 /* def_idx: 0 */ { +B0: + 0: Branch(0) +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/return_after_abort.exp b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/return_after_abort.exp index 0b5d7dce0681e..487fe2041cf79 100644 --- a/third_party/move/move-compiler-v2/tests/unreachable-code-remover/return_after_abort.exp +++ b/third_party/move/move-compiler-v2/tests/unreachable-code-remover/return_after_abort.exp @@ -33,4 +33,15 @@ fun m::test(): u32 { } +============ disassembled file-format ================== +// Move bytecode v7 +module c0ffee.m { + + +test(): u32 /* def_idx: 0 */ { +B0: + 0: LdU64(0) + 1: Abort +} +} ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.exp index a58b76fe10539..1c8ed4cb68489 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.exp @@ -3,8 +3,10 @@ [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 - 0: $t2 := +($t0, $t1) - 1: return $t2 + var $t3: u64 + 0: $t3 := infer($t0) + 1: $t2 := +($t3, $t1) + 2: return $t2 } @@ -15,13 +17,15 @@ public fun m::test($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t2 := infer($t0) - 1: $t5 := 1 - 2: $t4 := +($t0, $t5) - 3: $t0 := infer($t4) - 4: $t3 := infer($t0) - 5: $t1 := m::add($t2, $t3) - 6: return $t1 + 1: $t5 := infer($t0) + 2: $t6 := 1 + 3: $t4 := +($t5, $t6) + 4: $t0 := infer($t4) + 5: $t3 := infer($t0) + 6: $t1 := m::add($t2, $t3) + 7: return $t1 } ============ after DeadStoreElimination: ================ @@ -29,8 +33,10 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 - 0: $t2 := +($t0, $t1) - 1: return $t2 + var $t3: u64 + 0: $t3 := move($t0) + 1: $t2 := +($t3, $t1) + 2: return $t2 } @@ -41,13 +47,15 @@ public fun m::test($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t2 := copy($t0) - 1: $t5 := 1 - 2: $t4 := +($t0, $t5) - 3: $t0 := move($t4) - 4: $t3 := move($t0) - 5: $t1 := m::add($t2, $t3) - 6: return $t1 + 1: $t5 := move($t0) + 2: $t6 := 1 + 3: $t4 := +($t5, $t6) + 4: $t0 := move($t4) + 5: $t3 := move($t0) + 6: $t1 := m::add($t2, $t3) + 7: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -55,12 +63,16 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 + var $t3: u64 # live vars: $t0, $t1 - # events: b:$t0, b:$t1, e:$t0, e:$t1, b:$t2 - 0: $t2 := +($t0, $t1) + # events: b:$t0, b:$t1, e:$t0, b:$t3 + 0: $t3 := move($t0) + # live vars: $t1, $t3 + # events: e:$t1, e:$t3, b:$t2 + 1: $t2 := +($t3, $t1) # live vars: $t2 # events: e:$t2 - 1: return $t2 + 2: return $t2 } @@ -71,27 +83,31 @@ public fun m::test($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) # live vars: $t0, $t2 # events: b:$t5 - 1: $t5 := 1 - # live vars: $t0, $t2, $t5 - # events: e:$t5, b:$t4 - 2: $t4 := +($t0, $t5) + 1: $t5 := move($t0) + # live vars: $t2, $t5 + # events: b:$t6 + 2: $t6 := 1 + # live vars: $t2, $t5, $t6 + # events: e:$t5, e:$t6, b:$t4 + 3: $t4 := +($t5, $t6) # live vars: $t2, $t4 # events: e:$t4 - 3: $t0 := move($t4) + 4: $t0 := move($t4) # live vars: $t0, $t2 # events: e:$t0, b:$t3 - 4: $t3 := move($t0) + 5: $t3 := move($t0) # live vars: $t2, $t3 # events: e:$t2, e:$t3, b:$t1 - 5: $t1 := m::add($t2, $t3) + 6: $t1 := m::add($t2, $t3) # live vars: $t1 # events: e:$t1 - 6: return $t1 + 7: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -99,8 +115,10 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 [unused] - 0: $t0 := +($t0, $t1) - 1: return $t0 + var $t3: u64 [unused] + 0: $t0 := move($t0) + 1: $t0 := +($t0, $t1) + 2: return $t0 } @@ -111,13 +129,15 @@ public fun m::test($t0: u64): u64 { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 + var $t6: u64 0: $t2 := copy($t0) - 1: $t5 := 1 - 2: $t5 := +($t0, $t5) - 3: $t0 := move($t5) - 4: $t0 := move($t0) - 5: $t0 := m::add($t2, $t0) - 6: return $t0 + 1: $t5 := move($t0) + 2: $t6 := 1 + 3: $t5 := +($t5, $t6) + 4: $t0 := move($t5) + 5: $t0 := move($t0) + 6: $t0 := m::add($t2, $t0) + 7: return $t0 } ============ after DeadStoreElimination: ================ @@ -125,8 +145,10 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 [unused] - 0: $t0 := +($t0, $t1) - 1: return $t0 + var $t3: u64 [unused] + 0: $t0 := move($t0) + 1: $t0 := +($t0, $t1) + 2: return $t0 } @@ -137,12 +159,14 @@ public fun m::test($t0: u64): u64 { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 + var $t6: u64 0: $t2 := copy($t0) - 1: $t5 := 1 - 2: $t5 := +($t0, $t5) - 3: $t0 := move($t5) - 4: $t0 := m::add($t2, $t0) - 5: return $t0 + 1: $t5 := move($t0) + 2: $t6 := 1 + 3: $t5 := +($t5, $t6) + 4: $t0 := move($t5) + 5: $t0 := m::add($t2, $t0) + 6: return $t0 } @@ -159,7 +183,6 @@ B0: 3: Ret } public test(Arg0: u64): u64 /* def_idx: 1 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: MoveLoc[0](Arg0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.opt.exp index a58b76fe10539..1c8ed4cb68489 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/args_with_side_effects.opt.exp @@ -3,8 +3,10 @@ [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 - 0: $t2 := +($t0, $t1) - 1: return $t2 + var $t3: u64 + 0: $t3 := infer($t0) + 1: $t2 := +($t3, $t1) + 2: return $t2 } @@ -15,13 +17,15 @@ public fun m::test($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t2 := infer($t0) - 1: $t5 := 1 - 2: $t4 := +($t0, $t5) - 3: $t0 := infer($t4) - 4: $t3 := infer($t0) - 5: $t1 := m::add($t2, $t3) - 6: return $t1 + 1: $t5 := infer($t0) + 2: $t6 := 1 + 3: $t4 := +($t5, $t6) + 4: $t0 := infer($t4) + 5: $t3 := infer($t0) + 6: $t1 := m::add($t2, $t3) + 7: return $t1 } ============ after DeadStoreElimination: ================ @@ -29,8 +33,10 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 - 0: $t2 := +($t0, $t1) - 1: return $t2 + var $t3: u64 + 0: $t3 := move($t0) + 1: $t2 := +($t3, $t1) + 2: return $t2 } @@ -41,13 +47,15 @@ public fun m::test($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t2 := copy($t0) - 1: $t5 := 1 - 2: $t4 := +($t0, $t5) - 3: $t0 := move($t4) - 4: $t3 := move($t0) - 5: $t1 := m::add($t2, $t3) - 6: return $t1 + 1: $t5 := move($t0) + 2: $t6 := 1 + 3: $t4 := +($t5, $t6) + 4: $t0 := move($t4) + 5: $t3 := move($t0) + 6: $t1 := m::add($t2, $t3) + 7: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -55,12 +63,16 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 + var $t3: u64 # live vars: $t0, $t1 - # events: b:$t0, b:$t1, e:$t0, e:$t1, b:$t2 - 0: $t2 := +($t0, $t1) + # events: b:$t0, b:$t1, e:$t0, b:$t3 + 0: $t3 := move($t0) + # live vars: $t1, $t3 + # events: e:$t1, e:$t3, b:$t2 + 1: $t2 := +($t3, $t1) # live vars: $t2 # events: e:$t2 - 1: return $t2 + 2: return $t2 } @@ -71,27 +83,31 @@ public fun m::test($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) # live vars: $t0, $t2 # events: b:$t5 - 1: $t5 := 1 - # live vars: $t0, $t2, $t5 - # events: e:$t5, b:$t4 - 2: $t4 := +($t0, $t5) + 1: $t5 := move($t0) + # live vars: $t2, $t5 + # events: b:$t6 + 2: $t6 := 1 + # live vars: $t2, $t5, $t6 + # events: e:$t5, e:$t6, b:$t4 + 3: $t4 := +($t5, $t6) # live vars: $t2, $t4 # events: e:$t4 - 3: $t0 := move($t4) + 4: $t0 := move($t4) # live vars: $t0, $t2 # events: e:$t0, b:$t3 - 4: $t3 := move($t0) + 5: $t3 := move($t0) # live vars: $t2, $t3 # events: e:$t2, e:$t3, b:$t1 - 5: $t1 := m::add($t2, $t3) + 6: $t1 := m::add($t2, $t3) # live vars: $t1 # events: e:$t1 - 6: return $t1 + 7: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -99,8 +115,10 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 [unused] - 0: $t0 := +($t0, $t1) - 1: return $t0 + var $t3: u64 [unused] + 0: $t0 := move($t0) + 1: $t0 := +($t0, $t1) + 2: return $t0 } @@ -111,13 +129,15 @@ public fun m::test($t0: u64): u64 { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 + var $t6: u64 0: $t2 := copy($t0) - 1: $t5 := 1 - 2: $t5 := +($t0, $t5) - 3: $t0 := move($t5) - 4: $t0 := move($t0) - 5: $t0 := m::add($t2, $t0) - 6: return $t0 + 1: $t5 := move($t0) + 2: $t6 := 1 + 3: $t5 := +($t5, $t6) + 4: $t0 := move($t5) + 5: $t0 := move($t0) + 6: $t0 := m::add($t2, $t0) + 7: return $t0 } ============ after DeadStoreElimination: ================ @@ -125,8 +145,10 @@ public fun m::test($t0: u64): u64 { [variant baseline] fun m::add($t0: u64, $t1: u64): u64 { var $t2: u64 [unused] - 0: $t0 := +($t0, $t1) - 1: return $t0 + var $t3: u64 [unused] + 0: $t0 := move($t0) + 1: $t0 := +($t0, $t1) + 2: return $t0 } @@ -137,12 +159,14 @@ public fun m::test($t0: u64): u64 { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 + var $t6: u64 0: $t2 := copy($t0) - 1: $t5 := 1 - 2: $t5 := +($t0, $t5) - 3: $t0 := move($t5) - 4: $t0 := m::add($t2, $t0) - 5: return $t0 + 1: $t5 := move($t0) + 2: $t6 := 1 + 3: $t5 := +($t5, $t6) + 4: $t0 := move($t5) + 5: $t0 := m::add($t2, $t0) + 6: return $t0 } @@ -159,7 +183,6 @@ B0: 3: Ret } public test(Arg0: u64): u64 /* def_idx: 1 */ { -L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: MoveLoc[0](Arg0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_1.exp index 79aa80de12745..d916e03530cdb 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_1.exp @@ -6,6 +6,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t3 := infer($t1) 1: if ($t0) goto 2 else goto 6 2: label L0 @@ -14,9 +15,10 @@ fun m::foo($t0: bool, $t1: u64): u64 { 5: goto 7 6: label L1 7: label L2 - 8: $t5 := 1 - 9: $t2 := +($t3, $t5) - 10: return $t2 + 8: $t5 := infer($t3) + 9: $t6 := 1 + 10: $t2 := +($t5, $t6) + 11: return $t2 } ============ after DeadStoreElimination: ================ @@ -27,6 +29,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t3 := move($t1) 1: if ($t0) goto 4 else goto 2 2: label L3 @@ -35,9 +38,10 @@ fun m::foo($t0: bool, $t1: u64): u64 { 5: $t4 := 0 6: $t3 := move($t4) 7: label L2 - 8: $t5 := 1 - 9: $t2 := +($t3, $t5) - 10: return $t2 + 8: $t5 := move($t3) + 9: $t6 := 1 + 10: $t2 := +($t5, $t6) + 11: return $t2 } ============ after VariableCoalescingAnnotator: ================ @@ -48,6 +52,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 # live vars: $t0, $t1 # events: b:$t0, b:$t1, e:$t1, b:$t3 0: $t3 := move($t1) @@ -69,14 +74,17 @@ fun m::foo($t0: bool, $t1: u64): u64 { # live vars: $t3 7: label L2 # live vars: $t3 - # events: b:$t5 - 8: $t5 := 1 - # live vars: $t3, $t5 - # events: e:$t3, e:$t5, b:$t2 - 9: $t2 := +($t3, $t5) + # events: e:$t3, b:$t5 + 8: $t5 := move($t3) + # live vars: $t5 + # events: b:$t6 + 9: $t6 := 1 + # live vars: $t5, $t6 + # events: e:$t5, e:$t6, b:$t2 + 10: $t2 := +($t5, $t6) # live vars: $t2 # events: e:$t2 - 10: return $t2 + 11: return $t2 } ============ after VariableCoalescingTransformer: ================ @@ -87,6 +95,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 [unused] var $t4: u64 var $t5: u64 [unused] + var $t6: u64 [unused] 0: $t1 := move($t1) 1: if ($t0) goto 4 else goto 2 2: label L3 @@ -95,9 +104,10 @@ fun m::foo($t0: bool, $t1: u64): u64 { 5: $t4 := 0 6: $t1 := move($t4) 7: label L2 - 8: $t4 := 1 - 9: $t1 := +($t1, $t4) - 10: return $t1 + 8: $t1 := move($t1) + 9: $t4 := 1 + 10: $t1 := +($t1, $t4) + 11: return $t1 } ============ after DeadStoreElimination: ================ @@ -108,16 +118,19 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 [unused] var $t4: u64 var $t5: u64 [unused] - 0: if ($t0) goto 3 else goto 1 - 1: label L3 - 2: goto 6 - 3: label L0 - 4: $t4 := 0 - 5: $t1 := move($t4) - 6: label L2 - 7: $t4 := 1 - 8: $t1 := +($t1, $t4) - 9: return $t1 + var $t6: u64 [unused] + 0: $t1 := move($t1) + 1: if ($t0) goto 4 else goto 2 + 2: label L3 + 3: goto 7 + 4: label L0 + 5: $t4 := 0 + 6: $t1 := move($t4) + 7: label L2 + 8: $t1 := move($t1) + 9: $t4 := 1 + 10: $t1 := +($t1, $t4) + 11: return $t1 } @@ -127,7 +140,6 @@ module c0ffee.m { foo(Arg0: bool, Arg1: u64): u64 /* def_idx: 0 */ { -L2: loc0: u64 B0: 0: MoveLoc[0](Arg0: bool) 1: BrTrue(3) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_1.opt.exp index 79aa80de12745..d916e03530cdb 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/branch_1.opt.exp @@ -6,6 +6,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t3 := infer($t1) 1: if ($t0) goto 2 else goto 6 2: label L0 @@ -14,9 +15,10 @@ fun m::foo($t0: bool, $t1: u64): u64 { 5: goto 7 6: label L1 7: label L2 - 8: $t5 := 1 - 9: $t2 := +($t3, $t5) - 10: return $t2 + 8: $t5 := infer($t3) + 9: $t6 := 1 + 10: $t2 := +($t5, $t6) + 11: return $t2 } ============ after DeadStoreElimination: ================ @@ -27,6 +29,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t3 := move($t1) 1: if ($t0) goto 4 else goto 2 2: label L3 @@ -35,9 +38,10 @@ fun m::foo($t0: bool, $t1: u64): u64 { 5: $t4 := 0 6: $t3 := move($t4) 7: label L2 - 8: $t5 := 1 - 9: $t2 := +($t3, $t5) - 10: return $t2 + 8: $t5 := move($t3) + 9: $t6 := 1 + 10: $t2 := +($t5, $t6) + 11: return $t2 } ============ after VariableCoalescingAnnotator: ================ @@ -48,6 +52,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 # live vars: $t0, $t1 # events: b:$t0, b:$t1, e:$t1, b:$t3 0: $t3 := move($t1) @@ -69,14 +74,17 @@ fun m::foo($t0: bool, $t1: u64): u64 { # live vars: $t3 7: label L2 # live vars: $t3 - # events: b:$t5 - 8: $t5 := 1 - # live vars: $t3, $t5 - # events: e:$t3, e:$t5, b:$t2 - 9: $t2 := +($t3, $t5) + # events: e:$t3, b:$t5 + 8: $t5 := move($t3) + # live vars: $t5 + # events: b:$t6 + 9: $t6 := 1 + # live vars: $t5, $t6 + # events: e:$t5, e:$t6, b:$t2 + 10: $t2 := +($t5, $t6) # live vars: $t2 # events: e:$t2 - 10: return $t2 + 11: return $t2 } ============ after VariableCoalescingTransformer: ================ @@ -87,6 +95,7 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 [unused] var $t4: u64 var $t5: u64 [unused] + var $t6: u64 [unused] 0: $t1 := move($t1) 1: if ($t0) goto 4 else goto 2 2: label L3 @@ -95,9 +104,10 @@ fun m::foo($t0: bool, $t1: u64): u64 { 5: $t4 := 0 6: $t1 := move($t4) 7: label L2 - 8: $t4 := 1 - 9: $t1 := +($t1, $t4) - 10: return $t1 + 8: $t1 := move($t1) + 9: $t4 := 1 + 10: $t1 := +($t1, $t4) + 11: return $t1 } ============ after DeadStoreElimination: ================ @@ -108,16 +118,19 @@ fun m::foo($t0: bool, $t1: u64): u64 { var $t3: u64 [unused] var $t4: u64 var $t5: u64 [unused] - 0: if ($t0) goto 3 else goto 1 - 1: label L3 - 2: goto 6 - 3: label L0 - 4: $t4 := 0 - 5: $t1 := move($t4) - 6: label L2 - 7: $t4 := 1 - 8: $t1 := +($t1, $t4) - 9: return $t1 + var $t6: u64 [unused] + 0: $t1 := move($t1) + 1: if ($t0) goto 4 else goto 2 + 2: label L3 + 3: goto 7 + 4: label L0 + 5: $t4 := 0 + 6: $t1 := move($t4) + 7: label L2 + 8: $t1 := move($t1) + 9: $t4 := 1 + 10: $t1 := +($t1, $t4) + 11: return $t1 } @@ -127,7 +140,6 @@ module c0ffee.m { foo(Arg0: bool, Arg1: u64): u64 /* def_idx: 0 */ { -L2: loc0: u64 B0: 0: MoveLoc[0](Arg0: bool) 1: BrTrue(3) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/bug_12068.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/bug_12068.exp index 3d253d06f0147..9330b8cd46a7c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/bug_12068.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/bug_12068.exp @@ -6,34 +6,38 @@ fun m::main() { var $t1: bool var $t2: u64 var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t0 := 0 1: label L0 2: $t1 := true - 3: if ($t1) goto 4 else goto 10 + 3: if ($t1) goto 4 else goto 11 4: label L2 - 5: $t3 := 1 - 6: $t2 := +($t0, $t3) - 7: $t0 := infer($t2) - 8: goto 14 - 9: goto 12 - 10: label L3 - 11: goto 14 - 12: label L4 - 13: goto 1 - 14: label L1 - 15: $t5 := 1 - 16: $t4 := ==($t0, $t5) - 17: if ($t4) goto 18 else goto 20 - 18: label L5 - 19: goto 23 - 20: label L6 - 21: $t6 := 42 - 22: abort($t6) - 23: label L7 - 24: return () + 5: $t3 := infer($t0) + 6: $t4 := 1 + 7: $t2 := +($t3, $t4) + 8: $t0 := infer($t2) + 9: goto 15 + 10: goto 13 + 11: label L3 + 12: goto 15 + 13: label L4 + 14: goto 1 + 15: label L1 + 16: $t6 := infer($t0) + 17: $t7 := 1 + 18: $t5 := ==($t6, $t7) + 19: if ($t5) goto 20 else goto 22 + 20: label L5 + 21: goto 25 + 22: label L6 + 23: $t8 := 42 + 24: abort($t8) + 25: label L7 + 26: return () } ============ after DeadStoreElimination: ================ @@ -44,27 +48,31 @@ fun m::main() { var $t1: bool var $t2: u64 var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t0 := 0 1: $t1 := true 2: if ($t1) goto 5 else goto 3 3: label L7 - 4: goto 9 + 4: goto 10 5: label L2 - 6: $t3 := 1 - 7: $t2 := +($t0, $t3) - 8: $t0 := move($t2) - 9: label L1 - 10: $t5 := 1 - 11: $t4 := ==($t0, $t5) - 12: if ($t4) goto 13 else goto 15 - 13: label L5 - 14: return () - 15: label L6 - 16: $t6 := 42 - 17: abort($t6) + 6: $t3 := move($t0) + 7: $t4 := 1 + 8: $t2 := +($t3, $t4) + 9: $t0 := move($t2) + 10: label L1 + 11: $t6 := move($t0) + 12: $t7 := 1 + 13: $t5 := ==($t6, $t7) + 14: if ($t5) goto 15 else goto 17 + 15: label L5 + 16: return () + 17: label L6 + 18: $t8 := 42 + 19: abort($t8) } ============ after VariableCoalescingAnnotator: ================ @@ -75,9 +83,11 @@ fun m::main() { var $t1: bool var $t2: u64 var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: # events: b:$t0 0: $t0 := 0 @@ -90,41 +100,47 @@ fun m::main() { # live vars: $t0 3: label L7 # live vars: $t0 - 4: goto 9 + 4: goto 10 # live vars: $t0 5: label L2 # live vars: $t0 # events: b:$t3 - 6: $t3 := 1 - # live vars: $t0, $t3 - # events: e:$t3, b:$t2 - 7: $t2 := +($t0, $t3) + 6: $t3 := move($t0) + # live vars: $t3 + # events: b:$t4 + 7: $t4 := 1 + # live vars: $t3, $t4 + # events: e:$t3, e:$t4, b:$t2 + 8: $t2 := +($t3, $t4) # live vars: $t2 # events: e:$t2 - 8: $t0 := move($t2) + 9: $t0 := move($t2) # live vars: $t0 - 9: label L1 + 10: label L1 # live vars: $t0 - # events: b:$t5 - 10: $t5 := 1 - # live vars: $t0, $t5 - # events: e:$t0, e:$t5, b:$t4 - 11: $t4 := ==($t0, $t5) - # live vars: $t4 - # events: e:$t4 - 12: if ($t4) goto 13 else goto 15 + # events: e:$t0, b:$t6 + 11: $t6 := move($t0) + # live vars: $t6 + # events: b:$t7 + 12: $t7 := 1 + # live vars: $t6, $t7 + # events: e:$t6, e:$t7, b:$t5 + 13: $t5 := ==($t6, $t7) + # live vars: $t5 + # events: e:$t5 + 14: if ($t5) goto 15 else goto 17 # live vars: - 13: label L5 + 15: label L5 # live vars: - 14: return () + 16: return () # live vars: - 15: label L6 + 17: label L6 # live vars: - # events: b:$t6 - 16: $t6 := 42 - # live vars: $t6 - # events: e:$t6 - 17: abort($t6) + # events: b:$t8 + 18: $t8 := 42 + # live vars: $t8 + # events: e:$t8 + 19: abort($t8) } ============ after VariableCoalescingTransformer: ================ @@ -135,27 +151,31 @@ fun m::main() { var $t1: bool var $t2: u64 [unused] var $t3: u64 - var $t4: bool [unused] - var $t5: u64 [unused] + var $t4: u64 + var $t5: bool [unused] var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t0 := 0 1: $t1 := true 2: if ($t1) goto 5 else goto 3 3: label L7 - 4: goto 9 + 4: goto 10 5: label L2 - 6: $t3 := 1 - 7: $t3 := +($t0, $t3) - 8: $t0 := move($t3) - 9: label L1 - 10: $t3 := 1 - 11: $t1 := ==($t0, $t3) - 12: if ($t1) goto 13 else goto 15 - 13: label L5 - 14: return () - 15: label L6 - 16: $t0 := 42 - 17: abort($t0) + 6: $t3 := move($t0) + 7: $t4 := 1 + 8: $t3 := +($t3, $t4) + 9: $t0 := move($t3) + 10: label L1 + 11: $t0 := move($t0) + 12: $t3 := 1 + 13: $t1 := ==($t0, $t3) + 14: if ($t1) goto 15 else goto 17 + 15: label L5 + 16: return () + 17: label L6 + 18: $t0 := 42 + 19: abort($t0) } ============ after DeadStoreElimination: ================ @@ -166,27 +186,31 @@ fun m::main() { var $t1: bool var $t2: u64 [unused] var $t3: u64 - var $t4: bool [unused] - var $t5: u64 [unused] + var $t4: u64 + var $t5: bool [unused] var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t0 := 0 1: $t1 := true 2: if ($t1) goto 5 else goto 3 3: label L7 - 4: goto 9 + 4: goto 10 5: label L2 - 6: $t3 := 1 - 7: $t3 := +($t0, $t3) - 8: $t0 := move($t3) - 9: label L1 - 10: $t3 := 1 - 11: $t1 := ==($t0, $t3) - 12: if ($t1) goto 13 else goto 15 - 13: label L5 - 14: return () - 15: label L6 - 16: $t0 := 42 - 17: abort($t0) + 6: $t3 := move($t0) + 7: $t4 := 1 + 8: $t3 := +($t3, $t4) + 9: $t0 := move($t3) + 10: label L1 + 11: $t0 := move($t0) + 12: $t3 := 1 + 13: $t1 := ==($t0, $t3) + 14: if ($t1) goto 15 else goto 17 + 15: label L5 + 16: return () + 17: label L6 + 18: $t0 := 42 + 19: abort($t0) } @@ -197,7 +221,6 @@ module 32.m { main() /* def_idx: 0 */ { L0: loc0: u64 -L1: loc1: u64 B0: 0: LdU64(0) 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/bug_12068.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/bug_12068.opt.exp index 3d253d06f0147..9330b8cd46a7c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/bug_12068.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/bug_12068.opt.exp @@ -6,34 +6,38 @@ fun m::main() { var $t1: bool var $t2: u64 var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t0 := 0 1: label L0 2: $t1 := true - 3: if ($t1) goto 4 else goto 10 + 3: if ($t1) goto 4 else goto 11 4: label L2 - 5: $t3 := 1 - 6: $t2 := +($t0, $t3) - 7: $t0 := infer($t2) - 8: goto 14 - 9: goto 12 - 10: label L3 - 11: goto 14 - 12: label L4 - 13: goto 1 - 14: label L1 - 15: $t5 := 1 - 16: $t4 := ==($t0, $t5) - 17: if ($t4) goto 18 else goto 20 - 18: label L5 - 19: goto 23 - 20: label L6 - 21: $t6 := 42 - 22: abort($t6) - 23: label L7 - 24: return () + 5: $t3 := infer($t0) + 6: $t4 := 1 + 7: $t2 := +($t3, $t4) + 8: $t0 := infer($t2) + 9: goto 15 + 10: goto 13 + 11: label L3 + 12: goto 15 + 13: label L4 + 14: goto 1 + 15: label L1 + 16: $t6 := infer($t0) + 17: $t7 := 1 + 18: $t5 := ==($t6, $t7) + 19: if ($t5) goto 20 else goto 22 + 20: label L5 + 21: goto 25 + 22: label L6 + 23: $t8 := 42 + 24: abort($t8) + 25: label L7 + 26: return () } ============ after DeadStoreElimination: ================ @@ -44,27 +48,31 @@ fun m::main() { var $t1: bool var $t2: u64 var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t0 := 0 1: $t1 := true 2: if ($t1) goto 5 else goto 3 3: label L7 - 4: goto 9 + 4: goto 10 5: label L2 - 6: $t3 := 1 - 7: $t2 := +($t0, $t3) - 8: $t0 := move($t2) - 9: label L1 - 10: $t5 := 1 - 11: $t4 := ==($t0, $t5) - 12: if ($t4) goto 13 else goto 15 - 13: label L5 - 14: return () - 15: label L6 - 16: $t6 := 42 - 17: abort($t6) + 6: $t3 := move($t0) + 7: $t4 := 1 + 8: $t2 := +($t3, $t4) + 9: $t0 := move($t2) + 10: label L1 + 11: $t6 := move($t0) + 12: $t7 := 1 + 13: $t5 := ==($t6, $t7) + 14: if ($t5) goto 15 else goto 17 + 15: label L5 + 16: return () + 17: label L6 + 18: $t8 := 42 + 19: abort($t8) } ============ after VariableCoalescingAnnotator: ================ @@ -75,9 +83,11 @@ fun m::main() { var $t1: bool var $t2: u64 var $t3: u64 - var $t4: bool - var $t5: u64 + var $t4: u64 + var $t5: bool var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: # events: b:$t0 0: $t0 := 0 @@ -90,41 +100,47 @@ fun m::main() { # live vars: $t0 3: label L7 # live vars: $t0 - 4: goto 9 + 4: goto 10 # live vars: $t0 5: label L2 # live vars: $t0 # events: b:$t3 - 6: $t3 := 1 - # live vars: $t0, $t3 - # events: e:$t3, b:$t2 - 7: $t2 := +($t0, $t3) + 6: $t3 := move($t0) + # live vars: $t3 + # events: b:$t4 + 7: $t4 := 1 + # live vars: $t3, $t4 + # events: e:$t3, e:$t4, b:$t2 + 8: $t2 := +($t3, $t4) # live vars: $t2 # events: e:$t2 - 8: $t0 := move($t2) + 9: $t0 := move($t2) # live vars: $t0 - 9: label L1 + 10: label L1 # live vars: $t0 - # events: b:$t5 - 10: $t5 := 1 - # live vars: $t0, $t5 - # events: e:$t0, e:$t5, b:$t4 - 11: $t4 := ==($t0, $t5) - # live vars: $t4 - # events: e:$t4 - 12: if ($t4) goto 13 else goto 15 + # events: e:$t0, b:$t6 + 11: $t6 := move($t0) + # live vars: $t6 + # events: b:$t7 + 12: $t7 := 1 + # live vars: $t6, $t7 + # events: e:$t6, e:$t7, b:$t5 + 13: $t5 := ==($t6, $t7) + # live vars: $t5 + # events: e:$t5 + 14: if ($t5) goto 15 else goto 17 # live vars: - 13: label L5 + 15: label L5 # live vars: - 14: return () + 16: return () # live vars: - 15: label L6 + 17: label L6 # live vars: - # events: b:$t6 - 16: $t6 := 42 - # live vars: $t6 - # events: e:$t6 - 17: abort($t6) + # events: b:$t8 + 18: $t8 := 42 + # live vars: $t8 + # events: e:$t8 + 19: abort($t8) } ============ after VariableCoalescingTransformer: ================ @@ -135,27 +151,31 @@ fun m::main() { var $t1: bool var $t2: u64 [unused] var $t3: u64 - var $t4: bool [unused] - var $t5: u64 [unused] + var $t4: u64 + var $t5: bool [unused] var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t0 := 0 1: $t1 := true 2: if ($t1) goto 5 else goto 3 3: label L7 - 4: goto 9 + 4: goto 10 5: label L2 - 6: $t3 := 1 - 7: $t3 := +($t0, $t3) - 8: $t0 := move($t3) - 9: label L1 - 10: $t3 := 1 - 11: $t1 := ==($t0, $t3) - 12: if ($t1) goto 13 else goto 15 - 13: label L5 - 14: return () - 15: label L6 - 16: $t0 := 42 - 17: abort($t0) + 6: $t3 := move($t0) + 7: $t4 := 1 + 8: $t3 := +($t3, $t4) + 9: $t0 := move($t3) + 10: label L1 + 11: $t0 := move($t0) + 12: $t3 := 1 + 13: $t1 := ==($t0, $t3) + 14: if ($t1) goto 15 else goto 17 + 15: label L5 + 16: return () + 17: label L6 + 18: $t0 := 42 + 19: abort($t0) } ============ after DeadStoreElimination: ================ @@ -166,27 +186,31 @@ fun m::main() { var $t1: bool var $t2: u64 [unused] var $t3: u64 - var $t4: bool [unused] - var $t5: u64 [unused] + var $t4: u64 + var $t5: bool [unused] var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t0 := 0 1: $t1 := true 2: if ($t1) goto 5 else goto 3 3: label L7 - 4: goto 9 + 4: goto 10 5: label L2 - 6: $t3 := 1 - 7: $t3 := +($t0, $t3) - 8: $t0 := move($t3) - 9: label L1 - 10: $t3 := 1 - 11: $t1 := ==($t0, $t3) - 12: if ($t1) goto 13 else goto 15 - 13: label L5 - 14: return () - 15: label L6 - 16: $t0 := 42 - 17: abort($t0) + 6: $t3 := move($t0) + 7: $t4 := 1 + 8: $t3 := +($t3, $t4) + 9: $t0 := move($t3) + 10: label L1 + 11: $t0 := move($t0) + 12: $t3 := 1 + 13: $t1 := ==($t0, $t3) + 14: if ($t1) goto 15 else goto 17 + 15: label L5 + 16: return () + 17: label L6 + 18: $t0 := 42 + 19: abort($t0) } @@ -197,7 +221,6 @@ module 32.m { main() /* def_idx: 0 */ { L0: loc0: u64 -L1: loc1: u64 B0: 0: LdU64(0) 1: StLoc[0](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/call_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/call_1.exp index 3f4ff64c3e1c9..e7f5b6b27d6c2 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/call_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/call_1.exp @@ -140,7 +140,8 @@ fun m::test($t0: u64): u64 { [variant baseline] fun m::id($t0: u64): u64 { var $t1: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } @@ -152,10 +153,11 @@ fun m::test($t0: u64): u64 { var $t4: u64 [unused] var $t5: u64 [unused] var $t6: u64 [unused] - 0: $t0 := m::id($t0) + 0: $t0 := move($t0) 1: $t0 := m::id($t0) 2: $t0 := m::id($t0) - 3: return $t0 + 3: $t0 := m::id($t0) + 4: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/call_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/call_1.opt.exp index 3f4ff64c3e1c9..e7f5b6b27d6c2 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/call_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/call_1.opt.exp @@ -140,7 +140,8 @@ fun m::test($t0: u64): u64 { [variant baseline] fun m::id($t0: u64): u64 { var $t1: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } @@ -152,10 +153,11 @@ fun m::test($t0: u64): u64 { var $t4: u64 [unused] var $t5: u64 [unused] var $t6: u64 [unused] - 0: $t0 := m::id($t0) + 0: $t0 := move($t0) 1: $t0 := m::id($t0) 2: $t0 := m::id($t0) - 3: return $t0 + 3: $t0 := m::id($t0) + 4: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/call_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/call_2.exp index d51e981ce065e..49b17686bb69a 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/call_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/call_2.exp @@ -144,9 +144,10 @@ fun m::test($t0: u64): u64 { var $t4: u64 [unused] var $t5: &mut u64 0: $t2 := copy($t0) - 1: $t5 := borrow_local($t2) - 2: m::update($t5) - 3: return $t0 + 1: $t0 := move($t0) + 2: $t5 := borrow_local($t2) + 3: m::update($t5) + 4: return $t0 } @@ -167,9 +168,9 @@ L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) - 2: MutBorrowLoc[1](loc0: u64) - 3: Call update(&mut u64) - 4: MoveLoc[0](Arg0: u64) + 2: MoveLoc[0](Arg0: u64) + 3: MutBorrowLoc[1](loc0: u64) + 4: Call update(&mut u64) 5: Ret } } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/call_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/call_2.opt.exp index d51e981ce065e..49b17686bb69a 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/call_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/call_2.opt.exp @@ -144,9 +144,10 @@ fun m::test($t0: u64): u64 { var $t4: u64 [unused] var $t5: &mut u64 0: $t2 := copy($t0) - 1: $t5 := borrow_local($t2) - 2: m::update($t5) - 3: return $t0 + 1: $t0 := move($t0) + 2: $t5 := borrow_local($t2) + 3: m::update($t5) + 4: return $t0 } @@ -167,9 +168,9 @@ L1: loc0: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) - 2: MutBorrowLoc[1](loc0: u64) - 3: Call update(&mut u64) - 4: MoveLoc[0](Arg0: u64) + 2: MoveLoc[0](Arg0: u64) + 3: MutBorrowLoc[1](loc0: u64) + 4: Call update(&mut u64) 5: Ret } } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_coalesce_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_coalesce_1.exp index 4006c3f61f920..e00c0bf60093f 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_coalesce_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_coalesce_1.exp @@ -13,10 +13,12 @@ public fun m::test($t0: u64): u64 { var $t1: u64 var $t2: u64 var $t3: u64 - 0: $t2 := +($t0, $t0) - 1: $t3 := 2 - 2: $t1 := infer($t3) - 3: return $t1 + var $t4: u64 + 0: $t3 := infer($t0) + 1: $t2 := +($t3, $t0) + 2: $t4 := 2 + 3: $t1 := infer($t4) + 4: return $t1 } @@ -34,10 +36,12 @@ public fun m::test($t0: u64): u64 { var $t1: u64 var $t2: u64 var $t3: u64 - 0: $t2 := +($t0, $t0) - 1: $t3 := 2 - 2: $t1 := move($t3) - 3: return $t1 + var $t4: u64 + 0: $t3 := copy($t0) + 1: $t2 := +($t3, $t0) + 2: $t4 := 2 + 3: $t1 := move($t4) + 4: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -47,18 +51,22 @@ public fun m::test($t0: u64): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 # live vars: $t0 - # events: b:$t0, e:$t0, e:$t2, b:$t2 - 0: $t2 := +($t0, $t0) + # events: b:$t0, b:$t3 + 0: $t3 := copy($t0) + # live vars: $t0, $t3 + # events: e:$t0, e:$t2, e:$t3, b:$t2 + 1: $t2 := +($t3, $t0) # live vars: - # events: b:$t3 - 1: $t3 := 2 - # live vars: $t3 - # events: e:$t3, b:$t1 - 2: $t1 := move($t3) + # events: b:$t4 + 2: $t4 := 2 + # live vars: $t4 + # events: e:$t4, b:$t1 + 3: $t1 := move($t4) # live vars: $t1 # events: e:$t1 - 3: return $t1 + 4: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -67,11 +75,13 @@ public fun m::test($t0: u64): u64 { public fun m::test($t0: u64): u64 { var $t1: u64 [unused] var $t2: u64 - var $t3: u64 [unused] - 0: $t0 := +($t0, $t0) - 1: $t2 := 2 - 2: $t2 := move($t2) - 3: return $t2 + var $t3: u64 + var $t4: u64 [unused] + 0: $t3 := copy($t0) + 1: $t0 := +($t3, $t0) + 2: $t2 := 2 + 3: $t2 := move($t2) + 4: return $t2 } ============ after DeadStoreElimination: ================ @@ -80,10 +90,12 @@ public fun m::test($t0: u64): u64 { public fun m::test($t0: u64): u64 { var $t1: u64 [unused] var $t2: u64 - var $t3: u64 [unused] - 0: $t0 := +($t0, $t0) - 1: $t2 := 2 - 2: return $t2 + var $t3: u64 + var $t4: u64 [unused] + 0: $t3 := copy($t0) + 1: $t0 := +($t3, $t0) + 2: $t2 := 2 + 3: return $t2 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_coalesce_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_coalesce_1.opt.exp index 398c9816847c6..3c13338dc2ac1 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_coalesce_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_coalesce_1.opt.exp @@ -12,9 +12,11 @@ warning: Unused local variable `x`. Consider removing or prefixing with an under public fun m::test($t0: u64): u64 { var $t1: u64 var $t2: u64 - 0: $t2 := +($t0, $t0) - 1: $t1 := 2 - 2: return $t1 + var $t3: u64 + 0: $t3 := infer($t0) + 1: $t2 := +($t3, $t0) + 2: $t1 := 2 + 3: return $t1 } @@ -31,9 +33,11 @@ warning: Unused assignment to `x`. Consider removing or prefixing with an unders public fun m::test($t0: u64): u64 { var $t1: u64 var $t2: u64 - 0: $t2 := +($t0, $t0) - 1: $t1 := 2 - 2: return $t1 + var $t3: u64 + 0: $t3 := copy($t0) + 1: $t2 := +($t3, $t0) + 2: $t1 := 2 + 3: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -42,15 +46,19 @@ public fun m::test($t0: u64): u64 { public fun m::test($t0: u64): u64 { var $t1: u64 var $t2: u64 + var $t3: u64 # live vars: $t0 - # events: b:$t0, e:$t0, e:$t2, b:$t2 - 0: $t2 := +($t0, $t0) + # events: b:$t0, b:$t3 + 0: $t3 := copy($t0) + # live vars: $t0, $t3 + # events: e:$t0, e:$t2, e:$t3, b:$t2 + 1: $t2 := +($t3, $t0) # live vars: # events: b:$t1 - 1: $t1 := 2 + 2: $t1 := 2 # live vars: $t1 # events: e:$t1 - 2: return $t1 + 3: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -59,9 +67,11 @@ public fun m::test($t0: u64): u64 { public fun m::test($t0: u64): u64 { var $t1: u64 [unused] var $t2: u64 - 0: $t0 := +($t0, $t0) - 1: $t2 := 2 - 2: return $t2 + var $t3: u64 + 0: $t3 := copy($t0) + 1: $t0 := +($t3, $t0) + 2: $t2 := 2 + 3: return $t2 } ============ after DeadStoreElimination: ================ @@ -70,9 +80,11 @@ public fun m::test($t0: u64): u64 { public fun m::test($t0: u64): u64 { var $t1: u64 [unused] var $t2: u64 - 0: $t0 := +($t0, $t0) - 1: $t2 := 2 - 2: return $t2 + var $t3: u64 + 0: $t3 := copy($t0) + 1: $t0 := +($t3, $t0) + 2: $t2 := 2 + 3: return $t2 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_copy_propagate.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_copy_propagate.exp index 7204294002594..da6e6748d8cc2 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_copy_propagate.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_copy_propagate.exp @@ -15,20 +15,22 @@ fun m::test($t0: u64, $t1: bool) { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 0: $t2 := move($t0) 1: if ($t1) goto 2 else goto 5 2: label L0 3: m::consume($t2) - 4: goto 12 + 4: goto 13 5: label L1 6: $t3 := 99 7: $t0 := infer($t3) 8: $t4 := infer($t2) - 9: $t6 := 1 - 10: $t5 := +($t4, $t6) - 11: $t4 := infer($t5) - 12: label L2 - 13: return () + 9: $t6 := infer($t4) + 10: $t7 := 1 + 11: $t5 := +($t6, $t7) + 12: $t4 := infer($t5) + 13: label L2 + 14: return () } @@ -61,6 +63,7 @@ fun m::test($t0: u64, $t1: bool) { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 0: $t2 := move($t0) 1: if ($t1) goto 2 else goto 6 2: label L0 @@ -69,9 +72,10 @@ fun m::test($t0: u64, $t1: bool) { 5: return () 6: label L1 7: $t4 := move($t2) - 8: $t6 := 1 - 9: $t5 := +($t4, $t6) - 10: goto 4 + 8: $t6 := move($t4) + 9: $t7 := 1 + 10: $t5 := +($t6, $t7) + 11: goto 4 } ============ after VariableCoalescingAnnotator: ================ @@ -92,6 +96,7 @@ fun m::test($t0: u64, $t1: bool) { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 # live vars: $t0, $t1 # events: b:$t0, b:$t1, e:$t0, b:$t2 0: $t2 := move($t0) @@ -112,13 +117,16 @@ fun m::test($t0: u64, $t1: bool) { # events: e:$t2, b:$t4 7: $t4 := move($t2) # live vars: $t4 - # events: b:$t6 - 8: $t6 := 1 - # live vars: $t4, $t6 - # events: e:$t4, e:$t5, e:$t6, b:$t5 - 9: $t5 := +($t4, $t6) + # events: e:$t4, b:$t6 + 8: $t6 := move($t4) + # live vars: $t6 + # events: b:$t7 + 9: $t7 := 1 + # live vars: $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 10: $t5 := +($t6, $t7) # live vars: - 10: goto 4 + 11: goto 4 } ============ after VariableCoalescingTransformer: ================ @@ -136,7 +144,8 @@ fun m::test($t0: u64, $t1: bool) { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 0: $t0 := move($t0) 1: if ($t1) goto 2 else goto 6 2: label L0 @@ -145,9 +154,10 @@ fun m::test($t0: u64, $t1: bool) { 5: return () 6: label L1 7: $t0 := move($t0) - 8: $t6 := 1 - 9: $t0 := +($t0, $t6) - 10: goto 4 + 8: $t0 := move($t0) + 9: $t7 := 1 + 10: $t0 := +($t0, $t7) + 11: goto 4 } ============ after DeadStoreElimination: ================ @@ -165,16 +175,19 @@ fun m::test($t0: u64, $t1: bool) { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 [unused] - var $t6: u64 - 0: if ($t1) goto 1 else goto 5 - 1: label L0 - 2: m::consume($t0) - 3: label L2 - 4: return () - 5: label L1 - 6: $t6 := 1 - 7: $t0 := +($t0, $t6) - 8: goto 3 + var $t6: u64 [unused] + var $t7: u64 + 0: $t0 := move($t0) + 1: if ($t1) goto 2 else goto 6 + 2: label L0 + 3: m::consume($t0) + 4: label L2 + 5: return () + 6: label L1 + 7: $t0 := move($t0) + 8: $t7 := 1 + 9: $t0 := +($t0, $t7) + 10: goto 4 } @@ -188,7 +201,6 @@ B0: 0: Ret } test(Arg0: u64, Arg1: bool) /* def_idx: 1 */ { -L2: loc0: u64 B0: 0: MoveLoc[1](Arg1: bool) 1: BrFalse(5) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_copy_propagate.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_copy_propagate.opt.exp index 7204294002594..da6e6748d8cc2 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_copy_propagate.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cant_copy_propagate.opt.exp @@ -15,20 +15,22 @@ fun m::test($t0: u64, $t1: bool) { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 0: $t2 := move($t0) 1: if ($t1) goto 2 else goto 5 2: label L0 3: m::consume($t2) - 4: goto 12 + 4: goto 13 5: label L1 6: $t3 := 99 7: $t0 := infer($t3) 8: $t4 := infer($t2) - 9: $t6 := 1 - 10: $t5 := +($t4, $t6) - 11: $t4 := infer($t5) - 12: label L2 - 13: return () + 9: $t6 := infer($t4) + 10: $t7 := 1 + 11: $t5 := +($t6, $t7) + 12: $t4 := infer($t5) + 13: label L2 + 14: return () } @@ -61,6 +63,7 @@ fun m::test($t0: u64, $t1: bool) { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 0: $t2 := move($t0) 1: if ($t1) goto 2 else goto 6 2: label L0 @@ -69,9 +72,10 @@ fun m::test($t0: u64, $t1: bool) { 5: return () 6: label L1 7: $t4 := move($t2) - 8: $t6 := 1 - 9: $t5 := +($t4, $t6) - 10: goto 4 + 8: $t6 := move($t4) + 9: $t7 := 1 + 10: $t5 := +($t6, $t7) + 11: goto 4 } ============ after VariableCoalescingAnnotator: ================ @@ -92,6 +96,7 @@ fun m::test($t0: u64, $t1: bool) { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 # live vars: $t0, $t1 # events: b:$t0, b:$t1, e:$t0, b:$t2 0: $t2 := move($t0) @@ -112,13 +117,16 @@ fun m::test($t0: u64, $t1: bool) { # events: e:$t2, b:$t4 7: $t4 := move($t2) # live vars: $t4 - # events: b:$t6 - 8: $t6 := 1 - # live vars: $t4, $t6 - # events: e:$t4, e:$t5, e:$t6, b:$t5 - 9: $t5 := +($t4, $t6) + # events: e:$t4, b:$t6 + 8: $t6 := move($t4) + # live vars: $t6 + # events: b:$t7 + 9: $t7 := 1 + # live vars: $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 10: $t5 := +($t6, $t7) # live vars: - 10: goto 4 + 11: goto 4 } ============ after VariableCoalescingTransformer: ================ @@ -136,7 +144,8 @@ fun m::test($t0: u64, $t1: bool) { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 0: $t0 := move($t0) 1: if ($t1) goto 2 else goto 6 2: label L0 @@ -145,9 +154,10 @@ fun m::test($t0: u64, $t1: bool) { 5: return () 6: label L1 7: $t0 := move($t0) - 8: $t6 := 1 - 9: $t0 := +($t0, $t6) - 10: goto 4 + 8: $t0 := move($t0) + 9: $t7 := 1 + 10: $t0 := +($t0, $t7) + 11: goto 4 } ============ after DeadStoreElimination: ================ @@ -165,16 +175,19 @@ fun m::test($t0: u64, $t1: bool) { var $t3: u64 [unused] var $t4: u64 [unused] var $t5: u64 [unused] - var $t6: u64 - 0: if ($t1) goto 1 else goto 5 - 1: label L0 - 2: m::consume($t0) - 3: label L2 - 4: return () - 5: label L1 - 6: $t6 := 1 - 7: $t0 := +($t0, $t6) - 8: goto 3 + var $t6: u64 [unused] + var $t7: u64 + 0: $t0 := move($t0) + 1: if ($t1) goto 2 else goto 6 + 2: label L0 + 3: m::consume($t0) + 4: label L2 + 5: return () + 6: label L1 + 7: $t0 := move($t0) + 8: $t7 := 1 + 9: $t0 := +($t0, $t7) + 10: goto 4 } @@ -188,7 +201,6 @@ B0: 0: Ret } test(Arg0: u64, Arg1: bool) /* def_idx: 1 */ { -L2: loc0: u64 B0: 0: MoveLoc[1](Arg1: bool) 1: BrFalse(5) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/conditional.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/conditional.exp index 4259871b96bbb..faacecd9a425d 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/conditional.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/conditional.exp @@ -7,18 +7,20 @@ fun m::test($t0: bool): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t2 := 2 1: if ($t0) goto 2 else goto 6 2: label L0 3: $t3 := 3 4: $t1 := infer($t3) - 5: goto 10 + 5: goto 11 6: label L1 - 7: $t5 := 1 - 8: $t4 := +($t2, $t5) - 9: $t1 := infer($t4) - 10: label L2 - 11: return $t1 + 7: $t5 := infer($t2) + 8: $t6 := 1 + 9: $t4 := +($t5, $t6) + 10: $t1 := infer($t4) + 11: label L2 + 12: return $t1 } ============ after DeadStoreElimination: ================ @@ -30,6 +32,7 @@ fun m::test($t0: bool): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t2 := 2 1: if ($t0) goto 2 else goto 7 2: label L0 @@ -38,10 +41,11 @@ fun m::test($t0: bool): u64 { 5: label L2 6: return $t1 7: label L1 - 8: $t5 := 1 - 9: $t4 := +($t2, $t5) - 10: $t1 := move($t4) - 11: goto 5 + 8: $t5 := move($t2) + 9: $t6 := 1 + 10: $t4 := +($t5, $t6) + 11: $t1 := move($t4) + 12: goto 5 } ============ after VariableCoalescingAnnotator: ================ @@ -53,6 +57,7 @@ fun m::test($t0: bool): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := 2 @@ -74,17 +79,20 @@ fun m::test($t0: bool): u64 { # live vars: $t2 7: label L1 # live vars: $t2 - # events: b:$t5 - 8: $t5 := 1 - # live vars: $t2, $t5 - # events: e:$t2, e:$t5, b:$t4 - 9: $t4 := +($t2, $t5) + # events: e:$t2, b:$t5 + 8: $t5 := move($t2) + # live vars: $t5 + # events: b:$t6 + 9: $t6 := 1 + # live vars: $t5, $t6 + # events: e:$t5, e:$t6, b:$t4 + 10: $t4 := +($t5, $t6) # live vars: $t4 # events: e:$t4 - 10: $t1 := move($t4) + 11: $t1 := move($t4) # live vars: $t1 # events: e:$t1 - 11: goto 5 + 12: goto 5 } ============ after VariableCoalescingTransformer: ================ @@ -95,7 +103,8 @@ fun m::test($t0: bool): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] - var $t5: u64 + var $t5: u64 [unused] + var $t6: u64 0: $t2 := 2 1: if ($t0) goto 2 else goto 7 2: label L0 @@ -104,10 +113,11 @@ fun m::test($t0: bool): u64 { 5: label L2 6: return $t3 7: label L1 - 8: $t5 := 1 - 9: $t2 := +($t2, $t5) - 10: $t3 := move($t2) - 11: goto 5 + 8: $t2 := move($t2) + 9: $t6 := 1 + 10: $t2 := +($t2, $t6) + 11: $t3 := move($t2) + 12: goto 5 } ============ after DeadStoreElimination: ================ @@ -118,7 +128,8 @@ fun m::test($t0: bool): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] - var $t5: u64 + var $t5: u64 [unused] + var $t6: u64 0: $t2 := 2 1: if ($t0) goto 2 else goto 6 2: label L0 @@ -126,10 +137,11 @@ fun m::test($t0: bool): u64 { 4: label L2 5: return $t3 6: label L1 - 7: $t5 := 1 - 8: $t2 := +($t2, $t5) - 9: $t3 := move($t2) - 10: goto 4 + 7: $t2 := move($t2) + 8: $t6 := 1 + 9: $t2 := +($t2, $t6) + 10: $t3 := move($t2) + 11: goto 4 } @@ -141,7 +153,6 @@ module c0ffee.m { test(Arg0: bool): u64 /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: LdU64(2) 1: StLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.exp index 9467564dc9e2c..70c9af2424c4c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.exp @@ -163,18 +163,20 @@ fun m::consume_($t0: 0xc0ffee::m::W) { [variant baseline] public fun m::test1($t0: u64) { var $t1: u64 [unused] - 0: m::consume($t0) + 0: $t0 := move($t0) 1: m::consume($t0) - 2: return () + 2: m::consume($t0) + 3: return () } [variant baseline] public fun m::test2($t0: 0xc0ffee::m::W) { var $t1: 0xc0ffee::m::W [unused] - 0: m::consume_($t0) + 0: $t0 := move($t0) 1: m::consume_($t0) - 2: return () + 2: m::consume_($t0) + 3: return () } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.opt.exp index 9467564dc9e2c..70c9af2424c4c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/consume_2.opt.exp @@ -163,18 +163,20 @@ fun m::consume_($t0: 0xc0ffee::m::W) { [variant baseline] public fun m::test1($t0: u64) { var $t1: u64 [unused] - 0: m::consume($t0) + 0: $t0 := move($t0) 1: m::consume($t0) - 2: return () + 2: m::consume($t0) + 3: return () } [variant baseline] public fun m::test2($t0: 0xc0ffee::m::W) { var $t1: 0xc0ffee::m::W [unused] - 0: m::consume_($t0) + 0: $t0 := move($t0) 1: m::consume_($t0) - 2: return () + 2: m::consume_($t0) + 3: return () } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.exp index 532b75388a4fb..eb2737329ba18 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.exp @@ -6,23 +6,27 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t4: bool var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t3 := 0 1: label L0 - 2: $t4 := <($t3, $t0) - 3: if ($t4) goto 4 else goto 11 - 4: label L2 - 5: $t1 := infer($t2) - 6: $t2 := infer($t1) - 7: $t6 := 1 - 8: $t5 := +($t3, $t6) - 9: $t3 := infer($t5) - 10: goto 13 - 11: label L3 + 2: $t5 := infer($t3) + 3: $t4 := <($t5, $t0) + 4: if ($t4) goto 5 else goto 13 + 5: label L2 + 6: $t1 := infer($t2) + 7: $t2 := infer($t1) + 8: $t7 := infer($t3) + 9: $t8 := 1 + 10: $t6 := +($t7, $t8) + 11: $t3 := infer($t6) 12: goto 15 - 13: label L4 - 14: goto 1 - 15: label L1 - 16: return () + 13: label L3 + 14: goto 17 + 15: label L4 + 16: goto 1 + 17: label L1 + 18: return () } @@ -32,22 +36,26 @@ public fun m::test2($t0: u64, $t1: u64) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := 0 1: label L0 - 2: $t3 := <($t2, $t0) - 3: if ($t3) goto 4 else goto 10 - 4: label L2 - 5: $t1 := infer($t1) - 6: $t5 := 1 - 7: $t4 := +($t2, $t5) - 8: $t2 := infer($t4) - 9: goto 12 - 10: label L3 + 2: $t4 := infer($t2) + 3: $t3 := <($t4, $t0) + 4: if ($t3) goto 5 else goto 12 + 5: label L2 + 6: $t1 := infer($t1) + 7: $t6 := infer($t2) + 8: $t7 := 1 + 9: $t5 := +($t6, $t7) + 10: $t2 := infer($t5) 11: goto 14 - 12: label L4 - 13: goto 1 - 14: label L1 - 15: return () + 12: label L3 + 13: goto 16 + 14: label L4 + 15: goto 1 + 16: label L1 + 17: return () } ============ after DeadStoreElimination: ================ @@ -58,19 +66,23 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t4: bool var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t3 := 0 1: label L0 - 2: $t4 := <($t3, $t0) - 3: if ($t4) goto 4 else goto 11 - 4: label L2 - 5: $t1 := move($t2) - 6: $t2 := move($t1) - 7: $t6 := 1 - 8: $t5 := +($t3, $t6) - 9: $t3 := move($t5) - 10: goto 1 - 11: label L3 - 12: return () + 2: $t5 := copy($t3) + 3: $t4 := <($t5, $t0) + 4: if ($t4) goto 5 else goto 13 + 5: label L2 + 6: $t1 := move($t2) + 7: $t2 := move($t1) + 8: $t7 := move($t3) + 9: $t8 := 1 + 10: $t6 := +($t7, $t8) + 11: $t3 := move($t6) + 12: goto 1 + 13: label L3 + 14: return () } @@ -80,17 +92,21 @@ public fun m::test2($t0: u64, $t1: u64) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := 0 1: label L0 - 2: $t3 := <($t2, $t0) - 3: if ($t3) goto 4 else goto 9 - 4: label L2 - 5: $t5 := 1 - 6: $t4 := +($t2, $t5) - 7: $t2 := move($t4) - 8: goto 1 - 9: label L3 - 10: return () + 2: $t4 := copy($t2) + 3: $t3 := <($t4, $t0) + 4: if ($t3) goto 5 else goto 11 + 5: label L2 + 6: $t6 := move($t2) + 7: $t7 := 1 + 8: $t5 := +($t6, $t7) + 9: $t2 := move($t5) + 10: goto 1 + 11: label L3 + 12: return () } ============ after VariableCoalescingAnnotator: ================ @@ -101,40 +117,48 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t4: bool var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: $t0, $t1, $t2 # events: b:$t0, b:$t1, b:$t2, b:$t3 0: $t3 := 0 # live vars: $t0, $t2, $t3 1: label L0 # live vars: $t0, $t2, $t3 - # events: b:$t4 - 2: $t4 := <($t3, $t0) + # events: b:$t5 + 2: $t5 := copy($t3) + # live vars: $t0, $t2, $t3, $t5 + # events: e:$t5, b:$t4 + 3: $t4 := <($t5, $t0) # live vars: $t0, $t2, $t3, $t4 # events: e:$t4 - 3: if ($t4) goto 4 else goto 11 + 4: if ($t4) goto 5 else goto 13 # live vars: $t0, $t2, $t3 - 4: label L2 + 5: label L2 # live vars: $t0, $t2, $t3 - 5: $t1 := move($t2) + 6: $t1 := move($t2) # live vars: $t0, $t1, $t3 # events: e:$t1 - 6: $t2 := move($t1) + 7: $t2 := move($t1) # live vars: $t0, $t2, $t3 - # events: b:$t6 - 7: $t6 := 1 - # live vars: $t0, $t2, $t3, $t6 - # events: e:$t6, b:$t5 - 8: $t5 := +($t3, $t6) - # live vars: $t0, $t2, $t5 - # events: e:$t5 - 9: $t3 := move($t5) + # events: b:$t7 + 8: $t7 := move($t3) + # live vars: $t0, $t2, $t7 + # events: b:$t8 + 9: $t8 := 1 + # live vars: $t0, $t2, $t7, $t8 + # events: e:$t7, e:$t8, b:$t6 + 10: $t6 := +($t7, $t8) + # live vars: $t0, $t2, $t6 + # events: e:$t6 + 11: $t3 := move($t6) # live vars: $t0, $t2, $t3 - 10: goto 1 + 12: goto 1 # live vars: $t0, $t2, $t3 # events: e:$t0, e:$t2, e:$t3 - 11: label L3 + 13: label L3 # live vars: - 12: return () + 14: return () } @@ -144,35 +168,43 @@ public fun m::test2($t0: u64, $t1: u64) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: $t0, $t1 # events: b:$t0, b:$t1, e:$t1, b:$t2 0: $t2 := 0 # live vars: $t0, $t2 1: label L0 # live vars: $t0, $t2 - # events: b:$t3 - 2: $t3 := <($t2, $t0) + # events: b:$t4 + 2: $t4 := copy($t2) + # live vars: $t0, $t2, $t4 + # events: e:$t4, b:$t3 + 3: $t3 := <($t4, $t0) # live vars: $t0, $t2, $t3 # events: e:$t3 - 3: if ($t3) goto 4 else goto 9 + 4: if ($t3) goto 5 else goto 11 # live vars: $t0, $t2 - 4: label L2 + 5: label L2 # live vars: $t0, $t2 - # events: b:$t5 - 5: $t5 := 1 - # live vars: $t0, $t2, $t5 - # events: e:$t5, b:$t4 - 6: $t4 := +($t2, $t5) - # live vars: $t0, $t4 - # events: e:$t4 - 7: $t2 := move($t4) + # events: b:$t6 + 6: $t6 := move($t2) + # live vars: $t0, $t6 + # events: b:$t7 + 7: $t7 := 1 + # live vars: $t0, $t6, $t7 + # events: e:$t6, e:$t7, b:$t5 + 8: $t5 := +($t6, $t7) + # live vars: $t0, $t5 + # events: e:$t5 + 9: $t2 := move($t5) # live vars: $t0, $t2 - 8: goto 1 + 10: goto 1 # live vars: $t0, $t2 # events: e:$t0, e:$t2 - 9: label L3 + 11: label L3 # live vars: - 10: return () + 12: return () } ============ after VariableCoalescingTransformer: ================ @@ -181,21 +213,25 @@ public fun m::test2($t0: u64, $t1: u64) { public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t3: u64 var $t4: bool - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t3 := 0 1: label L0 - 2: $t4 := <($t3, $t0) - 3: if ($t4) goto 4 else goto 11 - 4: label L2 - 5: $t1 := move($t2) - 6: $t2 := move($t1) - 7: $t1 := 1 - 8: $t1 := +($t3, $t1) - 9: $t3 := move($t1) - 10: goto 1 - 11: label L3 - 12: return () + 2: $t5 := copy($t3) + 3: $t4 := <($t5, $t0) + 4: if ($t4) goto 5 else goto 13 + 5: label L2 + 6: $t1 := move($t2) + 7: $t2 := move($t1) + 8: $t1 := move($t3) + 9: $t5 := 1 + 10: $t1 := +($t1, $t5) + 11: $t3 := move($t1) + 12: goto 1 + 13: label L3 + 14: return () } @@ -203,19 +239,23 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { public fun m::test2($t0: u64, $t1: u64) { var $t2: u64 [unused] var $t3: bool - var $t4: u64 [unused] - var $t5: u64 + var $t4: u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 0: $t1 := 0 1: label L0 - 2: $t3 := <($t1, $t0) - 3: if ($t3) goto 4 else goto 9 - 4: label L2 - 5: $t5 := 1 - 6: $t5 := +($t1, $t5) - 7: $t1 := move($t5) - 8: goto 1 - 9: label L3 - 10: return () + 2: $t4 := copy($t1) + 3: $t3 := <($t4, $t0) + 4: if ($t3) goto 5 else goto 11 + 5: label L2 + 6: $t4 := move($t1) + 7: $t7 := 1 + 8: $t4 := +($t4, $t7) + 9: $t1 := move($t4) + 10: goto 1 + 11: label L3 + 12: return () } ============ after DeadStoreElimination: ================ @@ -224,21 +264,25 @@ public fun m::test2($t0: u64, $t1: u64) { public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t3: u64 var $t4: bool - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t3 := 0 1: label L0 - 2: $t4 := <($t3, $t0) - 3: if ($t4) goto 4 else goto 11 - 4: label L2 - 5: $t1 := move($t2) - 6: $t2 := move($t1) - 7: $t1 := 1 - 8: $t1 := +($t3, $t1) - 9: $t3 := move($t1) - 10: goto 1 - 11: label L3 - 12: return () + 2: $t5 := copy($t3) + 3: $t4 := <($t5, $t0) + 4: if ($t4) goto 5 else goto 13 + 5: label L2 + 6: $t1 := move($t2) + 7: $t2 := move($t1) + 8: $t1 := move($t3) + 9: $t5 := 1 + 10: $t1 := +($t1, $t5) + 11: $t3 := move($t1) + 12: goto 1 + 13: label L3 + 14: return () } @@ -246,19 +290,23 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { public fun m::test2($t0: u64, $t1: u64) { var $t2: u64 [unused] var $t3: bool - var $t4: u64 [unused] - var $t5: u64 + var $t4: u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 0: $t1 := 0 1: label L0 - 2: $t3 := <($t1, $t0) - 3: if ($t3) goto 4 else goto 9 - 4: label L2 - 5: $t5 := 1 - 6: $t5 := +($t1, $t5) - 7: $t1 := move($t5) - 8: goto 1 - 9: label L3 - 10: return () + 2: $t4 := copy($t1) + 3: $t3 := <($t4, $t0) + 4: if ($t3) goto 5 else goto 11 + 5: label L2 + 6: $t4 := move($t1) + 7: $t7 := 1 + 8: $t4 := +($t4, $t7) + 9: $t1 := move($t4) + 10: goto 1 + 11: label L3 + 12: return () } @@ -276,20 +324,17 @@ B1: 2: CopyLoc[3](loc0: u64) 3: CopyLoc[0](Arg0: u64) 4: Lt - 5: BrFalse(13) + 5: BrFalse(11) B2: - 6: MoveLoc[2](Arg2: u64) - 7: MoveLoc[3](loc0: u64) - 8: LdU64(1) - 9: Add - 10: StLoc[3](loc0: u64) - 11: StLoc[2](Arg2: u64) - 12: Branch(2) + 6: MoveLoc[3](loc0: u64) + 7: LdU64(1) + 8: Add + 9: StLoc[3](loc0: u64) + 10: Branch(2) B3: - 13: Ret + 11: Ret } public test2(Arg0: u64, Arg1: u64) /* def_idx: 1 */ { -L2: loc0: u64 B0: 0: LdU64(0) 1: StLoc[1](Arg1: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.opt.exp index 532b75388a4fb..eb2737329ba18 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/cyclic_dead_store.opt.exp @@ -6,23 +6,27 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t4: bool var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t3 := 0 1: label L0 - 2: $t4 := <($t3, $t0) - 3: if ($t4) goto 4 else goto 11 - 4: label L2 - 5: $t1 := infer($t2) - 6: $t2 := infer($t1) - 7: $t6 := 1 - 8: $t5 := +($t3, $t6) - 9: $t3 := infer($t5) - 10: goto 13 - 11: label L3 + 2: $t5 := infer($t3) + 3: $t4 := <($t5, $t0) + 4: if ($t4) goto 5 else goto 13 + 5: label L2 + 6: $t1 := infer($t2) + 7: $t2 := infer($t1) + 8: $t7 := infer($t3) + 9: $t8 := 1 + 10: $t6 := +($t7, $t8) + 11: $t3 := infer($t6) 12: goto 15 - 13: label L4 - 14: goto 1 - 15: label L1 - 16: return () + 13: label L3 + 14: goto 17 + 15: label L4 + 16: goto 1 + 17: label L1 + 18: return () } @@ -32,22 +36,26 @@ public fun m::test2($t0: u64, $t1: u64) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := 0 1: label L0 - 2: $t3 := <($t2, $t0) - 3: if ($t3) goto 4 else goto 10 - 4: label L2 - 5: $t1 := infer($t1) - 6: $t5 := 1 - 7: $t4 := +($t2, $t5) - 8: $t2 := infer($t4) - 9: goto 12 - 10: label L3 + 2: $t4 := infer($t2) + 3: $t3 := <($t4, $t0) + 4: if ($t3) goto 5 else goto 12 + 5: label L2 + 6: $t1 := infer($t1) + 7: $t6 := infer($t2) + 8: $t7 := 1 + 9: $t5 := +($t6, $t7) + 10: $t2 := infer($t5) 11: goto 14 - 12: label L4 - 13: goto 1 - 14: label L1 - 15: return () + 12: label L3 + 13: goto 16 + 14: label L4 + 15: goto 1 + 16: label L1 + 17: return () } ============ after DeadStoreElimination: ================ @@ -58,19 +66,23 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t4: bool var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t3 := 0 1: label L0 - 2: $t4 := <($t3, $t0) - 3: if ($t4) goto 4 else goto 11 - 4: label L2 - 5: $t1 := move($t2) - 6: $t2 := move($t1) - 7: $t6 := 1 - 8: $t5 := +($t3, $t6) - 9: $t3 := move($t5) - 10: goto 1 - 11: label L3 - 12: return () + 2: $t5 := copy($t3) + 3: $t4 := <($t5, $t0) + 4: if ($t4) goto 5 else goto 13 + 5: label L2 + 6: $t1 := move($t2) + 7: $t2 := move($t1) + 8: $t7 := move($t3) + 9: $t8 := 1 + 10: $t6 := +($t7, $t8) + 11: $t3 := move($t6) + 12: goto 1 + 13: label L3 + 14: return () } @@ -80,17 +92,21 @@ public fun m::test2($t0: u64, $t1: u64) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := 0 1: label L0 - 2: $t3 := <($t2, $t0) - 3: if ($t3) goto 4 else goto 9 - 4: label L2 - 5: $t5 := 1 - 6: $t4 := +($t2, $t5) - 7: $t2 := move($t4) - 8: goto 1 - 9: label L3 - 10: return () + 2: $t4 := copy($t2) + 3: $t3 := <($t4, $t0) + 4: if ($t3) goto 5 else goto 11 + 5: label L2 + 6: $t6 := move($t2) + 7: $t7 := 1 + 8: $t5 := +($t6, $t7) + 9: $t2 := move($t5) + 10: goto 1 + 11: label L3 + 12: return () } ============ after VariableCoalescingAnnotator: ================ @@ -101,40 +117,48 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t4: bool var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: $t0, $t1, $t2 # events: b:$t0, b:$t1, b:$t2, b:$t3 0: $t3 := 0 # live vars: $t0, $t2, $t3 1: label L0 # live vars: $t0, $t2, $t3 - # events: b:$t4 - 2: $t4 := <($t3, $t0) + # events: b:$t5 + 2: $t5 := copy($t3) + # live vars: $t0, $t2, $t3, $t5 + # events: e:$t5, b:$t4 + 3: $t4 := <($t5, $t0) # live vars: $t0, $t2, $t3, $t4 # events: e:$t4 - 3: if ($t4) goto 4 else goto 11 + 4: if ($t4) goto 5 else goto 13 # live vars: $t0, $t2, $t3 - 4: label L2 + 5: label L2 # live vars: $t0, $t2, $t3 - 5: $t1 := move($t2) + 6: $t1 := move($t2) # live vars: $t0, $t1, $t3 # events: e:$t1 - 6: $t2 := move($t1) + 7: $t2 := move($t1) # live vars: $t0, $t2, $t3 - # events: b:$t6 - 7: $t6 := 1 - # live vars: $t0, $t2, $t3, $t6 - # events: e:$t6, b:$t5 - 8: $t5 := +($t3, $t6) - # live vars: $t0, $t2, $t5 - # events: e:$t5 - 9: $t3 := move($t5) + # events: b:$t7 + 8: $t7 := move($t3) + # live vars: $t0, $t2, $t7 + # events: b:$t8 + 9: $t8 := 1 + # live vars: $t0, $t2, $t7, $t8 + # events: e:$t7, e:$t8, b:$t6 + 10: $t6 := +($t7, $t8) + # live vars: $t0, $t2, $t6 + # events: e:$t6 + 11: $t3 := move($t6) # live vars: $t0, $t2, $t3 - 10: goto 1 + 12: goto 1 # live vars: $t0, $t2, $t3 # events: e:$t0, e:$t2, e:$t3 - 11: label L3 + 13: label L3 # live vars: - 12: return () + 14: return () } @@ -144,35 +168,43 @@ public fun m::test2($t0: u64, $t1: u64) { var $t3: bool var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: $t0, $t1 # events: b:$t0, b:$t1, e:$t1, b:$t2 0: $t2 := 0 # live vars: $t0, $t2 1: label L0 # live vars: $t0, $t2 - # events: b:$t3 - 2: $t3 := <($t2, $t0) + # events: b:$t4 + 2: $t4 := copy($t2) + # live vars: $t0, $t2, $t4 + # events: e:$t4, b:$t3 + 3: $t3 := <($t4, $t0) # live vars: $t0, $t2, $t3 # events: e:$t3 - 3: if ($t3) goto 4 else goto 9 + 4: if ($t3) goto 5 else goto 11 # live vars: $t0, $t2 - 4: label L2 + 5: label L2 # live vars: $t0, $t2 - # events: b:$t5 - 5: $t5 := 1 - # live vars: $t0, $t2, $t5 - # events: e:$t5, b:$t4 - 6: $t4 := +($t2, $t5) - # live vars: $t0, $t4 - # events: e:$t4 - 7: $t2 := move($t4) + # events: b:$t6 + 6: $t6 := move($t2) + # live vars: $t0, $t6 + # events: b:$t7 + 7: $t7 := 1 + # live vars: $t0, $t6, $t7 + # events: e:$t6, e:$t7, b:$t5 + 8: $t5 := +($t6, $t7) + # live vars: $t0, $t5 + # events: e:$t5 + 9: $t2 := move($t5) # live vars: $t0, $t2 - 8: goto 1 + 10: goto 1 # live vars: $t0, $t2 # events: e:$t0, e:$t2 - 9: label L3 + 11: label L3 # live vars: - 10: return () + 12: return () } ============ after VariableCoalescingTransformer: ================ @@ -181,21 +213,25 @@ public fun m::test2($t0: u64, $t1: u64) { public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t3: u64 var $t4: bool - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t3 := 0 1: label L0 - 2: $t4 := <($t3, $t0) - 3: if ($t4) goto 4 else goto 11 - 4: label L2 - 5: $t1 := move($t2) - 6: $t2 := move($t1) - 7: $t1 := 1 - 8: $t1 := +($t3, $t1) - 9: $t3 := move($t1) - 10: goto 1 - 11: label L3 - 12: return () + 2: $t5 := copy($t3) + 3: $t4 := <($t5, $t0) + 4: if ($t4) goto 5 else goto 13 + 5: label L2 + 6: $t1 := move($t2) + 7: $t2 := move($t1) + 8: $t1 := move($t3) + 9: $t5 := 1 + 10: $t1 := +($t1, $t5) + 11: $t3 := move($t1) + 12: goto 1 + 13: label L3 + 14: return () } @@ -203,19 +239,23 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { public fun m::test2($t0: u64, $t1: u64) { var $t2: u64 [unused] var $t3: bool - var $t4: u64 [unused] - var $t5: u64 + var $t4: u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 0: $t1 := 0 1: label L0 - 2: $t3 := <($t1, $t0) - 3: if ($t3) goto 4 else goto 9 - 4: label L2 - 5: $t5 := 1 - 6: $t5 := +($t1, $t5) - 7: $t1 := move($t5) - 8: goto 1 - 9: label L3 - 10: return () + 2: $t4 := copy($t1) + 3: $t3 := <($t4, $t0) + 4: if ($t3) goto 5 else goto 11 + 5: label L2 + 6: $t4 := move($t1) + 7: $t7 := 1 + 8: $t4 := +($t4, $t7) + 9: $t1 := move($t4) + 10: goto 1 + 11: label L3 + 12: return () } ============ after DeadStoreElimination: ================ @@ -224,21 +264,25 @@ public fun m::test2($t0: u64, $t1: u64) { public fun m::test1($t0: u64, $t1: u64, $t2: u64) { var $t3: u64 var $t4: bool - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t3 := 0 1: label L0 - 2: $t4 := <($t3, $t0) - 3: if ($t4) goto 4 else goto 11 - 4: label L2 - 5: $t1 := move($t2) - 6: $t2 := move($t1) - 7: $t1 := 1 - 8: $t1 := +($t3, $t1) - 9: $t3 := move($t1) - 10: goto 1 - 11: label L3 - 12: return () + 2: $t5 := copy($t3) + 3: $t4 := <($t5, $t0) + 4: if ($t4) goto 5 else goto 13 + 5: label L2 + 6: $t1 := move($t2) + 7: $t2 := move($t1) + 8: $t1 := move($t3) + 9: $t5 := 1 + 10: $t1 := +($t1, $t5) + 11: $t3 := move($t1) + 12: goto 1 + 13: label L3 + 14: return () } @@ -246,19 +290,23 @@ public fun m::test1($t0: u64, $t1: u64, $t2: u64) { public fun m::test2($t0: u64, $t1: u64) { var $t2: u64 [unused] var $t3: bool - var $t4: u64 [unused] - var $t5: u64 + var $t4: u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 0: $t1 := 0 1: label L0 - 2: $t3 := <($t1, $t0) - 3: if ($t3) goto 4 else goto 9 - 4: label L2 - 5: $t5 := 1 - 6: $t5 := +($t1, $t5) - 7: $t1 := move($t5) - 8: goto 1 - 9: label L3 - 10: return () + 2: $t4 := copy($t1) + 3: $t3 := <($t4, $t0) + 4: if ($t3) goto 5 else goto 11 + 5: label L2 + 6: $t4 := move($t1) + 7: $t7 := 1 + 8: $t4 := +($t4, $t7) + 9: $t1 := move($t4) + 10: goto 1 + 11: label L3 + 12: return () } @@ -276,20 +324,17 @@ B1: 2: CopyLoc[3](loc0: u64) 3: CopyLoc[0](Arg0: u64) 4: Lt - 5: BrFalse(13) + 5: BrFalse(11) B2: - 6: MoveLoc[2](Arg2: u64) - 7: MoveLoc[3](loc0: u64) - 8: LdU64(1) - 9: Add - 10: StLoc[3](loc0: u64) - 11: StLoc[2](Arg2: u64) - 12: Branch(2) + 6: MoveLoc[3](loc0: u64) + 7: LdU64(1) + 8: Add + 9: StLoc[3](loc0: u64) + 10: Branch(2) B3: - 13: Ret + 11: Ret } public test2(Arg0: u64, Arg1: u64) /* def_idx: 1 */ { -L2: loc0: u64 B0: 0: LdU64(0) 1: StLoc[1](Arg1: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_1.exp index 2cc99f49b4eab..7dd05bb58a5b3 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_1.exp @@ -65,7 +65,8 @@ fun m::dead($t0: u64): u64 { var $t1: u64 [unused] var $t2: u64 [unused] var $t3: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_1.opt.exp index 2cc99f49b4eab..7dd05bb58a5b3 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_1.opt.exp @@ -65,7 +65,8 @@ fun m::dead($t0: u64): u64 { var $t1: u64 [unused] var $t2: u64 [unused] var $t3: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_2.exp index ff4216c1abb91..351ca18eaaa97 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_2.exp @@ -44,7 +44,8 @@ fun m::dead($t0: u64): u64 { [variant baseline] fun m::dead($t0: u64): u64 { var $t1: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_2.opt.exp index ff4216c1abb91..351ca18eaaa97 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_2.opt.exp @@ -44,7 +44,8 @@ fun m::dead($t0: u64): u64 { [variant baseline] fun m::dead($t0: u64): u64 { var $t1: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_4.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_4.exp index 970a6b84ab094..e5d53fcb4a3b2 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_4.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_4.exp @@ -243,7 +243,8 @@ public fun m::test1(): u64 { public fun m::test2($t0: u64): u64 { var $t1: u64 [unused] var $t2: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_4.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_4.opt.exp index c4b4326890f8a..28520f67195bc 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_4.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/dead_assignment_4.opt.exp @@ -210,7 +210,8 @@ public fun m::test1(): u64 { public fun m::test2($t0: u64): u64 { var $t1: u64 [unused] var $t2: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.exp index 6d8197b4a1bcd..ab6be61985f7f 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.exp @@ -7,13 +7,17 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 + var $t6: u64 0: $t1 := 1 1: $t2 := 2 - 2: $t3 := +($t1, $t2) - 3: $t1 := infer($t3) - 4: $t4 := infer($t2) - 5: $t0 := +($t4, $t2) - 6: return $t0 + 2: $t4 := infer($t1) + 3: $t3 := +($t4, $t2) + 4: $t1 := infer($t3) + 5: $t5 := infer($t2) + 6: $t6 := infer($t5) + 7: $t0 := +($t6, $t2) + 8: return $t0 } @@ -33,12 +37,16 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 + var $t6: u64 0: $t1 := 1 1: $t2 := 2 - 2: $t3 := +($t1, $t2) - 3: $t4 := copy($t2) - 4: $t0 := +($t4, $t2) - 5: return $t0 + 2: $t4 := move($t1) + 3: $t3 := +($t4, $t2) + 4: $t5 := copy($t2) + 5: $t6 := move($t5) + 6: $t0 := +($t6, $t2) + 7: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -50,6 +58,8 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 + var $t6: u64 # live vars: # events: b:$t1 0: $t1 := 1 @@ -57,17 +67,23 @@ fun m::test(): u64 { # events: b:$t2 1: $t2 := 2 # live vars: $t1, $t2 - # events: e:$t1, e:$t3, b:$t3 - 2: $t3 := +($t1, $t2) - # live vars: $t2 - # events: b:$t4 - 3: $t4 := copy($t2) + # events: e:$t1, b:$t4 + 2: $t4 := move($t1) # live vars: $t2, $t4 - # events: e:$t2, e:$t4, b:$t0 - 4: $t0 := +($t4, $t2) + # events: e:$t3, e:$t4, b:$t3 + 3: $t3 := +($t4, $t2) + # live vars: $t2 + # events: b:$t5 + 4: $t5 := copy($t2) + # live vars: $t2, $t5 + # events: e:$t5, b:$t6 + 5: $t6 := move($t5) + # live vars: $t2, $t6 + # events: e:$t2, e:$t6, b:$t0 + 6: $t0 := +($t6, $t2) # live vars: $t0 # events: e:$t0 - 5: return $t0 + 7: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -79,12 +95,16 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] + var $t5: u64 [unused] + var $t6: u64 [unused] 0: $t1 := 1 1: $t2 := 2 - 2: $t1 := +($t1, $t2) - 3: $t3 := copy($t2) - 4: $t2 := +($t3, $t2) - 5: return $t2 + 2: $t1 := move($t1) + 3: $t1 := +($t1, $t2) + 4: $t3 := copy($t2) + 5: $t3 := move($t3) + 6: $t2 := +($t3, $t2) + 7: return $t2 } ============ after DeadStoreElimination: ================ @@ -96,6 +116,8 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] + var $t5: u64 [unused] + var $t6: u64 [unused] 0: $t1 := 1 1: $t2 := 2 2: $t1 := +($t1, $t2) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.opt.exp index 1dc1eb6f44cd7..c510bcdf05fe1 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_1.opt.exp @@ -6,12 +6,14 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: $t1 := 1 - 1: $t3 := 2 - 2: $t2 := +($t1, $t3) - 3: $t1 := infer($t2) - 4: $t0 := 4 - 5: return $t0 + 1: $t3 := infer($t1) + 2: $t4 := 2 + 3: $t2 := +($t3, $t4) + 4: $t1 := infer($t2) + 5: $t0 := 4 + 6: return $t0 } @@ -30,11 +32,13 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: $t1 := 1 - 1: $t3 := 2 - 2: $t2 := +($t1, $t3) - 3: $t0 := 4 - 4: return $t0 + 1: $t3 := move($t1) + 2: $t4 := 2 + 3: $t2 := +($t3, $t4) + 4: $t0 := 4 + 5: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -45,21 +49,25 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 # live vars: # events: b:$t1 0: $t1 := 1 # live vars: $t1 - # events: b:$t3 - 1: $t3 := 2 - # live vars: $t1, $t3 - # events: e:$t1, e:$t2, e:$t3, b:$t2 - 2: $t2 := +($t1, $t3) + # events: e:$t1, b:$t3 + 1: $t3 := move($t1) + # live vars: $t3 + # events: b:$t4 + 2: $t4 := 2 + # live vars: $t3, $t4 + # events: e:$t2, e:$t3, e:$t4, b:$t2 + 3: $t2 := +($t3, $t4) # live vars: # events: b:$t0 - 3: $t0 := 4 + 4: $t0 := 4 # live vars: $t0 # events: e:$t0 - 4: return $t0 + 5: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -69,12 +77,14 @@ fun m::test(): u64 { var $t0: u64 [unused] var $t1: u64 var $t2: u64 - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 0: $t1 := 1 - 1: $t3 := 2 - 2: $t1 := +($t1, $t3) - 3: $t2 := 4 - 4: return $t2 + 1: $t1 := move($t1) + 2: $t4 := 2 + 3: $t1 := +($t1, $t4) + 4: $t2 := 4 + 5: return $t2 } ============ after DeadStoreElimination: ================ @@ -84,10 +94,11 @@ fun m::test(): u64 { var $t0: u64 [unused] var $t1: u64 var $t2: u64 - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 0: $t1 := 1 - 1: $t3 := 2 - 2: $t1 := +($t1, $t3) + 1: $t4 := 2 + 2: $t1 := +($t1, $t4) 3: $t2 := 4 4: return $t2 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.exp index c1d0ebf04aff7..f64720867bb98 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.exp @@ -8,14 +8,18 @@ fun m::test(): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t1 := 1 1: $t2 := 2 - 2: $t4 := 1 - 3: $t3 := +($t1, $t4) - 4: $t1 := infer($t3) - 5: $t5 := infer($t2) - 6: $t0 := +($t5, $t1) - 7: return $t0 + 2: $t4 := infer($t1) + 3: $t5 := 1 + 4: $t3 := +($t4, $t5) + 5: $t1 := infer($t3) + 6: $t6 := infer($t2) + 7: $t7 := infer($t6) + 8: $t0 := +($t7, $t1) + 9: return $t0 } ============ after DeadStoreElimination: ================ @@ -28,14 +32,18 @@ fun m::test(): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t1 := 1 1: $t2 := 2 - 2: $t4 := 1 - 3: $t3 := +($t1, $t4) - 4: $t1 := move($t3) - 5: $t5 := move($t2) - 6: $t0 := +($t5, $t1) - 7: return $t0 + 2: $t4 := move($t1) + 3: $t5 := 1 + 4: $t3 := +($t4, $t5) + 5: $t1 := move($t3) + 6: $t6 := move($t2) + 7: $t7 := move($t6) + 8: $t0 := +($t7, $t1) + 9: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -48,6 +56,8 @@ fun m::test(): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: # events: b:$t1 0: $t1 := 1 @@ -56,22 +66,28 @@ fun m::test(): u64 { 1: $t2 := 2 # live vars: $t1, $t2 # events: b:$t4 - 2: $t4 := 1 - # live vars: $t1, $t2, $t4 - # events: e:$t4, b:$t3 - 3: $t3 := +($t1, $t4) + 2: $t4 := move($t1) + # live vars: $t2, $t4 + # events: b:$t5 + 3: $t5 := 1 + # live vars: $t2, $t4, $t5 + # events: e:$t4, e:$t5, b:$t3 + 4: $t3 := +($t4, $t5) # live vars: $t2, $t3 # events: e:$t3 - 4: $t1 := move($t3) + 5: $t1 := move($t3) # live vars: $t1, $t2 - # events: e:$t2, b:$t5 - 5: $t5 := move($t2) - # live vars: $t1, $t5 - # events: e:$t1, e:$t5, b:$t0 - 6: $t0 := +($t5, $t1) + # events: e:$t2, b:$t6 + 6: $t6 := move($t2) + # live vars: $t1, $t6 + # events: e:$t6, b:$t7 + 7: $t7 := move($t6) + # live vars: $t1, $t7 + # events: e:$t1, e:$t7, b:$t0 + 8: $t0 := +($t7, $t1) # live vars: $t0 # events: e:$t0 - 7: return $t0 + 9: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -83,15 +99,19 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 [unused] var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 + var $t6: u64 [unused] + var $t7: u64 [unused] 0: $t1 := 1 1: $t2 := 2 - 2: $t4 := 1 - 3: $t4 := +($t1, $t4) - 4: $t1 := move($t4) - 5: $t2 := move($t2) - 6: $t1 := +($t2, $t1) - 7: return $t1 + 2: $t4 := move($t1) + 3: $t5 := 1 + 4: $t4 := +($t4, $t5) + 5: $t1 := move($t4) + 6: $t2 := move($t2) + 7: $t2 := move($t2) + 8: $t1 := +($t2, $t1) + 9: return $t1 } ============ after DeadStoreElimination: ================ @@ -103,14 +123,17 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 [unused] var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 + var $t6: u64 [unused] + var $t7: u64 [unused] 0: $t1 := 1 1: $t2 := 2 - 2: $t4 := 1 - 3: $t4 := +($t1, $t4) - 4: $t1 := move($t4) - 5: $t1 := +($t2, $t1) - 6: return $t1 + 2: $t4 := move($t1) + 3: $t5 := 1 + 4: $t4 := +($t4, $t5) + 5: $t1 := move($t4) + 6: $t1 := +($t2, $t1) + 7: return $t1 } @@ -121,17 +144,13 @@ module c0ffee.m { test(): u64 /* def_idx: 0 */ { L0: loc0: u64 -L1: loc1: u64 -L2: loc2: u64 B0: - 0: LdU64(1) + 0: LdU64(2) 1: LdU64(1) - 2: Add - 3: StLoc[2](loc2: u64) - 4: LdU64(2) - 5: MoveLoc[2](loc2: u64) - 6: Add - 7: Ret + 2: LdU64(1) + 3: Add + 4: Add + 5: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.opt.exp index 6eb72ab89b2c0..bc0c54da967d8 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_2.opt.exp @@ -7,13 +7,15 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 0: $t1 := 1 - 1: $t3 := 1 - 2: $t2 := +($t1, $t3) - 3: $t1 := infer($t2) - 4: $t4 := 2 - 5: $t0 := +($t4, $t1) - 6: return $t0 + 1: $t3 := infer($t1) + 2: $t4 := 1 + 3: $t2 := +($t3, $t4) + 4: $t1 := infer($t2) + 5: $t5 := 2 + 6: $t0 := +($t5, $t1) + 7: return $t0 } ============ after DeadStoreElimination: ================ @@ -25,13 +27,15 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 0: $t1 := 1 - 1: $t3 := 1 - 2: $t2 := +($t1, $t3) - 3: $t1 := move($t2) - 4: $t4 := 2 - 5: $t0 := +($t4, $t1) - 6: return $t0 + 1: $t3 := move($t1) + 2: $t4 := 1 + 3: $t2 := +($t3, $t4) + 4: $t1 := move($t2) + 5: $t5 := 2 + 6: $t0 := +($t5, $t1) + 7: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -43,27 +47,31 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 # live vars: # events: b:$t1 0: $t1 := 1 # live vars: $t1 # events: b:$t3 - 1: $t3 := 1 - # live vars: $t1, $t3 - # events: e:$t3, b:$t2 - 2: $t2 := +($t1, $t3) + 1: $t3 := move($t1) + # live vars: $t3 + # events: b:$t4 + 2: $t4 := 1 + # live vars: $t3, $t4 + # events: e:$t3, e:$t4, b:$t2 + 3: $t2 := +($t3, $t4) # live vars: $t2 # events: e:$t2 - 3: $t1 := move($t2) + 4: $t1 := move($t2) # live vars: $t1 - # events: b:$t4 - 4: $t4 := 2 - # live vars: $t1, $t4 - # events: e:$t1, e:$t4, b:$t0 - 5: $t0 := +($t4, $t1) + # events: b:$t5 + 5: $t5 := 2 + # live vars: $t1, $t5 + # events: e:$t1, e:$t5, b:$t0 + 6: $t0 := +($t5, $t1) # live vars: $t0 # events: e:$t0 - 6: return $t0 + 7: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -74,14 +82,16 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 [unused] var $t3: u64 - var $t4: u64 [unused] + var $t4: u64 + var $t5: u64 [unused] 0: $t1 := 1 - 1: $t3 := 1 - 2: $t3 := +($t1, $t3) - 3: $t1 := move($t3) - 4: $t3 := 2 - 5: $t1 := +($t3, $t1) - 6: return $t1 + 1: $t3 := move($t1) + 2: $t4 := 1 + 3: $t3 := +($t3, $t4) + 4: $t1 := move($t3) + 5: $t3 := 2 + 6: $t1 := +($t3, $t1) + 7: return $t1 } ============ after DeadStoreElimination: ================ @@ -92,14 +102,16 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 [unused] var $t3: u64 - var $t4: u64 [unused] + var $t4: u64 + var $t5: u64 [unused] 0: $t1 := 1 - 1: $t3 := 1 - 2: $t3 := +($t1, $t3) - 3: $t1 := move($t3) - 4: $t3 := 2 - 5: $t1 := +($t3, $t1) - 6: return $t1 + 1: $t3 := move($t1) + 2: $t4 := 1 + 3: $t3 := +($t3, $t4) + 4: $t1 := move($t3) + 5: $t3 := 2 + 6: $t1 := +($t3, $t1) + 7: return $t1 } @@ -110,14 +122,13 @@ module c0ffee.m { test(): u64 /* def_idx: 0 */ { L0: loc0: u64 -L1: loc1: u64 B0: 0: LdU64(1) 1: LdU64(1) 2: Add - 3: StLoc[1](loc1: u64) + 3: StLoc[0](loc0: u64) 4: LdU64(2) - 5: MoveLoc[1](loc1: u64) + 5: MoveLoc[0](loc0: u64) 6: Add 7: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_3.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_3.exp index bdbed18eca8eb..50896e93a95a3 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_3.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_3.exp @@ -8,14 +8,16 @@ fun m::test(): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t1 := 1 1: $t2 := 2 - 2: $t4 := 1 - 3: $t3 := +($t1, $t4) - 4: $t1 := infer($t3) - 5: $t5 := infer($t2) - 6: $t0 := infer($t5) - 7: return $t0 + 2: $t4 := infer($t1) + 3: $t5 := 1 + 4: $t3 := +($t4, $t5) + 5: $t1 := infer($t3) + 6: $t6 := infer($t2) + 7: $t0 := infer($t6) + 8: return $t0 } @@ -36,13 +38,15 @@ fun m::test(): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: $t1 := 1 1: $t2 := 2 - 2: $t4 := 1 - 3: $t3 := +($t1, $t4) - 4: $t5 := move($t2) - 5: $t0 := move($t5) - 6: return $t0 + 2: $t4 := move($t1) + 3: $t5 := 1 + 4: $t3 := +($t4, $t5) + 5: $t6 := move($t2) + 6: $t0 := move($t6) + 7: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -55,6 +59,7 @@ fun m::test(): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 # live vars: # events: b:$t1 0: $t1 := 1 @@ -62,20 +67,23 @@ fun m::test(): u64 { # events: b:$t2 1: $t2 := 2 # live vars: $t1, $t2 - # events: b:$t4 - 2: $t4 := 1 - # live vars: $t1, $t2, $t4 - # events: e:$t1, e:$t3, e:$t4, b:$t3 - 3: $t3 := +($t1, $t4) + # events: e:$t1, b:$t4 + 2: $t4 := move($t1) + # live vars: $t2, $t4 + # events: b:$t5 + 3: $t5 := 1 + # live vars: $t2, $t4, $t5 + # events: e:$t3, e:$t4, e:$t5, b:$t3 + 4: $t3 := +($t4, $t5) # live vars: $t2 - # events: e:$t2, b:$t5 - 4: $t5 := move($t2) - # live vars: $t5 - # events: e:$t5, b:$t0 - 5: $t0 := move($t5) + # events: e:$t2, b:$t6 + 5: $t6 := move($t2) + # live vars: $t6 + # events: e:$t6, b:$t0 + 6: $t0 := move($t6) # live vars: $t0 # events: e:$t0 - 6: return $t0 + 7: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -86,15 +94,17 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 [unused] - var $t4: u64 - var $t5: u64 [unused] + var $t4: u64 [unused] + var $t5: u64 + var $t6: u64 [unused] 0: $t1 := 1 1: $t2 := 2 - 2: $t4 := 1 - 3: $t1 := +($t1, $t4) - 4: $t2 := move($t2) + 2: $t1 := move($t1) + 3: $t5 := 1 + 4: $t1 := +($t1, $t5) 5: $t2 := move($t2) - 6: return $t2 + 6: $t2 := move($t2) + 7: return $t2 } ============ after DeadStoreElimination: ================ @@ -105,12 +115,13 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 [unused] - var $t4: u64 - var $t5: u64 [unused] + var $t4: u64 [unused] + var $t5: u64 + var $t6: u64 [unused] 0: $t1 := 1 1: $t2 := 2 - 2: $t4 := 1 - 3: $t1 := +($t1, $t4) + 2: $t5 := 1 + 3: $t1 := +($t1, $t5) 4: return $t2 } @@ -123,13 +134,12 @@ module c0ffee.m { test(): u64 /* def_idx: 0 */ { L0: loc0: u64 L1: loc1: u64 -L2: loc2: u64 B0: - 0: LdU64(1) + 0: LdU64(2) 1: LdU64(1) - 2: Add - 3: Pop - 4: LdU64(2) + 2: LdU64(1) + 3: Add + 4: Pop 5: Ret } } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_3.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_3.opt.exp index 5bdf9150dff2d..18270e0d1f323 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_3.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/intermingled_3.opt.exp @@ -6,12 +6,14 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: $t1 := 1 - 1: $t3 := 1 - 2: $t2 := +($t1, $t3) - 3: $t1 := infer($t2) - 4: $t0 := 2 - 5: return $t0 + 1: $t3 := infer($t1) + 2: $t4 := 1 + 3: $t2 := +($t3, $t4) + 4: $t1 := infer($t2) + 5: $t0 := 2 + 6: return $t0 } @@ -30,11 +32,13 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: $t1 := 1 - 1: $t3 := 1 - 2: $t2 := +($t1, $t3) - 3: $t0 := 2 - 4: return $t0 + 1: $t3 := move($t1) + 2: $t4 := 1 + 3: $t2 := +($t3, $t4) + 4: $t0 := 2 + 5: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -45,21 +49,25 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 # live vars: # events: b:$t1 0: $t1 := 1 # live vars: $t1 - # events: b:$t3 - 1: $t3 := 1 - # live vars: $t1, $t3 - # events: e:$t1, e:$t2, e:$t3, b:$t2 - 2: $t2 := +($t1, $t3) + # events: e:$t1, b:$t3 + 1: $t3 := move($t1) + # live vars: $t3 + # events: b:$t4 + 2: $t4 := 1 + # live vars: $t3, $t4 + # events: e:$t2, e:$t3, e:$t4, b:$t2 + 3: $t2 := +($t3, $t4) # live vars: # events: b:$t0 - 3: $t0 := 2 + 4: $t0 := 2 # live vars: $t0 # events: e:$t0 - 4: return $t0 + 5: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -69,12 +77,14 @@ fun m::test(): u64 { var $t0: u64 [unused] var $t1: u64 var $t2: u64 - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 0: $t1 := 1 - 1: $t3 := 1 - 2: $t1 := +($t1, $t3) - 3: $t2 := 2 - 4: return $t2 + 1: $t1 := move($t1) + 2: $t4 := 1 + 3: $t1 := +($t1, $t4) + 4: $t2 := 2 + 5: return $t2 } ============ after DeadStoreElimination: ================ @@ -84,10 +94,11 @@ fun m::test(): u64 { var $t0: u64 [unused] var $t1: u64 var $t2: u64 - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 0: $t1 := 1 - 1: $t3 := 1 - 2: $t1 := +($t1, $t3) + 1: $t4 := 1 + 2: $t1 := +($t1, $t4) 3: $t2 := 2 4: return $t2 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.exp index b8c4d57d833a0..41fb4d41dddfe 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.exp @@ -9,25 +9,29 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := infer($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := infer($t6) - 11: goto 14 - 12: label L3 + 3: $t5 := infer($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := infer($t0) + 9: $t8 := infer($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := infer($t7) 13: goto 16 - 14: label L4 - 15: goto 2 - 16: label L1 - 17: $t1 := infer($t2) - 18: return $t1 + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 2 + 18: label L1 + 19: $t1 := infer($t2) + 20: return $t1 } ============ after DeadStoreElimination: ================ @@ -41,21 +45,25 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := move($t6) - 11: goto 2 - 12: label L3 - 13: $t1 := move($t2) - 14: return $t1 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t8 := move($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := move($t7) + 13: goto 2 + 14: label L3 + 15: $t1 := move($t2) + 16: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -69,6 +77,8 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := 0 @@ -79,37 +89,43 @@ fun m::test($t0: u64): u64 { 2: label L0 # live vars: $t0, $t2, $t3 # events: b:$t5 - 3: $t5 := 10 + 3: $t5 := copy($t3) # live vars: $t0, $t2, $t3, $t5 - # events: e:$t5, b:$t4 - 4: $t4 := <($t3, $t5) + # events: b:$t6 + 4: $t6 := 10 + # live vars: $t0, $t2, $t3, $t5, $t6 + # events: e:$t5, e:$t6, b:$t4 + 5: $t4 := <($t5, $t6) # live vars: $t0, $t2, $t3, $t4 # events: e:$t4 - 5: if ($t4) goto 6 else goto 12 + 6: if ($t4) goto 7 else goto 14 # live vars: $t0, $t2, $t3 - 6: label L2 + 7: label L2 # live vars: $t0, $t3 - 7: $t2 := copy($t0) + 8: $t2 := copy($t0) # live vars: $t0, $t2, $t3 - # events: b:$t7 - 8: $t7 := 1 - # live vars: $t0, $t2, $t3, $t7 - # events: e:$t7, b:$t6 - 9: $t6 := +($t3, $t7) - # live vars: $t0, $t2, $t6 - # events: e:$t6 - 10: $t3 := move($t6) + # events: b:$t8 + 9: $t8 := move($t3) + # live vars: $t0, $t2, $t8 + # events: b:$t9 + 10: $t9 := 1 + # live vars: $t0, $t2, $t8, $t9 + # events: e:$t8, e:$t9, b:$t7 + 11: $t7 := +($t8, $t9) + # live vars: $t0, $t2, $t7 + # events: e:$t7 + 12: $t3 := move($t7) # live vars: $t0, $t2, $t3 - 11: goto 2 + 13: goto 2 # live vars: $t0, $t2, $t3 # events: e:$t0, e:$t3 - 12: label L3 + 14: label L3 # live vars: $t2 # events: e:$t2, b:$t1 - 13: $t1 := move($t2) + 15: $t1 := move($t2) # live vars: $t1 # events: e:$t1 - 14: return $t1 + 16: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -121,23 +137,27 @@ fun m::test($t0: u64): u64 { var $t3: u64 var $t4: bool var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t5 := 1 - 9: $t5 := +($t3, $t5) - 10: $t3 := move($t5) - 11: goto 2 - 12: label L3 - 13: $t2 := move($t2) - 14: return $t2 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t5 := move($t3) + 10: $t6 := 1 + 11: $t5 := +($t5, $t6) + 12: $t3 := move($t5) + 13: goto 2 + 14: label L3 + 15: $t2 := move($t2) + 16: return $t2 } ============ after DeadStoreElimination: ================ @@ -149,22 +169,27 @@ fun m::test($t0: u64): u64 { var $t3: u64 var $t4: bool var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t5 := 1 - 9: $t5 := +($t3, $t5) - 10: $t3 := move($t5) - 11: goto 2 - 12: label L3 - 13: return $t2 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t5 := move($t3) + 10: $t6 := 1 + 11: $t5 := +($t5, $t6) + 12: $t3 := move($t5) + 13: goto 2 + 14: label L3 + 15: $t2 := move($t2) + 16: return $t2 } @@ -176,7 +201,6 @@ module c0ffee.m { test(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) @@ -189,11 +213,11 @@ B1: 7: BrFalse(15) B2: 8: CopyLoc[0](Arg0: u64) - 9: MoveLoc[2](loc1: u64) - 10: LdU64(1) - 11: Add - 12: StLoc[2](loc1: u64) - 13: StLoc[1](loc0: u64) + 9: StLoc[1](loc0: u64) + 10: MoveLoc[2](loc1: u64) + 11: LdU64(1) + 12: Add + 13: StLoc[2](loc1: u64) 14: Branch(4) B3: 15: MoveLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.opt.exp index b8c4d57d833a0..41fb4d41dddfe 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_1.opt.exp @@ -9,25 +9,29 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := infer($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := infer($t6) - 11: goto 14 - 12: label L3 + 3: $t5 := infer($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := infer($t0) + 9: $t8 := infer($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := infer($t7) 13: goto 16 - 14: label L4 - 15: goto 2 - 16: label L1 - 17: $t1 := infer($t2) - 18: return $t1 + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 2 + 18: label L1 + 19: $t1 := infer($t2) + 20: return $t1 } ============ after DeadStoreElimination: ================ @@ -41,21 +45,25 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := move($t6) - 11: goto 2 - 12: label L3 - 13: $t1 := move($t2) - 14: return $t1 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t8 := move($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := move($t7) + 13: goto 2 + 14: label L3 + 15: $t1 := move($t2) + 16: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -69,6 +77,8 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := 0 @@ -79,37 +89,43 @@ fun m::test($t0: u64): u64 { 2: label L0 # live vars: $t0, $t2, $t3 # events: b:$t5 - 3: $t5 := 10 + 3: $t5 := copy($t3) # live vars: $t0, $t2, $t3, $t5 - # events: e:$t5, b:$t4 - 4: $t4 := <($t3, $t5) + # events: b:$t6 + 4: $t6 := 10 + # live vars: $t0, $t2, $t3, $t5, $t6 + # events: e:$t5, e:$t6, b:$t4 + 5: $t4 := <($t5, $t6) # live vars: $t0, $t2, $t3, $t4 # events: e:$t4 - 5: if ($t4) goto 6 else goto 12 + 6: if ($t4) goto 7 else goto 14 # live vars: $t0, $t2, $t3 - 6: label L2 + 7: label L2 # live vars: $t0, $t3 - 7: $t2 := copy($t0) + 8: $t2 := copy($t0) # live vars: $t0, $t2, $t3 - # events: b:$t7 - 8: $t7 := 1 - # live vars: $t0, $t2, $t3, $t7 - # events: e:$t7, b:$t6 - 9: $t6 := +($t3, $t7) - # live vars: $t0, $t2, $t6 - # events: e:$t6 - 10: $t3 := move($t6) + # events: b:$t8 + 9: $t8 := move($t3) + # live vars: $t0, $t2, $t8 + # events: b:$t9 + 10: $t9 := 1 + # live vars: $t0, $t2, $t8, $t9 + # events: e:$t8, e:$t9, b:$t7 + 11: $t7 := +($t8, $t9) + # live vars: $t0, $t2, $t7 + # events: e:$t7 + 12: $t3 := move($t7) # live vars: $t0, $t2, $t3 - 11: goto 2 + 13: goto 2 # live vars: $t0, $t2, $t3 # events: e:$t0, e:$t3 - 12: label L3 + 14: label L3 # live vars: $t2 # events: e:$t2, b:$t1 - 13: $t1 := move($t2) + 15: $t1 := move($t2) # live vars: $t1 # events: e:$t1 - 14: return $t1 + 16: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -121,23 +137,27 @@ fun m::test($t0: u64): u64 { var $t3: u64 var $t4: bool var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t5 := 1 - 9: $t5 := +($t3, $t5) - 10: $t3 := move($t5) - 11: goto 2 - 12: label L3 - 13: $t2 := move($t2) - 14: return $t2 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t5 := move($t3) + 10: $t6 := 1 + 11: $t5 := +($t5, $t6) + 12: $t3 := move($t5) + 13: goto 2 + 14: label L3 + 15: $t2 := move($t2) + 16: return $t2 } ============ after DeadStoreElimination: ================ @@ -149,22 +169,27 @@ fun m::test($t0: u64): u64 { var $t3: u64 var $t4: bool var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: $t2 := 0 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t5 := 1 - 9: $t5 := +($t3, $t5) - 10: $t3 := move($t5) - 11: goto 2 - 12: label L3 - 13: return $t2 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t5 := move($t3) + 10: $t6 := 1 + 11: $t5 := +($t5, $t6) + 12: $t3 := move($t5) + 13: goto 2 + 14: label L3 + 15: $t2 := move($t2) + 16: return $t2 } @@ -176,7 +201,6 @@ module c0ffee.m { test(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) @@ -189,11 +213,11 @@ B1: 7: BrFalse(15) B2: 8: CopyLoc[0](Arg0: u64) - 9: MoveLoc[2](loc1: u64) - 10: LdU64(1) - 11: Add - 12: StLoc[2](loc1: u64) - 13: StLoc[1](loc0: u64) + 9: StLoc[1](loc0: u64) + 10: MoveLoc[2](loc1: u64) + 11: LdU64(1) + 12: Add + 13: StLoc[2](loc1: u64) 14: Branch(4) B3: 15: MoveLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.exp index 3334689dfa167..07402b30cdb90 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.exp @@ -9,25 +9,29 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := infer($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := infer($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := infer($t6) - 11: goto 14 - 12: label L3 + 3: $t5 := infer($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := infer($t0) + 9: $t8 := infer($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := infer($t7) 13: goto 16 - 14: label L4 - 15: goto 2 - 16: label L1 - 17: $t1 := infer($t2) - 18: return $t1 + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 2 + 18: label L1 + 19: $t1 := infer($t2) + 20: return $t1 } ============ after DeadStoreElimination: ================ @@ -41,21 +45,25 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := copy($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := move($t6) - 11: goto 2 - 12: label L3 - 13: $t1 := move($t2) - 14: return $t1 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t8 := move($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := move($t7) + 13: goto 2 + 14: label L3 + 15: $t1 := move($t2) + 16: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -69,6 +77,8 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) @@ -79,37 +89,43 @@ fun m::test($t0: u64): u64 { 2: label L0 # live vars: $t0, $t2, $t3 # events: b:$t5 - 3: $t5 := 10 + 3: $t5 := copy($t3) # live vars: $t0, $t2, $t3, $t5 - # events: e:$t5, b:$t4 - 4: $t4 := <($t3, $t5) + # events: b:$t6 + 4: $t6 := 10 + # live vars: $t0, $t2, $t3, $t5, $t6 + # events: e:$t5, e:$t6, b:$t4 + 5: $t4 := <($t5, $t6) # live vars: $t0, $t2, $t3, $t4 # events: e:$t4 - 5: if ($t4) goto 6 else goto 12 + 6: if ($t4) goto 7 else goto 14 # live vars: $t0, $t2, $t3 - 6: label L2 + 7: label L2 # live vars: $t0, $t3 - 7: $t2 := copy($t0) + 8: $t2 := copy($t0) # live vars: $t0, $t2, $t3 - # events: b:$t7 - 8: $t7 := 1 - # live vars: $t0, $t2, $t3, $t7 - # events: e:$t7, b:$t6 - 9: $t6 := +($t3, $t7) - # live vars: $t0, $t2, $t6 - # events: e:$t6 - 10: $t3 := move($t6) + # events: b:$t8 + 9: $t8 := move($t3) + # live vars: $t0, $t2, $t8 + # events: b:$t9 + 10: $t9 := 1 + # live vars: $t0, $t2, $t8, $t9 + # events: e:$t8, e:$t9, b:$t7 + 11: $t7 := +($t8, $t9) + # live vars: $t0, $t2, $t7 + # events: e:$t7 + 12: $t3 := move($t7) # live vars: $t0, $t2, $t3 - 11: goto 2 + 13: goto 2 # live vars: $t0, $t2, $t3 # events: e:$t0, e:$t3 - 12: label L3 + 14: label L3 # live vars: $t2 # events: e:$t2, b:$t1 - 13: $t1 := move($t2) + 15: $t1 := move($t2) # live vars: $t1 # events: e:$t1 - 14: return $t1 + 16: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -121,23 +137,27 @@ fun m::test($t0: u64): u64 { var $t3: u64 var $t4: bool var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t5 := 1 - 9: $t5 := +($t3, $t5) - 10: $t3 := move($t5) - 11: goto 2 - 12: label L3 - 13: $t2 := move($t2) - 14: return $t2 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t5 := move($t3) + 10: $t6 := 1 + 11: $t5 := +($t5, $t6) + 12: $t3 := move($t5) + 13: goto 2 + 14: label L3 + 15: $t2 := move($t2) + 16: return $t2 } ============ after DeadStoreElimination: ================ @@ -149,22 +169,27 @@ fun m::test($t0: u64): u64 { var $t3: u64 var $t4: bool var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t5 := 1 - 9: $t5 := +($t3, $t5) - 10: $t3 := move($t5) - 11: goto 2 - 12: label L3 - 13: return $t2 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t5 := move($t3) + 10: $t6 := 1 + 11: $t5 := +($t5, $t6) + 12: $t3 := move($t5) + 13: goto 2 + 14: label L3 + 15: $t2 := move($t2) + 16: return $t2 } @@ -176,27 +201,26 @@ module c0ffee.m { test(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: LdU64(0) - 2: StLoc[1](loc0: u64) + 1: StLoc[1](loc0: u64) + 2: LdU64(0) 3: StLoc[2](loc1: u64) B1: - 4: CopyLoc[1](loc0: u64) + 4: CopyLoc[2](loc1: u64) 5: LdU64(10) 6: Lt 7: BrFalse(15) B2: 8: CopyLoc[0](Arg0: u64) - 9: MoveLoc[1](loc0: u64) - 10: LdU64(1) - 11: Add - 12: StLoc[1](loc0: u64) + 9: StLoc[1](loc0: u64) + 10: MoveLoc[2](loc1: u64) + 11: LdU64(1) + 12: Add 13: StLoc[2](loc1: u64) 14: Branch(4) B3: - 15: MoveLoc[2](loc1: u64) + 15: MoveLoc[1](loc0: u64) 16: Ret } } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.opt.exp index 3334689dfa167..07402b30cdb90 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/loop_2.opt.exp @@ -9,25 +9,29 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := infer($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := infer($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := infer($t6) - 11: goto 14 - 12: label L3 + 3: $t5 := infer($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := infer($t0) + 9: $t8 := infer($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := infer($t7) 13: goto 16 - 14: label L4 - 15: goto 2 - 16: label L1 - 17: $t1 := infer($t2) - 18: return $t1 + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 2 + 18: label L1 + 19: $t1 := infer($t2) + 20: return $t1 } ============ after DeadStoreElimination: ================ @@ -41,21 +45,25 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 0: $t2 := copy($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t7 := 1 - 9: $t6 := +($t3, $t7) - 10: $t3 := move($t6) - 11: goto 2 - 12: label L3 - 13: $t1 := move($t2) - 14: return $t1 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t8 := move($t3) + 10: $t9 := 1 + 11: $t7 := +($t8, $t9) + 12: $t3 := move($t7) + 13: goto 2 + 14: label L3 + 15: $t1 := move($t2) + 16: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -69,6 +77,8 @@ fun m::test($t0: u64): u64 { var $t5: u64 var $t6: u64 var $t7: u64 + var $t8: u64 + var $t9: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) @@ -79,37 +89,43 @@ fun m::test($t0: u64): u64 { 2: label L0 # live vars: $t0, $t2, $t3 # events: b:$t5 - 3: $t5 := 10 + 3: $t5 := copy($t3) # live vars: $t0, $t2, $t3, $t5 - # events: e:$t5, b:$t4 - 4: $t4 := <($t3, $t5) + # events: b:$t6 + 4: $t6 := 10 + # live vars: $t0, $t2, $t3, $t5, $t6 + # events: e:$t5, e:$t6, b:$t4 + 5: $t4 := <($t5, $t6) # live vars: $t0, $t2, $t3, $t4 # events: e:$t4 - 5: if ($t4) goto 6 else goto 12 + 6: if ($t4) goto 7 else goto 14 # live vars: $t0, $t2, $t3 - 6: label L2 + 7: label L2 # live vars: $t0, $t3 - 7: $t2 := copy($t0) + 8: $t2 := copy($t0) # live vars: $t0, $t2, $t3 - # events: b:$t7 - 8: $t7 := 1 - # live vars: $t0, $t2, $t3, $t7 - # events: e:$t7, b:$t6 - 9: $t6 := +($t3, $t7) - # live vars: $t0, $t2, $t6 - # events: e:$t6 - 10: $t3 := move($t6) + # events: b:$t8 + 9: $t8 := move($t3) + # live vars: $t0, $t2, $t8 + # events: b:$t9 + 10: $t9 := 1 + # live vars: $t0, $t2, $t8, $t9 + # events: e:$t8, e:$t9, b:$t7 + 11: $t7 := +($t8, $t9) + # live vars: $t0, $t2, $t7 + # events: e:$t7 + 12: $t3 := move($t7) # live vars: $t0, $t2, $t3 - 11: goto 2 + 13: goto 2 # live vars: $t0, $t2, $t3 # events: e:$t0, e:$t3 - 12: label L3 + 14: label L3 # live vars: $t2 # events: e:$t2, b:$t1 - 13: $t1 := move($t2) + 15: $t1 := move($t2) # live vars: $t1 # events: e:$t1 - 14: return $t1 + 16: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -121,23 +137,27 @@ fun m::test($t0: u64): u64 { var $t3: u64 var $t4: bool var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t5 := 1 - 9: $t5 := +($t3, $t5) - 10: $t3 := move($t5) - 11: goto 2 - 12: label L3 - 13: $t2 := move($t2) - 14: return $t2 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t5 := move($t3) + 10: $t6 := 1 + 11: $t5 := +($t5, $t6) + 12: $t3 := move($t5) + 13: goto 2 + 14: label L3 + 15: $t2 := move($t2) + 16: return $t2 } ============ after DeadStoreElimination: ================ @@ -149,22 +169,27 @@ fun m::test($t0: u64): u64 { var $t3: u64 var $t4: bool var $t5: u64 - var $t6: u64 [unused] + var $t6: u64 var $t7: u64 [unused] + var $t8: u64 [unused] + var $t9: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := 0 2: label L0 - 3: $t5 := 10 - 4: $t4 := <($t3, $t5) - 5: if ($t4) goto 6 else goto 12 - 6: label L2 - 7: $t2 := copy($t0) - 8: $t5 := 1 - 9: $t5 := +($t3, $t5) - 10: $t3 := move($t5) - 11: goto 2 - 12: label L3 - 13: return $t2 + 3: $t5 := copy($t3) + 4: $t6 := 10 + 5: $t4 := <($t5, $t6) + 6: if ($t4) goto 7 else goto 14 + 7: label L2 + 8: $t2 := copy($t0) + 9: $t5 := move($t3) + 10: $t6 := 1 + 11: $t5 := +($t5, $t6) + 12: $t3 := move($t5) + 13: goto 2 + 14: label L3 + 15: $t2 := move($t2) + 16: return $t2 } @@ -176,27 +201,26 @@ module c0ffee.m { test(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) - 1: LdU64(0) - 2: StLoc[1](loc0: u64) + 1: StLoc[1](loc0: u64) + 2: LdU64(0) 3: StLoc[2](loc1: u64) B1: - 4: CopyLoc[1](loc0: u64) + 4: CopyLoc[2](loc1: u64) 5: LdU64(10) 6: Lt 7: BrFalse(15) B2: 8: CopyLoc[0](Arg0: u64) - 9: MoveLoc[1](loc0: u64) - 10: LdU64(1) - 11: Add - 12: StLoc[1](loc0: u64) + 9: StLoc[1](loc0: u64) + 10: MoveLoc[2](loc1: u64) + 11: LdU64(1) + 12: Add 13: StLoc[2](loc1: u64) 14: Branch(4) B3: - 15: MoveLoc[2](loc1: u64) + 15: MoveLoc[1](loc0: u64) 16: Ret } } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars1.exp index 0790b3db1cd47..02df37a49f25d 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars1.exp @@ -8,15 +8,19 @@ fun m::test() { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t1 := +($t0, $t2) - 3: $t0 := infer($t1) - 4: $t3 := 2 - 5: $t5 := 1 - 6: $t4 := +($t3, $t5) - 7: $t3 := infer($t4) - 8: return () + 1: $t2 := infer($t0) + 2: $t3 := 1 + 3: $t1 := +($t2, $t3) + 4: $t0 := infer($t1) + 5: $t4 := 2 + 6: $t6 := infer($t4) + 7: $t7 := 1 + 8: $t5 := +($t6, $t7) + 9: $t4 := infer($t5) + 10: return () } @@ -43,13 +47,17 @@ fun m::test() { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t1 := +($t0, $t2) - 3: $t3 := 2 - 4: $t5 := 1 - 5: $t4 := +($t3, $t5) - 6: return () + 1: $t2 := move($t0) + 2: $t3 := 1 + 3: $t1 := +($t2, $t3) + 4: $t4 := 2 + 5: $t6 := move($t4) + 6: $t7 := 1 + 7: $t5 := +($t6, $t7) + 8: return () } ============ after VariableCoalescingAnnotator: ================ @@ -62,26 +70,34 @@ fun m::test() { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: # events: b:$t0 0: $t0 := 1 # live vars: $t0 - # events: b:$t2 - 1: $t2 := 1 - # live vars: $t0, $t2 - # events: e:$t0, e:$t1, e:$t2, b:$t1 - 2: $t1 := +($t0, $t2) - # live vars: + # events: e:$t0, b:$t2 + 1: $t2 := move($t0) + # live vars: $t2 # events: b:$t3 - 3: $t3 := 2 - # live vars: $t3 - # events: b:$t5 - 4: $t5 := 1 - # live vars: $t3, $t5 - # events: e:$t3, e:$t4, e:$t5, b:$t4 - 5: $t4 := +($t3, $t5) + 2: $t3 := 1 + # live vars: $t2, $t3 + # events: e:$t1, e:$t2, e:$t3, b:$t1 + 3: $t1 := +($t2, $t3) # live vars: - 6: return () + # events: b:$t4 + 4: $t4 := 2 + # live vars: $t4 + # events: e:$t4, b:$t6 + 5: $t6 := move($t4) + # live vars: $t6 + # events: b:$t7 + 6: $t7 := 1 + # live vars: $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 7: $t5 := +($t6, $t7) + # live vars: + 8: return () } ============ after VariableCoalescingTransformer: ================ @@ -90,17 +106,21 @@ fun m::test() { fun m::test() { var $t0: u64 var $t1: u64 - var $t2: u64 - var $t3: u64 [unused] + var $t2: u64 [unused] + var $t3: u64 var $t4: u64 [unused] var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 [unused] 0: $t0 := 1 - 1: $t2 := 1 - 2: $t0 := +($t0, $t2) - 3: $t1 := 2 - 4: $t2 := 1 - 5: $t1 := +($t1, $t2) - 6: return () + 1: $t0 := move($t0) + 2: $t3 := 1 + 3: $t0 := +($t0, $t3) + 4: $t1 := 2 + 5: $t1 := move($t1) + 6: $t3 := 1 + 7: $t1 := +($t1, $t3) + 8: return () } ============ after DeadStoreElimination: ================ @@ -109,16 +129,18 @@ fun m::test() { fun m::test() { var $t0: u64 var $t1: u64 - var $t2: u64 - var $t3: u64 [unused] + var $t2: u64 [unused] + var $t3: u64 var $t4: u64 [unused] var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 [unused] 0: $t0 := 1 - 1: $t2 := 1 - 2: $t0 := +($t0, $t2) + 1: $t3 := 1 + 2: $t0 := +($t0, $t3) 3: $t1 := 2 - 4: $t2 := 1 - 5: $t1 := +($t1, $t2) + 4: $t3 := 1 + 5: $t1 := +($t1, $t3) 6: return () } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars1.opt.exp index 0790b3db1cd47..02df37a49f25d 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars1.opt.exp @@ -8,15 +8,19 @@ fun m::test() { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t1 := +($t0, $t2) - 3: $t0 := infer($t1) - 4: $t3 := 2 - 5: $t5 := 1 - 6: $t4 := +($t3, $t5) - 7: $t3 := infer($t4) - 8: return () + 1: $t2 := infer($t0) + 2: $t3 := 1 + 3: $t1 := +($t2, $t3) + 4: $t0 := infer($t1) + 5: $t4 := 2 + 6: $t6 := infer($t4) + 7: $t7 := 1 + 8: $t5 := +($t6, $t7) + 9: $t4 := infer($t5) + 10: return () } @@ -43,13 +47,17 @@ fun m::test() { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t1 := +($t0, $t2) - 3: $t3 := 2 - 4: $t5 := 1 - 5: $t4 := +($t3, $t5) - 6: return () + 1: $t2 := move($t0) + 2: $t3 := 1 + 3: $t1 := +($t2, $t3) + 4: $t4 := 2 + 5: $t6 := move($t4) + 6: $t7 := 1 + 7: $t5 := +($t6, $t7) + 8: return () } ============ after VariableCoalescingAnnotator: ================ @@ -62,26 +70,34 @@ fun m::test() { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: # events: b:$t0 0: $t0 := 1 # live vars: $t0 - # events: b:$t2 - 1: $t2 := 1 - # live vars: $t0, $t2 - # events: e:$t0, e:$t1, e:$t2, b:$t1 - 2: $t1 := +($t0, $t2) - # live vars: + # events: e:$t0, b:$t2 + 1: $t2 := move($t0) + # live vars: $t2 # events: b:$t3 - 3: $t3 := 2 - # live vars: $t3 - # events: b:$t5 - 4: $t5 := 1 - # live vars: $t3, $t5 - # events: e:$t3, e:$t4, e:$t5, b:$t4 - 5: $t4 := +($t3, $t5) + 2: $t3 := 1 + # live vars: $t2, $t3 + # events: e:$t1, e:$t2, e:$t3, b:$t1 + 3: $t1 := +($t2, $t3) # live vars: - 6: return () + # events: b:$t4 + 4: $t4 := 2 + # live vars: $t4 + # events: e:$t4, b:$t6 + 5: $t6 := move($t4) + # live vars: $t6 + # events: b:$t7 + 6: $t7 := 1 + # live vars: $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 7: $t5 := +($t6, $t7) + # live vars: + 8: return () } ============ after VariableCoalescingTransformer: ================ @@ -90,17 +106,21 @@ fun m::test() { fun m::test() { var $t0: u64 var $t1: u64 - var $t2: u64 - var $t3: u64 [unused] + var $t2: u64 [unused] + var $t3: u64 var $t4: u64 [unused] var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 [unused] 0: $t0 := 1 - 1: $t2 := 1 - 2: $t0 := +($t0, $t2) - 3: $t1 := 2 - 4: $t2 := 1 - 5: $t1 := +($t1, $t2) - 6: return () + 1: $t0 := move($t0) + 2: $t3 := 1 + 3: $t0 := +($t0, $t3) + 4: $t1 := 2 + 5: $t1 := move($t1) + 6: $t3 := 1 + 7: $t1 := +($t1, $t3) + 8: return () } ============ after DeadStoreElimination: ================ @@ -109,16 +129,18 @@ fun m::test() { fun m::test() { var $t0: u64 var $t1: u64 - var $t2: u64 - var $t3: u64 [unused] + var $t2: u64 [unused] + var $t3: u64 var $t4: u64 [unused] var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 [unused] 0: $t0 := 1 - 1: $t2 := 1 - 2: $t0 := +($t0, $t2) + 1: $t3 := 1 + 2: $t0 := +($t0, $t3) 3: $t1 := 2 - 4: $t2 := 1 - 5: $t1 := +($t1, $t2) + 4: $t3 := 1 + 5: $t1 := +($t1, $t3) 6: return () } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars_diff_type.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars_diff_type.exp index 631c697bc491e..84ab65613679c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars_diff_type.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars_diff_type.exp @@ -5,18 +5,22 @@ fun m::test() { var $t0: u32 var $t1: u32 var $t2: u32 - var $t3: u64 + var $t3: u32 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t1 := +($t0, $t2) - 3: $t0 := infer($t1) - 4: $t3 := 2 - 5: $t5 := 1 - 6: $t4 := +($t3, $t5) - 7: $t3 := infer($t4) - 8: return () + 1: $t2 := infer($t0) + 2: $t3 := 1 + 3: $t1 := +($t2, $t3) + 4: $t0 := infer($t1) + 5: $t4 := 2 + 6: $t6 := infer($t4) + 7: $t7 := 1 + 8: $t5 := +($t6, $t7) + 9: $t4 := infer($t5) + 10: return () } @@ -40,16 +44,20 @@ fun m::test() { var $t0: u32 var $t1: u32 var $t2: u32 - var $t3: u64 + var $t3: u32 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t1 := +($t0, $t2) - 3: $t3 := 2 - 4: $t5 := 1 - 5: $t4 := +($t3, $t5) - 6: return () + 1: $t2 := move($t0) + 2: $t3 := 1 + 3: $t1 := +($t2, $t3) + 4: $t4 := 2 + 5: $t6 := move($t4) + 6: $t7 := 1 + 7: $t5 := +($t6, $t7) + 8: return () } ============ after VariableCoalescingAnnotator: ================ @@ -59,29 +67,37 @@ fun m::test() { var $t0: u32 var $t1: u32 var $t2: u32 - var $t3: u64 + var $t3: u32 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: # events: b:$t0 0: $t0 := 1 # live vars: $t0 - # events: b:$t2 - 1: $t2 := 1 - # live vars: $t0, $t2 - # events: e:$t0, e:$t1, e:$t2, b:$t1 - 2: $t1 := +($t0, $t2) - # live vars: + # events: e:$t0, b:$t2 + 1: $t2 := move($t0) + # live vars: $t2 # events: b:$t3 - 3: $t3 := 2 - # live vars: $t3 - # events: b:$t5 - 4: $t5 := 1 - # live vars: $t3, $t5 - # events: e:$t3, e:$t4, e:$t5, b:$t4 - 5: $t4 := +($t3, $t5) + 2: $t3 := 1 + # live vars: $t2, $t3 + # events: e:$t1, e:$t2, e:$t3, b:$t1 + 3: $t1 := +($t2, $t3) # live vars: - 6: return () + # events: b:$t4 + 4: $t4 := 2 + # live vars: $t4 + # events: e:$t4, b:$t6 + 5: $t6 := move($t4) + # live vars: $t6 + # events: b:$t7 + 6: $t7 := 1 + # live vars: $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 7: $t5 := +($t6, $t7) + # live vars: + 8: return () } ============ after VariableCoalescingTransformer: ================ @@ -90,17 +106,21 @@ fun m::test() { fun m::test() { var $t0: u32 var $t1: u32 [unused] - var $t2: u32 - var $t3: u64 - var $t4: u64 [unused] - var $t5: u64 + var $t2: u32 [unused] + var $t3: u32 + var $t4: u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t0 := +($t0, $t2) - 3: $t3 := 2 - 4: $t5 := 1 - 5: $t3 := +($t3, $t5) - 6: return () + 1: $t0 := move($t0) + 2: $t3 := 1 + 3: $t0 := +($t0, $t3) + 4: $t4 := 2 + 5: $t4 := move($t4) + 6: $t7 := 1 + 7: $t4 := +($t4, $t7) + 8: return () } ============ after DeadStoreElimination: ================ @@ -109,16 +129,18 @@ fun m::test() { fun m::test() { var $t0: u32 var $t1: u32 [unused] - var $t2: u32 - var $t3: u64 - var $t4: u64 [unused] - var $t5: u64 + var $t2: u32 [unused] + var $t3: u32 + var $t4: u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t0 := +($t0, $t2) - 3: $t3 := 2 - 4: $t5 := 1 - 5: $t3 := +($t3, $t5) + 1: $t3 := 1 + 2: $t0 := +($t0, $t3) + 3: $t4 := 2 + 4: $t7 := 1 + 5: $t4 := +($t4, $t7) 6: return () } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars_diff_type.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars_diff_type.opt.exp index 631c697bc491e..84ab65613679c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars_diff_type.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/non_overlapping_vars_diff_type.opt.exp @@ -5,18 +5,22 @@ fun m::test() { var $t0: u32 var $t1: u32 var $t2: u32 - var $t3: u64 + var $t3: u32 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t1 := +($t0, $t2) - 3: $t0 := infer($t1) - 4: $t3 := 2 - 5: $t5 := 1 - 6: $t4 := +($t3, $t5) - 7: $t3 := infer($t4) - 8: return () + 1: $t2 := infer($t0) + 2: $t3 := 1 + 3: $t1 := +($t2, $t3) + 4: $t0 := infer($t1) + 5: $t4 := 2 + 6: $t6 := infer($t4) + 7: $t7 := 1 + 8: $t5 := +($t6, $t7) + 9: $t4 := infer($t5) + 10: return () } @@ -40,16 +44,20 @@ fun m::test() { var $t0: u32 var $t1: u32 var $t2: u32 - var $t3: u64 + var $t3: u32 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t1 := +($t0, $t2) - 3: $t3 := 2 - 4: $t5 := 1 - 5: $t4 := +($t3, $t5) - 6: return () + 1: $t2 := move($t0) + 2: $t3 := 1 + 3: $t1 := +($t2, $t3) + 4: $t4 := 2 + 5: $t6 := move($t4) + 6: $t7 := 1 + 7: $t5 := +($t6, $t7) + 8: return () } ============ after VariableCoalescingAnnotator: ================ @@ -59,29 +67,37 @@ fun m::test() { var $t0: u32 var $t1: u32 var $t2: u32 - var $t3: u64 + var $t3: u32 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: # events: b:$t0 0: $t0 := 1 # live vars: $t0 - # events: b:$t2 - 1: $t2 := 1 - # live vars: $t0, $t2 - # events: e:$t0, e:$t1, e:$t2, b:$t1 - 2: $t1 := +($t0, $t2) - # live vars: + # events: e:$t0, b:$t2 + 1: $t2 := move($t0) + # live vars: $t2 # events: b:$t3 - 3: $t3 := 2 - # live vars: $t3 - # events: b:$t5 - 4: $t5 := 1 - # live vars: $t3, $t5 - # events: e:$t3, e:$t4, e:$t5, b:$t4 - 5: $t4 := +($t3, $t5) + 2: $t3 := 1 + # live vars: $t2, $t3 + # events: e:$t1, e:$t2, e:$t3, b:$t1 + 3: $t1 := +($t2, $t3) # live vars: - 6: return () + # events: b:$t4 + 4: $t4 := 2 + # live vars: $t4 + # events: e:$t4, b:$t6 + 5: $t6 := move($t4) + # live vars: $t6 + # events: b:$t7 + 6: $t7 := 1 + # live vars: $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 7: $t5 := +($t6, $t7) + # live vars: + 8: return () } ============ after VariableCoalescingTransformer: ================ @@ -90,17 +106,21 @@ fun m::test() { fun m::test() { var $t0: u32 var $t1: u32 [unused] - var $t2: u32 - var $t3: u64 - var $t4: u64 [unused] - var $t5: u64 + var $t2: u32 [unused] + var $t3: u32 + var $t4: u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t0 := +($t0, $t2) - 3: $t3 := 2 - 4: $t5 := 1 - 5: $t3 := +($t3, $t5) - 6: return () + 1: $t0 := move($t0) + 2: $t3 := 1 + 3: $t0 := +($t0, $t3) + 4: $t4 := 2 + 5: $t4 := move($t4) + 6: $t7 := 1 + 7: $t4 := +($t4, $t7) + 8: return () } ============ after DeadStoreElimination: ================ @@ -109,16 +129,18 @@ fun m::test() { fun m::test() { var $t0: u32 var $t1: u32 [unused] - var $t2: u32 - var $t3: u64 - var $t4: u64 [unused] - var $t5: u64 + var $t2: u32 [unused] + var $t3: u32 + var $t4: u64 + var $t5: u64 [unused] + var $t6: u64 [unused] + var $t7: u64 0: $t0 := 1 - 1: $t2 := 1 - 2: $t0 := +($t0, $t2) - 3: $t3 := 2 - 4: $t5 := 1 - 5: $t3 := +($t3, $t5) + 1: $t3 := 1 + 2: $t0 := +($t0, $t3) + 3: $t4 := 2 + 4: $t7 := 1 + 5: $t4 := +($t4, $t7) 6: return () } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/overlapping_vars.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/overlapping_vars.exp index 6a7fe387fea8d..100bf7dc94e2b 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/overlapping_vars.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/overlapping_vars.exp @@ -7,12 +7,14 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 0: $t1 := 1 1: $t2 := 2 2: $t3 := 3 - 3: $t4 := +($t1, $t2) - 4: $t0 := +($t4, $t3) - 5: return $t0 + 3: $t5 := infer($t1) + 4: $t4 := +($t5, $t2) + 5: $t0 := +($t4, $t3) + 6: return $t0 } ============ after DeadStoreElimination: ================ @@ -24,12 +26,14 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 0: $t1 := 1 1: $t2 := 2 2: $t3 := 3 - 3: $t4 := +($t1, $t2) - 4: $t0 := +($t4, $t3) - 5: return $t0 + 3: $t5 := move($t1) + 4: $t4 := +($t5, $t2) + 5: $t0 := +($t4, $t3) + 6: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -41,6 +45,7 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 # live vars: # events: b:$t1 0: $t1 := 1 @@ -51,14 +56,17 @@ fun m::test(): u64 { # events: b:$t3 2: $t3 := 3 # live vars: $t1, $t2, $t3 - # events: e:$t1, e:$t2, b:$t4 - 3: $t4 := +($t1, $t2) + # events: e:$t1, b:$t5 + 3: $t5 := move($t1) + # live vars: $t2, $t3, $t5 + # events: e:$t2, e:$t5, b:$t4 + 4: $t4 := +($t5, $t2) # live vars: $t3, $t4 # events: e:$t3, e:$t4, b:$t0 - 4: $t0 := +($t4, $t3) + 5: $t0 := +($t4, $t3) # live vars: $t0 # events: e:$t0 - 5: return $t0 + 6: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -70,12 +78,14 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] + var $t5: u64 [unused] 0: $t1 := 1 1: $t2 := 2 2: $t3 := 3 - 3: $t1 := +($t1, $t2) - 4: $t1 := +($t1, $t3) - 5: return $t1 + 3: $t1 := move($t1) + 4: $t1 := +($t1, $t2) + 5: $t1 := +($t1, $t3) + 6: return $t1 } ============ after DeadStoreElimination: ================ @@ -87,6 +97,7 @@ fun m::test(): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] + var $t5: u64 [unused] 0: $t1 := 1 1: $t2 := 2 2: $t3 := 3 diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/reassigned_var.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/reassigned_var.exp index 1910043c0413b..c562039b5f8e4 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/reassigned_var.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/reassigned_var.exp @@ -6,12 +6,14 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: $t1 := 1 1: $t2 := 2 2: $t3 := 9 3: $t1 := infer($t3) - 4: $t0 := +($t1, $t2) - 5: return $t0 + 4: $t4 := infer($t1) + 5: $t0 := +($t4, $t2) + 6: return $t0 } @@ -30,11 +32,13 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: $t2 := 2 1: $t3 := 9 2: $t1 := move($t3) - 3: $t0 := +($t1, $t2) - 4: return $t0 + 3: $t4 := move($t1) + 4: $t0 := +($t4, $t2) + 5: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -45,6 +49,7 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 # live vars: # events: b:$t2 0: $t2 := 2 @@ -55,11 +60,14 @@ fun m::test(): u64 { # events: e:$t3, b:$t1 2: $t1 := move($t3) # live vars: $t1, $t2 - # events: e:$t1, e:$t2, b:$t0 - 3: $t0 := +($t1, $t2) + # events: e:$t1, b:$t4 + 3: $t4 := move($t1) + # live vars: $t2, $t4 + # events: e:$t2, e:$t4, b:$t0 + 4: $t0 := +($t4, $t2) # live vars: $t0 # events: e:$t0 - 4: return $t0 + 5: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -70,11 +78,13 @@ fun m::test(): u64 { var $t1: u64 [unused] var $t2: u64 var $t3: u64 + var $t4: u64 [unused] 0: $t2 := 2 1: $t3 := 9 2: $t3 := move($t3) - 3: $t2 := +($t3, $t2) - 4: return $t2 + 3: $t3 := move($t3) + 4: $t2 := +($t3, $t2) + 5: return $t2 } ============ after DeadStoreElimination: ================ @@ -85,6 +95,7 @@ fun m::test(): u64 { var $t1: u64 [unused] var $t2: u64 var $t3: u64 + var $t4: u64 [unused] 0: $t2 := 2 1: $t3 := 9 2: $t2 := +($t3, $t2) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/reassigned_var.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/reassigned_var.opt.exp index 0bff15a1e37e6..de6e03454830c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/reassigned_var.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/reassigned_var.opt.exp @@ -6,12 +6,14 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: $t1 := 1 1: $t2 := 9 2: $t1 := infer($t2) - 3: $t3 := 2 - 4: $t0 := +($t1, $t3) - 5: return $t0 + 3: $t3 := infer($t1) + 4: $t4 := 2 + 5: $t0 := +($t3, $t4) + 6: return $t0 } @@ -30,11 +32,13 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 0: $t2 := 9 1: $t1 := move($t2) - 2: $t3 := 2 - 3: $t0 := +($t1, $t3) - 4: return $t0 + 2: $t3 := move($t1) + 3: $t4 := 2 + 4: $t0 := +($t3, $t4) + 5: return $t0 } ============ after VariableCoalescingAnnotator: ================ @@ -45,6 +49,7 @@ fun m::test(): u64 { var $t1: u64 var $t2: u64 var $t3: u64 + var $t4: u64 # live vars: # events: b:$t2 0: $t2 := 9 @@ -52,14 +57,17 @@ fun m::test(): u64 { # events: e:$t2, b:$t1 1: $t1 := move($t2) # live vars: $t1 - # events: b:$t3 - 2: $t3 := 2 - # live vars: $t1, $t3 - # events: e:$t1, e:$t3, b:$t0 - 3: $t0 := +($t1, $t3) + # events: e:$t1, b:$t3 + 2: $t3 := move($t1) + # live vars: $t3 + # events: b:$t4 + 3: $t4 := 2 + # live vars: $t3, $t4 + # events: e:$t3, e:$t4, b:$t0 + 4: $t0 := +($t3, $t4) # live vars: $t0 # events: e:$t0 - 4: return $t0 + 5: return $t0 } ============ after VariableCoalescingTransformer: ================ @@ -69,12 +77,14 @@ fun m::test(): u64 { var $t0: u64 [unused] var $t1: u64 [unused] var $t2: u64 - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 0: $t2 := 9 1: $t2 := move($t2) - 2: $t3 := 2 - 3: $t2 := +($t2, $t3) - 4: return $t2 + 2: $t2 := move($t2) + 3: $t4 := 2 + 4: $t2 := +($t2, $t4) + 5: return $t2 } ============ after DeadStoreElimination: ================ @@ -84,10 +94,11 @@ fun m::test(): u64 { var $t0: u64 [unused] var $t1: u64 [unused] var $t2: u64 - var $t3: u64 + var $t3: u64 [unused] + var $t4: u64 0: $t2 := 9 - 1: $t3 := 2 - 2: $t2 := +($t2, $t3) + 1: $t4 := 2 + 2: $t2 := +($t2, $t4) 3: return $t2 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/self_assigns.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/self_assigns.exp index bceab3ecdb634..58ba325ed068c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/self_assigns.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/self_assigns.exp @@ -25,25 +25,29 @@ public fun m::test3(): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t1 := 0 1: $t2 := 1 2: label L0 - 3: $t4 := 42 - 4: $t3 := <($t1, $t4) - 5: if ($t3) goto 6 else goto 12 - 6: label L2 - 7: $t2 := infer($t2) - 8: $t6 := 1 - 9: $t5 := +($t1, $t6) - 10: $t1 := infer($t5) - 11: goto 14 - 12: label L3 + 3: $t4 := infer($t1) + 4: $t5 := 42 + 5: $t3 := <($t4, $t5) + 6: if ($t3) goto 7 else goto 14 + 7: label L2 + 8: $t2 := infer($t2) + 9: $t7 := infer($t1) + 10: $t8 := 1 + 11: $t6 := +($t7, $t8) + 12: $t1 := infer($t6) 13: goto 16 - 14: label L4 - 15: goto 2 - 16: label L1 - 17: $t0 := infer($t2) - 18: return $t0 + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 2 + 18: label L1 + 19: $t0 := infer($t2) + 20: return $t0 } @@ -55,24 +59,28 @@ public fun m::test4($t0: u64): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 11 - 5: label L2 - 6: $t0 := infer($t0) - 7: $t6 := 1 - 8: $t5 := +($t2, $t6) - 9: $t2 := infer($t5) - 10: goto 13 - 11: label L3 + 2: $t4 := infer($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 13 + 6: label L2 + 7: $t0 := infer($t0) + 8: $t7 := infer($t2) + 9: $t8 := 1 + 10: $t6 := +($t7, $t8) + 11: $t2 := infer($t6) 12: goto 15 - 13: label L4 - 14: goto 1 - 15: label L1 - 16: $t1 := infer($t0) - 17: return $t1 + 13: label L3 + 14: goto 17 + 15: label L4 + 16: goto 1 + 17: label L1 + 18: $t1 := infer($t0) + 19: return $t1 } @@ -108,20 +116,24 @@ public fun m::test3(): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t1 := 0 1: $t2 := 1 2: label L0 - 3: $t4 := 42 - 4: $t3 := <($t1, $t4) - 5: if ($t3) goto 6 else goto 11 - 6: label L2 - 7: $t6 := 1 - 8: $t5 := +($t1, $t6) - 9: $t1 := move($t5) - 10: goto 2 - 11: label L3 - 12: $t0 := move($t2) - 13: return $t0 + 3: $t4 := copy($t1) + 4: $t5 := 42 + 5: $t3 := <($t4, $t5) + 6: if ($t3) goto 7 else goto 13 + 7: label L2 + 8: $t7 := move($t1) + 9: $t8 := 1 + 10: $t6 := +($t7, $t8) + 11: $t1 := move($t6) + 12: goto 2 + 13: label L3 + 14: $t0 := move($t2) + 15: return $t0 } @@ -133,19 +145,23 @@ public fun m::test4($t0: u64): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 10 - 5: label L2 - 6: $t6 := 1 - 7: $t5 := +($t2, $t6) - 8: $t2 := move($t5) - 9: goto 1 - 10: label L3 - 11: $t1 := move($t0) - 12: return $t1 + 2: $t4 := copy($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 12 + 6: label L2 + 7: $t7 := move($t2) + 8: $t8 := 1 + 9: $t6 := +($t7, $t8) + 10: $t2 := move($t6) + 11: goto 1 + 12: label L3 + 13: $t1 := move($t0) + 14: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -179,6 +195,8 @@ public fun m::test3(): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: # events: b:$t1 0: $t1 := 0 @@ -189,35 +207,41 @@ public fun m::test3(): u64 { 2: label L0 # live vars: $t1, $t2 # events: b:$t4 - 3: $t4 := 42 + 3: $t4 := copy($t1) # live vars: $t1, $t2, $t4 - # events: e:$t4, b:$t3 - 4: $t3 := <($t1, $t4) + # events: b:$t5 + 4: $t5 := 42 + # live vars: $t1, $t2, $t4, $t5 + # events: e:$t4, e:$t5, b:$t3 + 5: $t3 := <($t4, $t5) # live vars: $t1, $t2, $t3 # events: e:$t3 - 5: if ($t3) goto 6 else goto 11 + 6: if ($t3) goto 7 else goto 13 # live vars: $t1, $t2 - 6: label L2 + 7: label L2 # live vars: $t1, $t2 - # events: b:$t6 - 7: $t6 := 1 - # live vars: $t1, $t2, $t6 - # events: e:$t6, b:$t5 - 8: $t5 := +($t1, $t6) - # live vars: $t2, $t5 - # events: e:$t5 - 9: $t1 := move($t5) + # events: b:$t7 + 8: $t7 := move($t1) + # live vars: $t2, $t7 + # events: b:$t8 + 9: $t8 := 1 + # live vars: $t2, $t7, $t8 + # events: e:$t7, e:$t8, b:$t6 + 10: $t6 := +($t7, $t8) + # live vars: $t2, $t6 + # events: e:$t6 + 11: $t1 := move($t6) # live vars: $t1, $t2 - 10: goto 2 + 12: goto 2 # live vars: $t1, $t2 # events: e:$t1 - 11: label L3 + 13: label L3 # live vars: $t2 # events: e:$t2, b:$t0 - 12: $t0 := move($t2) + 14: $t0 := move($t2) # live vars: $t0 # events: e:$t0 - 13: return $t0 + 15: return $t0 } @@ -229,6 +253,8 @@ public fun m::test4($t0: u64): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := 0 @@ -236,35 +262,41 @@ public fun m::test4($t0: u64): u64 { 1: label L0 # live vars: $t0, $t2 # events: b:$t4 - 2: $t4 := 42 + 2: $t4 := copy($t2) # live vars: $t0, $t2, $t4 - # events: e:$t4, b:$t3 - 3: $t3 := <($t2, $t4) + # events: b:$t5 + 3: $t5 := 42 + # live vars: $t0, $t2, $t4, $t5 + # events: e:$t4, e:$t5, b:$t3 + 4: $t3 := <($t4, $t5) # live vars: $t0, $t2, $t3 # events: e:$t3 - 4: if ($t3) goto 5 else goto 10 + 5: if ($t3) goto 6 else goto 12 # live vars: $t0, $t2 - 5: label L2 + 6: label L2 # live vars: $t0, $t2 - # events: b:$t6 - 6: $t6 := 1 - # live vars: $t0, $t2, $t6 - # events: e:$t6, b:$t5 - 7: $t5 := +($t2, $t6) - # live vars: $t0, $t5 - # events: e:$t5 - 8: $t2 := move($t5) + # events: b:$t7 + 7: $t7 := move($t2) + # live vars: $t0, $t7 + # events: b:$t8 + 8: $t8 := 1 + # live vars: $t0, $t7, $t8 + # events: e:$t7, e:$t8, b:$t6 + 9: $t6 := +($t7, $t8) + # live vars: $t0, $t6 + # events: e:$t6 + 10: $t2 := move($t6) # live vars: $t0, $t2 - 9: goto 1 + 11: goto 1 # live vars: $t0, $t2 # events: e:$t2 - 10: label L3 + 12: label L3 # live vars: $t0 # events: e:$t0, b:$t1 - 11: $t1 := move($t0) + 13: $t1 := move($t0) # live vars: $t1 # events: e:$t1 - 12: return $t1 + 14: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -290,22 +322,26 @@ public fun m::test3(): u64 { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t1 := 0 1: $t2 := 1 2: label L0 - 3: $t4 := 42 - 4: $t3 := <($t1, $t4) - 5: if ($t3) goto 6 else goto 11 - 6: label L2 - 7: $t4 := 1 - 8: $t4 := +($t1, $t4) - 9: $t1 := move($t4) - 10: goto 2 - 11: label L3 - 12: $t2 := move($t2) - 13: return $t2 + 3: $t4 := copy($t1) + 4: $t5 := 42 + 5: $t3 := <($t4, $t5) + 6: if ($t3) goto 7 else goto 13 + 7: label L2 + 8: $t4 := move($t1) + 9: $t5 := 1 + 10: $t4 := +($t4, $t5) + 11: $t1 := move($t4) + 12: goto 2 + 13: label L3 + 14: $t2 := move($t2) + 15: return $t2 } @@ -315,21 +351,25 @@ public fun m::test4($t0: u64): u64 { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 10 - 5: label L2 - 6: $t4 := 1 - 7: $t4 := +($t2, $t4) - 8: $t2 := move($t4) - 9: goto 1 - 10: label L3 - 11: $t0 := move($t0) - 12: return $t0 + 2: $t4 := copy($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 12 + 6: label L2 + 7: $t4 := move($t2) + 8: $t5 := 1 + 9: $t4 := +($t4, $t5) + 10: $t2 := move($t4) + 11: goto 1 + 12: label L3 + 13: $t0 := move($t0) + 14: return $t0 } ============ after DeadStoreElimination: ================ @@ -343,7 +383,8 @@ public fun m::test1($t0: u64) { [variant baseline] public fun m::test2($t0: u64): u64 { var $t1: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } @@ -354,21 +395,26 @@ public fun m::test3(): u64 { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t1 := 0 1: $t2 := 1 2: label L0 - 3: $t4 := 42 - 4: $t3 := <($t1, $t4) - 5: if ($t3) goto 6 else goto 11 - 6: label L2 - 7: $t4 := 1 - 8: $t4 := +($t1, $t4) - 9: $t1 := move($t4) - 10: goto 2 - 11: label L3 - 12: return $t2 + 3: $t4 := copy($t1) + 4: $t5 := 42 + 5: $t3 := <($t4, $t5) + 6: if ($t3) goto 7 else goto 13 + 7: label L2 + 8: $t4 := move($t1) + 9: $t5 := 1 + 10: $t4 := +($t4, $t5) + 11: $t1 := move($t4) + 12: goto 2 + 13: label L3 + 14: $t2 := move($t2) + 15: return $t2 } @@ -378,20 +424,25 @@ public fun m::test4($t0: u64): u64 { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 10 - 5: label L2 - 6: $t4 := 1 - 7: $t4 := +($t2, $t4) - 8: $t2 := move($t4) - 9: goto 1 - 10: label L3 - 11: return $t0 + 2: $t4 := copy($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 12 + 6: label L2 + 7: $t4 := move($t2) + 8: $t5 := 1 + 9: $t4 := +($t4, $t5) + 10: $t2 := move($t4) + 11: goto 1 + 12: label L3 + 13: $t0 := move($t0) + 14: return $t0 } @@ -412,7 +463,6 @@ B0: public test3(): u64 /* def_idx: 2 */ { L0: loc0: u64 L1: loc1: u64 -L2: loc2: u64 B0: 0: LdU64(0) 1: StLoc[0](loc0: u64) @@ -435,7 +485,6 @@ B3: } public test4(Arg0: u64): u64 /* def_idx: 3 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/self_assigns.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/self_assigns.opt.exp index bceab3ecdb634..58ba325ed068c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/self_assigns.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/self_assigns.opt.exp @@ -25,25 +25,29 @@ public fun m::test3(): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t1 := 0 1: $t2 := 1 2: label L0 - 3: $t4 := 42 - 4: $t3 := <($t1, $t4) - 5: if ($t3) goto 6 else goto 12 - 6: label L2 - 7: $t2 := infer($t2) - 8: $t6 := 1 - 9: $t5 := +($t1, $t6) - 10: $t1 := infer($t5) - 11: goto 14 - 12: label L3 + 3: $t4 := infer($t1) + 4: $t5 := 42 + 5: $t3 := <($t4, $t5) + 6: if ($t3) goto 7 else goto 14 + 7: label L2 + 8: $t2 := infer($t2) + 9: $t7 := infer($t1) + 10: $t8 := 1 + 11: $t6 := +($t7, $t8) + 12: $t1 := infer($t6) 13: goto 16 - 14: label L4 - 15: goto 2 - 16: label L1 - 17: $t0 := infer($t2) - 18: return $t0 + 14: label L3 + 15: goto 18 + 16: label L4 + 17: goto 2 + 18: label L1 + 19: $t0 := infer($t2) + 20: return $t0 } @@ -55,24 +59,28 @@ public fun m::test4($t0: u64): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 11 - 5: label L2 - 6: $t0 := infer($t0) - 7: $t6 := 1 - 8: $t5 := +($t2, $t6) - 9: $t2 := infer($t5) - 10: goto 13 - 11: label L3 + 2: $t4 := infer($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 13 + 6: label L2 + 7: $t0 := infer($t0) + 8: $t7 := infer($t2) + 9: $t8 := 1 + 10: $t6 := +($t7, $t8) + 11: $t2 := infer($t6) 12: goto 15 - 13: label L4 - 14: goto 1 - 15: label L1 - 16: $t1 := infer($t0) - 17: return $t1 + 13: label L3 + 14: goto 17 + 15: label L4 + 16: goto 1 + 17: label L1 + 18: $t1 := infer($t0) + 19: return $t1 } @@ -108,20 +116,24 @@ public fun m::test3(): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t1 := 0 1: $t2 := 1 2: label L0 - 3: $t4 := 42 - 4: $t3 := <($t1, $t4) - 5: if ($t3) goto 6 else goto 11 - 6: label L2 - 7: $t6 := 1 - 8: $t5 := +($t1, $t6) - 9: $t1 := move($t5) - 10: goto 2 - 11: label L3 - 12: $t0 := move($t2) - 13: return $t0 + 3: $t4 := copy($t1) + 4: $t5 := 42 + 5: $t3 := <($t4, $t5) + 6: if ($t3) goto 7 else goto 13 + 7: label L2 + 8: $t7 := move($t1) + 9: $t8 := 1 + 10: $t6 := +($t7, $t8) + 11: $t1 := move($t6) + 12: goto 2 + 13: label L3 + 14: $t0 := move($t2) + 15: return $t0 } @@ -133,19 +145,23 @@ public fun m::test4($t0: u64): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 10 - 5: label L2 - 6: $t6 := 1 - 7: $t5 := +($t2, $t6) - 8: $t2 := move($t5) - 9: goto 1 - 10: label L3 - 11: $t1 := move($t0) - 12: return $t1 + 2: $t4 := copy($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 12 + 6: label L2 + 7: $t7 := move($t2) + 8: $t8 := 1 + 9: $t6 := +($t7, $t8) + 10: $t2 := move($t6) + 11: goto 1 + 12: label L3 + 13: $t1 := move($t0) + 14: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -179,6 +195,8 @@ public fun m::test3(): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: # events: b:$t1 0: $t1 := 0 @@ -189,35 +207,41 @@ public fun m::test3(): u64 { 2: label L0 # live vars: $t1, $t2 # events: b:$t4 - 3: $t4 := 42 + 3: $t4 := copy($t1) # live vars: $t1, $t2, $t4 - # events: e:$t4, b:$t3 - 4: $t3 := <($t1, $t4) + # events: b:$t5 + 4: $t5 := 42 + # live vars: $t1, $t2, $t4, $t5 + # events: e:$t4, e:$t5, b:$t3 + 5: $t3 := <($t4, $t5) # live vars: $t1, $t2, $t3 # events: e:$t3 - 5: if ($t3) goto 6 else goto 11 + 6: if ($t3) goto 7 else goto 13 # live vars: $t1, $t2 - 6: label L2 + 7: label L2 # live vars: $t1, $t2 - # events: b:$t6 - 7: $t6 := 1 - # live vars: $t1, $t2, $t6 - # events: e:$t6, b:$t5 - 8: $t5 := +($t1, $t6) - # live vars: $t2, $t5 - # events: e:$t5 - 9: $t1 := move($t5) + # events: b:$t7 + 8: $t7 := move($t1) + # live vars: $t2, $t7 + # events: b:$t8 + 9: $t8 := 1 + # live vars: $t2, $t7, $t8 + # events: e:$t7, e:$t8, b:$t6 + 10: $t6 := +($t7, $t8) + # live vars: $t2, $t6 + # events: e:$t6 + 11: $t1 := move($t6) # live vars: $t1, $t2 - 10: goto 2 + 12: goto 2 # live vars: $t1, $t2 # events: e:$t1 - 11: label L3 + 13: label L3 # live vars: $t2 # events: e:$t2, b:$t0 - 12: $t0 := move($t2) + 14: $t0 := move($t2) # live vars: $t0 # events: e:$t0 - 13: return $t0 + 15: return $t0 } @@ -229,6 +253,8 @@ public fun m::test4($t0: u64): u64 { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := 0 @@ -236,35 +262,41 @@ public fun m::test4($t0: u64): u64 { 1: label L0 # live vars: $t0, $t2 # events: b:$t4 - 2: $t4 := 42 + 2: $t4 := copy($t2) # live vars: $t0, $t2, $t4 - # events: e:$t4, b:$t3 - 3: $t3 := <($t2, $t4) + # events: b:$t5 + 3: $t5 := 42 + # live vars: $t0, $t2, $t4, $t5 + # events: e:$t4, e:$t5, b:$t3 + 4: $t3 := <($t4, $t5) # live vars: $t0, $t2, $t3 # events: e:$t3 - 4: if ($t3) goto 5 else goto 10 + 5: if ($t3) goto 6 else goto 12 # live vars: $t0, $t2 - 5: label L2 + 6: label L2 # live vars: $t0, $t2 - # events: b:$t6 - 6: $t6 := 1 - # live vars: $t0, $t2, $t6 - # events: e:$t6, b:$t5 - 7: $t5 := +($t2, $t6) - # live vars: $t0, $t5 - # events: e:$t5 - 8: $t2 := move($t5) + # events: b:$t7 + 7: $t7 := move($t2) + # live vars: $t0, $t7 + # events: b:$t8 + 8: $t8 := 1 + # live vars: $t0, $t7, $t8 + # events: e:$t7, e:$t8, b:$t6 + 9: $t6 := +($t7, $t8) + # live vars: $t0, $t6 + # events: e:$t6 + 10: $t2 := move($t6) # live vars: $t0, $t2 - 9: goto 1 + 11: goto 1 # live vars: $t0, $t2 # events: e:$t2 - 10: label L3 + 12: label L3 # live vars: $t0 # events: e:$t0, b:$t1 - 11: $t1 := move($t0) + 13: $t1 := move($t0) # live vars: $t1 # events: e:$t1 - 12: return $t1 + 14: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -290,22 +322,26 @@ public fun m::test3(): u64 { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t1 := 0 1: $t2 := 1 2: label L0 - 3: $t4 := 42 - 4: $t3 := <($t1, $t4) - 5: if ($t3) goto 6 else goto 11 - 6: label L2 - 7: $t4 := 1 - 8: $t4 := +($t1, $t4) - 9: $t1 := move($t4) - 10: goto 2 - 11: label L3 - 12: $t2 := move($t2) - 13: return $t2 + 3: $t4 := copy($t1) + 4: $t5 := 42 + 5: $t3 := <($t4, $t5) + 6: if ($t3) goto 7 else goto 13 + 7: label L2 + 8: $t4 := move($t1) + 9: $t5 := 1 + 10: $t4 := +($t4, $t5) + 11: $t1 := move($t4) + 12: goto 2 + 13: label L3 + 14: $t2 := move($t2) + 15: return $t2 } @@ -315,21 +351,25 @@ public fun m::test4($t0: u64): u64 { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 10 - 5: label L2 - 6: $t4 := 1 - 7: $t4 := +($t2, $t4) - 8: $t2 := move($t4) - 9: goto 1 - 10: label L3 - 11: $t0 := move($t0) - 12: return $t0 + 2: $t4 := copy($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 12 + 6: label L2 + 7: $t4 := move($t2) + 8: $t5 := 1 + 9: $t4 := +($t4, $t5) + 10: $t2 := move($t4) + 11: goto 1 + 12: label L3 + 13: $t0 := move($t0) + 14: return $t0 } ============ after DeadStoreElimination: ================ @@ -343,7 +383,8 @@ public fun m::test1($t0: u64) { [variant baseline] public fun m::test2($t0: u64): u64 { var $t1: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } @@ -354,21 +395,26 @@ public fun m::test3(): u64 { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t1 := 0 1: $t2 := 1 2: label L0 - 3: $t4 := 42 - 4: $t3 := <($t1, $t4) - 5: if ($t3) goto 6 else goto 11 - 6: label L2 - 7: $t4 := 1 - 8: $t4 := +($t1, $t4) - 9: $t1 := move($t4) - 10: goto 2 - 11: label L3 - 12: return $t2 + 3: $t4 := copy($t1) + 4: $t5 := 42 + 5: $t3 := <($t4, $t5) + 6: if ($t3) goto 7 else goto 13 + 7: label L2 + 8: $t4 := move($t1) + 9: $t5 := 1 + 10: $t4 := +($t4, $t5) + 11: $t1 := move($t4) + 12: goto 2 + 13: label L3 + 14: $t2 := move($t2) + 15: return $t2 } @@ -378,20 +424,25 @@ public fun m::test4($t0: u64): u64 { var $t2: u64 var $t3: bool var $t4: u64 - var $t5: u64 [unused] + var $t5: u64 var $t6: u64 [unused] + var $t7: u64 [unused] + var $t8: u64 [unused] 0: $t2 := 0 1: label L0 - 2: $t4 := 42 - 3: $t3 := <($t2, $t4) - 4: if ($t3) goto 5 else goto 10 - 5: label L2 - 6: $t4 := 1 - 7: $t4 := +($t2, $t4) - 8: $t2 := move($t4) - 9: goto 1 - 10: label L3 - 11: return $t0 + 2: $t4 := copy($t2) + 3: $t5 := 42 + 4: $t3 := <($t4, $t5) + 5: if ($t3) goto 6 else goto 12 + 6: label L2 + 7: $t4 := move($t2) + 8: $t5 := 1 + 9: $t4 := +($t4, $t5) + 10: $t2 := move($t4) + 11: goto 1 + 12: label L3 + 13: $t0 := move($t0) + 14: return $t0 } @@ -412,7 +463,6 @@ B0: public test3(): u64 /* def_idx: 2 */ { L0: loc0: u64 L1: loc1: u64 -L2: loc2: u64 B0: 0: LdU64(0) 1: StLoc[0](loc0: u64) @@ -435,7 +485,6 @@ B3: } public test4(Arg0: u64): u64 /* def_idx: 3 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: LdU64(0) 1: StLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.exp index 86b5890cae6d7..5356fad8a5f8e 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.exp @@ -8,14 +8,18 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t3 := infer($t5) - 6: $t1 := ==($t2, $t4) - 7: return $t1 + 3: $t6 := infer($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t3 := infer($t5) + 7: $t8 := infer($t2) + 8: $t1 := ==($t8, $t4) + 9: return $t1 } @@ -36,13 +40,17 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := copy($t0) 1: $t3 := copy($t2) 2: $t4 := move($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t1 := ==($t2, $t4) - 6: return $t1 + 3: $t6 := move($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t8 := move($t2) + 7: $t1 := ==($t8, $t4) + 8: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -55,6 +63,8 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) @@ -65,17 +75,23 @@ fun m::test($t0: u64): bool { # events: e:$t3, b:$t4 2: $t4 := move($t3) # live vars: $t0, $t2, $t4 - # events: b:$t6 - 3: $t6 := 1 - # live vars: $t0, $t2, $t4, $t6 - # events: e:$t0, e:$t5, e:$t6, b:$t5 - 4: $t5 := +($t0, $t6) + # events: e:$t0, b:$t6 + 3: $t6 := move($t0) + # live vars: $t2, $t4, $t6 + # events: b:$t7 + 4: $t7 := 1 + # live vars: $t2, $t4, $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 5: $t5 := +($t6, $t7) # live vars: $t2, $t4 - # events: e:$t2, e:$t4, b:$t1 - 5: $t1 := ==($t2, $t4) + # events: e:$t2, b:$t8 + 6: $t8 := move($t2) + # live vars: $t4, $t8 + # events: e:$t4, e:$t8, b:$t1 + 7: $t1 := ==($t8, $t4) # live vars: $t1 # events: e:$t1 - 6: return $t1 + 8: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -87,14 +103,18 @@ fun m::test($t0: u64): bool { var $t3: u64 var $t4: u64 [unused] var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := copy($t2) 2: $t3 := move($t3) - 3: $t6 := 1 - 4: $t0 := +($t0, $t6) - 5: $t1 := ==($t2, $t3) - 6: return $t1 + 3: $t0 := move($t0) + 4: $t7 := 1 + 5: $t0 := +($t0, $t7) + 6: $t2 := move($t2) + 7: $t1 := ==($t2, $t3) + 8: return $t1 } ============ after DeadStoreElimination: ================ @@ -106,13 +126,16 @@ fun m::test($t0: u64): bool { var $t3: u64 var $t4: u64 [unused] var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t6 := 1 - 3: $t0 := +($t0, $t6) - 4: $t1 := ==($t2, $t3) - 5: return $t1 + 2: $t0 := move($t0) + 3: $t7 := 1 + 4: $t0 := +($t0, $t7) + 5: $t1 := ==($t2, $t3) + 6: return $t1 } @@ -124,7 +147,6 @@ module c0ffee.m { test(Arg0: u64): bool /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) @@ -133,9 +155,9 @@ B0: 4: LdU64(1) 5: Add 6: Pop - 7: StLoc[3](loc2: u64) + 7: StLoc[2](loc1: u64) 8: MoveLoc[1](loc0: u64) - 9: MoveLoc[3](loc2: u64) + 9: MoveLoc[2](loc1: u64) 10: Eq 11: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.opt.exp index 86b5890cae6d7..5356fad8a5f8e 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_1.opt.exp @@ -8,14 +8,18 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t3 := infer($t5) - 6: $t1 := ==($t2, $t4) - 7: return $t1 + 3: $t6 := infer($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t3 := infer($t5) + 7: $t8 := infer($t2) + 8: $t1 := ==($t8, $t4) + 9: return $t1 } @@ -36,13 +40,17 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := copy($t0) 1: $t3 := copy($t2) 2: $t4 := move($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t1 := ==($t2, $t4) - 6: return $t1 + 3: $t6 := move($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t8 := move($t2) + 7: $t1 := ==($t8, $t4) + 8: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -55,6 +63,8 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) @@ -65,17 +75,23 @@ fun m::test($t0: u64): bool { # events: e:$t3, b:$t4 2: $t4 := move($t3) # live vars: $t0, $t2, $t4 - # events: b:$t6 - 3: $t6 := 1 - # live vars: $t0, $t2, $t4, $t6 - # events: e:$t0, e:$t5, e:$t6, b:$t5 - 4: $t5 := +($t0, $t6) + # events: e:$t0, b:$t6 + 3: $t6 := move($t0) + # live vars: $t2, $t4, $t6 + # events: b:$t7 + 4: $t7 := 1 + # live vars: $t2, $t4, $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 5: $t5 := +($t6, $t7) # live vars: $t2, $t4 - # events: e:$t2, e:$t4, b:$t1 - 5: $t1 := ==($t2, $t4) + # events: e:$t2, b:$t8 + 6: $t8 := move($t2) + # live vars: $t4, $t8 + # events: e:$t4, e:$t8, b:$t1 + 7: $t1 := ==($t8, $t4) # live vars: $t1 # events: e:$t1 - 6: return $t1 + 8: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -87,14 +103,18 @@ fun m::test($t0: u64): bool { var $t3: u64 var $t4: u64 [unused] var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := copy($t2) 2: $t3 := move($t3) - 3: $t6 := 1 - 4: $t0 := +($t0, $t6) - 5: $t1 := ==($t2, $t3) - 6: return $t1 + 3: $t0 := move($t0) + 4: $t7 := 1 + 5: $t0 := +($t0, $t7) + 6: $t2 := move($t2) + 7: $t1 := ==($t2, $t3) + 8: return $t1 } ============ after DeadStoreElimination: ================ @@ -106,13 +126,16 @@ fun m::test($t0: u64): bool { var $t3: u64 var $t4: u64 [unused] var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t6 := 1 - 3: $t0 := +($t0, $t6) - 4: $t1 := ==($t2, $t3) - 5: return $t1 + 2: $t0 := move($t0) + 3: $t7 := 1 + 4: $t0 := +($t0, $t7) + 5: $t1 := ==($t2, $t3) + 6: return $t1 } @@ -124,7 +147,6 @@ module c0ffee.m { test(Arg0: u64): bool /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) @@ -133,9 +155,9 @@ B0: 4: LdU64(1) 5: Add 6: Pop - 7: StLoc[3](loc2: u64) + 7: StLoc[2](loc1: u64) 8: MoveLoc[1](loc0: u64) - 9: MoveLoc[3](loc2: u64) + 9: MoveLoc[2](loc1: u64) 10: Eq 11: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.exp index eb034ba9ffbaf..3276987a3f816 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.exp @@ -8,14 +8,18 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t2 := infer($t5) - 6: $t1 := ==($t3, $t4) - 7: return $t1 + 3: $t6 := infer($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t2 := infer($t5) + 7: $t8 := infer($t3) + 8: $t1 := ==($t8, $t4) + 9: return $t1 } @@ -36,13 +40,17 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := copy($t0) 1: $t3 := move($t2) 2: $t4 := copy($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t1 := ==($t3, $t4) - 6: return $t1 + 3: $t6 := move($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t8 := move($t3) + 7: $t1 := ==($t8, $t4) + 8: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -55,6 +63,8 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) @@ -65,17 +75,23 @@ fun m::test($t0: u64): bool { # events: b:$t4 2: $t4 := copy($t3) # live vars: $t0, $t3, $t4 - # events: b:$t6 - 3: $t6 := 1 - # live vars: $t0, $t3, $t4, $t6 - # events: e:$t0, e:$t5, e:$t6, b:$t5 - 4: $t5 := +($t0, $t6) + # events: e:$t0, b:$t6 + 3: $t6 := move($t0) + # live vars: $t3, $t4, $t6 + # events: b:$t7 + 4: $t7 := 1 + # live vars: $t3, $t4, $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 5: $t5 := +($t6, $t7) # live vars: $t3, $t4 - # events: e:$t3, e:$t4, b:$t1 - 5: $t1 := ==($t3, $t4) + # events: e:$t3, b:$t8 + 6: $t8 := move($t3) + # live vars: $t4, $t8 + # events: e:$t4, e:$t8, b:$t1 + 7: $t1 := ==($t8, $t4) # live vars: $t1 # events: e:$t1 - 6: return $t1 + 8: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -87,14 +103,18 @@ fun m::test($t0: u64): bool { var $t3: u64 [unused] var $t4: u64 var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] 0: $t2 := copy($t0) 1: $t2 := move($t2) 2: $t4 := copy($t2) - 3: $t6 := 1 - 4: $t0 := +($t0, $t6) - 5: $t1 := ==($t2, $t4) - 6: return $t1 + 3: $t0 := move($t0) + 4: $t7 := 1 + 5: $t0 := +($t0, $t7) + 6: $t2 := move($t2) + 7: $t1 := ==($t2, $t4) + 8: return $t1 } ============ after DeadStoreElimination: ================ @@ -106,13 +126,16 @@ fun m::test($t0: u64): bool { var $t3: u64 [unused] var $t4: u64 var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] 0: $t2 := copy($t0) 1: $t4 := copy($t2) - 2: $t6 := 1 - 3: $t0 := +($t0, $t6) - 4: $t1 := ==($t2, $t4) - 5: return $t1 + 2: $t0 := move($t0) + 3: $t7 := 1 + 4: $t0 := +($t0, $t7) + 5: $t1 := ==($t2, $t4) + 6: return $t1 } @@ -124,7 +147,6 @@ module c0ffee.m { test(Arg0: u64): bool /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) @@ -133,9 +155,9 @@ B0: 4: LdU64(1) 5: Add 6: Pop - 7: StLoc[3](loc2: u64) + 7: StLoc[2](loc1: u64) 8: MoveLoc[1](loc0: u64) - 9: MoveLoc[3](loc2: u64) + 9: MoveLoc[2](loc1: u64) 10: Eq 11: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.opt.exp index eb034ba9ffbaf..3276987a3f816 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/seq_kills_2.opt.exp @@ -8,14 +8,18 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) 2: $t4 := infer($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t2 := infer($t5) - 6: $t1 := ==($t3, $t4) - 7: return $t1 + 3: $t6 := infer($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t2 := infer($t5) + 7: $t8 := infer($t3) + 8: $t1 := ==($t8, $t4) + 9: return $t1 } @@ -36,13 +40,17 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 0: $t2 := copy($t0) 1: $t3 := move($t2) 2: $t4 := copy($t3) - 3: $t6 := 1 - 4: $t5 := +($t0, $t6) - 5: $t1 := ==($t3, $t4) - 6: return $t1 + 3: $t6 := move($t0) + 4: $t7 := 1 + 5: $t5 := +($t6, $t7) + 6: $t8 := move($t3) + 7: $t1 := ==($t8, $t4) + 8: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -55,6 +63,8 @@ fun m::test($t0: u64): bool { var $t4: u64 var $t5: u64 var $t6: u64 + var $t7: u64 + var $t8: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) @@ -65,17 +75,23 @@ fun m::test($t0: u64): bool { # events: b:$t4 2: $t4 := copy($t3) # live vars: $t0, $t3, $t4 - # events: b:$t6 - 3: $t6 := 1 - # live vars: $t0, $t3, $t4, $t6 - # events: e:$t0, e:$t5, e:$t6, b:$t5 - 4: $t5 := +($t0, $t6) + # events: e:$t0, b:$t6 + 3: $t6 := move($t0) + # live vars: $t3, $t4, $t6 + # events: b:$t7 + 4: $t7 := 1 + # live vars: $t3, $t4, $t6, $t7 + # events: e:$t5, e:$t6, e:$t7, b:$t5 + 5: $t5 := +($t6, $t7) # live vars: $t3, $t4 - # events: e:$t3, e:$t4, b:$t1 - 5: $t1 := ==($t3, $t4) + # events: e:$t3, b:$t8 + 6: $t8 := move($t3) + # live vars: $t4, $t8 + # events: e:$t4, e:$t8, b:$t1 + 7: $t1 := ==($t8, $t4) # live vars: $t1 # events: e:$t1 - 6: return $t1 + 8: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -87,14 +103,18 @@ fun m::test($t0: u64): bool { var $t3: u64 [unused] var $t4: u64 var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] 0: $t2 := copy($t0) 1: $t2 := move($t2) 2: $t4 := copy($t2) - 3: $t6 := 1 - 4: $t0 := +($t0, $t6) - 5: $t1 := ==($t2, $t4) - 6: return $t1 + 3: $t0 := move($t0) + 4: $t7 := 1 + 5: $t0 := +($t0, $t7) + 6: $t2 := move($t2) + 7: $t1 := ==($t2, $t4) + 8: return $t1 } ============ after DeadStoreElimination: ================ @@ -106,13 +126,16 @@ fun m::test($t0: u64): bool { var $t3: u64 [unused] var $t4: u64 var $t5: u64 [unused] - var $t6: u64 + var $t6: u64 [unused] + var $t7: u64 + var $t8: u64 [unused] 0: $t2 := copy($t0) 1: $t4 := copy($t2) - 2: $t6 := 1 - 3: $t0 := +($t0, $t6) - 4: $t1 := ==($t2, $t4) - 5: return $t1 + 2: $t0 := move($t0) + 3: $t7 := 1 + 4: $t0 := +($t0, $t7) + 5: $t1 := ==($t2, $t4) + 6: return $t1 } @@ -124,7 +147,6 @@ module c0ffee.m { test(Arg0: u64): bool /* def_idx: 0 */ { L1: loc0: u64 L2: loc1: u64 -L3: loc2: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) @@ -133,9 +155,9 @@ B0: 4: LdU64(1) 5: Add 6: Pop - 7: StLoc[3](loc2: u64) + 7: StLoc[2](loc1: u64) 8: MoveLoc[1](loc0: u64) - 9: MoveLoc[3](loc2: u64) + 9: MoveLoc[2](loc1: u64) 10: Eq 11: Ret } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.exp index d07e8b35bdcd3..14b304721a80a 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.exp @@ -98,7 +98,8 @@ fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { var $t4: 0xc0ffee::m::Foo [unused] var $t5: 0xc0ffee::m::Foo [unused] var $t6: 0xc0ffee::m::Foo [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.opt.exp index d07e8b35bdcd3..14b304721a80a 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/sequential_assign_struct.opt.exp @@ -98,7 +98,8 @@ fun m::sequential($t0: 0xc0ffee::m::Foo): 0xc0ffee::m::Foo { var $t4: 0xc0ffee::m::Foo [unused] var $t5: 0xc0ffee::m::Foo [unused] var $t6: 0xc0ffee::m::Foo [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/simple_sequential_assign.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/simple_sequential_assign.exp index f8f714d03bae3..212171e0178cf 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/simple_sequential_assign.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/simple_sequential_assign.exp @@ -98,7 +98,8 @@ fun m::sequential($t0: u64): u64 { var $t4: u64 [unused] var $t5: u64 [unused] var $t6: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/simple_sequential_assign.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/simple_sequential_assign.opt.exp index f8f714d03bae3..212171e0178cf 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/simple_sequential_assign.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/simple_sequential_assign.opt.exp @@ -98,7 +98,8 @@ fun m::sequential($t0: u64): u64 { var $t4: u64 [unused] var $t5: u64 [unused] var $t6: u64 [unused] - 0: return $t0 + 0: $t0 := move($t0) + 1: return $t0 } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.exp index 822f245566624..ebc4a657f613c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.exp @@ -7,13 +7,17 @@ fun m::copy_kill($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) - 2: $t5 := 1 - 3: $t4 := +($t0, $t5) - 4: $t0 := infer($t4) - 5: $t1 := +($t3, $t2) - 6: return $t1 + 2: $t5 := infer($t0) + 3: $t6 := 1 + 4: $t4 := +($t5, $t6) + 5: $t0 := infer($t4) + 6: $t7 := infer($t3) + 7: $t1 := +($t7, $t2) + 8: return $t1 } @@ -33,12 +37,16 @@ fun m::copy_kill($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t5 := 1 - 3: $t4 := +($t0, $t5) - 4: $t1 := +($t3, $t2) - 5: return $t1 + 2: $t5 := move($t0) + 3: $t6 := 1 + 4: $t4 := +($t5, $t6) + 5: $t7 := move($t3) + 6: $t1 := +($t7, $t2) + 7: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -50,6 +58,8 @@ fun m::copy_kill($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) @@ -57,17 +67,23 @@ fun m::copy_kill($t0: u64): u64 { # events: b:$t3 1: $t3 := copy($t2) # live vars: $t0, $t2, $t3 - # events: b:$t5 - 2: $t5 := 1 - # live vars: $t0, $t2, $t3, $t5 - # events: e:$t0, e:$t4, e:$t5, b:$t4 - 3: $t4 := +($t0, $t5) + # events: e:$t0, b:$t5 + 2: $t5 := move($t0) + # live vars: $t2, $t3, $t5 + # events: b:$t6 + 3: $t6 := 1 + # live vars: $t2, $t3, $t5, $t6 + # events: e:$t4, e:$t5, e:$t6, b:$t4 + 4: $t4 := +($t5, $t6) # live vars: $t2, $t3 - # events: e:$t2, e:$t3, b:$t1 - 4: $t1 := +($t3, $t2) + # events: e:$t3, b:$t7 + 5: $t7 := move($t3) + # live vars: $t2, $t7 + # events: e:$t2, e:$t7, b:$t1 + 6: $t1 := +($t7, $t2) # live vars: $t1 # events: e:$t1 - 5: return $t1 + 7: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -78,13 +94,17 @@ fun m::copy_kill($t0: u64): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] - var $t5: u64 + var $t5: u64 [unused] + var $t6: u64 + var $t7: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t5 := 1 - 3: $t0 := +($t0, $t5) - 4: $t2 := +($t3, $t2) - 5: return $t2 + 2: $t0 := move($t0) + 3: $t6 := 1 + 4: $t0 := +($t0, $t6) + 5: $t3 := move($t3) + 6: $t2 := +($t3, $t2) + 7: return $t2 } ============ after DeadStoreElimination: ================ @@ -95,13 +115,16 @@ fun m::copy_kill($t0: u64): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] - var $t5: u64 + var $t5: u64 [unused] + var $t6: u64 + var $t7: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t5 := 1 - 3: $t0 := +($t0, $t5) - 4: $t2 := +($t3, $t2) - 5: return $t2 + 2: $t0 := move($t0) + 3: $t6 := 1 + 4: $t0 := +($t0, $t6) + 5: $t2 := +($t3, $t2) + 6: return $t2 } @@ -112,7 +135,6 @@ module c0ffee.m { copy_kill(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.opt.exp index 822f245566624..ebc4a657f613c 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/straight_line_kills.opt.exp @@ -7,13 +7,17 @@ fun m::copy_kill($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := infer($t0) 1: $t3 := infer($t2) - 2: $t5 := 1 - 3: $t4 := +($t0, $t5) - 4: $t0 := infer($t4) - 5: $t1 := +($t3, $t2) - 6: return $t1 + 2: $t5 := infer($t0) + 3: $t6 := 1 + 4: $t4 := +($t5, $t6) + 5: $t0 := infer($t4) + 6: $t7 := infer($t3) + 7: $t1 := +($t7, $t2) + 8: return $t1 } @@ -33,12 +37,16 @@ fun m::copy_kill($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t5 := 1 - 3: $t4 := +($t0, $t5) - 4: $t1 := +($t3, $t2) - 5: return $t1 + 2: $t5 := move($t0) + 3: $t6 := 1 + 4: $t4 := +($t5, $t6) + 5: $t7 := move($t3) + 6: $t1 := +($t7, $t2) + 7: return $t1 } ============ after VariableCoalescingAnnotator: ================ @@ -50,6 +58,8 @@ fun m::copy_kill($t0: u64): u64 { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 + var $t7: u64 # live vars: $t0 # events: b:$t0, b:$t2 0: $t2 := copy($t0) @@ -57,17 +67,23 @@ fun m::copy_kill($t0: u64): u64 { # events: b:$t3 1: $t3 := copy($t2) # live vars: $t0, $t2, $t3 - # events: b:$t5 - 2: $t5 := 1 - # live vars: $t0, $t2, $t3, $t5 - # events: e:$t0, e:$t4, e:$t5, b:$t4 - 3: $t4 := +($t0, $t5) + # events: e:$t0, b:$t5 + 2: $t5 := move($t0) + # live vars: $t2, $t3, $t5 + # events: b:$t6 + 3: $t6 := 1 + # live vars: $t2, $t3, $t5, $t6 + # events: e:$t4, e:$t5, e:$t6, b:$t4 + 4: $t4 := +($t5, $t6) # live vars: $t2, $t3 - # events: e:$t2, e:$t3, b:$t1 - 4: $t1 := +($t3, $t2) + # events: e:$t3, b:$t7 + 5: $t7 := move($t3) + # live vars: $t2, $t7 + # events: e:$t2, e:$t7, b:$t1 + 6: $t1 := +($t7, $t2) # live vars: $t1 # events: e:$t1 - 5: return $t1 + 7: return $t1 } ============ after VariableCoalescingTransformer: ================ @@ -78,13 +94,17 @@ fun m::copy_kill($t0: u64): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] - var $t5: u64 + var $t5: u64 [unused] + var $t6: u64 + var $t7: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t5 := 1 - 3: $t0 := +($t0, $t5) - 4: $t2 := +($t3, $t2) - 5: return $t2 + 2: $t0 := move($t0) + 3: $t6 := 1 + 4: $t0 := +($t0, $t6) + 5: $t3 := move($t3) + 6: $t2 := +($t3, $t2) + 7: return $t2 } ============ after DeadStoreElimination: ================ @@ -95,13 +115,16 @@ fun m::copy_kill($t0: u64): u64 { var $t2: u64 var $t3: u64 var $t4: u64 [unused] - var $t5: u64 + var $t5: u64 [unused] + var $t6: u64 + var $t7: u64 [unused] 0: $t2 := copy($t0) 1: $t3 := copy($t2) - 2: $t5 := 1 - 3: $t0 := +($t0, $t5) - 4: $t2 := +($t3, $t2) - 5: return $t2 + 2: $t0 := move($t0) + 3: $t6 := 1 + 4: $t0 := +($t0, $t6) + 5: $t2 := +($t3, $t2) + 6: return $t2 } @@ -112,7 +135,6 @@ module c0ffee.m { copy_kill(Arg0: u64): u64 /* def_idx: 0 */ { L1: loc0: u64 -L2: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[1](loc0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.exp index 08533b6b6dd91..bcdd09b79ebc9 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.exp @@ -92,12 +92,10 @@ public test(Arg0: u64, Arg1: u64): u64 * u64 /* def_idx: 0 */ { L2: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) - 1: MoveLoc[1](Arg1: u64) - 2: StLoc[0](Arg0: u64) - 3: StLoc[1](Arg1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: MoveLoc[1](Arg1: u64) - 6: Ret + 1: StLoc[2](loc0: u64) + 2: MoveLoc[1](Arg1: u64) + 3: MoveLoc[2](loc0: u64) + 4: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.opt.exp index 08533b6b6dd91..bcdd09b79ebc9 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap.opt.exp @@ -92,12 +92,10 @@ public test(Arg0: u64, Arg1: u64): u64 * u64 /* def_idx: 0 */ { L2: loc0: u64 B0: 0: MoveLoc[0](Arg0: u64) - 1: MoveLoc[1](Arg1: u64) - 2: StLoc[0](Arg0: u64) - 3: StLoc[1](Arg1: u64) - 4: MoveLoc[0](Arg0: u64) - 5: MoveLoc[1](Arg1: u64) - 6: Ret + 1: StLoc[2](loc0: u64) + 2: MoveLoc[1](Arg1: u64) + 3: MoveLoc[2](loc0: u64) + 4: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.exp index 4b4283ceb66ac..b25d39a45b007 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.exp @@ -10,27 +10,31 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t7: u64 var $t8: u64 var $t9: u64 + var $t10: u64 + var $t11: u64 0: $t4 := infer($t0) 1: label L0 - 2: $t7 := 0 - 3: $t6 := >($t4, $t7) - 4: if ($t6) goto 5 else goto 13 - 5: label L2 - 6: $t5 := infer($t0) - 7: $t0 := infer($t1) - 8: $t1 := infer($t5) - 9: $t9 := 1 - 10: $t8 := -($t4, $t9) - 11: $t4 := infer($t8) - 12: goto 15 - 13: label L3 + 2: $t7 := infer($t4) + 3: $t8 := 0 + 4: $t6 := >($t7, $t8) + 5: if ($t6) goto 6 else goto 15 + 6: label L2 + 7: $t5 := infer($t0) + 8: $t0 := infer($t1) + 9: $t1 := infer($t5) + 10: $t10 := infer($t4) + 11: $t11 := 1 + 12: $t9 := -($t10, $t11) + 13: $t4 := infer($t9) 14: goto 17 - 15: label L4 - 16: goto 1 - 17: label L1 - 18: $t2 := infer($t0) - 19: $t3 := infer($t1) - 20: return ($t2, $t3) + 15: label L3 + 16: goto 19 + 17: label L4 + 18: goto 1 + 19: label L1 + 20: $t2 := infer($t0) + 21: $t3 := infer($t1) + 22: return ($t2, $t3) } ============ after DeadStoreElimination: ================ @@ -45,23 +49,27 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t7: u64 var $t8: u64 var $t9: u64 + var $t10: u64 + var $t11: u64 0: $t4 := copy($t0) 1: label L0 - 2: $t7 := 0 - 3: $t6 := >($t4, $t7) - 4: if ($t6) goto 5 else goto 13 - 5: label L2 - 6: $t5 := move($t0) - 7: $t0 := move($t1) - 8: $t1 := move($t5) - 9: $t9 := 1 - 10: $t8 := -($t4, $t9) - 11: $t4 := move($t8) - 12: goto 1 - 13: label L3 - 14: $t2 := move($t0) - 15: $t3 := move($t1) - 16: return ($t2, $t3) + 2: $t7 := copy($t4) + 3: $t8 := 0 + 4: $t6 := >($t7, $t8) + 5: if ($t6) goto 6 else goto 15 + 6: label L2 + 7: $t5 := move($t0) + 8: $t0 := move($t1) + 9: $t1 := move($t5) + 10: $t10 := move($t4) + 11: $t11 := 1 + 12: $t9 := -($t10, $t11) + 13: $t4 := move($t9) + 14: goto 1 + 15: label L3 + 16: $t2 := move($t0) + 17: $t3 := move($t1) + 18: return ($t2, $t3) } ============ after VariableCoalescingAnnotator: ================ @@ -76,6 +84,8 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t7: u64 var $t8: u64 var $t9: u64 + var $t10: u64 + var $t11: u64 # live vars: $t0, $t1 # events: b:$t0, b:$t1, b:$t4 0: $t4 := copy($t0) @@ -83,46 +93,52 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { 1: label L0 # live vars: $t0, $t1, $t4 # events: b:$t7 - 2: $t7 := 0 + 2: $t7 := copy($t4) # live vars: $t0, $t1, $t4, $t7 - # events: e:$t7, b:$t6 - 3: $t6 := >($t4, $t7) + # events: b:$t8 + 3: $t8 := 0 + # live vars: $t0, $t1, $t4, $t7, $t8 + # events: e:$t7, e:$t8, b:$t6 + 4: $t6 := >($t7, $t8) # live vars: $t0, $t1, $t4, $t6 # events: e:$t6 - 4: if ($t6) goto 5 else goto 13 + 5: if ($t6) goto 6 else goto 15 # live vars: $t0, $t1, $t4 - 5: label L2 + 6: label L2 # live vars: $t0, $t1, $t4 # events: b:$t5 - 6: $t5 := move($t0) + 7: $t5 := move($t0) # live vars: $t1, $t4, $t5 - 7: $t0 := move($t1) + 8: $t0 := move($t1) # live vars: $t0, $t4, $t5 # events: e:$t5 - 8: $t1 := move($t5) + 9: $t1 := move($t5) # live vars: $t0, $t1, $t4 - # events: b:$t9 - 9: $t9 := 1 - # live vars: $t0, $t1, $t4, $t9 - # events: e:$t9, b:$t8 - 10: $t8 := -($t4, $t9) - # live vars: $t0, $t1, $t8 - # events: e:$t8 - 11: $t4 := move($t8) + # events: b:$t10 + 10: $t10 := move($t4) + # live vars: $t0, $t1, $t10 + # events: b:$t11 + 11: $t11 := 1 + # live vars: $t0, $t1, $t10, $t11 + # events: e:$t10, e:$t11, b:$t9 + 12: $t9 := -($t10, $t11) + # live vars: $t0, $t1, $t9 + # events: e:$t9 + 13: $t4 := move($t9) # live vars: $t0, $t1, $t4 - 12: goto 1 + 14: goto 1 # live vars: $t0, $t1, $t4 # events: e:$t4 - 13: label L3 + 15: label L3 # live vars: $t0, $t1 # events: e:$t0, b:$t2 - 14: $t2 := move($t0) + 16: $t2 := move($t0) # live vars: $t1, $t2 # events: e:$t1, b:$t3 - 15: $t3 := move($t1) + 17: $t3 := move($t1) # live vars: $t2, $t3 # events: e:$t2, e:$t3 - 16: return ($t2, $t3) + 18: return ($t2, $t3) } ============ after VariableCoalescingTransformer: ================ @@ -135,25 +151,29 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t5: u64 [unused] var $t6: bool var $t7: u64 - var $t8: u64 [unused] + var $t8: u64 var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] 0: $t4 := copy($t0) 1: label L0 - 2: $t7 := 0 - 3: $t6 := >($t4, $t7) - 4: if ($t6) goto 5 else goto 13 - 5: label L2 - 6: $t7 := move($t0) - 7: $t0 := move($t1) - 8: $t1 := move($t7) - 9: $t7 := 1 - 10: $t7 := -($t4, $t7) - 11: $t4 := move($t7) - 12: goto 1 - 13: label L3 - 14: $t0 := move($t0) - 15: $t1 := move($t1) - 16: return ($t0, $t1) + 2: $t7 := copy($t4) + 3: $t8 := 0 + 4: $t6 := >($t7, $t8) + 5: if ($t6) goto 6 else goto 15 + 6: label L2 + 7: $t7 := move($t0) + 8: $t0 := move($t1) + 9: $t1 := move($t7) + 10: $t7 := move($t4) + 11: $t8 := 1 + 12: $t7 := -($t7, $t8) + 13: $t4 := move($t7) + 14: goto 1 + 15: label L3 + 16: $t0 := move($t0) + 17: $t1 := move($t1) + 18: return ($t0, $t1) } ============ after DeadStoreElimination: ================ @@ -166,23 +186,29 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t5: u64 [unused] var $t6: bool var $t7: u64 - var $t8: u64 [unused] + var $t8: u64 var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] 0: $t4 := copy($t0) 1: label L0 - 2: $t7 := 0 - 3: $t6 := >($t4, $t7) - 4: if ($t6) goto 5 else goto 13 - 5: label L2 - 6: $t7 := move($t0) - 7: $t0 := move($t1) - 8: $t1 := move($t7) - 9: $t7 := 1 - 10: $t7 := -($t4, $t7) - 11: $t4 := move($t7) - 12: goto 1 - 13: label L3 - 14: return ($t0, $t1) + 2: $t7 := copy($t4) + 3: $t8 := 0 + 4: $t6 := >($t7, $t8) + 5: if ($t6) goto 6 else goto 15 + 6: label L2 + 7: $t7 := move($t0) + 8: $t0 := move($t1) + 9: $t1 := move($t7) + 10: $t7 := move($t4) + 11: $t8 := 1 + 12: $t7 := -($t7, $t8) + 13: $t4 := move($t7) + 14: goto 1 + 15: label L3 + 16: $t0 := move($t0) + 17: $t1 := move($t1) + 18: return ($t0, $t1) } @@ -193,7 +219,6 @@ module c0ffee.m { public test(Arg0: u64, Arg1: u64): u64 * u64 /* def_idx: 0 */ { L2: loc0: u64 -L3: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[2](loc0: u64) @@ -206,11 +231,11 @@ B2: 6: MoveLoc[0](Arg0: u64) 7: MoveLoc[1](Arg1: u64) 8: StLoc[0](Arg0: u64) - 9: MoveLoc[2](loc0: u64) - 10: LdU64(1) - 11: Sub - 12: StLoc[2](loc0: u64) - 13: StLoc[1](Arg1: u64) + 9: StLoc[1](Arg1: u64) + 10: MoveLoc[2](loc0: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[2](loc0: u64) 14: Branch(2) B3: 15: MoveLoc[0](Arg0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.opt.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.opt.exp index 4b4283ceb66ac..b25d39a45b007 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.opt.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/swap_in_a_loop.opt.exp @@ -10,27 +10,31 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t7: u64 var $t8: u64 var $t9: u64 + var $t10: u64 + var $t11: u64 0: $t4 := infer($t0) 1: label L0 - 2: $t7 := 0 - 3: $t6 := >($t4, $t7) - 4: if ($t6) goto 5 else goto 13 - 5: label L2 - 6: $t5 := infer($t0) - 7: $t0 := infer($t1) - 8: $t1 := infer($t5) - 9: $t9 := 1 - 10: $t8 := -($t4, $t9) - 11: $t4 := infer($t8) - 12: goto 15 - 13: label L3 + 2: $t7 := infer($t4) + 3: $t8 := 0 + 4: $t6 := >($t7, $t8) + 5: if ($t6) goto 6 else goto 15 + 6: label L2 + 7: $t5 := infer($t0) + 8: $t0 := infer($t1) + 9: $t1 := infer($t5) + 10: $t10 := infer($t4) + 11: $t11 := 1 + 12: $t9 := -($t10, $t11) + 13: $t4 := infer($t9) 14: goto 17 - 15: label L4 - 16: goto 1 - 17: label L1 - 18: $t2 := infer($t0) - 19: $t3 := infer($t1) - 20: return ($t2, $t3) + 15: label L3 + 16: goto 19 + 17: label L4 + 18: goto 1 + 19: label L1 + 20: $t2 := infer($t0) + 21: $t3 := infer($t1) + 22: return ($t2, $t3) } ============ after DeadStoreElimination: ================ @@ -45,23 +49,27 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t7: u64 var $t8: u64 var $t9: u64 + var $t10: u64 + var $t11: u64 0: $t4 := copy($t0) 1: label L0 - 2: $t7 := 0 - 3: $t6 := >($t4, $t7) - 4: if ($t6) goto 5 else goto 13 - 5: label L2 - 6: $t5 := move($t0) - 7: $t0 := move($t1) - 8: $t1 := move($t5) - 9: $t9 := 1 - 10: $t8 := -($t4, $t9) - 11: $t4 := move($t8) - 12: goto 1 - 13: label L3 - 14: $t2 := move($t0) - 15: $t3 := move($t1) - 16: return ($t2, $t3) + 2: $t7 := copy($t4) + 3: $t8 := 0 + 4: $t6 := >($t7, $t8) + 5: if ($t6) goto 6 else goto 15 + 6: label L2 + 7: $t5 := move($t0) + 8: $t0 := move($t1) + 9: $t1 := move($t5) + 10: $t10 := move($t4) + 11: $t11 := 1 + 12: $t9 := -($t10, $t11) + 13: $t4 := move($t9) + 14: goto 1 + 15: label L3 + 16: $t2 := move($t0) + 17: $t3 := move($t1) + 18: return ($t2, $t3) } ============ after VariableCoalescingAnnotator: ================ @@ -76,6 +84,8 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t7: u64 var $t8: u64 var $t9: u64 + var $t10: u64 + var $t11: u64 # live vars: $t0, $t1 # events: b:$t0, b:$t1, b:$t4 0: $t4 := copy($t0) @@ -83,46 +93,52 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { 1: label L0 # live vars: $t0, $t1, $t4 # events: b:$t7 - 2: $t7 := 0 + 2: $t7 := copy($t4) # live vars: $t0, $t1, $t4, $t7 - # events: e:$t7, b:$t6 - 3: $t6 := >($t4, $t7) + # events: b:$t8 + 3: $t8 := 0 + # live vars: $t0, $t1, $t4, $t7, $t8 + # events: e:$t7, e:$t8, b:$t6 + 4: $t6 := >($t7, $t8) # live vars: $t0, $t1, $t4, $t6 # events: e:$t6 - 4: if ($t6) goto 5 else goto 13 + 5: if ($t6) goto 6 else goto 15 # live vars: $t0, $t1, $t4 - 5: label L2 + 6: label L2 # live vars: $t0, $t1, $t4 # events: b:$t5 - 6: $t5 := move($t0) + 7: $t5 := move($t0) # live vars: $t1, $t4, $t5 - 7: $t0 := move($t1) + 8: $t0 := move($t1) # live vars: $t0, $t4, $t5 # events: e:$t5 - 8: $t1 := move($t5) + 9: $t1 := move($t5) # live vars: $t0, $t1, $t4 - # events: b:$t9 - 9: $t9 := 1 - # live vars: $t0, $t1, $t4, $t9 - # events: e:$t9, b:$t8 - 10: $t8 := -($t4, $t9) - # live vars: $t0, $t1, $t8 - # events: e:$t8 - 11: $t4 := move($t8) + # events: b:$t10 + 10: $t10 := move($t4) + # live vars: $t0, $t1, $t10 + # events: b:$t11 + 11: $t11 := 1 + # live vars: $t0, $t1, $t10, $t11 + # events: e:$t10, e:$t11, b:$t9 + 12: $t9 := -($t10, $t11) + # live vars: $t0, $t1, $t9 + # events: e:$t9 + 13: $t4 := move($t9) # live vars: $t0, $t1, $t4 - 12: goto 1 + 14: goto 1 # live vars: $t0, $t1, $t4 # events: e:$t4 - 13: label L3 + 15: label L3 # live vars: $t0, $t1 # events: e:$t0, b:$t2 - 14: $t2 := move($t0) + 16: $t2 := move($t0) # live vars: $t1, $t2 # events: e:$t1, b:$t3 - 15: $t3 := move($t1) + 17: $t3 := move($t1) # live vars: $t2, $t3 # events: e:$t2, e:$t3 - 16: return ($t2, $t3) + 18: return ($t2, $t3) } ============ after VariableCoalescingTransformer: ================ @@ -135,25 +151,29 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t5: u64 [unused] var $t6: bool var $t7: u64 - var $t8: u64 [unused] + var $t8: u64 var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] 0: $t4 := copy($t0) 1: label L0 - 2: $t7 := 0 - 3: $t6 := >($t4, $t7) - 4: if ($t6) goto 5 else goto 13 - 5: label L2 - 6: $t7 := move($t0) - 7: $t0 := move($t1) - 8: $t1 := move($t7) - 9: $t7 := 1 - 10: $t7 := -($t4, $t7) - 11: $t4 := move($t7) - 12: goto 1 - 13: label L3 - 14: $t0 := move($t0) - 15: $t1 := move($t1) - 16: return ($t0, $t1) + 2: $t7 := copy($t4) + 3: $t8 := 0 + 4: $t6 := >($t7, $t8) + 5: if ($t6) goto 6 else goto 15 + 6: label L2 + 7: $t7 := move($t0) + 8: $t0 := move($t1) + 9: $t1 := move($t7) + 10: $t7 := move($t4) + 11: $t8 := 1 + 12: $t7 := -($t7, $t8) + 13: $t4 := move($t7) + 14: goto 1 + 15: label L3 + 16: $t0 := move($t0) + 17: $t1 := move($t1) + 18: return ($t0, $t1) } ============ after DeadStoreElimination: ================ @@ -166,23 +186,29 @@ public fun m::test($t0: u64, $t1: u64): (u64, u64) { var $t5: u64 [unused] var $t6: bool var $t7: u64 - var $t8: u64 [unused] + var $t8: u64 var $t9: u64 [unused] + var $t10: u64 [unused] + var $t11: u64 [unused] 0: $t4 := copy($t0) 1: label L0 - 2: $t7 := 0 - 3: $t6 := >($t4, $t7) - 4: if ($t6) goto 5 else goto 13 - 5: label L2 - 6: $t7 := move($t0) - 7: $t0 := move($t1) - 8: $t1 := move($t7) - 9: $t7 := 1 - 10: $t7 := -($t4, $t7) - 11: $t4 := move($t7) - 12: goto 1 - 13: label L3 - 14: return ($t0, $t1) + 2: $t7 := copy($t4) + 3: $t8 := 0 + 4: $t6 := >($t7, $t8) + 5: if ($t6) goto 6 else goto 15 + 6: label L2 + 7: $t7 := move($t0) + 8: $t0 := move($t1) + 9: $t1 := move($t7) + 10: $t7 := move($t4) + 11: $t8 := 1 + 12: $t7 := -($t7, $t8) + 13: $t4 := move($t7) + 14: goto 1 + 15: label L3 + 16: $t0 := move($t0) + 17: $t1 := move($t1) + 18: return ($t0, $t1) } @@ -193,7 +219,6 @@ module c0ffee.m { public test(Arg0: u64, Arg1: u64): u64 * u64 /* def_idx: 0 */ { L2: loc0: u64 -L3: loc1: u64 B0: 0: CopyLoc[0](Arg0: u64) 1: StLoc[2](loc0: u64) @@ -206,11 +231,11 @@ B2: 6: MoveLoc[0](Arg0: u64) 7: MoveLoc[1](Arg1: u64) 8: StLoc[0](Arg0: u64) - 9: MoveLoc[2](loc0: u64) - 10: LdU64(1) - 11: Sub - 12: StLoc[2](loc0: u64) - 13: StLoc[1](Arg1: u64) + 9: StLoc[1](Arg1: u64) + 10: MoveLoc[2](loc0: u64) + 11: LdU64(1) + 12: Sub + 13: StLoc[2](loc0: u64) 14: Branch(2) B3: 15: MoveLoc[0](Arg0: u64) diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/unused_add.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/unused_add.exp index 850ba7d9bb591..e408f58495292 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/unused_add.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/unused_add.exp @@ -13,10 +13,12 @@ public fun m::test() { var $t0: u64 var $t1: u64 var $t2: u64 + var $t3: u64 0: $t0 := 1 1: $t1 := 2 - 2: $t2 := +($t0, $t1) - 3: return () + 2: $t3 := infer($t0) + 3: $t2 := +($t3, $t1) + 4: return () } @@ -34,10 +36,12 @@ public fun m::test() { var $t0: u64 var $t1: u64 var $t2: u64 + var $t3: u64 0: $t0 := 1 1: $t1 := 2 - 2: $t2 := +($t0, $t1) - 3: return () + 2: $t3 := move($t0) + 3: $t2 := +($t3, $t1) + 4: return () } ============ after VariableCoalescingAnnotator: ================ @@ -47,6 +51,7 @@ public fun m::test() { var $t0: u64 var $t1: u64 var $t2: u64 + var $t3: u64 # live vars: # events: b:$t0 0: $t0 := 1 @@ -54,10 +59,13 @@ public fun m::test() { # events: b:$t1 1: $t1 := 2 # live vars: $t0, $t1 - # events: e:$t0, e:$t1, e:$t2, b:$t2 - 2: $t2 := +($t0, $t1) + # events: e:$t0, b:$t3 + 2: $t3 := move($t0) + # live vars: $t1, $t3 + # events: e:$t1, e:$t2, e:$t3, b:$t2 + 3: $t2 := +($t3, $t1) # live vars: - 3: return () + 4: return () } ============ after VariableCoalescingTransformer: ================ @@ -67,10 +75,12 @@ public fun m::test() { var $t0: u64 var $t1: u64 var $t2: u64 [unused] + var $t3: u64 [unused] 0: $t0 := 1 1: $t1 := 2 - 2: $t0 := +($t0, $t1) - 3: return () + 2: $t0 := move($t0) + 3: $t0 := +($t0, $t1) + 4: return () } ============ after DeadStoreElimination: ================ @@ -80,6 +90,7 @@ public fun m::test() { var $t0: u64 var $t1: u64 var $t2: u64 [unused] + var $t3: u64 [unused] 0: $t0 := 1 1: $t1 := 2 2: $t0 := +($t0, $t1) diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/deep_exp.no-optimize.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/deep_exp.no-optimize.exp index 756e53eb56d10..baae5717928b6 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/deep_exp.no-optimize.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/inlining/deep_exp.no-optimize.exp @@ -1,23 +1,6 @@ -comparison between v1 and v2 failed: -= processed 2 tasks -= -+ task 0 'publish'. lines 1-28: -+ Error: compilation errors: -+ error: exceeded maximal local count: 255 -+ ┌─ TEMPFILE:19:16 -+ │ -+ 19 │ public fun test(): u64 { -+ │ ^^^^ -+ -+ -+ -= task 1 'run'. lines 30-30: -- return values: 625 -+ Error: Function execution failed with VMError: { -+ major_status: LINKER_ERROR, -+ sub_status: None, -+ location: undefined, -+ indices: redacted, -+ offsets: redacted, -+ } -= +processed 2 tasks + +task 1 'run'. lines 30-30: +return values: 625 + +==> Compiler v2 delivered same results! diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bitwise_features.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bitwise_features.exp new file mode 100644 index 0000000000000..a6db107b3b9ca --- /dev/null +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bitwise_features.exp @@ -0,0 +1,3 @@ +processed 2 tasks + +==> Compiler v2 delivered same results! diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bitwise_features.move b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bitwise_features.move new file mode 100644 index 0000000000000..22d826b57cfe9 --- /dev/null +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bitwise_features.move @@ -0,0 +1,58 @@ +//# publish +module 0x42::TestFeatures { + use std::vector; + + /// The enabled features, represented by a bitset stored on chain. + struct Features has key { + features: vector, + } + + /// Helper to check whether a feature flag is enabled. + fun contains(features: &vector, feature: u64): bool { + let byte_index = feature / 8; + let bit_mask = 1 << ((feature % 8) as u8); + byte_index < vector::length(features) && ((*vector::borrow(features, byte_index))) & bit_mask != 0 + } + + fun set(features: &mut vector, feature: u64, include: bool) { + let old_n = vector::length(features); // ghost var + let _old_features = *features; // ghost var + let n = old_n; // ghost var + + let byte_index = feature / 8; + let bit_mask = 1 << ((feature % 8) as u8); + while ({ + vector::length(features) <= byte_index + }) { + vector::push_back(features, 0); + n = n + 1; + }; + let entry = vector::borrow_mut(features, byte_index); + if (include) + *entry = *entry | bit_mask + else + *entry = *entry & (0xff ^ bit_mask) + } + + public fun enable_feature_flags(enable: vector) acquires Features { + let features = &mut borrow_global_mut(@0xbeef).features; + let i = 0; + let n = vector::length(&enable); + while ({ + i < n + }) { + set(features, *vector::borrow(&enable, i), true); + i = i + 1; + }; + } + + public fun test(s: signer) acquires Features { + move_to(&s, Features { features: vector[1, 2, 3] }); + enable_feature_flags(vector[2]); + assert!(contains(&borrow_global(@0xbeef).features, 2), 0); + assert!(!contains(&borrow_global(@0xbeef).features, 1), 1); + assert!(!contains(&borrow_global(@0xbeef).features, 3), 2); + } +} + +//# run 0x42::TestFeatures::test --signers 0xbeef diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bug_14243_stack_size.no-optimize.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bug_14243_stack_size.no-optimize.exp index 478e6e10b07a0..43fa023709801 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bug_14243_stack_size.no-optimize.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/bug_14243_stack_size.no-optimize.exp @@ -7,13 +7,9 @@ comparison between v1 and v2 failed: = = = id_mut(Arg0: &mut Ty0): &mut Ty0 /* def_idx: 0 */ { -+ L1: loc0: &mut Ty0 = B0: = 0: MoveLoc[0](Arg0: &mut Ty0) -- 1: Ret -+ 1: StLoc[1](loc0: &mut Ty0) -+ 2: MoveLoc[1](loc0: &mut Ty0) -+ 3: Ret += 1: Ret = } = t0() /* def_idx: 1 */ { = L0: loc0: u64 diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/misc/vector_popback.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/vector_popback.exp new file mode 100644 index 0000000000000..15b4a3261910f --- /dev/null +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/vector_popback.exp @@ -0,0 +1,3 @@ +processed 3 tasks + +==> Compiler v2 delivered same results! diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/misc/vector_popback.move b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/vector_popback.move new file mode 100644 index 0000000000000..c37a6ba8deb27 --- /dev/null +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/misc/vector_popback.move @@ -0,0 +1,37 @@ +//# publish +module 0x42::vector { + fun create(): vector { + vector[1, 2, 3] + } + + public fun test_fold() { + use std::vector; + let v = vector[1]; + let accu = vector::fold(v, 0, |_, _| 0 ); + assert!(accu == 0 , 0) + } + + public fun test_remove() { + use std::vector; + let v = create(); + let e = remove(&mut v, 1); + assert!(e == 2, 0); + assert!(vector::length(&v) == 2, 0); + assert!(*vector::borrow(&v, 0) == 1, 0); + assert!(*vector::borrow(&v, 1) == 3, 0); + } + + public fun remove(v: &mut vector, i: u64): Element { + use std::vector; + let len = vector::length(v); + if (i >= len) abort 1; + + len = len - 1; + while (i < len) vector::swap(v, i, { i = i + 1; i }); + vector::pop_back(v) + } +} + +//# run 0x42::vector::test_fold + +//# run 0x42::vector::test_remove diff --git a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.no-optimize.exp b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.no-optimize.exp index 338c3a8756696..6b808b49a2d81 100644 --- a/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.no-optimize.exp +++ b/third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/assert_one.no-optimize.exp @@ -6,5 +6,5 @@ Error: Script execution failed with VMError: { sub_status: Some(14566554180833181696), location: script, indices: [], - offsets: [(FunctionDefinitionIndex(0), 32)], + offsets: [(FunctionDefinitionIndex(0), 26)], } diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/abort_example.exp b/third_party/move/move-model/bytecode/ast-generator-tests/tests/abort_example.exp index bf73e7d811621..bd030fe155637 100644 --- a/third_party/move/move-model/bytecode/ast-generator-tests/tests/abort_example.exp +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/abort_example.exp @@ -12,90 +12,89 @@ public fun f(length: u64): u64 { --- Stackless Bytecode public fun m::f($t0|length: u64): u64 { var $t1|$t3: u64 - var $t2|$t11: u64 [unused] + var $t2: u64 var $t3: u64 - var $t4: u64 - var $t5: bool + var $t4: bool + var $t5: u64 var $t6: u64 - var $t7: u64 - var $t8: bool + var $t7: bool + var $t8: u64 var $t9: u64 var $t10: u64 - var $t11: u64 - var $t12: bool + var $t11: bool + var $t12: u64 var $t13: u64 var $t14: u64 var $t15: u64 var $t16: u64 var $t17: u64 - var $t18: u64 - 0: $t3 := copy($t0) - 1: $t4 := 0 - 2: $t5 := >($t3, $t4) - 3: if ($t5) goto 4 else goto 30 + 0: $t2 := copy($t0) + 1: $t3 := 0 + 2: $t4 := >($t2, $t3) + 3: if ($t4) goto 4 else goto 30 4: label L1 - 5: $t6 := copy($t0) - 6: $t7 := 100 - 7: $t8 := <($t6, $t7) - 8: if ($t8) goto 9 else goto 27 + 5: $t5 := copy($t0) + 6: $t6 := 100 + 7: $t7 := <($t5, $t6) + 8: if ($t7) goto 9 else goto 27 9: label L3 - 10: $t9 := 0 - 11: $t1 := $t9 + 10: $t8 := 0 + 11: $t1 := $t8 12: goto 13 13: label L6 - 14: $t10 := copy($t1) - 15: $t11 := copy($t0) - 16: $t12 := <($t10, $t11) - 17: if ($t12) goto 18 else goto 24 + 14: $t9 := copy($t1) + 15: $t10 := copy($t0) + 16: $t11 := <($t9, $t10) + 17: if ($t11) goto 18 else goto 24 18: label L5 - 19: $t13 := move($t1) - 20: $t14 := 1 - 21: $t15 := +($t13, $t14) - 22: $t1 := $t15 + 19: $t12 := move($t1) + 20: $t13 := 1 + 21: $t14 := +($t12, $t13) + 22: $t1 := $t14 23: goto 13 24: label L4 - 25: $t16 := move($t1) - 26: return $t16 + 25: $t15 := move($t1) + 26: return $t15 27: label L2 - 28: $t17 := 2 - 29: abort($t17) + 28: $t16 := 2 + 29: abort($t16) 30: label L0 - 31: $t18 := 1 - 32: abort($t18) + 31: $t17 := 1 + 32: abort($t17) } --- Raw Generated AST -_t3: u64 = length; -_t4: u64 = 0; -_t5: bool = Gt(_t3, _t4); +_t2: u64 = length; +_t3: u64 = 0; +_t4: bool = Gt(_t2, _t3); loop { - if (_t5) break; - _t18: u64 = 1; - Abort(_t18) + if (_t4) break; + _t17: u64 = 1; + Abort(_t17) }; -_t6: u64 = length; -_t7: u64 = 100; -_t8: bool = Lt(_t6, _t7); +_t5: u64 = length; +_t6: u64 = 100; +_t7: bool = Lt(_t5, _t6); loop { - if (_t8) break; - _t17: u64 = 2; - Abort(_t17) + if (_t7) break; + _t16: u64 = 2; + Abort(_t16) }; -_t9: u64 = 0; -_t1: u64 = _t9; +_t8: u64 = 0; +_t1: u64 = _t8; loop { - _t10: u64 = _t1; - _t11: u64 = length; - _t12: bool = Lt(_t10, _t11); - if (Not(_t12)) break; - _t13: u64 = _t1; - _t14: u64 = 1; - _t15: u64 = Add(_t13, _t14); - _t1: u64 = _t15; + _t9: u64 = _t1; + _t10: u64 = length; + _t11: bool = Lt(_t9, _t10); + if (Not(_t11)) break; + _t12: u64 = _t1; + _t13: u64 = 1; + _t14: u64 = Add(_t12, _t13); + _t1: u64 = _t14; continue }; -_t16: u64 = _t1; -return _t16 +_t15: u64 = _t1; +return _t15 --- Assign-Transformed Generated AST loop { diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/bit_vector_loop_example.exp b/third_party/move/move-model/bytecode/ast-generator-tests/tests/bit_vector_loop_example.exp index 732f4d6f359fb..0d69bba7b69b8 100644 --- a/third_party/move/move-model/bytecode/ast-generator-tests/tests/bit_vector_loop_example.exp +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/bit_vector_loop_example.exp @@ -8,68 +8,56 @@ public fun is_index_set(self: &BitVector, bit_index: u64): bool { --- Stackless Bytecode public fun m::is_index_set($t0|self: &0x1::m::BitVector, $t1|bit_index: u64): bool { - var $t2|$t4: u64 - var $t3|$t5: u64 - var $t4: u64 - var $t5: &0x1::m::BitVector - var $t6: &vector - var $t7: u64 - var $t8: u64 + var $t2: u64 + var $t3: &0x1::m::BitVector + var $t4: &vector + var $t5: u64 + var $t6: bool + var $t7: &0x1::m::BitVector + var $t8: &vector var $t9: u64 - var $t10: bool - var $t11: &0x1::m::BitVector - var $t12: &vector + var $t10: &bool + var $t11: bool + var $t12: &0x1::m::BitVector var $t13: u64 - var $t14: &bool - var $t15: bool - var $t16: &0x1::m::BitVector - var $t17: u64 - 0: $t4 := copy($t1) - 1: $t2 := $t4 - 2: $t5 := copy($t0) - 3: $t6 := borrow_field<0x1::m::BitVector>.bit_field($t5) - 4: $t7 := vector::length($t6) - 5: $t3 := $t7 - 6: $t8 := move($t2) - 7: $t9 := move($t3) - 8: $t10 := <($t8, $t9) - 9: if ($t10) goto 10 else goto 17 - 10: label L1 - 11: $t11 := move($t0) - 12: $t12 := borrow_field<0x1::m::BitVector>.bit_field($t11) - 13: $t13 := move($t1) - 14: $t14 := vector::borrow($t12, $t13) - 15: $t15 := read_ref($t14) - 16: return $t15 - 17: label L0 - 18: $t16 := move($t0) - 19: drop($t16) - 20: $t17 := 131072 - 21: abort($t17) + 0: $t2 := copy($t1) + 1: $t3 := copy($t0) + 2: $t4 := borrow_field<0x1::m::BitVector>.bit_field($t3) + 3: $t5 := vector::length($t4) + 4: $t6 := <($t2, $t5) + 5: if ($t6) goto 6 else goto 13 + 6: label L1 + 7: $t7 := move($t0) + 8: $t8 := borrow_field<0x1::m::BitVector>.bit_field($t7) + 9: $t9 := move($t1) + 10: $t10 := vector::borrow($t8, $t9) + 11: $t11 := read_ref($t10) + 12: return $t11 + 13: label L0 + 14: $t12 := move($t0) + 15: drop($t12) + 16: $t13 := 131072 + 17: abort($t13) } --- Raw Generated AST -_t4: u64 = bit_index; -_t2: u64 = _t4; -_t5: &BitVector = self; -_t6: &vector = select m::BitVector.bit_field(_t5); -_t7: u64 = vector::length(_t6); -_t3: u64 = _t7; -_t8: u64 = _t2; -_t9: u64 = _t3; -_t10: bool = Lt(_t8, _t9); +_t2: u64 = bit_index; +_t3: &BitVector = self; +_t4: &vector = select m::BitVector.bit_field(_t3); +_t5: u64 = vector::length(_t4); +_t6: bool = Lt(_t2, _t5); loop { - if (_t10) break; - _t16: &BitVector = self; - _t17: u64 = 131072; - Abort(_t17) + if (_t6) break; + _t12: &BitVector = self; + _t13: u64 = 131072; + Abort(_t13) }; -_t11: &BitVector = self; -_t12: &vector = select m::BitVector.bit_field(_t11); -_t13: u64 = bit_index; -_t14: &bool = vector::borrow(_t12, _t13); -_t15: bool = Deref(_t14); -return _t15 +_t7: &BitVector = self; +_t8: &vector = select m::BitVector.bit_field(_t7); +_t9: u64 = bit_index; +_t10: &bool = vector::borrow(_t8, _t9); +_t11: bool = Deref(_t10); +return _t11 --- Assign-Transformed Generated AST loop { @@ -97,75 +85,63 @@ public fun set(self: &mut BitVector, bit_index: u64) { --- Stackless Bytecode public fun m::set($t0|self: &mut 0x1::m::BitVector, $t1|bit_index: u64) { - var $t2|$t3: u64 - var $t3|$t4: u64 - var $t4|x: &mut bool - var $t5: u64 - var $t6: &mut 0x1::m::BitVector - var $t7: &vector - var $t8: u64 - var $t9: u64 + var $t2|x: &mut bool + var $t3: u64 + var $t4: &mut 0x1::m::BitVector + var $t5: &vector + var $t6: u64 + var $t7: bool + var $t8: &mut 0x1::m::BitVector + var $t9: &mut vector var $t10: u64 - var $t11: bool - var $t12: &mut 0x1::m::BitVector - var $t13: &mut vector - var $t14: u64 - var $t15: &mut bool - var $t16: bool - var $t17: &mut bool - var $t18: &mut 0x1::m::BitVector - var $t19: u64 - 0: $t5 := copy($t1) - 1: $t2 := $t5 - 2: $t6 := copy($t0) - 3: $t7 := borrow_field<0x1::m::BitVector>.bit_field($t6) - 4: $t8 := vector::length($t7) - 5: $t3 := $t8 - 6: $t9 := move($t2) - 7: $t10 := move($t3) - 8: $t11 := <($t9, $t10) - 9: if ($t11) goto 10 else goto 20 - 10: label L1 - 11: $t12 := move($t0) - 12: $t13 := borrow_field<0x1::m::BitVector>.bit_field($t12) - 13: $t14 := move($t1) - 14: $t15 := vector::borrow_mut($t13, $t14) - 15: $t4 := $t15 - 16: $t16 := true - 17: $t17 := move($t4) - 18: write_ref($t17, $t16) - 19: return () - 20: label L0 - 21: $t18 := move($t0) - 22: drop($t18) - 23: $t19 := 131072 - 24: abort($t19) + var $t11: &mut bool + var $t12: bool + var $t13: &mut bool + var $t14: &mut 0x1::m::BitVector + var $t15: u64 + 0: $t3 := copy($t1) + 1: $t4 := copy($t0) + 2: $t5 := borrow_field<0x1::m::BitVector>.bit_field($t4) + 3: $t6 := vector::length($t5) + 4: $t7 := <($t3, $t6) + 5: if ($t7) goto 6 else goto 16 + 6: label L1 + 7: $t8 := move($t0) + 8: $t9 := borrow_field<0x1::m::BitVector>.bit_field($t8) + 9: $t10 := move($t1) + 10: $t11 := vector::borrow_mut($t9, $t10) + 11: $t2 := $t11 + 12: $t12 := true + 13: $t13 := move($t2) + 14: write_ref($t13, $t12) + 15: return () + 16: label L0 + 17: $t14 := move($t0) + 18: drop($t14) + 19: $t15 := 131072 + 20: abort($t15) } --- Raw Generated AST -_t5: u64 = bit_index; -_t2: u64 = _t5; -_t6: &mut BitVector = self; -_t7: &vector = select m::BitVector.bit_field(_t6); -_t8: u64 = vector::length(_t7); -_t3: u64 = _t8; -_t9: u64 = _t2; -_t10: u64 = _t3; -_t11: bool = Lt(_t9, _t10); +_t3: u64 = bit_index; +_t4: &mut BitVector = self; +_t5: &vector = select m::BitVector.bit_field(_t4); +_t6: u64 = vector::length(_t5); +_t7: bool = Lt(_t3, _t6); loop { - if (_t11) break; - _t18: &mut BitVector = self; - _t19: u64 = 131072; - Abort(_t19) + if (_t7) break; + _t14: &mut BitVector = self; + _t15: u64 = 131072; + Abort(_t15) }; -_t12: &mut BitVector = self; -_t13: &mut vector = select m::BitVector.bit_field(_t12); -_t14: u64 = bit_index; -_t15: &mut bool = vector::borrow_mut(_t13, _t14); -_t4: &mut bool = _t15; -_t16: bool = true; -_t17: &mut bool = _t4; -_t17 = _t16; +_t8: &mut BitVector = self; +_t9: &mut vector = select m::BitVector.bit_field(_t8); +_t10: u64 = bit_index; +_t11: &mut bool = vector::borrow_mut(_t9, _t10); +_t2: &mut bool = _t11; +_t12: bool = true; +_t13: &mut bool = _t2; +_t13 = _t12; return Tuple() --- Assign-Transformed Generated AST @@ -214,361 +190,320 @@ public fun shift_left(self: &mut BitVector, amount: u64) { --- Stackless Bytecode public fun m::shift_left($t0|self: &mut 0x1::m::BitVector, $t1|amount: u64) { - var $t2|$t3: u64 - var $t3|$t6: &mut vector - var $t4|$t9: u64 - var $t5|$t10: u64 - var $t6|$t13: &mut bool - var $t7: &mut 0x1::m::BitVector - var $t8: &u64 - var $t9: u64 - var $t10: u64 - var $t11: u64 - var $t12: bool - var $t13: &mut 0x1::m::BitVector + var $t2|$t7: &mut vector + var $t3|$t3: u64 + var $t4|$t14: &mut bool + var $t5: u64 + var $t6: &mut 0x1::m::BitVector + var $t7: &u64 + var $t8: u64 + var $t9: bool + var $t10: &mut 0x1::m::BitVector + var $t11: &mut vector + var $t12: u64 + var $t13: u64 var $t14: &mut vector - var $t15: u64 + var $t15: &vector var $t16: u64 - var $t17: &mut vector - var $t18: &vector + var $t17: bool + var $t18: &mut vector var $t19: u64 - var $t20: u64 - var $t21: u64 - var $t22: bool - var $t23: &mut vector + var $t20: &mut bool + var $t21: bool + var $t22: &mut bool + var $t23: u64 var $t24: u64 - var $t25: &mut bool - var $t26: bool - var $t27: &mut bool + var $t25: u64 + var $t26: &mut vector + var $t27: u64 var $t28: u64 - var $t29: u64 - var $t30: u64 - var $t31: &mut vector - var $t32: u64 + var $t29: &mut 0x1::m::BitVector + var $t30: &u64 + var $t31: u64 + var $t32: bool var $t33: &mut 0x1::m::BitVector - var $t34: &u64 + var $t34: &0x1::m::BitVector var $t35: u64 - var $t36: u64 - var $t37: u64 - var $t38: bool - var $t39: &mut 0x1::m::BitVector - var $t40: &0x1::m::BitVector + var $t36: bool + var $t37: &mut 0x1::m::BitVector + var $t38: u64 + var $t39: u64 + var $t40: u64 var $t41: u64 - var $t42: bool + var $t42: u64 var $t43: u64 - var $t44: u64 + var $t44: &mut 0x1::m::BitVector var $t45: u64 - var $t46: &mut 0x1::m::BitVector + var $t46: u64 var $t47: u64 - var $t48: u64 - var $t49: u64 + var $t48: &mut 0x1::m::BitVector + var $t49: &u64 var $t50: u64 var $t51: u64 var $t52: u64 var $t53: u64 var $t54: &mut 0x1::m::BitVector - var $t55: u64 - var $t56: &mut 0x1::m::BitVector - var $t57: &u64 - var $t58: u64 + var $t55: &u64 + var $t56: u64 + var $t57: bool + var $t58: &mut 0x1::m::BitVector var $t59: u64 var $t60: u64 - var $t61: &mut 0x1::m::BitVector - var $t62: &u64 - var $t63: u64 - var $t64: u64 - var $t65: u64 - var $t66: bool - var $t67: &mut 0x1::m::BitVector - var $t68: u64 - var $t69: u64 - var $t70: u64 - var $t71: u64 - var $t72: &mut 0x1::m::BitVector - 0: $t7 := copy($t0) - 1: $t8 := borrow_field<0x1::m::BitVector>.length($t7) - 2: $t9 := read_ref($t8) - 3: $t2 := $t9 - 4: $t10 := copy($t1) - 5: $t11 := move($t2) - 6: $t12 := >=($t10, $t11) - 7: if ($t12) goto 8 else goto 45 - 8: label L1 - 9: $t13 := move($t0) - 10: $t14 := borrow_field<0x1::m::BitVector>.bit_field($t13) - 11: $t3 := $t14 - 12: $t15 := 0 - 13: $t2 := $t15 - 14: goto 15 - 15: label L4 - 16: $t16 := copy($t2) - 17: $t4 := $t16 - 18: $t17 := copy($t3) - 19: $t18 := freeze_ref($t17) - 20: $t19 := vector::length($t18) - 21: $t5 := $t19 - 22: $t20 := move($t4) - 23: $t21 := move($t5) - 24: $t22 := <($t20, $t21) - 25: if ($t22) goto 26 else goto 39 - 26: label L3 - 27: $t23 := copy($t3) - 28: $t24 := copy($t2) - 29: $t25 := vector::borrow_mut($t23, $t24) - 30: $t6 := $t25 - 31: $t26 := false - 32: $t27 := move($t6) - 33: write_ref($t27, $t26) - 34: $t28 := move($t2) - 35: $t29 := 1 - 36: $t30 := +($t28, $t29) - 37: $t2 := $t30 - 38: goto 15 - 39: label L2 - 40: $t31 := move($t3) - 41: drop($t31) + var $t61: u64 + var $t62: u64 + var $t63: &mut 0x1::m::BitVector + 0: $t5 := copy($t1) + 1: $t6 := copy($t0) + 2: $t7 := borrow_field<0x1::m::BitVector>.length($t6) + 3: $t8 := read_ref($t7) + 4: $t9 := >=($t5, $t8) + 5: if ($t9) goto 6 else goto 39 + 6: label L1 + 7: $t10 := move($t0) + 8: $t11 := borrow_field<0x1::m::BitVector>.bit_field($t10) + 9: $t2 := $t11 + 10: $t12 := 0 + 11: $t3 := $t12 + 12: goto 13 + 13: label L4 + 14: $t13 := copy($t3) + 15: $t14 := copy($t2) + 16: $t15 := freeze_ref($t14) + 17: $t16 := vector::length($t15) + 18: $t17 := <($t13, $t16) + 19: if ($t17) goto 20 else goto 33 + 20: label L3 + 21: $t18 := copy($t2) + 22: $t19 := copy($t3) + 23: $t20 := vector::borrow_mut($t18, $t19) + 24: $t4 := $t20 + 25: $t21 := false + 26: $t22 := move($t4) + 27: write_ref($t22, $t21) + 28: $t23 := move($t3) + 29: $t24 := 1 + 30: $t25 := +($t23, $t24) + 31: $t3 := $t25 + 32: goto 13 + 33: label L2 + 34: $t26 := move($t2) + 35: drop($t26) + 36: goto 37 + 37: label L14 + 38: return () + 39: label L0 + 40: $t27 := copy($t1) + 41: $t3 := $t27 42: goto 43 - 43: label L14 - 44: return () - 45: label L0 - 46: $t32 := copy($t1) - 47: $t2 := $t32 - 48: goto 49 - 49: label L9 - 50: $t33 := copy($t0) - 51: $t34 := borrow_field<0x1::m::BitVector>.length($t33) - 52: $t35 := read_ref($t34) - 53: $t4 := $t35 - 54: $t36 := copy($t2) - 55: $t37 := move($t4) - 56: $t38 := <($t36, $t37) - 57: if ($t38) goto 58 else goto 88 - 58: label L6 - 59: $t39 := copy($t0) - 60: $t40 := freeze_ref($t39) - 61: $t41 := copy($t2) - 62: $t42 := m::is_index_set($t40, $t41) - 63: if ($t42) goto 64 else goto 79 - 64: label L8 - 65: $t43 := copy($t2) - 66: $t44 := copy($t1) - 67: $t45 := -($t43, $t44) - 68: $t4 := $t45 - 69: $t46 := copy($t0) - 70: $t47 := move($t4) - 71: m::set($t46, $t47) - 72: goto 73 - 73: label L10 - 74: $t48 := move($t2) - 75: $t49 := 1 - 76: $t50 := +($t48, $t49) - 77: $t2 := $t50 - 78: goto 49 - 79: label L7 - 80: $t51 := copy($t2) - 81: $t52 := copy($t1) - 82: $t53 := -($t51, $t52) - 83: $t4 := $t53 - 84: $t54 := copy($t0) - 85: $t55 := move($t4) - 86: m::unset($t54, $t55) - 87: goto 73 - 88: label L5 - 89: $t56 := copy($t0) - 90: $t57 := borrow_field<0x1::m::BitVector>.length($t56) - 91: $t58 := read_ref($t57) - 92: $t59 := move($t1) - 93: $t60 := -($t58, $t59) - 94: $t2 := $t60 - 95: goto 96 - 96: label L13 - 97: $t61 := copy($t0) - 98: $t62 := borrow_field<0x1::m::BitVector>.length($t61) - 99: $t63 := read_ref($t62) -100: $t1 := $t63 -101: $t64 := copy($t2) -102: $t65 := move($t1) -103: $t66 := <($t64, $t65) -104: if ($t66) goto 105 else goto 114 -105: label L12 -106: $t67 := copy($t0) -107: $t68 := copy($t2) -108: m::unset($t67, $t68) -109: $t69 := move($t2) -110: $t70 := 1 -111: $t71 := +($t69, $t70) -112: $t2 := $t71 -113: goto 96 -114: label L11 -115: $t72 := move($t0) -116: drop($t72) -117: goto 43 + 43: label L9 + 44: $t28 := copy($t3) + 45: $t29 := copy($t0) + 46: $t30 := borrow_field<0x1::m::BitVector>.length($t29) + 47: $t31 := read_ref($t30) + 48: $t32 := <($t28, $t31) + 49: if ($t32) goto 50 else goto 76 + 50: label L6 + 51: $t33 := copy($t0) + 52: $t34 := freeze_ref($t33) + 53: $t35 := copy($t3) + 54: $t36 := m::is_index_set($t34, $t35) + 55: if ($t36) goto 56 else goto 69 + 56: label L8 + 57: $t37 := copy($t0) + 58: $t38 := copy($t3) + 59: $t39 := copy($t1) + 60: $t40 := -($t38, $t39) + 61: m::set($t37, $t40) + 62: goto 63 + 63: label L10 + 64: $t41 := move($t3) + 65: $t42 := 1 + 66: $t43 := +($t41, $t42) + 67: $t3 := $t43 + 68: goto 43 + 69: label L7 + 70: $t44 := copy($t0) + 71: $t45 := copy($t3) + 72: $t46 := copy($t1) + 73: $t47 := -($t45, $t46) + 74: m::unset($t44, $t47) + 75: goto 63 + 76: label L5 + 77: $t48 := copy($t0) + 78: $t49 := borrow_field<0x1::m::BitVector>.length($t48) + 79: $t50 := read_ref($t49) + 80: $t51 := move($t1) + 81: $t52 := -($t50, $t51) + 82: $t3 := $t52 + 83: goto 84 + 84: label L13 + 85: $t53 := copy($t3) + 86: $t54 := copy($t0) + 87: $t55 := borrow_field<0x1::m::BitVector>.length($t54) + 88: $t56 := read_ref($t55) + 89: $t57 := <($t53, $t56) + 90: if ($t57) goto 91 else goto 100 + 91: label L12 + 92: $t58 := copy($t0) + 93: $t59 := copy($t3) + 94: m::unset($t58, $t59) + 95: $t60 := move($t3) + 96: $t61 := 1 + 97: $t62 := +($t60, $t61) + 98: $t3 := $t62 + 99: goto 84 +100: label L11 +101: $t63 := move($t0) +102: drop($t63) +103: goto 37 } --- Raw Generated AST -_t7: &mut BitVector = self; -_t8: &u64 = select m::BitVector.length(_t7); -_t9: u64 = Deref(_t8); -_t2: u64 = _t9; -_t10: u64 = amount; -_t11: u64 = _t2; -_t12: bool = Ge(_t10, _t11); +_t5: u64 = amount; +_t6: &mut BitVector = self; +_t7: &u64 = select m::BitVector.length(_t6); +_t8: u64 = Deref(_t7); +_t9: bool = Ge(_t5, _t8); loop { loop { loop { loop { - if (Not(_t12)) break; - _t13: &mut BitVector = self; - _t14: &mut vector = select m::BitVector.bit_field(_t13); - _t3: &mut vector = _t14; - _t15: u64 = 0; - _t2: u64 = _t15; + if (Not(_t9)) break; + _t10: &mut BitVector = self; + _t11: &mut vector = select m::BitVector.bit_field(_t10); + _t2: &mut vector = _t11; + _t12: u64 = 0; + _t3: u64 = _t12; break[1] }; - _t32: u64 = amount; - _t2: u64 = _t32; + _t27: u64 = amount; + _t3: u64 = _t27; break[1] }; loop { - _t16: u64 = _t2; - _t4: u64 = _t16; - _t17: &mut vector = _t3; - _t18: &vector = Freeze(true)(_t17); - _t19: u64 = vector::length(_t18); - _t5: u64 = _t19; - _t20: u64 = _t4; - _t21: u64 = _t5; - _t22: bool = Lt(_t20, _t21); - if (Not(_t22)) break; - _t23: &mut vector = _t3; - _t24: u64 = _t2; - _t25: &mut bool = vector::borrow_mut(_t23, _t24); - _t6: &mut bool = _t25; - _t26: bool = false; - _t27: &mut bool = _t6; - _t27 = _t26; - _t28: u64 = _t2; - _t29: u64 = 1; - _t30: u64 = Add(_t28, _t29); - _t2: u64 = _t30; + _t13: u64 = _t3; + _t14: &mut vector = _t2; + _t15: &vector = Freeze(true)(_t14); + _t16: u64 = vector::length(_t15); + _t17: bool = Lt(_t13, _t16); + if (Not(_t17)) break; + _t18: &mut vector = _t2; + _t19: u64 = _t3; + _t20: &mut bool = vector::borrow_mut(_t18, _t19); + _t4: &mut bool = _t20; + _t21: bool = false; + _t22: &mut bool = _t4; + _t22 = _t21; + _t23: u64 = _t3; + _t24: u64 = 1; + _t25: u64 = Add(_t23, _t24); + _t3: u64 = _t25; continue }; - _t31: &mut vector = _t3; + _t26: &mut vector = _t2; break[1] }; loop { + _t28: u64 = _t3; + _t29: &mut BitVector = self; + _t30: &u64 = select m::BitVector.length(_t29); + _t31: u64 = Deref(_t30); + _t32: bool = Lt(_t28, _t31); + if (Not(_t32)) break; _t33: &mut BitVector = self; - _t34: &u64 = select m::BitVector.length(_t33); - _t35: u64 = Deref(_t34); - _t4: u64 = _t35; - _t36: u64 = _t2; - _t37: u64 = _t4; - _t38: bool = Lt(_t36, _t37); - if (Not(_t38)) break; - _t39: &mut BitVector = self; - _t40: &BitVector = Freeze(true)(_t39); - _t41: u64 = _t2; - _t42: bool = m::is_index_set(_t40, _t41); + _t34: &BitVector = Freeze(true)(_t33); + _t35: u64 = _t3; + _t36: bool = m::is_index_set(_t34, _t35); loop { loop { - if (Not(_t42)) break; - _t43: u64 = _t2; - _t44: u64 = amount; - _t45: u64 = Sub(_t43, _t44); - _t4: u64 = _t45; - _t46: &mut BitVector = self; - _t47: u64 = _t4; - m::set(_t46, _t47); + if (Not(_t36)) break; + _t37: &mut BitVector = self; + _t38: u64 = _t3; + _t39: u64 = amount; + _t40: u64 = Sub(_t38, _t39); + m::set(_t37, _t40); break[1] }; - _t51: u64 = _t2; - _t52: u64 = amount; - _t53: u64 = Sub(_t51, _t52); - _t4: u64 = _t53; - _t54: &mut BitVector = self; - _t55: u64 = _t4; - m::unset(_t54, _t55); + _t44: &mut BitVector = self; + _t45: u64 = _t3; + _t46: u64 = amount; + _t47: u64 = Sub(_t45, _t46); + m::unset(_t44, _t47); break }; - _t48: u64 = _t2; - _t49: u64 = 1; - _t50: u64 = Add(_t48, _t49); - _t2: u64 = _t50; + _t41: u64 = _t3; + _t42: u64 = 1; + _t43: u64 = Add(_t41, _t42); + _t3: u64 = _t43; continue }; - _t56: &mut BitVector = self; - _t57: &u64 = select m::BitVector.length(_t56); - _t58: u64 = Deref(_t57); - _t59: u64 = amount; - _t60: u64 = Sub(_t58, _t59); - _t2: u64 = _t60; + _t48: &mut BitVector = self; + _t49: &u64 = select m::BitVector.length(_t48); + _t50: u64 = Deref(_t49); + _t51: u64 = amount; + _t52: u64 = Sub(_t50, _t51); + _t3: u64 = _t52; loop { - _t61: &mut BitVector = self; - _t62: &u64 = select m::BitVector.length(_t61); - _t63: u64 = Deref(_t62); - amount: u64 = _t63; - _t64: u64 = _t2; - _t65: u64 = amount; - _t66: bool = Lt(_t64, _t65); - if (Not(_t66)) break; - _t67: &mut BitVector = self; - _t68: u64 = _t2; - m::unset(_t67, _t68); - _t69: u64 = _t2; - _t70: u64 = 1; - _t71: u64 = Add(_t69, _t70); - _t2: u64 = _t71; + _t53: u64 = _t3; + _t54: &mut BitVector = self; + _t55: &u64 = select m::BitVector.length(_t54); + _t56: u64 = Deref(_t55); + _t57: bool = Lt(_t53, _t56); + if (Not(_t57)) break; + _t58: &mut BitVector = self; + _t59: u64 = _t3; + m::unset(_t58, _t59); + _t60: u64 = _t3; + _t61: u64 = 1; + _t62: u64 = Add(_t60, _t61); + _t3: u64 = _t62; continue }; - _t72: &mut BitVector = self; + _t63: &mut BitVector = self; break }; return Tuple() --- Assign-Transformed Generated AST -_t2: u64 = Deref(select m::BitVector.length(self)); loop { loop { loop { loop { - if (Not(Ge(amount, _t2))) break; - _t3: &mut vector = select m::BitVector.bit_field(self); - _t2: u64 = 0; + if (Not(Ge(amount, Deref(select m::BitVector.length(self))))) break; + _t2: &mut vector = select m::BitVector.bit_field(self); + _t3: u64 = 0; break[1] }; - _t2: u64 = amount; + _t3: u64 = amount; break[1] }; loop { - if (Not(Lt(_t2, vector::length(Freeze(true)(_t3))))) break; - vector::borrow_mut(_t3, _t2) = false; - _t2: u64 = Add(_t2, 1); + if (Not(Lt(_t3, vector::length(Freeze(true)(_t2))))) break; + vector::borrow_mut(_t2, _t3) = false; + _t3: u64 = Add(_t3, 1); continue }; break[1] }; loop { - _t4: u64 = Deref(select m::BitVector.length(self)); - if (Not(Lt(_t2, _t4))) break; + if (Not(Lt(_t3, Deref(select m::BitVector.length(self))))) break; loop { loop { - if (Not(m::is_index_set(Freeze(true)(self), _t2))) break; - _t4: u64 = Sub(_t2, amount); - m::set(self, _t4); + if (Not(m::is_index_set(Freeze(true)(self), _t3))) break; + m::set(self, Sub(_t3, amount)); break[1] }; - _t4: u64 = Sub(_t2, amount); - m::unset(self, _t4); + m::unset(self, Sub(_t3, amount)); break }; - _t2: u64 = Add(_t2, 1); + _t3: u64 = Add(_t3, 1); continue }; - _t2: u64 = Sub(Deref(select m::BitVector.length(self)), amount); + _t3: u64 = Sub(Deref(select m::BitVector.length(self)), amount); loop { - if (Not(Lt(_t2, Deref(select m::BitVector.length(self))))) break; - m::unset(self, _t2); - _t2: u64 = Add(_t2, 1); + if (Not(Lt(_t3, Deref(select m::BitVector.length(self))))) break; + m::unset(self, _t3); + _t3: u64 = Add(_t3, 1); continue }; break @@ -576,42 +511,38 @@ loop { return Tuple() --- If-Transformed Generated AST -_t2: u64 = Deref(select m::BitVector.length(self)); loop { loop { - if Ge(amount, _t2) { - _t3: &mut vector = select m::BitVector.bit_field(self); - _t2: u64 = 0 + if Ge(amount, Deref(select m::BitVector.length(self))) { + _t2: &mut vector = select m::BitVector.bit_field(self); + _t3: u64 = 0 } else { - _t2: u64 = amount; + _t3: u64 = amount; break }; loop { - if (Not(Lt(_t2, vector::length(Freeze(true)(_t3))))) break; - vector::borrow_mut(_t3, _t2) = false; - _t2: u64 = Add(_t2, 1); + if (Not(Lt(_t3, vector::length(Freeze(true)(_t2))))) break; + vector::borrow_mut(_t2, _t3) = false; + _t3: u64 = Add(_t3, 1); continue }; break[1] }; loop { - _t4: u64 = Deref(select m::BitVector.length(self)); - if (Not(Lt(_t2, _t4))) break; - if m::is_index_set(Freeze(true)(self), _t2) { - _t4: u64 = Sub(_t2, amount); - m::set(self, _t4) + if (Not(Lt(_t3, Deref(select m::BitVector.length(self))))) break; + if m::is_index_set(Freeze(true)(self), _t3) { + m::set(self, Sub(_t3, amount)) } else { - _t4: u64 = Sub(_t2, amount); - m::unset(self, _t4) + m::unset(self, Sub(_t3, amount)) }; - _t2: u64 = Add(_t2, 1); + _t3: u64 = Add(_t3, 1); continue }; - _t2: u64 = Sub(Deref(select m::BitVector.length(self)), amount); + _t3: u64 = Sub(Deref(select m::BitVector.length(self)), amount); loop { - if (Not(Lt(_t2, Deref(select m::BitVector.length(self))))) break; - m::unset(self, _t2); - _t2: u64 = Add(_t2, 1); + if (Not(Lt(_t3, Deref(select m::BitVector.length(self))))) break; + m::unset(self, _t3); + _t3: u64 = Add(_t3, 1); continue }; break @@ -620,53 +551,46 @@ return Tuple() --- Var-Bound Generated AST { - let _t4: u64; + let _t3: u64; { - let _t3: &mut vector; - { - let _t2: u64; - _t2: u64 = Deref(select m::BitVector.length(self)); + let _t2: &mut vector; + loop { loop { - loop { - if Ge(amount, _t2) { - _t3: &mut vector = select m::BitVector.bit_field(self); - _t2: u64 = 0 - } else { - _t2: u64 = amount; - break - }; - loop { - if (Not(Lt(_t2, vector::length(Freeze(true)(_t3))))) break; - vector::borrow_mut(_t3, _t2) = false; - _t2: u64 = Add(_t2, 1); - continue - }; - break[1] + if Ge(amount, Deref(select m::BitVector.length(self))) { + _t2: &mut vector = select m::BitVector.bit_field(self); + _t3: u64 = 0 + } else { + _t3: u64 = amount; + break }; loop { - _t4: u64 = Deref(select m::BitVector.length(self)); - if (Not(Lt(_t2, _t4))) break; - if m::is_index_set(Freeze(true)(self), _t2) { - _t4: u64 = Sub(_t2, amount); - m::set(self, _t4) - } else { - _t4: u64 = Sub(_t2, amount); - m::unset(self, _t4) - }; - _t2: u64 = Add(_t2, 1); + if (Not(Lt(_t3, vector::length(Freeze(true)(_t2))))) break; + vector::borrow_mut(_t2, _t3) = false; + _t3: u64 = Add(_t3, 1); continue }; - _t2: u64 = Sub(Deref(select m::BitVector.length(self)), amount); - loop { - if (Not(Lt(_t2, Deref(select m::BitVector.length(self))))) break; - m::unset(self, _t2); - _t2: u64 = Add(_t2, 1); - continue + break[1] + }; + loop { + if (Not(Lt(_t3, Deref(select m::BitVector.length(self))))) break; + if m::is_index_set(Freeze(true)(self), _t3) { + m::set(self, Sub(_t3, amount)) + } else { + m::unset(self, Sub(_t3, amount)) }; - break + _t3: u64 = Add(_t3, 1); + continue }; - return Tuple() - } + _t3: u64 = Sub(Deref(select m::BitVector.length(self)), amount); + loop { + if (Not(Lt(_t3, Deref(select m::BitVector.length(self))))) break; + m::unset(self, _t3); + _t3: u64 = Add(_t3, 1); + continue + }; + break + }; + return Tuple() } } @@ -681,75 +605,63 @@ public fun unset(self: &mut BitVector, bit_index: u64) { --- Stackless Bytecode public fun m::unset($t0|self: &mut 0x1::m::BitVector, $t1|bit_index: u64) { - var $t2|$t3: u64 - var $t3|$t4: u64 - var $t4|x: &mut bool - var $t5: u64 - var $t6: &mut 0x1::m::BitVector - var $t7: &vector - var $t8: u64 - var $t9: u64 + var $t2|x: &mut bool + var $t3: u64 + var $t4: &mut 0x1::m::BitVector + var $t5: &vector + var $t6: u64 + var $t7: bool + var $t8: &mut 0x1::m::BitVector + var $t9: &mut vector var $t10: u64 - var $t11: bool - var $t12: &mut 0x1::m::BitVector - var $t13: &mut vector - var $t14: u64 - var $t15: &mut bool - var $t16: bool - var $t17: &mut bool - var $t18: &mut 0x1::m::BitVector - var $t19: u64 - 0: $t5 := copy($t1) - 1: $t2 := $t5 - 2: $t6 := copy($t0) - 3: $t7 := borrow_field<0x1::m::BitVector>.bit_field($t6) - 4: $t8 := vector::length($t7) - 5: $t3 := $t8 - 6: $t9 := move($t2) - 7: $t10 := move($t3) - 8: $t11 := <($t9, $t10) - 9: if ($t11) goto 10 else goto 20 - 10: label L1 - 11: $t12 := move($t0) - 12: $t13 := borrow_field<0x1::m::BitVector>.bit_field($t12) - 13: $t14 := move($t1) - 14: $t15 := vector::borrow_mut($t13, $t14) - 15: $t4 := $t15 - 16: $t16 := false - 17: $t17 := move($t4) - 18: write_ref($t17, $t16) - 19: return () - 20: label L0 - 21: $t18 := move($t0) - 22: drop($t18) - 23: $t19 := 131072 - 24: abort($t19) + var $t11: &mut bool + var $t12: bool + var $t13: &mut bool + var $t14: &mut 0x1::m::BitVector + var $t15: u64 + 0: $t3 := copy($t1) + 1: $t4 := copy($t0) + 2: $t5 := borrow_field<0x1::m::BitVector>.bit_field($t4) + 3: $t6 := vector::length($t5) + 4: $t7 := <($t3, $t6) + 5: if ($t7) goto 6 else goto 16 + 6: label L1 + 7: $t8 := move($t0) + 8: $t9 := borrow_field<0x1::m::BitVector>.bit_field($t8) + 9: $t10 := move($t1) + 10: $t11 := vector::borrow_mut($t9, $t10) + 11: $t2 := $t11 + 12: $t12 := false + 13: $t13 := move($t2) + 14: write_ref($t13, $t12) + 15: return () + 16: label L0 + 17: $t14 := move($t0) + 18: drop($t14) + 19: $t15 := 131072 + 20: abort($t15) } --- Raw Generated AST -_t5: u64 = bit_index; -_t2: u64 = _t5; -_t6: &mut BitVector = self; -_t7: &vector = select m::BitVector.bit_field(_t6); -_t8: u64 = vector::length(_t7); -_t3: u64 = _t8; -_t9: u64 = _t2; -_t10: u64 = _t3; -_t11: bool = Lt(_t9, _t10); +_t3: u64 = bit_index; +_t4: &mut BitVector = self; +_t5: &vector = select m::BitVector.bit_field(_t4); +_t6: u64 = vector::length(_t5); +_t7: bool = Lt(_t3, _t6); loop { - if (_t11) break; - _t18: &mut BitVector = self; - _t19: u64 = 131072; - Abort(_t19) + if (_t7) break; + _t14: &mut BitVector = self; + _t15: u64 = 131072; + Abort(_t15) }; -_t12: &mut BitVector = self; -_t13: &mut vector = select m::BitVector.bit_field(_t12); -_t14: u64 = bit_index; -_t15: &mut bool = vector::borrow_mut(_t13, _t14); -_t4: &mut bool = _t15; -_t16: bool = false; -_t17: &mut bool = _t4; -_t17 = _t16; +_t8: &mut BitVector = self; +_t9: &mut vector = select m::BitVector.bit_field(_t8); +_t10: u64 = bit_index; +_t11: &mut bool = vector::borrow_mut(_t9, _t10); +_t2: &mut bool = _t11; +_t12: bool = false; +_t13: &mut bool = _t2; +_t13 = _t12; return Tuple() --- Assign-Transformed Generated AST @@ -785,41 +697,31 @@ module 0x1::m { *0x1::vector::borrow_mut(&mut self.bit_field, bit_index) = true; } public fun shift_left(self: &mut BitVector, amount: u64) { - let _t4; let _t3; let _t2; - _t2 = *&self.length; 'l0: loop { loop { - if (amount >= _t2) { - _t3 = &mut self.bit_field; - _t2 = 0 + if (amount >= *&self.length) { + _t2 = &mut self.bit_field; + _t3 = 0 } else { - _t2 = amount; + _t3 = amount; break }; - while (_t2 < 0x1::vector::length(/*freeze*/_t3)) { - *0x1::vector::borrow_mut(_t3, _t2) = false; - _t2 = _t2 + 1 + while (_t3 < 0x1::vector::length(/*freeze*/_t2)) { + *0x1::vector::borrow_mut(_t2, _t3) = false; + _t3 = _t3 + 1 }; break 'l0 }; - loop { - _t4 = *&self.length; - if (!(_t2 < _t4)) break; - if (is_index_set(/*freeze*/self, _t2)) { - _t4 = _t2 - amount; - set(self, _t4) - } else { - _t4 = _t2 - amount; - unset(self, _t4) - }; - _t2 = _t2 + 1 + while (_t3 < *&self.length) { + if (is_index_set(/*freeze*/self, _t3)) set(self, _t3 - amount) else unset(self, _t3 - amount); + _t3 = _t3 + 1 }; - _t2 = *&self.length - amount; - while (_t2 < *&self.length) { - unset(self, _t2); - _t2 = _t2 + 1 + _t3 = *&self.length - amount; + while (_t3 < *&self.length) { + unset(self, _t3); + _t3 = _t3 + 1 }; break }; diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.exp b/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.exp index be960ad6afff7..e094abccf4145 100644 --- a/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.exp +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/conditionals.exp @@ -264,41 +264,40 @@ fun if_else_3(c: bool): u64 { --- Stackless Bytecode fun m::if_else_3($t0|c: bool): u64 { var $t1|r: u64 - var $t2|return: u64 [unused] - var $t3: bool + var $t2: bool + var $t3: u64 var $t4: u64 var $t5: u64 - var $t6: u64 - 0: $t3 := move($t0) - 1: if ($t3) goto 2 else goto 9 + 0: $t2 := move($t0) + 1: if ($t2) goto 2 else goto 9 2: label L1 - 3: $t4 := 1 - 4: $t1 := $t4 + 3: $t3 := 1 + 4: $t1 := $t3 5: goto 6 6: label L2 - 7: $t5 := move($t1) - 8: return $t5 + 7: $t4 := move($t1) + 8: return $t4 9: label L0 - 10: $t6 := 2 - 11: $t1 := $t6 + 10: $t5 := 2 + 11: $t1 := $t5 12: goto 6 } --- Raw Generated AST -_t3: bool = c; +_t2: bool = c; loop { loop { - if (Not(_t3)) break; - _t4: u64 = 1; - _t1: u64 = _t4; + if (Not(_t2)) break; + _t3: u64 = 1; + _t1: u64 = _t3; break[1] }; - _t6: u64 = 2; - _t1: u64 = _t6; + _t5: u64 = 2; + _t1: u64 = _t5; break }; -_t5: u64 = _t1; -return _t5 +_t4: u64 = _t1; +return _t4 --- Assign-Transformed Generated AST loop { @@ -453,8 +452,8 @@ fun if_else_with_shared_exp(x: u64): u64 { --- Stackless Bytecode fun m::if_else_with_shared_exp($t0|x: u64): u64 { - var $t1|$t5: u64 - var $t2|$t7: u64 [unused] + var $t1|$t3: u64 + var $t2: u64 var $t3: u64 var $t4: u64 var $t5: u64 @@ -462,73 +461,72 @@ fun m::if_else_with_shared_exp($t0|x: u64): u64 { var $t7: u64 var $t8: u64 var $t9: u64 - var $t10: u64 - var $t11: bool + var $t10: bool + var $t11: u64 var $t12: u64 var $t13: u64 var $t14: u64 var $t15: u64 var $t16: u64 var $t17: u64 - var $t18: u64 - 0: $t3 := copy($t0) - 1: $t4 := move($t0) - 2: $t5 := +($t3, $t4) - 3: $t0 := $t5 - 4: $t6 := copy($t0) - 5: $t7 := move($t0) - 6: $t8 := *($t6, $t7) - 7: $t0 := $t8 - 8: $t9 := copy($t0) - 9: $t10 := 0 - 10: $t11 := >($t9, $t10) - 11: if ($t11) goto 12 else goto 21 + 0: $t2 := copy($t0) + 1: $t3 := move($t0) + 2: $t4 := +($t2, $t3) + 3: $t0 := $t4 + 4: $t5 := copy($t0) + 5: $t6 := move($t0) + 6: $t7 := *($t5, $t6) + 7: $t0 := $t7 + 8: $t8 := copy($t0) + 9: $t9 := 0 + 10: $t10 := >($t8, $t9) + 11: if ($t10) goto 12 else goto 21 12: label L1 - 13: $t12 := move($t0) - 14: $t13 := 1 - 15: $t14 := +($t12, $t13) - 16: $t1 := $t14 + 13: $t11 := move($t0) + 14: $t12 := 1 + 15: $t13 := +($t11, $t12) + 16: $t1 := $t13 17: goto 18 18: label L2 - 19: $t15 := move($t1) - 20: return $t15 + 19: $t14 := move($t1) + 20: return $t14 21: label L0 - 22: $t16 := move($t0) - 23: $t17 := 1 - 24: $t18 := -($t16, $t17) - 25: $t1 := $t18 + 22: $t15 := move($t0) + 23: $t16 := 1 + 24: $t17 := -($t15, $t16) + 25: $t1 := $t17 26: goto 18 } --- Raw Generated AST +_t2: u64 = x; _t3: u64 = x; -_t4: u64 = x; -_t5: u64 = Add(_t3, _t4); -x: u64 = _t5; +_t4: u64 = Add(_t2, _t3); +x: u64 = _t4; +_t5: u64 = x; _t6: u64 = x; -_t7: u64 = x; -_t8: u64 = Mul(_t6, _t7); -x: u64 = _t8; -_t9: u64 = x; -_t10: u64 = 0; -_t11: bool = Gt(_t9, _t10); +_t7: u64 = Mul(_t5, _t6); +x: u64 = _t7; +_t8: u64 = x; +_t9: u64 = 0; +_t10: bool = Gt(_t8, _t9); loop { loop { - if (Not(_t11)) break; - _t12: u64 = x; - _t13: u64 = 1; - _t14: u64 = Add(_t12, _t13); - _t1: u64 = _t14; + if (Not(_t10)) break; + _t11: u64 = x; + _t12: u64 = 1; + _t13: u64 = Add(_t11, _t12); + _t1: u64 = _t13; break[1] }; - _t16: u64 = x; - _t17: u64 = 1; - _t18: u64 = Sub(_t16, _t17); - _t1: u64 = _t18; + _t15: u64 = x; + _t16: u64 = 1; + _t17: u64 = Sub(_t15, _t16); + _t1: u64 = _t17; break }; -_t15: u64 = _t1; -return _t15 +_t14: u64 = _t1; +return _t14 --- Assign-Transformed Generated AST x: u64 = Add(x, x); diff --git a/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.exp b/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.exp index 77603ad0468e7..ef55daa883f37 100644 --- a/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.exp +++ b/third_party/move/move-model/bytecode/ast-generator-tests/tests/loops.exp @@ -13,79 +13,78 @@ fun loop_1(c: u64): u64 { --- Stackless Bytecode fun m::loop_1($t0|c: u64): u64 { - var $t1|$t3: u64 [unused] + var $t1: u64 var $t2: u64 var $t3: u64 var $t4: u64 var $t5: u64 var $t6: u64 var $t7: u64 - var $t8: u64 - var $t9: bool + var $t8: bool + var $t9: u64 var $t10: u64 var $t11: u64 var $t12: u64 var $t13: u64 var $t14: u64 var $t15: u64 - var $t16: u64 - var $t17: bool - var $t18: u64 + var $t16: bool + var $t17: u64 0: label L2 - 1: $t2 := move($t0) - 2: $t3 := 1 - 3: $t4 := +($t2, $t3) - 4: $t0 := $t4 - 5: $t5 := copy($t0) - 6: $t6 := 2 - 7: $t7 := %($t5, $t6) - 8: $t8 := 0 - 9: $t9 := ==($t7, $t8) - 10: if ($t9) goto 11 else goto 13 + 1: $t1 := move($t0) + 2: $t2 := 1 + 3: $t3 := +($t1, $t2) + 4: $t0 := $t3 + 5: $t4 := copy($t0) + 6: $t5 := 2 + 7: $t6 := %($t4, $t5) + 8: $t7 := 0 + 9: $t8 := ==($t6, $t7) + 10: if ($t8) goto 11 else goto 13 11: label L1 12: goto 0 13: label L0 - 14: $t10 := move($t0) - 15: $t11 := 3 - 16: $t12 := +($t10, $t11) - 17: $t0 := $t12 - 18: $t13 := copy($t0) - 19: $t14 := 2 - 20: $t15 := %($t13, $t14) - 21: $t16 := 1 - 22: $t17 := ==($t15, $t16) - 23: if ($t17) goto 24 else goto 0 + 14: $t9 := move($t0) + 15: $t10 := 3 + 16: $t11 := +($t9, $t10) + 17: $t0 := $t11 + 18: $t12 := copy($t0) + 19: $t13 := 2 + 20: $t14 := %($t12, $t13) + 21: $t15 := 1 + 22: $t16 := ==($t14, $t15) + 23: if ($t16) goto 24 else goto 0 24: label L3 - 25: $t18 := move($t0) - 26: return $t18 + 25: $t17 := move($t0) + 26: return $t17 } --- Raw Generated AST loop { - _t2: u64 = c; - _t3: u64 = 1; - _t4: u64 = Add(_t2, _t3); - c: u64 = _t4; - _t5: u64 = c; - _t6: u64 = 2; - _t7: u64 = Mod(_t5, _t6); - _t8: u64 = 0; - _t9: bool = Eq(_t7, _t8); - if (_t9) continue; - _t10: u64 = c; - _t11: u64 = 3; - _t12: u64 = Add(_t10, _t11); - c: u64 = _t12; - _t13: u64 = c; - _t14: u64 = 2; - _t15: u64 = Mod(_t13, _t14); - _t16: u64 = 1; - _t17: bool = Eq(_t15, _t16); - if (Not(_t17)) continue; + _t1: u64 = c; + _t2: u64 = 1; + _t3: u64 = Add(_t1, _t2); + c: u64 = _t3; + _t4: u64 = c; + _t5: u64 = 2; + _t6: u64 = Mod(_t4, _t5); + _t7: u64 = 0; + _t8: bool = Eq(_t6, _t7); + if (_t8) continue; + _t9: u64 = c; + _t10: u64 = 3; + _t11: u64 = Add(_t9, _t10); + c: u64 = _t11; + _t12: u64 = c; + _t13: u64 = 2; + _t14: u64 = Mod(_t12, _t13); + _t15: u64 = 1; + _t16: bool = Eq(_t14, _t15); + if (Not(_t16)) continue; break }; -_t18: u64 = c; -return _t18 +_t17: u64 = c; +return _t17 --- Assign-Transformed Generated AST loop { @@ -134,72 +133,71 @@ fun nested_loop(x: u64): u64 { --- Stackless Bytecode fun m::nested_loop($t0|x: u64): u64 { - var $t1|$t3: u64 [unused] + var $t1: u64 var $t2: u64 - var $t3: u64 - var $t4: bool + var $t3: bool + var $t4: u64 var $t5: u64 - var $t6: u64 - var $t7: bool + var $t6: bool + var $t7: u64 var $t8: u64 var $t9: u64 var $t10: u64 var $t11: u64 var $t12: u64 var $t13: u64 - var $t14: u64 0: label L5 - 1: $t2 := copy($t0) - 2: $t3 := 0 - 3: $t4 := >($t2, $t3) - 4: if ($t4) goto 5 else goto 22 + 1: $t1 := copy($t0) + 2: $t2 := 0 + 3: $t3 := >($t1, $t2) + 4: if ($t3) goto 5 else goto 22 5: label L1 - 6: $t5 := copy($t0) - 7: $t6 := 10 - 8: $t7 := >($t5, $t6) - 9: if ($t7) goto 10 else goto 16 + 6: $t4 := copy($t0) + 7: $t5 := 10 + 8: $t6 := >($t4, $t5) + 9: if ($t6) goto 10 else goto 16 10: label L2 - 11: $t8 := move($t0) - 12: $t9 := 1 - 13: $t10 := -($t8, $t9) - 14: $t0 := $t10 + 11: $t7 := move($t0) + 12: $t8 := 1 + 13: $t9 := -($t7, $t8) + 14: $t0 := $t9 15: goto 16 16: label L4 - 17: $t11 := move($t0) - 18: $t12 := 1 - 19: $t13 := -($t11, $t12) - 20: $t0 := $t13 + 17: $t10 := move($t0) + 18: $t11 := 1 + 19: $t12 := -($t10, $t11) + 20: $t0 := $t12 21: goto 0 22: label L0 - 23: $t14 := move($t0) - 24: return $t14 + 23: $t13 := move($t0) + 24: return $t13 } --- Raw Generated AST loop { - _t2: u64 = x; - _t3: u64 = 0; - _t4: bool = Gt(_t2, _t3); - if (Not(_t4)) break; - _t5: u64 = x; - _t6: u64 = 10; - _t7: bool = Gt(_t5, _t6); + _t1: u64 = x; + _t2: u64 = 0; + _t3: bool = Gt(_t1, _t2); + if (Not(_t3)) break; + _t4: u64 = x; + _t5: u64 = 10; + _t6: bool = Gt(_t4, _t5); loop { - if (Not(_t7)) break; - _t8: u64 = x; - _t9: u64 = 1; - _t10: u64 = Sub(_t8, _t9); - x: u64 = _t10; + if (Not(_t6)) break; + _t7: u64 = x; + _t8: u64 = 1; + _t9: u64 = Sub(_t7, _t8); + x: u64 = _t9; break }; - _t11: u64 = x; - _t12: u64 = 1; - _t13: u64 = Sub(_t11, _t12); - x: u64 = _t13; + _t10: u64 = x; + _t11: u64 = 1; + _t12: u64 = Sub(_t10, _t11); + x: u64 = _t12; continue }; -_t14: u64 = x; -return _t14 +_t13: u64 = x; +return _t13 --- Assign-Transformed Generated AST loop { @@ -241,23 +239,22 @@ fun while_1(c: u64) { --- Stackless Bytecode fun m::while_1($t0|c: u64) { - var $t1|$t2: u64 [unused] + var $t1: u64 var $t2: u64 - var $t3: u64 - var $t4: bool + var $t3: bool + var $t4: u64 var $t5: u64 var $t6: u64 - var $t7: u64 0: label L2 - 1: $t2 := copy($t0) - 2: $t3 := 0 - 3: $t4 := >($t2, $t3) - 4: if ($t4) goto 5 else goto 11 + 1: $t1 := copy($t0) + 2: $t2 := 0 + 3: $t3 := >($t1, $t2) + 4: if ($t3) goto 5 else goto 11 5: label L1 - 6: $t5 := move($t0) - 7: $t6 := 1 - 8: $t7 := -($t5, $t6) - 9: $t0 := $t7 + 6: $t4 := move($t0) + 7: $t5 := 1 + 8: $t6 := -($t4, $t5) + 9: $t0 := $t6 10: goto 0 11: label L0 12: return () @@ -265,14 +262,14 @@ fun m::while_1($t0|c: u64) { --- Raw Generated AST loop { - _t2: u64 = c; - _t3: u64 = 0; - _t4: bool = Gt(_t2, _t3); - if (Not(_t4)) break; - _t5: u64 = c; - _t6: u64 = 1; - _t7: u64 = Sub(_t5, _t6); - c: u64 = _t7; + _t1: u64 = c; + _t2: u64 = 0; + _t3: bool = Gt(_t1, _t2); + if (Not(_t3)) break; + _t4: u64 = c; + _t5: u64 = 1; + _t6: u64 = Sub(_t4, _t5); + c: u64 = _t6; continue }; return Tuple() @@ -316,62 +313,61 @@ fun while_2(c: u64): u64 { --- Stackless Bytecode fun m::while_2($t0|c: u64): u64 { - var $t1|$t3: u64 [unused] + var $t1: u64 var $t2: u64 - var $t3: u64 - var $t4: bool + var $t3: bool + var $t4: u64 var $t5: u64 - var $t6: u64 - var $t7: bool + var $t6: bool + var $t7: u64 var $t8: u64 var $t9: u64 var $t10: u64 var $t11: u64 var $t12: u64 - var $t13: u64 0: label L4 - 1: $t2 := copy($t0) - 2: $t3 := 0 - 3: $t4 := >($t2, $t3) - 4: if ($t4) goto 5 else goto 16 + 1: $t1 := copy($t0) + 2: $t2 := 0 + 3: $t3 := >($t1, $t2) + 4: if ($t3) goto 5 else goto 16 5: label L1 - 6: $t5 := copy($t0) - 7: $t6 := 10 - 8: $t7 := >=($t5, $t6) - 9: if ($t7) goto 10 else goto 0 + 6: $t4 := copy($t0) + 7: $t5 := 10 + 8: $t6 := >=($t4, $t5) + 9: if ($t6) goto 10 else goto 0 10: label L2 - 11: $t8 := move($t0) - 12: $t9 := 10 - 13: $t10 := -($t8, $t9) - 14: $t0 := $t10 + 11: $t7 := move($t0) + 12: $t8 := 10 + 13: $t9 := -($t7, $t8) + 14: $t0 := $t9 15: goto 0 16: label L0 - 17: $t11 := move($t0) - 18: $t12 := 1 - 19: $t13 := +($t11, $t12) - 20: return $t13 + 17: $t10 := move($t0) + 18: $t11 := 1 + 19: $t12 := +($t10, $t11) + 20: return $t12 } --- Raw Generated AST loop { - _t2: u64 = c; - _t3: u64 = 0; - _t4: bool = Gt(_t2, _t3); - if (Not(_t4)) break; - _t5: u64 = c; - _t6: u64 = 10; - _t7: bool = Ge(_t5, _t6); - if (Not(_t7)) continue; - _t8: u64 = c; - _t9: u64 = 10; - _t10: u64 = Sub(_t8, _t9); - c: u64 = _t10; + _t1: u64 = c; + _t2: u64 = 0; + _t3: bool = Gt(_t1, _t2); + if (Not(_t3)) break; + _t4: u64 = c; + _t5: u64 = 10; + _t6: bool = Ge(_t4, _t5); + if (Not(_t6)) continue; + _t7: u64 = c; + _t8: u64 = 10; + _t9: u64 = Sub(_t7, _t8); + c: u64 = _t9; continue }; -_t11: u64 = c; -_t12: u64 = 1; -_t13: u64 = Add(_t11, _t12); -return _t13 +_t10: u64 = c; +_t11: u64 = 1; +_t12: u64 = Add(_t10, _t11); +return _t12 --- Assign-Transformed Generated AST loop { @@ -413,74 +409,73 @@ fun while_3(c: u64): u64 { --- Stackless Bytecode fun m::while_3($t0|c: u64): u64 { - var $t1|$t3: u64 [unused] + var $t1: u64 var $t2: u64 - var $t3: u64 - var $t4: bool + var $t3: bool + var $t4: u64 var $t5: u64 - var $t6: u64 - var $t7: bool + var $t6: bool + var $t7: u64 var $t8: u64 var $t9: u64 var $t10: u64 var $t11: u64 var $t12: u64 var $t13: u64 - var $t14: u64 0: label L5 - 1: $t2 := copy($t0) - 2: $t3 := 0 - 3: $t4 := >($t2, $t3) - 4: if ($t4) goto 5 else goto 24 + 1: $t1 := copy($t0) + 2: $t2 := 0 + 3: $t3 := >($t1, $t2) + 4: if ($t3) goto 5 else goto 24 5: label L1 6: goto 7 7: label L2 - 8: $t5 := copy($t0) - 9: $t6 := 10 - 10: $t7 := >($t5, $t6) - 11: if ($t7) goto 12 else goto 18 + 8: $t4 := copy($t0) + 9: $t5 := 10 + 10: $t6 := >($t4, $t5) + 11: if ($t6) goto 12 else goto 18 12: label L4 - 13: $t8 := move($t0) - 14: $t9 := 10 - 15: $t10 := -($t8, $t9) - 16: $t0 := $t10 + 13: $t7 := move($t0) + 14: $t8 := 10 + 15: $t9 := -($t7, $t8) + 16: $t0 := $t9 17: goto 7 18: label L3 - 19: $t11 := move($t0) - 20: $t12 := 1 - 21: $t13 := -($t11, $t12) - 22: $t0 := $t13 + 19: $t10 := move($t0) + 20: $t11 := 1 + 21: $t12 := -($t10, $t11) + 22: $t0 := $t12 23: goto 0 24: label L0 - 25: $t14 := move($t0) - 26: return $t14 + 25: $t13 := move($t0) + 26: return $t13 } --- Raw Generated AST loop { - _t2: u64 = c; - _t3: u64 = 0; - _t4: bool = Gt(_t2, _t3); - if (Not(_t4)) break; + _t1: u64 = c; + _t2: u64 = 0; + _t3: bool = Gt(_t1, _t2); + if (Not(_t3)) break; loop { - _t5: u64 = c; - _t6: u64 = 10; - _t7: bool = Gt(_t5, _t6); - if (Not(_t7)) break; - _t8: u64 = c; - _t9: u64 = 10; - _t10: u64 = Sub(_t8, _t9); - c: u64 = _t10; + _t4: u64 = c; + _t5: u64 = 10; + _t6: bool = Gt(_t4, _t5); + if (Not(_t6)) break; + _t7: u64 = c; + _t8: u64 = 10; + _t9: u64 = Sub(_t7, _t8); + c: u64 = _t9; continue }; - _t11: u64 = c; - _t12: u64 = 1; - _t13: u64 = Sub(_t11, _t12); - c: u64 = _t13; + _t10: u64 = c; + _t11: u64 = 1; + _t12: u64 = Sub(_t10, _t11); + c: u64 = _t12; continue }; -_t14: u64 = c; -return _t14 +_t13: u64 = c; +return _t13 --- Assign-Transformed Generated AST loop { diff --git a/third_party/move/move-prover/tests/sources/functional/ModifiesErrorTest.v2_exp b/third_party/move/move-prover/tests/sources/functional/ModifiesErrorTest.v2_exp index 620e4ee6a4e64..4e9f110a47a40 100644 --- a/third_party/move/move-prover/tests/sources/functional/ModifiesErrorTest.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/ModifiesErrorTest.v2_exp @@ -28,7 +28,6 @@ error: caller does not have permission to modify `B::T` at given address = at tests/sources/functional/ModifiesErrorTest.move:51: move_to_test_incorrect = x0 = = at tests/sources/functional/ModifiesErrorTest.move:52: move_to_test_incorrect - = = error: caller does not have permission to modify `B::T` at given address ┌─ tests/sources/functional/ModifiesErrorTest.move:65:17 diff --git a/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp b/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp index 1a1a7100ee0d3..2c4601d2f5bfb 100644 --- a/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/ModifiesSchemaTest.v2_exp @@ -14,7 +14,7 @@ error: caller does not have permission to modify `A::S` at given address = at tests/sources/functional/ModifiesSchemaTest.move:12: mutate_at = addr = = at tests/sources/functional/ModifiesSchemaTest.move:13: mutate_at + = s = = at tests/sources/functional/ModifiesSchemaTest.move:14: mutate_at - = = = at tests/sources/functional/ModifiesSchemaTest.move:15: mutate_at = at tests/sources/functional/ModifiesSchemaTest.move:31: mutate_at_wrapper2 diff --git a/third_party/move/move-prover/tests/sources/functional/address_quant.v2_exp b/third_party/move/move-prover/tests/sources/functional/address_quant.v2_exp index 34e81d4b92112..427ee8258709d 100644 --- a/third_party/move/move-prover/tests/sources/functional/address_quant.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/address_quant.v2_exp @@ -11,6 +11,5 @@ error: post-condition does not hold = at tests/sources/functional/address_quant.move:46: multiple_copy_incorrect = sndr = = at tests/sources/functional/address_quant.move:47: multiple_copy_incorrect - = = = at tests/sources/functional/address_quant.move:48: multiple_copy_incorrect = at tests/sources/functional/address_quant.move:53 diff --git a/third_party/move/move-prover/tests/sources/functional/bitwise_features.v2_exp b/third_party/move/move-prover/tests/sources/functional/bitwise_features.v2_exp new file mode 100644 index 0000000000000..5910dbdcebcb8 --- /dev/null +++ b/third_party/move/move-prover/tests/sources/functional/bitwise_features.v2_exp @@ -0,0 +1,12 @@ +Move prover returns: exiting with verification errors +error: verification out of resources/timeout (global timeout set to 80s) + ┌─ tests/sources/functional/bitwise_features.move:154:5 + │ +154 │ ╭ public fun enable_feature_flags(enable: vector) acquires Features { +155 │ │ let features = &mut borrow_global_mut(@std).features; +156 │ │ let i = 0; +157 │ │ let n = vector::length(&enable); + · │ +170 │ │ }; +171 │ │ } + │ ╰─────^ diff --git a/third_party/move/move-prover/tests/sources/functional/choice.v2_exp b/third_party/move/move-prover/tests/sources/functional/choice.v2_exp index 8717b9158c33c..12365e40fda49 100644 --- a/third_party/move/move-prover/tests/sources/functional/choice.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/choice.v2_exp @@ -29,9 +29,7 @@ error: post-condition does not hold = s1 = = s2 = = at tests/sources/functional/choice.move:47: populate_R - = = = at tests/sources/functional/choice.move:48: populate_R - = = = at tests/sources/functional/choice.move:49: populate_R = at tests/sources/functional/choice.move:56: populate_R (spec) @@ -129,7 +127,6 @@ error: post-condition does not hold = ballot_account = = at tests/sources/functional/choice.move:284: create_ballot = at tests/sources/functional/choice.move:283: create_ballot - = = = at tests/sources/functional/choice.move:291 = at tests/sources/functional/choice.move:286: create_ballot = at tests/sources/functional/choice.move:272: new_ballot_id diff --git a/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp b/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp index 82b4721661b3f..2b5c25e3f356d 100644 --- a/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp @@ -42,8 +42,6 @@ error: data invariant does not hold = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:33: push_3 = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:35: push_3 = s = - = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:36: push_3 - = return = = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:31: push_3 = result = = s = diff --git a/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp b/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp index a8079e5f4d271..72c3d31e14b08 100644 --- a/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/data_invariant_in_map.v2_exp @@ -8,6 +8,6 @@ error: data invariant does not hold = at tests/sources/functional/data_invariant_in_map.move:20: violation_1 = at tests/sources/functional/data_invariant_in_map.move:21: violation_1 = at tests/sources/functional/data_invariant_in_map.move:22: violation_1 + = s = = at tests/sources/functional/data_invariant_in_map.move:23: violation_1 - = = = at tests/sources/functional/data_invariant_in_map.move:8 diff --git a/third_party/move/move-prover/tests/sources/functional/emits.v2_exp b/third_party/move/move-prover/tests/sources/functional/emits.v2_exp index a3c55d75f67cc..f68f38a31dbea 100644 --- a/third_party/move/move-prover/tests/sources/functional/emits.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/emits.v2_exp @@ -8,7 +8,6 @@ error: function does not emit the expected event = at tests/sources/functional/emits.move:19: simple_wrong_msg_incorrect = handle = = at tests/sources/functional/emits.move:20: simple_wrong_msg_incorrect - = = = at tests/sources/functional/emits.move:19: simple_wrong_msg_incorrect = handle = = at tests/sources/functional/emits.move:21: simple_wrong_msg_incorrect @@ -24,7 +23,6 @@ error: function does not emit the expected event = handle = = _handle2 = = at tests/sources/functional/emits.move:27: simple_wrong_handle_incorrect - = = = at tests/sources/functional/emits.move:26: simple_wrong_handle_incorrect = handle = = _handle2 = @@ -40,9 +38,7 @@ error: function does not emit the expected event = at tests/sources/functional/emits.move:47: multiple_incorrect = handle = = at tests/sources/functional/emits.move:48: multiple_incorrect - = = = at tests/sources/functional/emits.move:49: multiple_incorrect - = = = at tests/sources/functional/emits.move:47: multiple_incorrect = handle = = at tests/sources/functional/emits.move:50: multiple_incorrect @@ -59,7 +55,6 @@ error: function does not emit the expected event = at tests/sources/functional/emits.move:66: multiple_same_incorrect = handle = = at tests/sources/functional/emits.move:67: multiple_same_incorrect - = = = at tests/sources/functional/emits.move:66: multiple_same_incorrect = handle = = at tests/sources/functional/emits.move:68: multiple_same_incorrect @@ -102,9 +97,7 @@ error: function does not emit the expected event = b = = handle = = at tests/sources/functional/emits.move:150: conditional_multiple_incorrect - = = = at tests/sources/functional/emits.move:151: conditional_multiple_incorrect - = = = at tests/sources/functional/emits.move:152: conditional_multiple_incorrect = at tests/sources/functional/emits.move:149: conditional_multiple_incorrect = handle = @@ -122,9 +115,7 @@ error: function does not emit the expected event = b = = handle = = at tests/sources/functional/emits.move:180: conditional_multiple_same_incorrect - = = = at tests/sources/functional/emits.move:181: conditional_multiple_same_incorrect - = = = at tests/sources/functional/emits.move:182: conditional_multiple_same_incorrect = at tests/sources/functional/emits.move:179: conditional_multiple_same_incorrect = handle = @@ -143,9 +134,7 @@ error: emitted event not covered by any of the `emits` clauses = at tests/sources/functional/emits.move:231: partial_incorrect = handle = = at tests/sources/functional/emits.move:232: partial_incorrect - = = = at tests/sources/functional/emits.move:233: partial_incorrect - = = = at tests/sources/functional/emits.move:231: partial_incorrect = handle = = at tests/sources/functional/emits.move:234: partial_incorrect @@ -163,9 +152,7 @@ error: emitted event not covered by any of the `emits` clauses = at tests/sources/functional/emits.move:251: strict_incorrect = handle = = at tests/sources/functional/emits.move:252: strict_incorrect - = = = at tests/sources/functional/emits.move:253: strict_incorrect - = = = at tests/sources/functional/emits.move:251: strict_incorrect = handle = = at tests/sources/functional/emits.move:254: strict_incorrect @@ -180,10 +167,8 @@ error: function does not emit the expected event = at tests/sources/functional/emits.move:286: opaque_incorrect = handle = = at tests/sources/functional/emits.move:287: opaque_incorrect - = = = at tests/sources/functional/emits.move:288: opaque_incorrect = at tests/sources/functional/emits.move:289: opaque_incorrect - = = = at tests/sources/functional/emits.move:286: opaque_incorrect = handle = = at tests/sources/functional/emits.move:290: opaque_incorrect @@ -206,10 +191,8 @@ error: emitted event not covered by any of the `emits` clauses = at tests/sources/functional/emits.move:309: opaque_completeness_incorrect = handle = = at tests/sources/functional/emits.move:310: opaque_completeness_incorrect - = = = at tests/sources/functional/emits.move:311: opaque_completeness_incorrect = at tests/sources/functional/emits.move:312: opaque_completeness_incorrect - = = = at tests/sources/functional/emits.move:309: opaque_completeness_incorrect = handle = = at tests/sources/functional/emits.move:313: opaque_completeness_incorrect @@ -233,10 +216,8 @@ error: emitted event not covered by any of the `emits` clauses = at tests/sources/functional/emits.move:350: opaque_partial_incorrect = handle = = at tests/sources/functional/emits.move:351: opaque_partial_incorrect - = = = at tests/sources/functional/emits.move:352: opaque_partial_incorrect = at tests/sources/functional/emits.move:353: opaque_partial_incorrect - = = = at tests/sources/functional/emits.move:350: opaque_partial_incorrect = handle = = at tests/sources/functional/emits.move:354: opaque_partial_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp b/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp index 5c7f71304468c..56eef3ac787fe 100644 --- a/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/fixed_point_arithm.v2_exp @@ -22,8 +22,6 @@ error: post-condition does not hold = at tests/sources/functional/fixed_point_arithm.move:42: multiply_x_0_incorrect = x = = at tests/sources/functional/fixed_point_arithm.move:43: multiply_x_0_incorrect - = = - = at tests/sources/functional/fixed_point_arithm.move:43: multiply_x_0_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:44: multiply_x_0_incorrect = at tests/sources/functional/fixed_point_arithm.move:46: multiply_x_0_incorrect (spec) @@ -56,8 +54,6 @@ error: post-condition does not hold = at ../move-stdlib/sources/fixed_point32.move:126 = at ../move-stdlib/sources/fixed_point32.move:127 = at tests/sources/functional/fixed_point_arithm.move:82: multiply_x_1_incorrect - = = - = at tests/sources/functional/fixed_point_arithm.move:82: multiply_x_1_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:83: multiply_x_1_incorrect = at tests/sources/functional/fixed_point_arithm.move:85: multiply_x_1_incorrect (spec) @@ -80,8 +76,6 @@ error: post-condition does not hold = at ../move-stdlib/sources/fixed_point32.move:151: get_raw_value = y_raw_val = = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect - = y = - = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:108: mul_div_incorrect @@ -104,8 +98,6 @@ error: post-condition does not hold = at ../move-stdlib/sources/fixed_point32.move:151: get_raw_value = y_raw_val = = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect - = y = - = at tests/sources/functional/fixed_point_arithm.move:106: mul_div_incorrect = at tests/sources/functional/fixed_point_arithm.move:107: mul_div_incorrect = result = = at tests/sources/functional/fixed_point_arithm.move:108: mul_div_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/global_invariants.v2_exp b/third_party/move/move-prover/tests/sources/functional/global_invariants.v2_exp index 30735438b7dc4..5db58204b04cb 100644 --- a/third_party/move/move-prover/tests/sources/functional/global_invariants.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/global_invariants.v2_exp @@ -8,7 +8,6 @@ error: global memory invariant does not hold = at tests/sources/functional/global_invariants.move:38: create_R_invalid = account = = at tests/sources/functional/global_invariants.move:40: create_R_invalid - = = = at tests/sources/functional/global_invariants.move:38: create_R_invalid = at tests/sources/functional/global_invariants.move:40: create_R_invalid = at tests/sources/functional/global_invariants.move:18 diff --git a/third_party/move/move-prover/tests/sources/functional/global_vars.v2_exp b/third_party/move/move-prover/tests/sources/functional/global_vars.v2_exp index 7248ea9d13615..89dd1b7ce0cb7 100644 --- a/third_party/move/move-prover/tests/sources/functional/global_vars.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/global_vars.v2_exp @@ -62,7 +62,6 @@ error: global memory invariant does not hold = at tests/sources/functional/global_vars.move:220: publish = s = = at tests/sources/functional/global_vars.move:221: publish - = = = at tests/sources/functional/global_vars.move:222: publish = at tests/sources/functional/global_vars.move:230: limit_change_invalid = at tests/sources/functional/global_vars.move:232: limit_change_invalid (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp b/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp index 10d8fa2f9595e..49a8421362280 100644 --- a/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/loop_unroll.v2_exp @@ -19,47 +19,35 @@ error: abort not covered by any of the `aborts_if` clauses = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = = = i = = at tests/sources/functional/loop_unroll.move:97: t6_failure - = = - = at tests/sources/functional/loop_unroll.move:97: t6_failure = at tests/sources/functional/loop_unroll.move:92: t6_failure = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = = = i = = at tests/sources/functional/loop_unroll.move:97: t6_failure - = = = at tests/sources/functional/loop_unroll.move:91: t6_failure = at tests/sources/functional/loop_unroll.move:92: t6_failure = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = = = i = = at tests/sources/functional/loop_unroll.move:97: t6_failure - = = = at tests/sources/functional/loop_unroll.move:91: t6_failure = at tests/sources/functional/loop_unroll.move:92: t6_failure = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = = = i = = at tests/sources/functional/loop_unroll.move:97: t6_failure - = = = at tests/sources/functional/loop_unroll.move:91: t6_failure = at tests/sources/functional/loop_unroll.move:92: t6_failure = at tests/sources/functional/loop_unroll.move:94: t6_failure = at tests/sources/functional/loop_unroll.move:90: t6_failure = at tests/sources/functional/loop_unroll.move:96: t6_failure - = = = i = = at tests/sources/functional/loop_unroll.move:97: t6_failure - = = - = at tests/sources/functional/loop_unroll.move:97: t6_failure = ABORTED error: abort not covered by any of the `aborts_if` clauses diff --git a/third_party/move/move-prover/tests/sources/functional/loops.v2_exp b/third_party/move/move-prover/tests/sources/functional/loops.v2_exp index 72bdc9792f620..b660af31a58f6 100644 --- a/third_party/move/move-prover/tests/sources/functional/loops.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/loops.v2_exp @@ -12,7 +12,6 @@ error: function does not abort under this condition = i = = loop invariant holds at current state = at tests/sources/functional/loops.move:51: iter10_no_abort_incorrect - = = = at tests/sources/functional/loops.move:49: iter10_no_abort_incorrect = at tests/sources/functional/loops.move:58: iter10_no_abort_incorrect (spec) @@ -35,11 +34,8 @@ error: abort not covered by any of the `aborts_if` clauses = i = = loop invariant holds at current state = at tests/sources/functional/loops.move:80: iter10_abort_incorrect - = = = at tests/sources/functional/loops.move:78: iter10_abort_incorrect = at tests/sources/functional/loops.move:82: iter10_abort_incorrect - = = - = at tests/sources/functional/loops.move:82: iter10_abort_incorrect = ABORTED error: induction case of the loop invariant does not hold @@ -63,7 +59,6 @@ error: induction case of the loop invariant does not hold = y = = at tests/sources/functional/loops.move:128: nested_loop_outer_invariant_incorrect = at tests/sources/functional/loops.move:131: nested_loop_outer_invariant_incorrect - = = = x = = at tests/sources/functional/loops.move:117: nested_loop_outer_invariant_incorrect = at tests/sources/functional/loops.move:119: nested_loop_outer_invariant_incorrect @@ -86,7 +81,6 @@ error: induction case of the loop invariant does not hold = loop invariant holds at current state = at tests/sources/functional/loops.move:147: nested_loop_inner_invariant_incorrect = at tests/sources/functional/loops.move:150: nested_loop_inner_invariant_incorrect - = = = y = = at tests/sources/functional/loops.move:145: nested_loop_inner_invariant_incorrect @@ -109,7 +103,6 @@ error: induction case of the loop invariant does not hold = at tests/sources/functional/loops.move:191: loop_with_two_back_edges_incorrect = at tests/sources/functional/loops.move:195: loop_with_two_back_edges_incorrect = at tests/sources/functional/loops.move:196: loop_with_two_back_edges_incorrect - = = = x = = at tests/sources/functional/loops.move:197: loop_with_two_back_edges_incorrect = at tests/sources/functional/loops.move:189: loop_with_two_back_edges_incorrect @@ -145,7 +138,6 @@ error: induction case of the loop invariant does not hold = at tests/sources/functional/loops.move:225: loop_invariant_induction_invalid = at tests/sources/functional/loops.move:221: loop_invariant_induction_invalid = at tests/sources/functional/loops.move:227: loop_invariant_induction_invalid - = = = x = = at tests/sources/functional/loops.move:221: loop_invariant_induction_invalid = at tests/sources/functional/loops.move:223: loop_invariant_induction_invalid diff --git a/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp b/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp index d6f72efdfd3a5..c54e01557729d 100644 --- a/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/loops_with_memory_ops.v2_exp @@ -42,9 +42,7 @@ error: induction case of the loop invariant does not hold = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 = a = = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 - = b = = at tests/sources/functional/loops_with_memory_ops.move:85: nested_loop2 - = = = i = = at tests/sources/functional/loops_with_memory_ops.move:86: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:89: nested_loop2 @@ -102,7 +100,6 @@ error: unknown assertion failed = at tests/sources/functional/loops_with_memory_ops.move:81: nested_loop2 = b = = at tests/sources/functional/loops_with_memory_ops.move:85: nested_loop2 - = = = i = = at tests/sources/functional/loops_with_memory_ops.move:86: nested_loop2 = at tests/sources/functional/loops_with_memory_ops.move:93: nested_loop2 diff --git a/third_party/move/move-prover/tests/sources/functional/macro_verification.v2_exp b/third_party/move/move-prover/tests/sources/functional/macro_verification.v2_exp index 782a513256905..9aef5d28d0d93 100644 --- a/third_party/move/move-prover/tests/sources/functional/macro_verification.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/macro_verification.v2_exp @@ -36,8 +36,6 @@ error: post-condition does not hold = at tests/sources/functional/macro_verification.move:26: foreach = `invariant forall j in i..len(v): v[j] == old(v)[j];` = = at tests/sources/functional/macro_verification.move:17: foreach - = = - = at tests/sources/functional/macro_verification.move:17: foreach = at tests/sources/functional/macro_verification.move:15: foreach = v = = at tests/sources/functional/macro_verification.move:30: foreach (spec) @@ -79,9 +77,6 @@ error: post-condition does not hold = at tests/sources/functional/macro_verification.move:50: reduce = `invariant sum == spec_sum(v, i);` = = at tests/sources/functional/macro_verification.move:43: reduce - = = - = at tests/sources/functional/macro_verification.move:52: reduce - = = = at tests/sources/functional/macro_verification.move:40: reduce = result = = at tests/sources/functional/macro_verification.move:55: reduce (spec) @@ -130,9 +125,6 @@ error: post-condition does not hold = at tests/sources/functional/macro_verification.move:49: reduce = at tests/sources/functional/macro_verification.move:50: reduce = at tests/sources/functional/macro_verification.move:43: reduce - = = - = at tests/sources/functional/macro_verification.move:52: reduce - = = = at tests/sources/functional/macro_verification.move:40: reduce = result = = at tests/sources/functional/macro_verification.move:53: reduce diff --git a/third_party/move/move-prover/tests/sources/functional/module_level_spec.v2_exp b/third_party/move/move-prover/tests/sources/functional/module_level_spec.v2_exp index b82e398208518..15fa6af97d6bb 100644 --- a/third_party/move/move-prover/tests/sources/functional/module_level_spec.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/module_level_spec.v2_exp @@ -11,5 +11,4 @@ error: global memory invariant does not hold = s = = value = = at tests/sources/functional/module_level_spec.move:11: store_incorrect - = = = at tests/sources/functional/module_level_spec.move:18 diff --git a/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp b/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp index b3ceba69bb79e..d0db7fb4ce3c1 100644 --- a/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/mut_ref.v2_exp @@ -30,7 +30,6 @@ error: data invariant does not hold = at tests/sources/functional/mut_ref.move:120: call_return_ref_different_path_vec2_incorrect = x = = at tests/sources/functional/mut_ref.move:121: call_return_ref_different_path_vec2_incorrect - = = = at tests/sources/functional/mut_ref.move:90: return_ref_different_path_vec2 = b = = x = diff --git a/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp b/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp index d177659668d6f..b4d83685c0075 100644 --- a/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/nested_invariants.v2_exp @@ -13,8 +13,8 @@ error: data invariant does not hold = at tests/sources/functional/nested_invariants.move:64: mutate_inner_data_invariant_invalid = o = = at tests/sources/functional/nested_invariants.move:65: mutate_inner_data_invariant_invalid + = r = = at tests/sources/functional/nested_invariants.move:66: mutate_inner_data_invariant_invalid - = = = at tests/sources/functional/nested_invariants.move:29 = at tests/sources/functional/nested_invariants.move:32 = at tests/sources/functional/nested_invariants.move:16 @@ -42,8 +42,8 @@ error: data invariant does not hold = at tests/sources/functional/nested_invariants.move:58: mutate_outer_data_invariant_invalid = o = = at tests/sources/functional/nested_invariants.move:59: mutate_outer_data_invariant_invalid + = r = = at tests/sources/functional/nested_invariants.move:60: mutate_outer_data_invariant_invalid - = = = at tests/sources/functional/nested_invariants.move:29 = at tests/sources/functional/nested_invariants.move:32 diff --git a/third_party/move/move-prover/tests/sources/functional/script_incorrect.v2_exp b/third_party/move/move-prover/tests/sources/functional/script_incorrect.v2_exp index 8334205070254..52227eb833db7 100644 --- a/third_party/move/move-prover/tests/sources/functional/script_incorrect.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/script_incorrect.v2_exp @@ -25,6 +25,4 @@ error: abort not covered by any of the `aborts_if` clauses = result = = at ../move-stdlib/sources/signer.move:14: address_of = at tests/sources/functional/script_provider.move:10: register - = = - = at tests/sources/functional/script_provider.move:10: register = ABORTED diff --git a/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp b/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp index 4dc5d49a730b3..afdb0b70f765d 100644 --- a/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/specs_in_fun.v2_exp @@ -20,7 +20,6 @@ error: unknown assertion failed = at tests/sources/functional/specs_in_fun.move:49: simple2_incorrect = x = = at tests/sources/functional/specs_in_fun.move:51: simple2_incorrect - = = = y = = at tests/sources/functional/specs_in_fun.move:53: simple2_incorrect diff --git a/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp b/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp index 67b7e4f38736e..33c9f0347305e 100644 --- a/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/strong_edges.v2_exp @@ -10,8 +10,8 @@ error: post-condition does not hold = at tests/sources/functional/strong_edges.move:47: glob_and_field_edges_incorrect = addr = = at tests/sources/functional/strong_edges.move:48: glob_and_field_edges_incorrect + = s = = at tests/sources/functional/strong_edges.move:49: glob_and_field_edges_incorrect - = = = at tests/sources/functional/strong_edges.move:50: glob_and_field_edges_incorrect = at tests/sources/functional/strong_edges.move:55: glob_and_field_edges_incorrect (spec) = at tests/sources/functional/strong_edges.move:54: glob_and_field_edges_incorrect (spec) diff --git a/third_party/move/move-prover/tests/sources/functional/trace.v2_exp b/third_party/move/move-prover/tests/sources/functional/trace.v2_exp index 38e6e6733c25b..e24a41719d8a7 100644 --- a/third_party/move/move-prover/tests/sources/functional/trace.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/trace.v2_exp @@ -47,7 +47,7 @@ error: post-condition does not hold │ = Related Global Memory: = Resource name: TestTracing_R - = Values: {Address(18467): , Default: empty} + = Values: {Address(18467): , Default: TestTracing.R{x = 4}} = Related Bindings: = addr = = exists(addr) = @@ -61,7 +61,6 @@ error: post-condition does not hold = s = = x = = at tests/sources/functional/trace.move:30: publish_invalid - = = = at tests/sources/functional/trace.move:38 = at tests/sources/functional/trace.move:31: publish_invalid = at tests/sources/functional/trace.move:34: publish_invalid (spec) @@ -75,7 +74,7 @@ error: global memory invariant does not hold │ = Related Global Memory: = Resource name: TestTracing_R - = Values: {Address(0): , Default: empty} + = Values: {Address(0): , Default: TestTracing.R{x = 5}} = at tests/sources/functional/trace.move:29: publish_invalid = at tests/sources/functional/trace.move:33: publish_invalid (spec) = `let addr = signer::address_of(s);` = @@ -83,5 +82,4 @@ error: global memory invariant does not hold = s = = x = = at tests/sources/functional/trace.move:30: publish_invalid - = = = at tests/sources/functional/trace.move:38 diff --git a/third_party/move/move-prover/tests/sources/regression/Escape.v2_exp b/third_party/move/move-prover/tests/sources/regression/Escape.v2_exp index 95f6061110c17..6c00121c91033 100644 --- a/third_party/move/move-prover/tests/sources/regression/Escape.v2_exp +++ b/third_party/move/move-prover/tests/sources/regression/Escape.v2_exp @@ -9,7 +9,6 @@ error: global memory invariant does not hold = account = = thing = = at tests/sources/regression/Escape.move:25: install - = = = at tests/sources/regression/Escape.move:36 error: global memory invariant does not hold @@ -22,6 +21,5 @@ error: global memory invariant does not hold = account = = thing = = at tests/sources/regression/Escape.move:25: install - = = = at tests/sources/regression/Escape.move:36 = at tests/sources/regression/Escape.move:37 diff --git a/third_party/move/move-prover/tests/sources/regression/mono_after_global_invariant.v2_exp b/third_party/move/move-prover/tests/sources/regression/mono_after_global_invariant.v2_exp index 9604206e50aa8..a6a667d21ca5d 100644 --- a/third_party/move/move-prover/tests/sources/regression/mono_after_global_invariant.v2_exp +++ b/third_party/move/move-prover/tests/sources/regression/mono_after_global_invariant.v2_exp @@ -13,10 +13,8 @@ error: global memory invariant does not hold = at tests/sources/regression/mono_after_global_invariant.move:9: put_b = s = = at tests/sources/regression/mono_after_global_invariant.move:10: put_b - = = = at tests/sources/regression/mono_after_global_invariant.move:14: put_b = at tests/sources/regression/mono_after_global_invariant.move:32: put_r - = = = at tests/sources/regression/mono_after_global_invariant.move:30: put_r = at tests/sources/regression/mono_after_global_invariant.move:32: put_r = at tests/sources/regression/mono_after_global_invariant.move:44 diff --git a/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp b/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp index aa9b2951d4375..972aa1db72f40 100644 --- a/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp +++ b/third_party/move/move-prover/tests/sources/regression/type_param_bug_121721.v2_exp @@ -18,6 +18,5 @@ error: global memory invariant does not hold = at tests/sources/regression/type_param_bug_121721.move:86: create_ballot = at tests/sources/regression/type_param_bug_121721.move:88: create_ballot = at tests/sources/regression/type_param_bug_121721.move:87: create_ballot - = = = at tests/sources/regression/type_param_bug_121721.move:167 = at tests/sources/regression/type_param_bug_121721.move:173 diff --git a/third_party/move/move-prover/tests/sources/regression/vector_theory_boogie_array.v2_exp b/third_party/move/move-prover/tests/sources/regression/vector_theory_boogie_array.v2_exp index d4f05e0f2ba86..6f3780c21b0d8 100644 --- a/third_party/move/move-prover/tests/sources/regression/vector_theory_boogie_array.v2_exp +++ b/third_party/move/move-prover/tests/sources/regression/vector_theory_boogie_array.v2_exp @@ -12,8 +12,8 @@ error: post-condition does not hold = pool = = addr = = at tests/sources/regression/vector_theory_boogie_array.move:7: f1 - = at tests/sources/regression/vector_theory_boogie_array.move:8: f1 = idx = + = at tests/sources/regression/vector_theory_boogie_array.move:8: f1 = at tests/sources/regression/vector_theory_boogie_array.move:6: f1 = pool = = at tests/sources/regression/vector_theory_boogie_array.move:9: f1 diff --git a/third_party/move/tools/move-decompiler/tests/bit_vector.exp b/third_party/move/tools/move-decompiler/tests/bit_vector.exp index 762f2f5211648..5f27356b6fb61 100644 --- a/third_party/move/tools/move-decompiler/tests/bit_vector.exp +++ b/third_party/move/tools/move-decompiler/tests/bit_vector.exp @@ -12,41 +12,30 @@ module 0x1::bit_vector { *0x1::vector::borrow(&self.bit_field, bit_index) } public fun longest_set_sequence_starting_at(self: &BitVector, start_index: u64): u64 { - let _t3; let _t2; - _t2 = *&self.length; - if (!(start_index < _t2)) abort 131072; - _t3 = start_index; + if (!(start_index < *&self.length)) abort 131072; + _t2 = start_index; loop { { - loop { - _t2 = *&self.length; - if (!(_t3 < _t2)) break; - if (!is_index_set(self, _t3)) break; - _t2 = 1; - _t3 = _t3 + _t2 - }; + while (_t2 < *&self.length && is_index_set(self, _t2)) _t2 = _t2 + 1; break }; break }; - _t3 - start_index + _t2 - start_index } public fun new(length: u64): BitVector { - let _t3; let _t2; let _t1; + if (!(length > 0)) abort 131073; + if (!(length < 1024)) abort 131073; _t1 = 0; - if (!(length > _t1)) abort 131073; - _t1 = 1024; - if (!(length < _t1)) abort 131073; - _t2 = 0; - _t3 = 0x1::vector::empty(); - while (_t2 < length) { - 0x1::vector::push_back(&mut _t3, false); - _t2 = _t2 + 1 + _t2 = 0x1::vector::empty(); + while (_t1 < length) { + 0x1::vector::push_back(&mut _t2, false); + _t1 = _t1 + 1 }; - BitVector{length: length,bit_field: _t3} + BitVector{length: length,bit_field: _t2} } public fun set(self: &mut BitVector, bit_index: u64) { if (!(bit_index < 0x1::vector::length(&self.bit_field))) abort 131072; @@ -56,39 +45,30 @@ module 0x1::bit_vector { let _t4; let _t3; let _t2; - _t2 = *&self.length; 'l0: loop { loop { - if (amount >= _t2) { - _t3 = &mut self.bit_field; - _t2 = 0; - _t4 = 0x1::vector::length(/*freeze*/_t3) + if (amount >= *&self.length) { + _t2 = &mut self.bit_field; + _t3 = 0; + _t4 = 0x1::vector::length(/*freeze*/_t2) } else { - _t2 = amount; + _t3 = amount; break }; - while (_t2 < _t4) { - *0x1::vector::borrow_mut(_t3, _t2) = false; - _t2 = _t2 + 1 + while (_t3 < _t4) { + *0x1::vector::borrow_mut(_t2, _t3) = false; + _t3 = _t3 + 1 }; break 'l0 }; - loop { - _t4 = *&self.length; - if (!(_t2 < _t4)) break; - if (is_index_set(/*freeze*/self, _t2)) { - _t4 = _t2 - amount; - set(self, _t4) - } else { - _t4 = _t2 - amount; - unset(self, _t4) - }; - _t2 = _t2 + 1 + while (_t3 < *&self.length) { + if (is_index_set(/*freeze*/self, _t3)) set(self, _t3 - amount) else unset(self, _t3 - amount); + _t3 = _t3 + 1 }; - _t2 = *&self.length - amount; - while (_t2 < *&self.length) { - unset(self, _t2); - _t2 = _t2 + 1 + _t3 = *&self.length - amount; + while (_t3 < *&self.length) { + unset(self, _t3); + _t3 = _t3 + 1 }; break }; diff --git a/third_party/move/tools/move-decompiler/tests/fixed_point32.exp b/third_party/move/tools/move-decompiler/tests/fixed_point32.exp index f88e3a6e3ab55..a7c9846e00d2a 100644 --- a/third_party/move/tools/move-decompiler/tests/fixed_point32.exp +++ b/third_party/move/tools/move-decompiler/tests/fixed_point32.exp @@ -13,14 +13,14 @@ module 0x1::fixed_point32 { *&(&self).value >> 32u8 } public fun create_from_rational(numerator: u64, denominator: u64): FixedPoint32 { - let _t6; + let _t5; let _t4; let _t3; _t3 = (denominator as u128) << 32u8; if (!(_t3 != 0u128)) abort 65537; _t4 = ((numerator as u128) << 64u8) / _t3; - if (_t4 != 0u128) _t6 = true else _t6 = numerator == 0; - if (!_t6) abort 131077; + if (_t4 != 0u128) _t5 = true else _t5 = numerator == 0; + if (!_t5) abort 131077; if (!(_t4 <= 18446744073709551615u128)) abort 131077; FixedPoint32{value: _t4 as u64} } diff --git a/third_party/move/tools/move-decompiler/tests/simple_map.exp b/third_party/move/tools/move-decompiler/tests/simple_map.exp index 056957264c034..fc003d61fd8b1 100644 --- a/third_party/move/tools/move-decompiler/tests/simple_map.exp +++ b/third_party/move/tools/move-decompiler/tests/simple_map.exp @@ -115,33 +115,33 @@ module 0x1::simple_map { _t2 } public fun to_vec_pair(self: SimpleMap): (vector, vector) { - let _t25; - let _t24; + let _t22; + let _t21; let _t5; let _t4; let _t3; - let _t14; + let _t11; let _t2; let _t1; _t1 = vector::empty(); _t2 = vector::empty(); - SimpleMap{data: _t14} = self; - _t3 = _t14; + SimpleMap{data: _t11} = self; + _t3 = _t11; vector::reverse>(&mut _t3); _t4 = _t3; _t5 = vector::length>(&_t4); while (_t5 > 0) { - Element{key: _t24,value: _t25} = vector::pop_back>(&mut _t4); - vector::push_back(&mut _t1, _t24); - vector::push_back(&mut _t2, _t25); + Element{key: _t21,value: _t22} = vector::pop_back>(&mut _t4); + vector::push_back(&mut _t1, _t21); + vector::push_back(&mut _t2, _t22); _t5 = _t5 - 1 }; vector::destroy_empty>(_t4); (_t1, _t2) } public fun upsert(self: &mut SimpleMap, key: Key, value: Value): (option::Option, option::Option) { - let _t38; - let _t37; + let _t35; + let _t34; let _t5; let _t4; let _t3; @@ -152,8 +152,8 @@ module 0x1::simple_map { while (!(!(_t5 < _t4) || &vector::borrow>(/*freeze*/_t3, _t5).key == &key)) _t5 = _t5 + 1; vector::push_back>(_t3, Element{key: key,value: value}); vector::swap>(_t3, _t5, _t4); - Element{key: _t37,value: _t38} = vector::pop_back>(_t3); - return (option::some(_t37), option::some(_t38)) + Element{key: _t34,value: _t35} = vector::pop_back>(_t3); + return (option::some(_t34), option::some(_t35)) }; vector::push_back>(&mut self.data, Element{key: key,value: value}); (option::none(), option::none()) diff --git a/third_party/move/tools/move-decompiler/tests/string.exp b/third_party/move/tools/move-decompiler/tests/string.exp index 6df58cc3c6ebb..1a87dcb38e007 100644 --- a/third_party/move/tools/move-decompiler/tests/string.exp +++ b/third_party/move/tools/move-decompiler/tests/string.exp @@ -19,18 +19,16 @@ module 0x1::string { vector::append(&mut self.bytes, *&(&r).bytes); } public fun insert(self: &mut String, at: u64, o: String) { - let _t7; let _t6; let _t4; let _t3; _t3 = &self.bytes; - _t4 = at; - if (_t4 <= vector::length(_t3)) _t6 = internal_is_char_boundary(_t3, at) else _t6 = false; - if (!_t6) abort 2; - _t7 = sub_string(/*freeze*/self, 0, at); - append(&mut _t7, o); - append(&mut _t7, sub_string(/*freeze*/self, at, length(/*freeze*/self))); - *self = _t7; + if (at <= vector::length(_t3)) _t4 = internal_is_char_boundary(_t3, at) else _t4 = false; + if (!_t4) abort 2; + _t6 = sub_string(/*freeze*/self, 0, at); + append(&mut _t6, o); + append(&mut _t6, sub_string(/*freeze*/self, at, length(/*freeze*/self))); + *self = _t6; } native fun internal_is_char_boundary(v: &vector, i: u64): bool; public fun sub_string(self: &String, i: u64, j: u64): String { diff --git a/third_party/move/tools/move-decompiler/tests/vector.exp b/third_party/move/tools/move-decompiler/tests/vector.exp index 7462165278356..22e0c75e28a97 100644 --- a/third_party/move/tools/move-decompiler/tests/vector.exp +++ b/third_party/move/tools/move-decompiler/tests/vector.exp @@ -30,14 +30,14 @@ module 0x1::vector { range_with_step(start, end, 1) } public fun range_with_step(start: u64, end: u64, step: u64): vector { - let _t4; + let _t3; if (!(step > 0)) abort 131075; - _t4 = empty(); + _t3 = empty(); while (start < end) { - push_back(&mut _t4, start); + push_back(&mut _t3, start); start = start + step }; - _t4 + _t3 } public fun append(self: &mut vector, other: vector) { reverse(&mut other); @@ -121,16 +121,16 @@ module 0x1::vector { _t1 } public fun slice(self: &vector, start: u64, end: u64): vector { - let _t6; - let _t5; - if (start <= end) _t5 = end <= length(self) else _t5 = false; - if (!_t5) abort 131076; - _t6 = empty(); + let _t4; + let _t3; + if (start <= end) _t3 = end <= length(self) else _t3 = false; + if (!_t3) abort 131076; + _t4 = empty(); while (start < end) { - push_back(&mut _t6, *borrow(self, start)); + push_back(&mut _t4, *borrow(self, start)); start = start + 1 }; - _t6 + _t4 } public fun swap_remove(self: &mut vector, i: u64): Element { if (is_empty(/*freeze*/self)) abort 131072; From 6aa731ed8563653578bd7038d4454dac31704bc5 Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Sun, 15 Dec 2024 19:17:56 -0500 Subject: [PATCH 2/5] Fix cargo nextest version (#15608) --- scripts/dev_setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/dev_setup.sh b/scripts/dev_setup.sh index 84763fa616aed..6b6fa16d85251 100755 --- a/scripts/dev_setup.sh +++ b/scripts/dev_setup.sh @@ -506,7 +506,7 @@ function install_cargo_machete { function install_cargo_nextest { if ! command -v cargo-nextest &>/dev/null; then - cargo install cargo-nextest --locked + cargo install cargo-nextest --locked --version 0.9.85 fi } From b98e6b99260181e9efb3f65af1b15e6e043e0d30 Mon Sep 17 00:00:00 2001 From: Igor Date: Fri, 22 Nov 2024 10:17:31 -0800 Subject: [PATCH 3/5] Temporarily loosen backpressures, until module loading improvement speeds up blocks (cherry picked from commit c7fe4449949dccf8f7212cb03ce004f44e8f0002) --- config/src/config/consensus_config.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/src/config/consensus_config.rs b/config/src/config/consensus_config.rs index 11b430408e38b..4668b400691ba 100644 --- a/config/src/config/consensus_config.rs +++ b/config/src/config/consensus_config.rs @@ -195,11 +195,11 @@ impl Default for ConsensusConfig { vote_back_pressure_limit: 7, min_max_txns_in_block_after_filtering_from_backpressure: MIN_BLOCK_TXNS_AFTER_FILTERING, execution_backpressure: Some(ExecutionBackpressureConfig { - num_blocks_to_look_at: 12, - min_blocks_to_activate: 4, + num_blocks_to_look_at: 20, + min_blocks_to_activate: 10, percentile: 0.5, - target_block_time_ms: 250, - min_block_time_ms_to_activate: 100, + target_block_time_ms: 350, + min_block_time_ms_to_activate: 200, // allow at least two spreading group from reordering in a single block, to utilize paralellism min_calibrated_txns_per_block: 8, }), From 86c3e4d0f047165f446da253fd23a1088bf350d5 Mon Sep 17 00:00:00 2001 From: Sherry Xiao Date: Wed, 18 Dec 2024 12:28:17 -0800 Subject: [PATCH 4/5] Bump gas for 1.25 --- aptos-move/aptos-gas-schedule/src/ver.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/aptos-move/aptos-gas-schedule/src/ver.rs b/aptos-move/aptos-gas-schedule/src/ver.rs index 9e40e1d833880..31924b94a4c93 100644 --- a/aptos-move/aptos-gas-schedule/src/ver.rs +++ b/aptos-move/aptos-gas-schedule/src/ver.rs @@ -69,7 +69,7 @@ /// global operations. /// - V1 /// - TBA -pub const LATEST_GAS_FEATURE_VERSION: u64 = gas_feature_versions::RELEASE_V1_24; +pub const LATEST_GAS_FEATURE_VERSION: u64 = gas_feature_versions::RELEASE_V1_25; pub mod gas_feature_versions { pub const RELEASE_V1_8: u64 = 11; @@ -89,4 +89,5 @@ pub mod gas_feature_versions { pub const RELEASE_V1_22: u64 = 26; pub const RELEASE_V1_23: u64 = 27; pub const RELEASE_V1_24: u64 = 28; + pub const RELEASE_V1_25: u64 = 29; } From 6593fb81261f25490ffddc2252a861c994234c2a Mon Sep 17 00:00:00 2001 From: Sherry Xiao Date: Wed, 18 Dec 2024 12:22:34 -0800 Subject: [PATCH 5/5] Revert "Bumping up the max transaction execution gas limit for gov proposals" This reverts commit e2359fd575313dde0db0e4eea9f13e691318ff51. (cherry picked from commit 127df5c2c68891362f17c6b8cfe88e454c5ba0c5) --- aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs b/aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs index 62a09562f1bdf..5c51fa9ee314b 100644 --- a/aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs +++ b/aptos-move/aptos-gas-schedule/src/gas_schedule/transaction.rs @@ -212,7 +212,7 @@ crate::gas_schedule::macros::define_gas_parameters!( [ max_execution_gas_gov: InternalGas, { RELEASE_V1_13.. => "max_execution_gas.gov" }, - 4_300_000_000, + 4_000_000_000, ], [ max_io_gas: InternalGas,