From 7350bafd45452464e87324d15f470cfa0daa91e3 Mon Sep 17 00:00:00 2001 From: Wolfgang Grieskamp Date: Tue, 22 Aug 2023 00:09:51 -0700 Subject: [PATCH] [compiler v2] Stackless Bytecode Refactoring This is the 2nd step in the refactoring started in #9698. This splits off prover specific parts from the crate `move-model/bytecode` into `move-prover/bytecode-pipeline`. Sharable dataflow analysis and transformation processors, like livevar and reaching definitions, stay. The tests have been split as well, and a common testing driver has been moved in its own test utility crate. Github does not nicely show diffs like this, but this is functionally a no-op which only Moves code around. --- Cargo.lock | 55 +- Cargo.toml | 4 + aptos-move/framework/Cargo.toml | 3 +- aptos-move/framework/src/prover.rs | 6 +- .../move-model/bytecode-test-utils/Cargo.toml | 20 + .../move-model/bytecode-test-utils/src/lib.rs | 93 +++ .../move/move-model/bytecode/Cargo.toml | 3 +- .../move/move-model/bytecode/src/lib.rs | 23 +- .../bytecode/tests/borrow/basic_test.exp | 140 ++--- .../bytecode/tests/borrow/function_call.exp | 38 +- .../bytecode/tests/borrow/hyper_edge.exp | 18 +- .../tests/borrow_strong/basic_test.exp | 194 ++++--- .../bytecode/tests/borrow_strong/mut_ref.exp | 104 ++-- .../data_invariant_instrumentation/borrow.exp | 197 ------- .../borrow.move | 39 -- .../data_invariant_instrumentation/pack.exp | 36 -- .../data_invariant_instrumentation/pack.move | 24 - .../data_invariant_instrumentation/params.exp | 25 - .../params.move | 20 - .../data_invariant_instrumentation/vector.exp | 15 - .../vector.move | 18 - .../tests/eliminate_imm_refs/basic_test.exp | 176 ------ .../tests/eliminate_imm_refs/basic_test.move | 39 -- .../disable_in_body.exp | 54 -- .../disable_in_body.move | 15 - .../global_invariant_analysis/mutual_inst.exp | 418 -------------- .../mutual_inst.move | 60 -- .../uninst_type_param_in_inv.exp | 116 ---- .../uninst_type_param_in_inv.move | 27 - .../borrow.exp | 57 -- .../borrow.move | 14 - .../global_invariant_instrumentation/move.exp | 61 -- .../move.move | 18 - .../update.exp | 57 -- .../update.move | 14 - .../bytecode/tests/livevar/basic_test.exp | 191 ++++--- .../tests/memory_instr/basic_test.exp | 516 ----------------- .../tests/memory_instr/basic_test.move | 70 --- .../bytecode/tests/memory_instr/mut_ref.exp | 495 ---------------- .../bytecode/tests/memory_instr/mut_ref.move | 71 --- .../bytecode/tests/mono_analysis/test.exp | 79 --- .../bytecode/tests/mono_analysis/test.move | 37 -- .../mut_ref_instrumentation/basic_test.exp | 460 --------------- .../mut_ref_instrumentation/basic_test.move | 71 --- .../tests/reaching_def/basic_test.exp | 4 +- .../tests/reaching_def/test_branching.exp | 9 +- .../tests/spec_instrumentation/fun_spec.exp | 460 --------------- .../tests/spec_instrumentation/fun_spec.move | 72 --- .../tests/spec_instrumentation/generics.exp | 94 --- .../tests/spec_instrumentation/generics.move | 29 - .../tests/spec_instrumentation/modifies.exp | 537 ------------------ .../tests/spec_instrumentation/modifies.move | 102 ---- .../spec_instrumentation/opaque_call.exp | 218 ------- .../spec_instrumentation/opaque_call.move | 31 - .../move-model/bytecode/tests/testsuite.rs | 228 +------- .../verification_analysis/inv_relevance.exp | 120 ---- .../verification_analysis/inv_relevance.move | 25 - .../verification_analysis/inv_suspension.exp | 121 ---- .../verification_analysis/inv_suspension.move | 32 -- third_party/move/move-prover/Cargo.toml | 1 + .../move-prover/boogie-backend/Cargo.toml | 1 + .../boogie-backend/src/bytecode_translator.rs | 8 +- .../move-prover/boogie-backend/src/lib.rs | 2 +- .../boogie-backend/src/spec_translator.rs | 2 +- .../move-prover/bytecode-pipeline/Cargo.toml | 47 ++ .../src/clean_and_optimize.rs | 16 +- .../src/data_invariant_instrumentation.rs | 14 +- .../src/eliminate_imm_refs.rs | 12 +- .../src/global_invariant_analysis.rs | 16 +- .../src/global_invariant_instrumentation.rs | 16 +- .../global_invariant_instrumentation_v2.rs | 21 +- .../src/inconsistency_check.rs | 6 +- .../move-prover/bytecode-pipeline/src/lib.rs | 24 + .../bytecode-pipeline}/src/loop_analysis.rs | 18 +- .../src/memory_instrumentation.rs | 16 +- .../bytecode-pipeline}/src/mono_analysis.rs | 12 +- .../src/mut_ref_instrumentation.rs | 6 +- .../bytecode-pipeline}/src/mutation_tester.rs | 12 +- .../src/number_operation.rs | 2 +- .../src/number_operation_analysis.rs | 22 +- .../bytecode-pipeline}/src/options.rs | 0 .../src/packed_types_analysis.rs | 14 +- .../src/pipeline_factory.rs | 27 +- .../src/spec_instrumentation.rs | 26 +- .../src/verification_analysis.rs | 12 +- .../src/verification_analysis_v2.rs | 14 +- .../src/well_formed_instrumentation.rs | 14 +- .../bytecode-pipeline/tests/testsuite.rs | 165 ++++++ third_party/move/move-prover/lab/Cargo.toml | 1 + .../move/move-prover/lab/src/benchmark.rs | 2 +- third_party/move/move-prover/src/cli.rs | 2 +- third_party/move/move-prover/src/lib.rs | 6 +- 92 files changed, 951 insertions(+), 5879 deletions(-) create mode 100644 third_party/move/move-model/bytecode-test-utils/Cargo.toml create mode 100644 third_party/move/move-model/bytecode-test-utils/src/lib.rs delete mode 100644 third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/borrow.exp delete mode 100644 third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/borrow.move delete mode 100644 third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/pack.exp delete mode 100644 third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/pack.move delete mode 100644 third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/params.exp delete mode 100644 third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/params.move delete mode 100644 third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/vector.exp delete mode 100644 third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/vector.move delete mode 100644 third_party/move/move-model/bytecode/tests/eliminate_imm_refs/basic_test.exp delete mode 100644 third_party/move/move-model/bytecode/tests/eliminate_imm_refs/basic_test.move delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_analysis/disable_in_body.exp delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_analysis/disable_in_body.move delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_analysis/mutual_inst.exp delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_analysis/mutual_inst.move delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_analysis/uninst_type_param_in_inv.exp delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_analysis/uninst_type_param_in_inv.move delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/borrow.exp delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/borrow.move delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/move.exp delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/move.move delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/update.exp delete mode 100644 third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/update.move delete mode 100644 third_party/move/move-model/bytecode/tests/memory_instr/basic_test.exp delete mode 100644 third_party/move/move-model/bytecode/tests/memory_instr/basic_test.move delete mode 100644 third_party/move/move-model/bytecode/tests/memory_instr/mut_ref.exp delete mode 100644 third_party/move/move-model/bytecode/tests/memory_instr/mut_ref.move delete mode 100644 third_party/move/move-model/bytecode/tests/mono_analysis/test.exp delete mode 100644 third_party/move/move-model/bytecode/tests/mono_analysis/test.move delete mode 100644 third_party/move/move-model/bytecode/tests/mut_ref_instrumentation/basic_test.exp delete mode 100644 third_party/move/move-model/bytecode/tests/mut_ref_instrumentation/basic_test.move delete mode 100644 third_party/move/move-model/bytecode/tests/spec_instrumentation/fun_spec.exp delete mode 100644 third_party/move/move-model/bytecode/tests/spec_instrumentation/fun_spec.move delete mode 100644 third_party/move/move-model/bytecode/tests/spec_instrumentation/generics.exp delete mode 100644 third_party/move/move-model/bytecode/tests/spec_instrumentation/generics.move delete mode 100644 third_party/move/move-model/bytecode/tests/spec_instrumentation/modifies.exp delete mode 100644 third_party/move/move-model/bytecode/tests/spec_instrumentation/modifies.move delete mode 100644 third_party/move/move-model/bytecode/tests/spec_instrumentation/opaque_call.exp delete mode 100644 third_party/move/move-model/bytecode/tests/spec_instrumentation/opaque_call.move delete mode 100644 third_party/move/move-model/bytecode/tests/verification_analysis/inv_relevance.exp delete mode 100644 third_party/move/move-model/bytecode/tests/verification_analysis/inv_relevance.move delete mode 100644 third_party/move/move-model/bytecode/tests/verification_analysis/inv_suspension.exp delete mode 100644 third_party/move/move-model/bytecode/tests/verification_analysis/inv_suspension.move create mode 100644 third_party/move/move-prover/bytecode-pipeline/Cargo.toml rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/clean_and_optimize.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/data_invariant_instrumentation.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/eliminate_imm_refs.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/global_invariant_analysis.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/global_invariant_instrumentation.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/global_invariant_instrumentation_v2.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/inconsistency_check.rs (98%) create mode 100644 third_party/move/move-prover/bytecode-pipeline/src/lib.rs rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/loop_analysis.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/memory_instrumentation.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/mono_analysis.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/mut_ref_instrumentation.rs (98%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/mutation_tester.rs (98%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/number_operation.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/number_operation_analysis.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/options.rs (100%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/packed_types_analysis.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/pipeline_factory.rs (90%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/spec_instrumentation.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/verification_analysis.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/verification_analysis_v2.rs (99%) rename third_party/move/{move-model/bytecode => move-prover/bytecode-pipeline}/src/well_formed_instrumentation.rs (99%) create mode 100644 third_party/move/move-prover/bytecode-pipeline/tests/testsuite.rs diff --git a/Cargo.lock b/Cargo.lock index 47f0b7d5a95436..41110d2023de8a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1495,6 +1495,7 @@ dependencies = [ "move-package", "move-prover", "move-prover-boogie-backend", + "move-prover-bytecode-pipeline", "move-stackless-bytecode", "move-unit-test", "move-vm-runtime", @@ -9271,6 +9272,7 @@ dependencies = [ "move-ir-types", "move-model", "move-prover-boogie-backend", + "move-prover-bytecode-pipeline", "move-prover-test-utils", "move-stackless-bytecode", "num 0.4.0", @@ -9303,6 +9305,7 @@ dependencies = [ "move-compiler", "move-core-types", "move-model", + "move-prover-bytecode-pipeline", "move-stackless-bytecode", "num 0.4.0", "once_cell", @@ -9315,6 +9318,40 @@ dependencies = [ "tokio", ] +[[package]] +name = "move-prover-bytecode-pipeline" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-trait", + "atty", + "clap 4.3.21", + "codespan", + "codespan-reporting", + "datatest-stable", + "futures", + "hex", + "itertools", + "log", + "move-binary-format", + "move-core-types", + "move-model", + "move-stackless-bytecode", + "move-stackless-bytecode-test-utils", + "num 0.4.0", + "once_cell", + "pretty", + "rand 0.8.5", + "serde 1.0.149", + "serde_json", + "shell-words", + "simplelog", + "tempfile", + "tokio", + "toml 0.5.9", + "walkdir", +] + [[package]] name = "move-prover-test-utils" version = "0.1.0" @@ -9359,8 +9396,7 @@ dependencies = [ "move-core-types", "move-ir-to-bytecode", "move-model", - "move-prover-test-utils", - "move-stdlib", + "move-stackless-bytecode-test-utils", "num 0.4.0", "once_cell", "paste", @@ -9368,6 +9404,20 @@ dependencies = [ "serde 1.0.149", ] +[[package]] +name = "move-stackless-bytecode-test-utils" +version = "0.1.0" +dependencies = [ + "anyhow", + "codespan-reporting", + "move-command-line-common", + "move-compiler", + "move-model", + "move-prover-test-utils", + "move-stackless-bytecode", + "move-stdlib", +] + [[package]] name = "move-stdlib" version = "0.1.1" @@ -11081,6 +11131,7 @@ dependencies = [ "move-model", "move-prover", "move-prover-boogie-backend", + "move-prover-bytecode-pipeline", "move-stackless-bytecode", "num 0.4.0", "plotters", diff --git a/Cargo.toml b/Cargo.toml index f4b57941522896..13c1254ecd2203 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -195,8 +195,10 @@ members = [ "third_party/move/move-ir/types", "third_party/move/move-model", "third_party/move/move-model/bytecode", + "third_party/move/move-model/bytecode-test-utils", "third_party/move/move-prover", "third_party/move/move-prover/boogie-backend", + "third_party/move/move-prover/bytecode-pipeline", "third_party/move/move-prover/lab", "third_party/move/move-prover/move-abigen", "third_party/move/move-prover/move-docgen", @@ -658,7 +660,9 @@ move-model = { path = "third_party/move/move-model" } move-package = { path = "third_party/move/tools/move-package" } move-prover = { path = "third_party/move/move-prover" } move-prover-boogie-backend = { path = "third_party/move/move-prover/boogie-backend" } +move-prover-bytecode-pipeline = { path = "third_party/move/move-prover/bytecode-pipeline" } move-stackless-bytecode = { path = "third_party/move/move-model/bytecode" } +move-stackless-bytecode-test-utils = { path = "third_party/move/move-model/bytecode-test-utils" } aptos-move-stdlib = { path = "aptos-move/framework/move-stdlib" } aptos-table-natives = { path = "aptos-move/framework/table-natives" } move-prover-test-utils = { path = "third_party/move/move-prover/test-utils" } diff --git a/aptos-move/framework/Cargo.toml b/aptos-move/framework/Cargo.toml index c62b2e8776cdf4..d0bc9b2c114683 100644 --- a/aptos-move/framework/Cargo.toml +++ b/aptos-move/framework/Cargo.toml @@ -17,7 +17,7 @@ anyhow = { workspace = true } aptos-aggregator = { workspace = true } aptos-crypto = { workspace = true, features = ["fuzzing"] } aptos-gas-algebra = { workspace = true } -aptos-gas-schedule = { workspace = true } +aptos-gas-schedule = { workspace = true } aptos-move-stdlib = { workspace = true } aptos-native-interface = { workspace = true } aptos-sdk-builder = { workspace = true } @@ -59,6 +59,7 @@ move-model = { workspace = true } move-package = { workspace = true } move-prover = { workspace = true } move-prover-boogie-backend = { workspace = true } +move-prover-bytecode-pipeline = { workspace = true } move-stackless-bytecode = { workspace = true } move-vm-runtime = { workspace = true } move-vm-types = { workspace = true } diff --git a/aptos-move/framework/src/prover.rs b/aptos-move/framework/src/prover.rs index 16210705dcae95..2de96ee9269c1d 100644 --- a/aptos-move/framework/src/prover.rs +++ b/aptos-move/framework/src/prover.rs @@ -176,12 +176,12 @@ impl ProverOptions { let opts = move_prover::cli::Options { output_path: "".to_string(), verbosity_level, - prover: move_stackless_bytecode::options::ProverOptions { + prover: move_prover_bytecode_pipeline::options::ProverOptions { stable_test_output: self.stable_test_output, auto_trace_level: if self.trace { - move_stackless_bytecode::options::AutoTraceLevel::VerifiedFunction + move_prover_bytecode_pipeline::options::AutoTraceLevel::VerifiedFunction } else { - move_stackless_bytecode::options::AutoTraceLevel::Off + move_prover_bytecode_pipeline::options::AutoTraceLevel::Off }, report_severity: Severity::Warning, dump_bytecode: self.dump, diff --git a/third_party/move/move-model/bytecode-test-utils/Cargo.toml b/third_party/move/move-model/bytecode-test-utils/Cargo.toml new file mode 100644 index 00000000000000..5a8064fbaf96d2 --- /dev/null +++ b/third_party/move/move-model/bytecode-test-utils/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "move-stackless-bytecode-test-utils" +version = "0.1.0" +authors = ["Diem Association "] +description = "Move stackless bytecode" +repository = "https://github.com/diem/diem" +homepage = "https://diem.com" +license = "Apache-2.0" +publish = false +edition = "2021" + +[dependencies] +anyhow = "1.0.52" +codespan-reporting = { version = "0.11.1", features = ["serde", "serialization"] } +move-command-line-common = { path = "../../move-command-line-common" } +move-compiler = { path = "../../move-compiler" } +move-model = { path = ".." } +move-prover-test-utils = { path = "../../move-prover/test-utils" } +move-stackless-bytecode = { path = "../bytecode" } +move-stdlib = { path = "../../move-stdlib" } diff --git a/third_party/move/move-model/bytecode-test-utils/src/lib.rs b/third_party/move/move-model/bytecode-test-utils/src/lib.rs new file mode 100644 index 00000000000000..b6e0836a7c4c24 --- /dev/null +++ b/third_party/move/move-model/bytecode-test-utils/src/lib.rs @@ -0,0 +1,93 @@ +// Copyright © Aptos Foundation +// Parts of the project are originally copyright © Meta Platforms, Inc. +// SPDX-License-Identifier: Apache-2.0 + +use anyhow::anyhow; +use codespan_reporting::{diagnostic::Severity, term::termcolor::Buffer}; +use move_command_line_common::testing::EXP_EXT; +use move_compiler::shared::{known_attributes::KnownAttribute, PackagePaths}; +use move_model::{model::GlobalEnv, options::ModelBuilderOptions, run_model_builder_with_options}; +use move_prover_test_utils::{baseline_test::verify_or_update_baseline, extract_test_directives}; +use move_stackless_bytecode::{ + function_target_pipeline::{ + FunctionTargetPipeline, FunctionTargetsHolder, ProcessorResultDisplay, + }, + print_targets_for_test, +}; +use std::path::Path; + +/// A test runner which dumps annotated bytecode and can be used for implementing a `datatest` +/// runner. In addition to the path where the Move source resides, an optional processing +/// pipeline is passed to establish the state to be tested. This will dump the initial +/// bytecode and the result of the pipeline in a baseline file. +/// The Move source file can use comments of the form `// dep: file.move` to add additional +/// sources. +pub fn test_runner( + path: &Path, + pipeline_opt: Option, +) -> anyhow::Result<()> { + let mut sources = extract_test_directives(path, "// dep:")?; + sources.push(path.to_string_lossy().to_string()); + let env: GlobalEnv = run_model_builder_with_options( + vec![PackagePaths { + name: None, + paths: sources, + named_address_map: move_stdlib::move_stdlib_named_addresses(), + }], + vec![], + ModelBuilderOptions::default(), + false, + KnownAttribute::get_all_attribute_names(), + )?; + let out = if env.has_errors() { + let mut error_writer = Buffer::no_color(); + env.report_diag(&mut error_writer, Severity::Error); + String::from_utf8_lossy(&error_writer.into_inner()).to_string() + } else { + let dir_name = path + .parent() + .and_then(|p| p.file_name()) + .and_then(|p| p.to_str()) + .ok_or_else(|| anyhow!("bad file name"))?; + + // Initialize and print function targets + let mut text = String::new(); + let mut targets = FunctionTargetsHolder::default(); + for module_env in env.get_modules() { + for func_env in module_env.get_functions() { + targets.add_target(&func_env); + } + } + text += &print_targets_for_test(&env, "initial translation from Move", &targets); + + // Run pipeline if any + if let Some(pipeline) = pipeline_opt { + pipeline.run(&env, &mut targets); + let processor = pipeline.last_processor(); + if !processor.is_single_run() { + text += &print_targets_for_test( + &env, + &format!("after pipeline `{}`", dir_name), + &targets, + ); + } + text += &ProcessorResultDisplay { + env: &env, + targets: &targets, + processor, + } + .to_string(); + } + // add Warning and Error diagnostics to output + let mut error_writer = Buffer::no_color(); + if env.has_errors() || env.has_warnings() { + env.report_diag(&mut error_writer, Severity::Warning); + text += "============ Diagnostics ================\n"; + text += &String::from_utf8_lossy(&error_writer.into_inner()); + } + text + }; + let baseline_path = path.with_extension(EXP_EXT); + verify_or_update_baseline(baseline_path.as_path(), &out)?; + Ok(()) +} diff --git a/third_party/move/move-model/bytecode/Cargo.toml b/third_party/move/move-model/bytecode/Cargo.toml index 5f63141ccb8a91..36c3307e6b08c2 100644 --- a/third_party/move/move-model/bytecode/Cargo.toml +++ b/third_party/move/move-model/bytecode/Cargo.toml @@ -34,8 +34,7 @@ serde = { version = "1.0.124", features = ["derive"] } [dev-dependencies] anyhow = "1.0.52" datatest-stable = "0.1.1" -move-prover-test-utils = { path = "../../move-prover/test-utils" } -move-stdlib = { path = "../../move-stdlib" } +move-stackless-bytecode-test-utils = { path = "../bytecode-test-utils" } [[test]] name = "testsuite" diff --git a/third_party/move/move-model/bytecode/src/lib.rs b/third_party/move/move-model/bytecode/src/lib.rs index d9c38525f8770f..bb7420046f31b1 100644 --- a/third_party/move/move-model/bytecode/src/lib.rs +++ b/third_party/move/move-model/bytecode/src/lib.rs @@ -10,44 +10,23 @@ use std::fmt::Write; pub mod annotations; pub mod borrow_analysis; -pub mod clean_and_optimize; pub mod compositional_analysis; -pub mod data_invariant_instrumentation; pub mod dataflow_analysis; pub mod dataflow_domains; pub mod debug_instrumentation; -pub mod eliminate_imm_refs; pub mod function_data_builder; pub mod function_target; pub mod function_target_pipeline; -pub mod global_invariant_analysis; -pub mod global_invariant_instrumentation; -pub mod global_invariant_instrumentation_v2; pub mod graph; -pub mod inconsistency_check; pub mod livevar_analysis; -pub mod loop_analysis; -pub mod memory_instrumentation; -pub mod mono_analysis; -pub mod mut_ref_instrumentation; -pub mod mutation_tester; -pub mod number_operation; -pub mod number_operation_analysis; -pub mod options; -pub mod packed_types_analysis; -pub mod pipeline_factory; pub mod reaching_def_analysis; -pub mod spec_instrumentation; pub mod stackless_bytecode; pub mod stackless_bytecode_generator; pub mod stackless_control_flow_graph; pub mod usage_analysis; -pub mod verification_analysis; -pub mod verification_analysis_v2; -pub mod well_formed_instrumentation; /// An error message used for cases where a compiled module is expected to be attached -pub(crate) const COMPILED_MODULE_AVAILABLE: &str = "compiled module missing"; +pub const COMPILED_MODULE_AVAILABLE: &str = "compiled module missing"; /// Print function targets for testing and debugging. pub fn print_targets_for_test( diff --git a/third_party/move/move-model/bytecode/tests/borrow/basic_test.exp b/third_party/move/move-model/bytecode/tests/borrow/basic_test.exp index b4d7cf99bd71c0..a6f5acf70b0ee1 100644 --- a/third_party/move/move-model/bytecode/tests/borrow/basic_test.exp +++ b/third_party/move/move-model/bytecode/tests/borrow/basic_test.exp @@ -269,10 +269,8 @@ fun TestBorrow::test1(): TestBorrow::R { fun TestBorrow::test2($t0|x_ref: &mut u64, $t1|v: u64) { # live_nodes: LocalRoot($t1), Reference($t0) 0: write_ref($t0, $t1) - # live_nodes: LocalRoot($t1), Reference($t0) - 1: trace_local[x_ref]($t0) # live_nodes: LocalRoot($t1) - 2: return () + 1: return () } @@ -281,18 +279,14 @@ public fun TestBorrow::test3($t0|r_ref: &mut TestBorrow::R, $t1|v: u64) { var $t2: &mut u64 # live_nodes: LocalRoot($t1), Reference($t0) 0: $t2 := borrow_field.x($t0) - # live_nodes: LocalRoot($t1), Reference($t0), Reference($t2) + # live_nodes: LocalRoot($t1), Reference($t2) # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t2))} # borrows_from: Reference($t2) -> {(.x (u64), Reference($t0))} 1: TestBorrow::test2($t2, $t1) - # live_nodes: LocalRoot($t1), Reference($t0) - # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t2))} - # borrows_from: Reference($t2) -> {(.x (u64), Reference($t0))} - 2: trace_local[r_ref]($t0) # live_nodes: LocalRoot($t1) # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t2))} # borrows_from: Reference($t2) -> {(.x (u64), Reference($t0))} - 3: return () + 2: return () } @@ -329,14 +323,10 @@ public fun TestBorrow::test5($t0|r_ref: &mut TestBorrow::R): &mut u64 { var $t1: &mut u64 # live_nodes: Reference($t0) 0: $t1 := borrow_field.x($t0) - # live_nodes: Reference($t0), Reference($t1) - # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t1))} - # borrows_from: Reference($t1) -> {(.x (u64), Reference($t0))} - 1: trace_local[r_ref]($t0) # live_nodes: Reference($t1) # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t1))} # borrows_from: Reference($t1) -> {(.x (u64), Reference($t0))} - 2: return $t1 + 1: return $t1 } @@ -400,7 +390,7 @@ fun TestBorrow::test7($t0|b: bool) { # live_nodes: LocalRoot($t0), Reference($t3), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6))}, Reference($t6) -> {(@, LocalRoot($t1))} - 6: if ($t0) goto 15 else goto 18 + 6: if ($t0) goto 16 else goto 19 # live_nodes: LocalRoot($t0), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6))}, Reference($t6) -> {(@, LocalRoot($t1))} @@ -420,43 +410,47 @@ fun TestBorrow::test7($t0|b: bool) { # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, LocalRoot($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, Reference($t3))}, Reference($t7) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(@, LocalRoot($t2))} - 11: label L0 + 11: goto 12 + # live_nodes: LocalRoot($t0), Reference($t3) + # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, LocalRoot($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, Reference($t3))}, Reference($t7) -> {(@, Reference($t3))} + # borrows_from: Reference($t3) -> {(@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(@, LocalRoot($t2))} + 12: label L0 # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, LocalRoot($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, Reference($t3))}, Reference($t7) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(@, LocalRoot($t2))} - 12: $t8 := 0 + 13: $t8 := 0 # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, LocalRoot($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, Reference($t3))}, Reference($t7) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(@, LocalRoot($t2))} - 13: TestBorrow::test3($t3, $t8) + 14: TestBorrow::test3($t3, $t8) # live_nodes: LocalRoot($t0) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, LocalRoot($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, Reference($t3))}, Reference($t7) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(@, LocalRoot($t2))} - 14: return () + 15: return () # live_nodes: LocalRoot($t0), Reference($t3), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6))}, Reference($t6) -> {(@, LocalRoot($t1))} - 15: label L2 + 16: label L2 # live_nodes: LocalRoot($t0), Reference($t3), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6))}, Reference($t6) -> {(@, LocalRoot($t1))} - 16: destroy($t3) + 17: destroy($t3) # live_nodes: LocalRoot($t0), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6))}, Reference($t6) -> {(@, LocalRoot($t1))} - 17: goto 7 + 18: goto 7 # live_nodes: LocalRoot($t0), Reference($t3), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6))}, Reference($t6) -> {(@, LocalRoot($t1))} - 18: label L3 + 19: label L3 # live_nodes: LocalRoot($t0), Reference($t3), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6))}, Reference($t6) -> {(@, LocalRoot($t1))} - 19: destroy($t6) + 20: destroy($t6) # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t6))}, Reference($t6) -> {(@, LocalRoot($t1))} - 20: goto 11 + 21: goto 12 } @@ -493,154 +487,166 @@ fun TestBorrow::test8($t0|b: bool, $t1|n: u64, $t2|r_ref: &mut TestBorrow::R) { # borrowed_by: LocalRoot($t4) -> {(@, Reference($t8))} # borrows_from: Reference($t8) -> {(@, LocalRoot($t4))} 5: $t5 := $t8 + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) + # borrowed_by: LocalRoot($t4) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t5))} + # borrows_from: Reference($t5) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t4))} + 6: goto 7 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 6: label L6 + 7: label L6 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 7: $t9 := 0 + 8: $t9 := 0 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 8: $t10 := <($t9, $t1) + 9: $t10 := <($t9, $t1) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 9: if ($t10) goto 10 else goto 29 + 10: if ($t10) goto 11 else goto 32 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 10: label L1 + 11: label L1 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 11: label L2 + 12: goto 13 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 12: destroy($t5) + 13: label L2 + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) + # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} + # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} + 14: destroy($t5) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 13: $t11 := 2 + 15: $t11 := 2 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 14: $t12 := /($t1, $t11) + 16: $t12 := /($t1, $t11) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 15: $t13 := 0 + 17: $t13 := 0 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 16: $t14 := ==($t12, $t13) + 18: $t14 := ==($t12, $t13) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 17: if ($t14) goto 18 else goto 22 + 19: if ($t14) goto 20 else goto 24 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 18: label L4 + 20: label L4 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 19: $t15 := borrow_local($t3) + 21: $t15 := borrow_local($t3) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t15) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 20: $t5 := $t15 + 22: $t5 := $t15 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 21: goto 25 + 23: goto 28 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 22: label L3 + 24: label L3 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 23: $t16 := borrow_local($t4) + 25: $t16 := borrow_local($t4) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t16) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 24: $t5 := $t16 + 26: $t5 := $t16 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 25: label L5 + 27: goto 28 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 26: $t17 := 1 + 28: label L5 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 27: $t1 := -($t1, $t17) + 29: $t17 := 1 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 28: goto 6 + 30: $t1 := -($t1, $t17) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 29: label L0 + 31: goto 7 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 30: if ($t0) goto 31 else goto 36 + 32: label L0 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 31: label L8 + 33: if ($t0) goto 34 else goto 39 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 32: destroy($t5) - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) + 34: label L8 + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 33: $t18 := 0 + 35: destroy($t5) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 34: TestBorrow::test3($t2, $t18) + 36: $t18 := 0 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 35: goto 40 - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) + 37: TestBorrow::test3($t2, $t18) + # live_nodes: LocalRoot($t0), LocalRoot($t1) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 36: label L7 + 38: goto 44 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 37: destroy($t2) + 39: label L7 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 38: $t19 := 0 - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) + 40: destroy($t2) + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 39: TestBorrow::test3($t5, $t19) - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) + 41: $t19 := 0 + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 40: label L9 - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) + 42: TestBorrow::test3($t5, $t19) + # live_nodes: LocalRoot($t0), LocalRoot($t1) + # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} + # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} + 43: goto 44 + # live_nodes: LocalRoot($t0), LocalRoot($t1) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 41: trace_local[r_ref]($t2) + 44: label L9 # live_nodes: LocalRoot($t0), LocalRoot($t1) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t15))}, LocalRoot($t4) -> {(@, Reference($t8)), (@, Reference($t16))}, Reference($t8) -> {(@, Reference($t5))}, Reference($t15) -> {(@, Reference($t5))}, Reference($t16) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t8)), (@, Reference($t15)), (@, Reference($t16))}, Reference($t8) -> {(@, LocalRoot($t4))}, Reference($t15) -> {(@, LocalRoot($t3))}, Reference($t16) -> {(@, LocalRoot($t4))} - 42: return () + 45: return () } diff --git a/third_party/move/move-model/bytecode/tests/borrow/function_call.exp b/third_party/move/move-model/bytecode/tests/borrow/function_call.exp index 2172d27d3308ef..38764bb0398506 100644 --- a/third_party/move/move-model/bytecode/tests/borrow/function_call.exp +++ b/third_party/move/move-model/bytecode/tests/borrow/function_call.exp @@ -118,11 +118,11 @@ fun MultiLayerCalling::outer($t0|has_vector: &mut MultiLayerCalling::HasVector) ============ after pipeline `borrow` ================ [variant baseline] -public intrinsic fun vector::contains<#0>($t0|v: vector<#0>, $t1|e: #0): bool; +public intrinsic fun vector::contains<#0>($t0|v: &vector<#0>, $t1|e: �): bool; [variant baseline] -public intrinsic fun vector::index_of<#0>($t0|v: vector<#0>, $t1|e: #0): (bool, u64); +public intrinsic fun vector::index_of<#0>($t0|v: &vector<#0>, $t1|e: �): (bool, u64); [variant baseline] @@ -130,7 +130,7 @@ public intrinsic fun vector::append<#0>($t0|lhs: &mut vector<#0>, $t1|other: vec [variant baseline] -public native fun vector::borrow<#0>($t0|v: vector<#0>, $t1|i: u64): #0; +public native fun vector::borrow<#0>($t0|v: &vector<#0>, $t1|i: u64): � [variant baseline] @@ -146,11 +146,11 @@ public native fun vector::empty<#0>(): vector<#0>; [variant baseline] -public intrinsic fun vector::is_empty<#0>($t0|v: vector<#0>): bool; +public intrinsic fun vector::is_empty<#0>($t0|v: &vector<#0>): bool; [variant baseline] -public native fun vector::length<#0>($t0|v: vector<#0>): u64; +public native fun vector::length<#0>($t0|v: &vector<#0>): u64; [variant baseline] @@ -208,22 +208,18 @@ fun MultiLayerCalling::inner($t0|has_vector: &mut MultiLayerCalling::HasVector): var $t3: &mut MultiLayerCalling::HasAnotherVector # live_nodes: Reference($t0) 0: $t1 := borrow_field.v($t0) - # live_nodes: Reference($t0), Reference($t1) + # live_nodes: Reference($t1) # borrowed_by: Reference($t0) -> {(.v (vector), Reference($t1))} # borrows_from: Reference($t1) -> {(.v (vector), Reference($t0))} 1: $t2 := 7 - # live_nodes: Reference($t0), Reference($t1) + # live_nodes: Reference($t1) # borrowed_by: Reference($t0) -> {(.v (vector), Reference($t1))} # borrows_from: Reference($t1) -> {(.v (vector), Reference($t0))} 2: $t3 := vector::borrow_mut($t1, $t2) - # live_nodes: Reference($t0), Reference($t3) - # borrowed_by: Reference($t0) -> {(.v (vector), Reference($t1))}, Reference($t1) -> {([], Reference($t3))} - # borrows_from: Reference($t1) -> {(.v (vector), Reference($t0))}, Reference($t3) -> {([], Reference($t1))} - 3: trace_local[has_vector]($t0) # live_nodes: Reference($t3) # borrowed_by: Reference($t0) -> {(.v (vector), Reference($t1))}, Reference($t1) -> {([], Reference($t3))} # borrows_from: Reference($t1) -> {(.v (vector), Reference($t0))}, Reference($t3) -> {([], Reference($t1))} - 4: return $t3 + 3: return $t3 } @@ -232,14 +228,10 @@ fun MultiLayerCalling::mid($t0|has_vector: &mut MultiLayerCalling::HasVector): & var $t1: &mut MultiLayerCalling::HasAnotherVector # live_nodes: Reference($t0) 0: $t1 := MultiLayerCalling::inner($t0) - # live_nodes: Reference($t0), Reference($t1) - # borrowed_by: Reference($t0) -> {(.v (vector)/[], Reference($t1))} - # borrows_from: Reference($t1) -> {(.v (vector)/[], Reference($t0))} - 1: trace_local[has_vector]($t0) # live_nodes: Reference($t1) # borrowed_by: Reference($t0) -> {(.v (vector)/[], Reference($t1))} # borrows_from: Reference($t1) -> {(.v (vector)/[], Reference($t0))} - 2: return $t1 + 1: return $t1 } @@ -250,25 +242,21 @@ fun MultiLayerCalling::outer($t0|has_vector: &mut MultiLayerCalling::HasVector) var $t3: u8 # live_nodes: Reference($t0) 0: $t1 := MultiLayerCalling::mid($t0) - # live_nodes: Reference($t0), Reference($t1) + # live_nodes: Reference($t1) # borrowed_by: Reference($t0) -> {(.v (vector)/[], Reference($t1))} # borrows_from: Reference($t1) -> {(.v (vector)/[], Reference($t0))} 1: $t2 := borrow_field.v($t1) - # live_nodes: Reference($t0), Reference($t2) + # live_nodes: Reference($t2) # borrowed_by: Reference($t0) -> {(.v (vector)/[], Reference($t1))}, Reference($t1) -> {(.v (vector), Reference($t2))} # borrows_from: Reference($t1) -> {(.v (vector)/[], Reference($t0))}, Reference($t2) -> {(.v (vector), Reference($t1))} 2: $t3 := 42 - # live_nodes: Reference($t0), Reference($t2) + # live_nodes: Reference($t2) # borrowed_by: Reference($t0) -> {(.v (vector)/[], Reference($t1))}, Reference($t1) -> {(.v (vector), Reference($t2))} # borrows_from: Reference($t1) -> {(.v (vector)/[], Reference($t0))}, Reference($t2) -> {(.v (vector), Reference($t1))} 3: vector::push_back($t2, $t3) - # live_nodes: Reference($t0) - # borrowed_by: Reference($t0) -> {(.v (vector)/[], Reference($t1))}, Reference($t1) -> {(.v (vector), Reference($t2))} - # borrows_from: Reference($t1) -> {(.v (vector)/[], Reference($t0))}, Reference($t2) -> {(.v (vector), Reference($t1))} - 4: trace_local[has_vector]($t0) # borrowed_by: Reference($t0) -> {(.v (vector)/[], Reference($t1))}, Reference($t1) -> {(.v (vector), Reference($t2))} # borrows_from: Reference($t1) -> {(.v (vector)/[], Reference($t0))}, Reference($t2) -> {(.v (vector), Reference($t1))} - 5: return () + 4: return () } diff --git a/third_party/move/move-model/bytecode/tests/borrow/hyper_edge.exp b/third_party/move/move-model/bytecode/tests/borrow/hyper_edge.exp index 35a2f95de42ed8..0b2542c95d926f 100644 --- a/third_party/move/move-model/bytecode/tests/borrow/hyper_edge.exp +++ b/third_party/move/move-model/bytecode/tests/borrow/hyper_edge.exp @@ -130,11 +130,11 @@ public fun Test::foo<#0>($t0|i: u64) { ============ after pipeline `borrow` ================ [variant baseline] -public intrinsic fun vector::contains<#0>($t0|v: vector<#0>, $t1|e: #0): bool; +public intrinsic fun vector::contains<#0>($t0|v: &vector<#0>, $t1|e: �): bool; [variant baseline] -public intrinsic fun vector::index_of<#0>($t0|v: vector<#0>, $t1|e: #0): (bool, u64); +public intrinsic fun vector::index_of<#0>($t0|v: &vector<#0>, $t1|e: �): (bool, u64); [variant baseline] @@ -142,7 +142,7 @@ public intrinsic fun vector::append<#0>($t0|lhs: &mut vector<#0>, $t1|other: vec [variant baseline] -public native fun vector::borrow<#0>($t0|v: vector<#0>, $t1|i: u64): #0; +public native fun vector::borrow<#0>($t0|v: &vector<#0>, $t1|i: u64): � [variant baseline] @@ -158,11 +158,11 @@ public native fun vector::empty<#0>(): vector<#0>; [variant baseline] -public intrinsic fun vector::is_empty<#0>($t0|v: vector<#0>): bool; +public intrinsic fun vector::is_empty<#0>($t0|v: &vector<#0>): bool; [variant baseline] -public native fun vector::length<#0>($t0|v: vector<#0>): u64; +public native fun vector::length<#0>($t0|v: &vector<#0>): u64; [variant baseline] @@ -219,18 +219,14 @@ public fun Collection::borrow_mut<#0>($t0|c: &mut Collection::Collection<#0>, $t var $t3: &mut #0 # live_nodes: LocalRoot($t1), Reference($t0) 0: $t2 := borrow_field>.items($t0) - # live_nodes: LocalRoot($t1), Reference($t0), Reference($t2) + # live_nodes: LocalRoot($t1), Reference($t2) # borrowed_by: Reference($t0) -> {(.items (vector<#0>), Reference($t2))} # borrows_from: Reference($t2) -> {(.items (vector<#0>), Reference($t0))} 1: $t3 := vector::borrow_mut<#0>($t2, $t1) - # live_nodes: LocalRoot($t1), Reference($t0), Reference($t3) - # borrowed_by: Reference($t0) -> {(.items (vector<#0>), Reference($t2))}, Reference($t2) -> {([], Reference($t3))} - # borrows_from: Reference($t2) -> {(.items (vector<#0>), Reference($t0))}, Reference($t3) -> {([], Reference($t2))} - 2: trace_local[c]($t0) # live_nodes: LocalRoot($t1), Reference($t3) # borrowed_by: Reference($t0) -> {(.items (vector<#0>), Reference($t2))}, Reference($t2) -> {([], Reference($t3))} # borrows_from: Reference($t2) -> {(.items (vector<#0>), Reference($t0))}, Reference($t3) -> {([], Reference($t2))} - 3: return $t3 + 2: return $t3 } diff --git a/third_party/move/move-model/bytecode/tests/borrow_strong/basic_test.exp b/third_party/move/move-model/bytecode/tests/borrow_strong/basic_test.exp index 1728873fb23a92..f8b41f93ed568a 100644 --- a/third_party/move/move-model/bytecode/tests/borrow_strong/basic_test.exp +++ b/third_party/move/move-model/bytecode/tests/borrow_strong/basic_test.exp @@ -401,7 +401,7 @@ fun TestBorrow::test10($t0|b: bool): TestBorrow::R { # live_nodes: LocalRoot($t0), Reference($t2), Reference($t6), Reference($t7) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 6: if ($t0) goto 18 else goto 21 + 6: if ($t0) goto 19 else goto 22 # live_nodes: LocalRoot($t0), Reference($t6), Reference($t7) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} @@ -417,7 +417,7 @@ fun TestBorrow::test10($t0|b: bool): TestBorrow::R { # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.y (u64), Reference($t2)), (.x (u64)/@, Reference($t2)), (.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t6)), (.x (u64)/@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 10: goto 13 + 10: goto 14 # live_nodes: LocalRoot($t0), Reference($t2), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} @@ -426,50 +426,54 @@ fun TestBorrow::test10($t0|b: bool): TestBorrow::R { # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} 12: destroy($t6) + # live_nodes: LocalRoot($t0), Reference($t2) + # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} + # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} + 13: goto 14 # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.y (u64), Reference($t2)), (.x (u64)/@, Reference($t2)), (.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t6)), (.x (u64)/@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 13: label L2 + 14: label L2 # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.y (u64), Reference($t2)), (.x (u64)/@, Reference($t2)), (.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t6)), (.x (u64)/@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 14: $t8 := 0 + 15: $t8 := 0 # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.y (u64), Reference($t2)), (.x (u64)/@, Reference($t2)), (.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t6)), (.x (u64)/@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 15: write_ref($t2, $t8) + 16: write_ref($t2, $t8) # live_nodes: LocalRoot($t0) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.y (u64), Reference($t2)), (.x (u64)/@, Reference($t2)), (.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t6)), (.x (u64)/@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 16: $t9 := move($t1) + 17: $t9 := move($t1) # live_nodes: LocalRoot($t0), LocalRoot($t9) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.y (u64), Reference($t2)), (.x (u64)/@, Reference($t2)), (.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t6)), (.x (u64)/@, Reference($t6)), (@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 17: return $t9 + 18: return $t9 # live_nodes: LocalRoot($t0), Reference($t2), Reference($t6), Reference($t7) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 18: label L3 + 19: label L3 # live_nodes: LocalRoot($t0), Reference($t2), Reference($t6), Reference($t7) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 19: destroy($t2) + 20: destroy($t2) # live_nodes: LocalRoot($t0), Reference($t6), Reference($t7) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 20: goto 7 + 21: goto 7 # live_nodes: LocalRoot($t0), Reference($t2), Reference($t6), Reference($t7) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 21: label L4 + 22: label L4 # live_nodes: LocalRoot($t0), Reference($t2), Reference($t6), Reference($t7) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 22: destroy($t7) + 23: destroy($t7) # live_nodes: LocalRoot($t0), Reference($t2), Reference($t6) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t6))}, Reference($t6) -> {(.x (u64), Reference($t7))}, Reference($t7) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t7))}, Reference($t6) -> {(@, LocalRoot($t1))}, Reference($t7) -> {(.x (u64), Reference($t6))} - 23: goto 11 + 24: goto 11 } @@ -477,10 +481,8 @@ fun TestBorrow::test10($t0|b: bool): TestBorrow::R { fun TestBorrow::test2($t0|x_ref: &mut u64, $t1|v: u64) { # live_nodes: LocalRoot($t1), Reference($t0) 0: write_ref($t0, $t1) - # live_nodes: LocalRoot($t1), Reference($t0) - 1: trace_local[x_ref]($t0) # live_nodes: LocalRoot($t1) - 2: return () + 1: return () } @@ -489,18 +491,14 @@ public fun TestBorrow::test3($t0|r_ref: &mut TestBorrow::R, $t1|v: u64) { var $t2: &mut u64 # live_nodes: LocalRoot($t1), Reference($t0) 0: $t2 := borrow_field.x($t0) - # live_nodes: LocalRoot($t1), Reference($t0), Reference($t2) + # live_nodes: LocalRoot($t1), Reference($t2) # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t2))} # borrows_from: Reference($t2) -> {(.x (u64), Reference($t0))} 1: TestBorrow::test2($t2, $t1) - # live_nodes: LocalRoot($t1), Reference($t0) - # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t2))} - # borrows_from: Reference($t2) -> {(.x (u64), Reference($t0))} - 2: trace_local[r_ref]($t0) # live_nodes: LocalRoot($t1) # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t2))} # borrows_from: Reference($t2) -> {(.x (u64), Reference($t0))} - 3: return () + 2: return () } @@ -539,14 +537,10 @@ public fun TestBorrow::test5($t0|r_ref: &mut TestBorrow::R): &mut u64 { var $t1: &mut u64 # live_nodes: Reference($t0) 0: $t1 := borrow_field.x($t0) - # live_nodes: Reference($t0), Reference($t1) - # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t1))} - # borrows_from: Reference($t1) -> {(.x (u64), Reference($t0))} - 1: trace_local[r_ref]($t0) # live_nodes: Reference($t1) # borrowed_by: Reference($t0) -> {(.x (u64), Reference($t1))} # borrows_from: Reference($t1) -> {(.x (u64), Reference($t0))} - 2: return $t1 + 1: return $t1 } @@ -618,7 +612,7 @@ fun TestBorrow::test7($t0|b: bool) { # live_nodes: LocalRoot($t0), Reference($t3), Reference($t8) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t1))} - 8: if ($t0) goto 17 else goto 20 + 8: if ($t0) goto 18 else goto 21 # live_nodes: LocalRoot($t0), Reference($t8) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t1))} @@ -638,43 +632,47 @@ fun TestBorrow::test7($t0|b: bool) { # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, LocalRoot($t2) -> {(@, Reference($t9))}, Reference($t8) -> {(@, Reference($t3))}, Reference($t9) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8)), (@, Reference($t9))}, Reference($t8) -> {(@, LocalRoot($t1))}, Reference($t9) -> {(@, LocalRoot($t2))} - 13: label L0 + 13: goto 14 # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, LocalRoot($t2) -> {(@, Reference($t9))}, Reference($t8) -> {(@, Reference($t3))}, Reference($t9) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8)), (@, Reference($t9))}, Reference($t8) -> {(@, LocalRoot($t1))}, Reference($t9) -> {(@, LocalRoot($t2))} - 14: $t10 := 0 + 14: label L0 # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, LocalRoot($t2) -> {(@, Reference($t9))}, Reference($t8) -> {(@, Reference($t3))}, Reference($t9) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8)), (@, Reference($t9))}, Reference($t8) -> {(@, LocalRoot($t1))}, Reference($t9) -> {(@, LocalRoot($t2))} - 15: TestBorrow::test3($t3, $t10) + 15: $t10 := 0 + # live_nodes: LocalRoot($t0), Reference($t3) + # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, LocalRoot($t2) -> {(@, Reference($t9))}, Reference($t8) -> {(@, Reference($t3))}, Reference($t9) -> {(@, Reference($t3))} + # borrows_from: Reference($t3) -> {(@, Reference($t8)), (@, Reference($t9))}, Reference($t8) -> {(@, LocalRoot($t1))}, Reference($t9) -> {(@, LocalRoot($t2))} + 16: TestBorrow::test3($t3, $t10) # live_nodes: LocalRoot($t0) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, LocalRoot($t2) -> {(@, Reference($t9))}, Reference($t8) -> {(@, Reference($t3))}, Reference($t9) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8)), (@, Reference($t9))}, Reference($t8) -> {(@, LocalRoot($t1))}, Reference($t9) -> {(@, LocalRoot($t2))} - 16: return () + 17: return () # live_nodes: LocalRoot($t0), Reference($t3), Reference($t8) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t1))} - 17: label L2 + 18: label L2 # live_nodes: LocalRoot($t0), Reference($t3), Reference($t8) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t1))} - 18: destroy($t3) + 19: destroy($t3) # live_nodes: LocalRoot($t0), Reference($t8) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t1))} - 19: goto 9 + 20: goto 9 # live_nodes: LocalRoot($t0), Reference($t3), Reference($t8) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t1))} - 20: label L3 + 21: label L3 # live_nodes: LocalRoot($t0), Reference($t3), Reference($t8) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t1))} - 21: destroy($t8) + 22: destroy($t8) # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: LocalRoot($t1) -> {(@, Reference($t8))}, Reference($t8) -> {(@, Reference($t3))} # borrows_from: Reference($t3) -> {(@, Reference($t8))}, Reference($t8) -> {(@, LocalRoot($t1))} - 22: goto 13 + 23: goto 14 } @@ -717,154 +715,166 @@ fun TestBorrow::test8($t0|b: bool, $t1|n: u64, $t2|r_ref: &mut TestBorrow::R) { # borrowed_by: LocalRoot($t4) -> {(@, Reference($t10))} # borrows_from: Reference($t10) -> {(@, LocalRoot($t4))} 7: $t5 := $t10 + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) + # borrowed_by: LocalRoot($t4) -> {(@, Reference($t10))}, Reference($t10) -> {(@, Reference($t5))} + # borrows_from: Reference($t5) -> {(@, Reference($t10))}, Reference($t10) -> {(@, LocalRoot($t4))} + 8: goto 9 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 8: label L6 + 9: label L6 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 9: $t11 := 0 + 10: $t11 := 0 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 10: $t12 := <($t11, $t1) + 11: $t12 := <($t11, $t1) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 11: if ($t12) goto 12 else goto 31 + 12: if ($t12) goto 13 else goto 34 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 12: label L1 + 13: label L1 + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) + # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} + # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} + 14: goto 15 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 13: label L2 + 15: label L2 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 14: destroy($t5) + 16: destroy($t5) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 15: $t13 := 2 + 17: $t13 := 2 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 16: $t14 := /($t1, $t13) + 18: $t14 := /($t1, $t13) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 17: $t15 := 0 + 19: $t15 := 0 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 18: $t16 := ==($t14, $t15) + 20: $t16 := ==($t14, $t15) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 19: if ($t16) goto 20 else goto 24 + 21: if ($t16) goto 22 else goto 26 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 20: label L4 + 22: label L4 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 21: $t17 := borrow_local($t3) + 23: $t17 := borrow_local($t3) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t17) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 22: $t5 := $t17 + 24: $t5 := $t17 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 23: goto 27 + 25: goto 30 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 24: label L3 + 26: label L3 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 25: $t18 := borrow_local($t4) + 27: $t18 := borrow_local($t4) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t18) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 26: $t5 := $t18 + 28: $t5 := $t18 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 27: label L5 + 29: goto 30 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 28: $t19 := 1 + 30: label L5 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 29: $t1 := -($t1, $t19) + 31: $t19 := 1 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 30: goto 8 + 32: $t1 := -($t1, $t19) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 31: label L0 + 33: goto 9 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 32: if ($t0) goto 33 else goto 38 + 34: label L0 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 33: label L8 + 35: if ($t0) goto 36 else goto 41 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 34: destroy($t5) - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) + 36: label L8 + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 35: $t20 := 0 + 37: destroy($t5) # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 36: TestBorrow::test3($t2, $t20) + 38: $t20 := 0 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 37: goto 42 - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) + 39: TestBorrow::test3($t2, $t20) + # live_nodes: LocalRoot($t0), LocalRoot($t1) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 38: label L7 + 40: goto 46 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 39: destroy($t2) + 41: label L7 # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 40: $t21 := 0 - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2), Reference($t5) + 42: destroy($t2) + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 41: TestBorrow::test3($t5, $t21) - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) + 43: $t21 := 0 + # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t5) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 42: label L9 - # live_nodes: LocalRoot($t0), LocalRoot($t1), Reference($t2) + 44: TestBorrow::test3($t5, $t21) + # live_nodes: LocalRoot($t0), LocalRoot($t1) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 43: trace_local[r_ref]($t2) + 45: goto 46 # live_nodes: LocalRoot($t0), LocalRoot($t1) # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} - 44: return () + 46: label L9 + # live_nodes: LocalRoot($t0), LocalRoot($t1) + # borrowed_by: LocalRoot($t3) -> {(@, Reference($t17))}, LocalRoot($t4) -> {(@, Reference($t10)), (@, Reference($t18))}, Reference($t10) -> {(@, Reference($t5))}, Reference($t17) -> {(@, Reference($t5))}, Reference($t18) -> {(@, Reference($t5))} + # borrows_from: Reference($t5) -> {(@, Reference($t10)), (@, Reference($t17)), (@, Reference($t18))}, Reference($t10) -> {(@, LocalRoot($t4))}, Reference($t17) -> {(@, LocalRoot($t3))}, Reference($t18) -> {(@, LocalRoot($t4))} + 47: return () } @@ -895,10 +905,10 @@ fun TestBorrow::test9($t0|b: bool, $t1|r_ref: &mut TestBorrow::R): &mut u64 { # borrowed_by: Reference($t1) -> {(.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} 5: $t2 := borrow_field.y($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.y (u64), Reference($t2)), (.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t1)), (@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} - 6: goto 9 + 6: goto 10 # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) # borrowed_by: Reference($t1) -> {(.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} @@ -907,22 +917,22 @@ fun TestBorrow::test9($t0|b: bool, $t1|r_ref: &mut TestBorrow::R): &mut u64 { # borrowed_by: Reference($t1) -> {(.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} 8: destroy($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) - # borrowed_by: Reference($t1) -> {(.y (u64), Reference($t2)), (.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} - # borrows_from: Reference($t2) -> {(.y (u64), Reference($t1)), (@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} - 9: label L2 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) + # borrowed_by: Reference($t1) -> {(.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} + # borrows_from: Reference($t2) -> {(@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} + 9: goto 10 + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.y (u64), Reference($t2)), (.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t1)), (@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} - 10: $t4 := 0 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + 10: label L2 + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.y (u64), Reference($t2)), (.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t1)), (@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} - 11: write_ref($t2, $t4) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + 11: $t4 := 0 + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.y (u64), Reference($t2)), (.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t1)), (@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} - 12: trace_local[r_ref]($t1) + 12: write_ref($t2, $t4) # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.y (u64), Reference($t2)), (.x (u64), Reference($t3))}, Reference($t3) -> {(@, Reference($t2))} # borrows_from: Reference($t2) -> {(.y (u64), Reference($t1)), (@, Reference($t3))}, Reference($t3) -> {(.x (u64), Reference($t1))} diff --git a/third_party/move/move-model/bytecode/tests/borrow_strong/mut_ref.exp b/third_party/move/move-model/bytecode/tests/borrow_strong/mut_ref.exp index e689748dc2a174..70b15e6c620b60 100644 --- a/third_party/move/move-model/bytecode/tests/borrow_strong/mut_ref.exp +++ b/third_party/move/move-model/bytecode/tests/borrow_strong/mut_ref.exp @@ -450,11 +450,11 @@ fun TestMutRef::return_ref_different_root($t0|b: bool, $t1|x: &mut TestMutRef::T ============ after pipeline `borrow_strong` ================ [variant baseline] -public intrinsic fun vector::contains<#0>($t0|v: vector<#0>, $t1|e: #0): bool; +public intrinsic fun vector::contains<#0>($t0|v: &vector<#0>, $t1|e: �): bool; [variant baseline] -public intrinsic fun vector::index_of<#0>($t0|v: vector<#0>, $t1|e: #0): (bool, u64); +public intrinsic fun vector::index_of<#0>($t0|v: &vector<#0>, $t1|e: �): (bool, u64); [variant baseline] @@ -462,7 +462,7 @@ public intrinsic fun vector::append<#0>($t0|lhs: &mut vector<#0>, $t1|other: vec [variant baseline] -public native fun vector::borrow<#0>($t0|v: vector<#0>, $t1|i: u64): #0; +public native fun vector::borrow<#0>($t0|v: &vector<#0>, $t1|i: u64): � [variant baseline] @@ -478,11 +478,11 @@ public native fun vector::empty<#0>(): vector<#0>; [variant baseline] -public intrinsic fun vector::is_empty<#0>($t0|v: vector<#0>): bool; +public intrinsic fun vector::is_empty<#0>($t0|v: &vector<#0>): bool; [variant baseline] -public native fun vector::length<#0>($t0|v: vector<#0>): u64; +public native fun vector::length<#0>($t0|v: &vector<#0>): u64; [variant baseline] @@ -956,26 +956,26 @@ fun TestMutRef::return_ref_different_path($t0|b: bool, $t1|x: &mut TestMutRef::N 1: label L1 # live_nodes: LocalRoot($t0), Reference($t1) 2: $t2 := borrow_field.value($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t2))} # borrows_from: Reference($t2) -> {(.value (u64), Reference($t1))} - 3: goto 7 + 3: goto 8 # live_nodes: LocalRoot($t0), Reference($t1) 4: label L0 # live_nodes: LocalRoot($t0), Reference($t1) 5: $t3 := borrow_field.t($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t3) + # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: Reference($t1) -> {(.t (TestMutRef::T), Reference($t3))} # borrows_from: Reference($t3) -> {(.t (TestMutRef::T), Reference($t1))} 6: $t2 := borrow_field.value($t3) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) - # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t2)), (.t (TestMutRef::T), Reference($t3))}, Reference($t3) -> {(.value (u64), Reference($t2))} - # borrows_from: Reference($t2) -> {(.value (u64), Reference($t1)), (.value (u64), Reference($t3))}, Reference($t3) -> {(.t (TestMutRef::T), Reference($t1))} - 7: label L2 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) + # borrowed_by: Reference($t1) -> {(.t (TestMutRef::T), Reference($t3))}, Reference($t3) -> {(.value (u64), Reference($t2))} + # borrows_from: Reference($t2) -> {(.value (u64), Reference($t3))}, Reference($t3) -> {(.t (TestMutRef::T), Reference($t1))} + 7: goto 8 + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t2)), (.t (TestMutRef::T), Reference($t3))}, Reference($t3) -> {(.value (u64), Reference($t2))} # borrows_from: Reference($t2) -> {(.value (u64), Reference($t1)), (.value (u64), Reference($t3))}, Reference($t3) -> {(.t (TestMutRef::T), Reference($t1))} - 8: trace_local[x]($t1) + 8: label L2 # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t2)), (.t (TestMutRef::T), Reference($t3))}, Reference($t3) -> {(.value (u64), Reference($t2))} # borrows_from: Reference($t2) -> {(.value (u64), Reference($t1)), (.value (u64), Reference($t3))}, Reference($t3) -> {(.t (TestMutRef::T), Reference($t1))} @@ -996,38 +996,38 @@ fun TestMutRef::return_ref_different_path_vec($t0|b: bool, $t1|x: &mut TestMutRe 1: label L1 # live_nodes: LocalRoot($t0), Reference($t1) 2: $t3 := borrow_field.is($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t3) + # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3))} # borrows_from: Reference($t3) -> {(.is (vector), Reference($t1))} 3: $t4 := 1 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t3) + # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3))} # borrows_from: Reference($t3) -> {(.is (vector), Reference($t1))} 4: $t2 := vector::borrow_mut($t3, $t4) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3))}, Reference($t3) -> {([], Reference($t2))} # borrows_from: Reference($t2) -> {([], Reference($t3))}, Reference($t3) -> {(.is (vector), Reference($t1))} - 5: goto 10 + 5: goto 11 # live_nodes: LocalRoot($t0), Reference($t1) 6: label L0 # live_nodes: LocalRoot($t0), Reference($t1) 7: $t5 := borrow_field.is($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t5) + # live_nodes: LocalRoot($t0), Reference($t5) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t5))} # borrows_from: Reference($t5) -> {(.is (vector), Reference($t1))} 8: $t6 := 0 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t5) + # live_nodes: LocalRoot($t0), Reference($t5) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t5))} # borrows_from: Reference($t5) -> {(.is (vector), Reference($t1))} 9: $t2 := vector::borrow_mut($t5, $t6) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) - # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3)), (.is (vector), Reference($t5))}, Reference($t3) -> {([], Reference($t2))}, Reference($t5) -> {([], Reference($t2))} - # borrows_from: Reference($t2) -> {([], Reference($t3)), ([], Reference($t5))}, Reference($t3) -> {(.is (vector), Reference($t1))}, Reference($t5) -> {(.is (vector), Reference($t1))} - 10: label L2 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) + # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t5))}, Reference($t5) -> {([], Reference($t2))} + # borrows_from: Reference($t2) -> {([], Reference($t5))}, Reference($t5) -> {(.is (vector), Reference($t1))} + 10: goto 11 + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3)), (.is (vector), Reference($t5))}, Reference($t3) -> {([], Reference($t2))}, Reference($t5) -> {([], Reference($t2))} # borrows_from: Reference($t2) -> {([], Reference($t3)), ([], Reference($t5))}, Reference($t3) -> {(.is (vector), Reference($t1))}, Reference($t5) -> {(.is (vector), Reference($t1))} - 11: trace_local[x]($t1) + 11: label L2 # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3)), (.is (vector), Reference($t5))}, Reference($t3) -> {([], Reference($t2))}, Reference($t5) -> {([], Reference($t2))} # borrows_from: Reference($t2) -> {([], Reference($t3)), ([], Reference($t5))}, Reference($t3) -> {(.is (vector), Reference($t1))}, Reference($t5) -> {(.is (vector), Reference($t1))} @@ -1049,42 +1049,42 @@ fun TestMutRef::return_ref_different_path_vec2($t0|b: bool, $t1|x: &mut TestMutR 1: label L1 # live_nodes: LocalRoot($t0), Reference($t1) 2: $t3 := borrow_field.is($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t3) + # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3))} # borrows_from: Reference($t3) -> {(.is (vector), Reference($t1))} 3: $t4 := 1 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t3) + # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3))} # borrows_from: Reference($t3) -> {(.is (vector), Reference($t1))} 4: $t2 := vector::borrow_mut($t3, $t4) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3))}, Reference($t3) -> {([], Reference($t2))} # borrows_from: Reference($t2) -> {([], Reference($t3))}, Reference($t3) -> {(.is (vector), Reference($t1))} - 5: goto 11 + 5: goto 12 # live_nodes: LocalRoot($t0), Reference($t1) 6: label L0 # live_nodes: LocalRoot($t0), Reference($t1) 7: $t5 := borrow_field.ts($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t5) + # live_nodes: LocalRoot($t0), Reference($t5) # borrowed_by: Reference($t1) -> {(.ts (vector), Reference($t5))} # borrows_from: Reference($t5) -> {(.ts (vector), Reference($t1))} 8: $t6 := 0 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t5) + # live_nodes: LocalRoot($t0), Reference($t5) # borrowed_by: Reference($t1) -> {(.ts (vector), Reference($t5))} # borrows_from: Reference($t5) -> {(.ts (vector), Reference($t1))} 9: $t7 := vector::borrow_mut($t5, $t6) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t7) + # live_nodes: LocalRoot($t0), Reference($t7) # borrowed_by: Reference($t1) -> {(.ts (vector), Reference($t5))}, Reference($t5) -> {([], Reference($t7))} # borrows_from: Reference($t5) -> {(.ts (vector), Reference($t1))}, Reference($t7) -> {([], Reference($t5))} 10: $t2 := borrow_field.value($t7) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) - # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3)), (.ts (vector), Reference($t5))}, Reference($t3) -> {([], Reference($t2))}, Reference($t5) -> {([], Reference($t7))}, Reference($t7) -> {(.value (u64), Reference($t2))} - # borrows_from: Reference($t2) -> {([], Reference($t3)), (.value (u64), Reference($t7))}, Reference($t3) -> {(.is (vector), Reference($t1))}, Reference($t5) -> {(.ts (vector), Reference($t1))}, Reference($t7) -> {([], Reference($t5))} - 11: label L2 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) + # borrowed_by: Reference($t1) -> {(.ts (vector), Reference($t5))}, Reference($t5) -> {([], Reference($t7))}, Reference($t7) -> {(.value (u64), Reference($t2))} + # borrows_from: Reference($t2) -> {(.value (u64), Reference($t7))}, Reference($t5) -> {(.ts (vector), Reference($t1))}, Reference($t7) -> {([], Reference($t5))} + 11: goto 12 + # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3)), (.ts (vector), Reference($t5))}, Reference($t3) -> {([], Reference($t2))}, Reference($t5) -> {([], Reference($t7))}, Reference($t7) -> {(.value (u64), Reference($t2))} # borrows_from: Reference($t2) -> {([], Reference($t3)), (.value (u64), Reference($t7))}, Reference($t3) -> {(.is (vector), Reference($t1))}, Reference($t5) -> {(.ts (vector), Reference($t1))}, Reference($t7) -> {([], Reference($t5))} - 12: trace_local[x]($t1) + 12: label L2 # live_nodes: LocalRoot($t0), Reference($t2) # borrowed_by: Reference($t1) -> {(.is (vector), Reference($t3)), (.ts (vector), Reference($t5))}, Reference($t3) -> {([], Reference($t2))}, Reference($t5) -> {([], Reference($t7))}, Reference($t7) -> {(.value (u64), Reference($t2))} # borrows_from: Reference($t2) -> {([], Reference($t3)), (.value (u64), Reference($t7))}, Reference($t3) -> {(.is (vector), Reference($t1))}, Reference($t5) -> {(.ts (vector), Reference($t1))}, Reference($t7) -> {([], Reference($t5))} @@ -1101,34 +1101,30 @@ fun TestMutRef::return_ref_different_root($t0|b: bool, $t1|x: &mut TestMutRef::T 1: label L1 # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) 2: destroy($t2) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t1) 3: $t3 := borrow_field.value($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2), Reference($t3) + # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t3))} # borrows_from: Reference($t3) -> {(.value (u64), Reference($t1))} - 4: goto 8 + 4: goto 9 # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) 5: label L0 # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) 6: destroy($t1) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2) + # live_nodes: LocalRoot($t0), Reference($t2) 7: $t3 := borrow_field.value($t2) - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2), Reference($t3) - # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t3))}, Reference($t2) -> {(.value (u64), Reference($t3))} - # borrows_from: Reference($t3) -> {(.value (u64), Reference($t1)), (.value (u64), Reference($t2))} - 8: label L2 - # live_nodes: LocalRoot($t0), Reference($t1), Reference($t2), Reference($t3) - # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t3))}, Reference($t2) -> {(.value (u64), Reference($t3))} - # borrows_from: Reference($t3) -> {(.value (u64), Reference($t1)), (.value (u64), Reference($t2))} - 9: trace_local[x]($t1) - # live_nodes: LocalRoot($t0), Reference($t2), Reference($t3) + # live_nodes: LocalRoot($t0), Reference($t3) + # borrowed_by: Reference($t2) -> {(.value (u64), Reference($t3))} + # borrows_from: Reference($t3) -> {(.value (u64), Reference($t2))} + 8: goto 9 + # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t3))}, Reference($t2) -> {(.value (u64), Reference($t3))} # borrows_from: Reference($t3) -> {(.value (u64), Reference($t1)), (.value (u64), Reference($t2))} - 10: trace_local[y]($t2) + 9: label L2 # live_nodes: LocalRoot($t0), Reference($t3) # borrowed_by: Reference($t1) -> {(.value (u64), Reference($t3))}, Reference($t2) -> {(.value (u64), Reference($t3))} # borrows_from: Reference($t3) -> {(.value (u64), Reference($t1)), (.value (u64), Reference($t2))} - 11: return $t3 + 10: return $t3 } diff --git a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/borrow.exp b/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/borrow.exp deleted file mode 100644 index c4d3ef42d7ad45..00000000000000 --- a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/borrow.exp +++ /dev/null @@ -1,197 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun Test::test_borrow_imm<#0>(): u64 { - var $t0: address - var $t1: &Test::R<#0> - var $t2: &u64 - var $t3: u64 - 0: $t0 := 0x1 - 1: $t1 := borrow_global>($t0) - 2: $t2 := borrow_field>.x($t1) - 3: $t3 := read_ref($t2) - 4: return $t3 -} - - -[variant baseline] -public fun Test::test_borrow_mut<#0>(): u64 { - var $t0|r: &mut Test::R<#0> - var $t1: address - var $t2: &mut Test::R<#0> - var $t3: u64 - var $t4: &mut Test::R<#0> - var $t5: &mut Test::S - var $t6: &mut u64 - var $t7: u64 - var $t8: &mut Test::R<#0> - var $t9: &mut u64 - var $t10: &mut Test::R<#0> - var $t11: &u64 - var $t12: u64 - 0: $t1 := 0x1 - 1: $t2 := borrow_global>($t1) - 2: $t0 := $t2 - 3: $t3 := 2 - 4: $t4 := copy($t0) - 5: $t5 := borrow_field>.s($t4) - 6: $t6 := borrow_field.y($t5) - 7: write_ref($t6, $t3) - 8: $t7 := 3 - 9: $t8 := copy($t0) - 10: $t9 := borrow_field>.x($t8) - 11: write_ref($t9, $t7) - 12: $t10 := move($t0) - 13: $t11 := borrow_field>.x($t10) - 14: $t12 := read_ref($t11) - 15: return $t12 -} - - -[variant baseline] -public fun Test::test_borrow_mut_local(): Test::R { - var $t0|d: Test::R - var $t1|r: &mut Test::R - var $t2: u64 - var $t3: u64 - var $t4: Test::S - var $t5: u64 - var $t6: Test::R - var $t7: &mut Test::R - var $t8: u64 - var $t9: &mut Test::R - var $t10: &mut Test::S - var $t11: &mut u64 - var $t12: u64 - var $t13: &mut Test::R - var $t14: &mut u64 - var $t15: Test::R - 0: $t2 := 2 - 1: $t3 := 1 - 2: $t4 := pack Test::S($t3) - 3: $t5 := 0 - 4: $t6 := pack Test::R($t2, $t4, $t5) - 5: $t0 := $t6 - 6: $t7 := borrow_local($t0) - 7: $t1 := $t7 - 8: $t8 := 2 - 9: $t9 := copy($t1) - 10: $t10 := borrow_field>.s($t9) - 11: $t11 := borrow_field.y($t10) - 12: write_ref($t11, $t8) - 13: $t12 := 3 - 14: $t13 := move($t1) - 15: $t14 := borrow_field>.x($t13) - 16: write_ref($t14, $t12) - 17: $t15 := move($t0) - 18: return $t15 -} - -============ after pipeline `data_invariant_instrumentation` ================ - -[variant verification] -public fun Test::test_borrow_imm<#0>(): u64 { - var $t0: address - var $t1: Test::R<#0> - var $t2: num - var $t3: u64 - 0: assume forall $rsc: Test::R<#0>: ResourceDomain>(): And(WellFormed($rsc), And(Gt(select Test::R.x($rsc), select Test::S.y(select Test::R.s($rsc))), Gt(select Test::S.y(select Test::R.s($rsc)), 0))) - 1: $t0 := 0x1 - 2: $t1 := get_global>($t0) on_abort goto 6 with $t2 - 3: $t3 := get_field>.x($t1) - 4: label L1 - 5: return $t3 - 6: label L2 - 7: abort($t2) -} - - -[variant verification] -public fun Test::test_borrow_mut<#0>(): u64 { - var $t0|r: &mut Test::R<#0> - var $t1: address - var $t2: &mut Test::R<#0> - var $t3: num - var $t4: u64 - var $t5: &mut Test::S - var $t6: &mut u64 - var $t7: u64 - var $t8: &mut u64 - var $t9: u64 - 0: assume forall $rsc: Test::R<#0>: ResourceDomain>(): And(WellFormed($rsc), And(Gt(select Test::R.x($rsc), select Test::S.y(select Test::R.s($rsc))), Gt(select Test::S.y(select Test::R.s($rsc)), 0))) - 1: $t1 := 0x1 - 2: $t2 := borrow_global>($t1) on_abort goto 19 with $t3 - 3: $t4 := 2 - 4: $t5 := borrow_field>.s($t2) - 5: $t6 := borrow_field.y($t5) - 6: write_ref($t6, $t4) - 7: write_back[Reference($t5).y (u64)]($t6) - 8: write_back[Reference($t2).s (Test::S)]($t5) - 9: $t7 := 3 - 10: $t8 := borrow_field>.x($t2) - 11: write_ref($t8, $t7) - 12: write_back[Reference($t2).x (u64)]($t8) - 13: $t9 := get_field>.x($t2) - # data invariant at tests/data_invariant_instrumentation/borrow.move:13:9+18 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:13:9+18 - 14: assert Gt(select Test::R.x($t2), select Test::S.y(select Test::R.s($t2))) - # data invariant at tests/data_invariant_instrumentation/borrow.move:17:9+16 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:17:9+16 - 15: assert Gt(select Test::S.y(select Test::R.s($t2)), 0) - 16: write_back[Test::R<#0>@]($t2) - 17: label L1 - 18: return $t9 - 19: label L2 - 20: abort($t3) -} - - -[variant verification] -public fun Test::test_borrow_mut_local(): Test::R { - var $t0|d: Test::R - var $t1|r: &mut Test::R - var $t2: u64 - var $t3: u64 - var $t4: Test::S - var $t5: u64 - var $t6: &mut Test::R - var $t7: u64 - var $t8: &mut Test::S - var $t9: &mut u64 - var $t10: u64 - var $t11: &mut u64 - var $t12: Test::R - 0: $t2 := 2 - 1: $t3 := 1 - 2: $t4 := pack Test::S($t3) - # data invariant at tests/data_invariant_instrumentation/borrow.move:17:9+16 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:17:9+16 - 3: assert Gt(select Test::S.y($t4), 0) - 4: $t5 := 0 - 5: $t0 := pack Test::R($t2, $t4, $t5) - # data invariant at tests/data_invariant_instrumentation/borrow.move:13:9+18 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:13:9+18 - 6: assert Gt(select Test::R.x($t0), select Test::S.y(select Test::R.s($t0))) - 7: $t6 := borrow_local($t0) - 8: $t7 := 2 - 9: $t8 := borrow_field>.s($t6) - 10: $t9 := borrow_field.y($t8) - 11: write_ref($t9, $t7) - 12: write_back[Reference($t8).y (u64)]($t9) - 13: write_back[Reference($t6).s (Test::S)]($t8) - 14: $t10 := 3 - 15: $t11 := borrow_field>.x($t6) - 16: write_ref($t11, $t10) - 17: write_back[Reference($t6).x (u64)]($t11) - # data invariant at tests/data_invariant_instrumentation/borrow.move:13:9+18 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:13:9+18 - 18: assert Gt(select Test::R.x($t6), select Test::S.y(select Test::R.s($t6))) - # data invariant at tests/data_invariant_instrumentation/borrow.move:17:9+16 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/borrow.move:17:9+16 - 19: assert Gt(select Test::S.y(select Test::R.s($t6)), 0) - 20: write_back[LocalRoot($t0)@]($t6) - 21: trace_local[d]($t0) - 22: $t12 := move($t0) - 23: label L1 - 24: return $t12 -} diff --git a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/borrow.move b/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/borrow.move deleted file mode 100644 index b6ed6ab4211793..00000000000000 --- a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/borrow.move +++ /dev/null @@ -1,39 +0,0 @@ -module 0x42::Test { - struct R has key { - x: u64, - s: S, - t: T, - } - - struct S has copy, drop, store { - y: u64 - } - - spec R { - invariant x > s.y; - } - - spec S { - invariant y > 0; - } - - public fun test_borrow_imm(): u64 acquires R { - let r = borrow_global>(@0x1); - r.x - } - - public fun test_borrow_mut(): u64 acquires R { - let r = borrow_global_mut>(@0x1); - r.s.y = 2; - r.x = 3; - r.x - } - - public fun test_borrow_mut_local(): R { - let d = R{x: 2, s: S{y:1}, t: 0}; - let r = &mut d; - r.s.y = 2; - r.x = 3; - d - } -} diff --git a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/pack.exp b/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/pack.exp deleted file mode 100644 index afa97b82616c9d..00000000000000 --- a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/pack.exp +++ /dev/null @@ -1,36 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun Test::test_pack(): Test::R { - var $t0: u64 - var $t1: u64 - var $t2: Test::S - var $t3: Test::R - 0: $t0 := 3 - 1: $t1 := 1 - 2: $t2 := pack Test::S($t1) - 3: $t3 := pack Test::R($t0, $t2) - 4: return $t3 -} - -============ after pipeline `data_invariant_instrumentation` ================ - -[variant verification] -public fun Test::test_pack(): Test::R { - var $t0: u64 - var $t1: u64 - var $t2: Test::S - var $t3: Test::R - 0: $t0 := 3 - 1: $t1 := 1 - 2: $t2 := pack Test::S($t1) - # data invariant at tests/data_invariant_instrumentation/pack.move:16:9+16 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/pack.move:16:9+16 - 3: assert Gt(select Test::S.y($t2), 0) - 4: $t3 := pack Test::R($t0, $t2) - # data invariant at tests/data_invariant_instrumentation/pack.move:12:9+18 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/pack.move:12:9+18 - 5: assert Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))) - 6: label L1 - 7: return $t3 -} diff --git a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/pack.move b/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/pack.move deleted file mode 100644 index 12acb45bf868a1..00000000000000 --- a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/pack.move +++ /dev/null @@ -1,24 +0,0 @@ -module 0x42::Test { - struct R { - x: u64, - s: S, - } - - struct S { - y: u64 - } - - spec R { - invariant x > s.y; - } - - spec S { - invariant y > 0; - } - - public fun test_pack() : R { - let s = S {y: 1}; - let r = R {x: 3, s: s}; - r - } -} diff --git a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/params.exp b/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/params.exp deleted file mode 100644 index 4ec2addfcbafe3..00000000000000 --- a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/params.exp +++ /dev/null @@ -1,25 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun Test::test_param($t0|_simple_R: Test::R, $t1|_ref_R: &Test::R, $t2|_simple_S: Test::S, $t3|_mut_R: &mut Test::R) { - 0: return () -} - -============ after pipeline `data_invariant_instrumentation` ================ - -[variant verification] -public fun Test::test_param($t0|_simple_R: Test::R, $t1|_ref_R: Test::R, $t2|_simple_S: Test::S, $t3|_mut_R: &mut Test::R) { - 0: assume And(WellFormed($t0), And(Gt(select Test::R.x($t0), select Test::S.y(select Test::R.s($t0))), Gt(select Test::S.y(select Test::R.s($t0)), 0))) - 1: assume And(WellFormed($t1), And(Gt(select Test::R.x($t1), select Test::S.y(select Test::R.s($t1))), Gt(select Test::S.y(select Test::R.s($t1)), 0))) - 2: assume And(WellFormed($t2), Gt(select Test::S.y($t2), 0)) - 3: assume And(WellFormed($t3), And(Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))), Gt(select Test::S.y(select Test::R.s($t3)), 0))) - 4: trace_local[_mut_R]($t3) - # data invariant at tests/data_invariant_instrumentation/params.move:12:9+18 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/params.move:12:9+18 - 5: assert Gt(select Test::R.x($t3), select Test::S.y(select Test::R.s($t3))) - # data invariant at tests/data_invariant_instrumentation/params.move:16:9+16 - # VC: data invariant does not hold at tests/data_invariant_instrumentation/params.move:16:9+16 - 6: assert Gt(select Test::S.y(select Test::R.s($t3)), 0) - 7: label L1 - 8: return () -} diff --git a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/params.move b/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/params.move deleted file mode 100644 index 63f81fbcfe41ff..00000000000000 --- a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/params.move +++ /dev/null @@ -1,20 +0,0 @@ -module 0x42::Test { - struct R has drop { - x: u64, - s: S, - } - - struct S has drop { - y: u64 - } - - spec R { - invariant x > s.y; - } - - spec S { - invariant y > 0; - } - - public fun test_param(_simple_R: R, _ref_R: &R, _simple_S: S, _mut_R: &mut R) {} -} diff --git a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/vector.exp b/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/vector.exp deleted file mode 100644 index ecfaa9fbfb0cbc..00000000000000 --- a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/vector.exp +++ /dev/null @@ -1,15 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun Test::test($t0|_r: Test::R) { - 0: return () -} - -============ after pipeline `data_invariant_instrumentation` ================ - -[variant verification] -public fun Test::test($t0|_r: Test::R) { - 0: assume And(WellFormed($t0), forall $elem: vector: select Test::R.s($t0): forall $elem: Test::S: $elem: Gt(select Test::S.y($elem), 0)) - 1: label L1 - 2: return () -} diff --git a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/vector.move b/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/vector.move deleted file mode 100644 index 0b13d1ec74418c..00000000000000 --- a/third_party/move/move-model/bytecode/tests/data_invariant_instrumentation/vector.move +++ /dev/null @@ -1,18 +0,0 @@ -module 0x42::Test { - - struct R has drop { - x: u64, - s: vector>, - } - - struct S has drop { - y: u64 - } - - spec S { - invariant y > 0; - } - - public fun test(_r: R) { - } -} diff --git a/third_party/move/move-model/bytecode/tests/eliminate_imm_refs/basic_test.exp b/third_party/move/move-model/bytecode/tests/eliminate_imm_refs/basic_test.exp deleted file mode 100644 index c1760b21b2d359..00000000000000 --- a/third_party/move/move-model/bytecode/tests/eliminate_imm_refs/basic_test.exp +++ /dev/null @@ -1,176 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun TestEliminateImmRefs::test1(): TestEliminateImmRefs::R { - var $t0|r: TestEliminateImmRefs::R - var $t1|x_ref: &mut u64 - var $t2: u64 - var $t3: TestEliminateImmRefs::R - var $t4: &mut TestEliminateImmRefs::R - var $t5: &mut u64 - var $t6: u64 - var $t7: &mut u64 - var $t8: TestEliminateImmRefs::R - 0: $t2 := 3 - 1: $t3 := pack TestEliminateImmRefs::R($t2) - 2: $t0 := $t3 - 3: $t4 := borrow_local($t0) - 4: $t5 := borrow_field.x($t4) - 5: $t1 := $t5 - 6: $t6 := 0 - 7: $t7 := move($t1) - 8: write_ref($t7, $t6) - 9: $t8 := move($t0) - 10: return $t8 -} - - -[variant baseline] -fun TestEliminateImmRefs::test2(): u64 { - var $t0|r: TestEliminateImmRefs::R - var $t1: u64 - var $t2: TestEliminateImmRefs::R - var $t3: &TestEliminateImmRefs::R - var $t4: &u64 - var $t5: u64 - 0: $t1 := 3 - 1: $t2 := pack TestEliminateImmRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: $t4 := borrow_field.x($t3) - 5: $t5 := read_ref($t4) - 6: return $t5 -} - - -[variant baseline] -fun TestEliminateImmRefs::test3($t0|r_ref: &TestEliminateImmRefs::R): u64 { - var $t1: &TestEliminateImmRefs::R - var $t2: &u64 - var $t3: u64 - 0: $t1 := move($t0) - 1: $t2 := borrow_field.x($t1) - 2: $t3 := read_ref($t2) - 3: return $t3 -} - - -[variant baseline] -fun TestEliminateImmRefs::test4(): u64 { - var $t0|r: TestEliminateImmRefs::R - var $t1: u64 - var $t2: TestEliminateImmRefs::R - var $t3: &TestEliminateImmRefs::R - var $t4: u64 - 0: $t1 := 3 - 1: $t2 := pack TestEliminateImmRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: $t4 := TestEliminateImmRefs::test3($t3) - 5: return $t4 -} - - -[variant baseline] -fun TestEliminateImmRefs::test5(): TestEliminateImmRefs::R { - var $t0|r: TestEliminateImmRefs::R - var $t1: u64 - var $t2: TestEliminateImmRefs::R - var $t3: &TestEliminateImmRefs::R - var $t4: TestEliminateImmRefs::R - 0: $t1 := 3 - 1: $t2 := pack TestEliminateImmRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: destroy($t3) - 5: $t4 := move($t0) - 6: return $t4 -} - -============ after pipeline `eliminate_imm_refs` ================ - -[variant baseline] -fun TestEliminateImmRefs::test1(): TestEliminateImmRefs::R { - var $t0|r: TestEliminateImmRefs::R - var $t1|x_ref: &mut u64 - var $t2: u64 - var $t3: TestEliminateImmRefs::R - var $t4: &mut TestEliminateImmRefs::R - var $t5: &mut u64 - var $t6: u64 - var $t7: &mut u64 - var $t8: TestEliminateImmRefs::R - 0: $t2 := 3 - 1: $t3 := pack TestEliminateImmRefs::R($t2) - 2: $t0 := $t3 - 3: $t4 := borrow_local($t0) - 4: $t5 := borrow_field.x($t4) - 5: $t1 := $t5 - 6: $t6 := 0 - 7: $t7 := move($t1) - 8: write_ref($t7, $t6) - 9: $t8 := move($t0) - 10: return $t8 -} - - -[variant baseline] -fun TestEliminateImmRefs::test2(): u64 { - var $t0|r: TestEliminateImmRefs::R - var $t1: u64 - var $t2: TestEliminateImmRefs::R - var $t3: TestEliminateImmRefs::R - var $t4: u64 - var $t5: u64 - 0: $t1 := 3 - 1: $t2 := pack TestEliminateImmRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := copy($t0) - 4: $t4 := get_field.x($t3) - 5: $t5 := move($t4) - 6: return $t5 -} - - -[variant baseline] -fun TestEliminateImmRefs::test3($t0|r_ref: TestEliminateImmRefs::R): u64 { - var $t1: TestEliminateImmRefs::R - var $t2: u64 - var $t3: u64 - 0: $t1 := move($t0) - 1: $t2 := get_field.x($t1) - 2: $t3 := move($t2) - 3: return $t3 -} - - -[variant baseline] -fun TestEliminateImmRefs::test4(): u64 { - var $t0|r: TestEliminateImmRefs::R - var $t1: u64 - var $t2: TestEliminateImmRefs::R - var $t3: TestEliminateImmRefs::R - var $t4: u64 - 0: $t1 := 3 - 1: $t2 := pack TestEliminateImmRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := copy($t0) - 4: $t4 := TestEliminateImmRefs::test3($t3) - 5: return $t4 -} - - -[variant baseline] -fun TestEliminateImmRefs::test5(): TestEliminateImmRefs::R { - var $t0|r: TestEliminateImmRefs::R - var $t1: u64 - var $t2: TestEliminateImmRefs::R - var $t3: TestEliminateImmRefs::R - var $t4: TestEliminateImmRefs::R - 0: $t1 := 3 - 1: $t2 := pack TestEliminateImmRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := copy($t0) - 4: $t4 := move($t0) - 5: return $t4 -} diff --git a/third_party/move/move-model/bytecode/tests/eliminate_imm_refs/basic_test.move b/third_party/move/move-model/bytecode/tests/eliminate_imm_refs/basic_test.move deleted file mode 100644 index 8dada99bc36125..00000000000000 --- a/third_party/move/move-model/bytecode/tests/eliminate_imm_refs/basic_test.move +++ /dev/null @@ -1,39 +0,0 @@ -module 0x42::TestEliminateImmRefs { - - struct R has copy, drop { - x: u64 - } - - fun test1() : R { - let r = R {x: 3}; - let r_ref = &mut r; - let x_ref = &mut r_ref.x; - *x_ref = 0; - r - } - - fun test2() : u64 { - let r = R {x: 3}; - let r_ref = & r; - let x_ref = & r_ref.x; - *x_ref - } - - fun test3(r_ref: &R) : u64 { - let x_ref = & r_ref.x; - *x_ref - } - - fun test4() : u64 { - let r = R {x: 3}; - let r_ref = & r; - test3(r_ref) - } - - fun test5() : R { - let r = R {x: 3}; - let p = &r; - let _ = p; - r - } -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/disable_in_body.exp b/third_party/move/move-model/bytecode/tests/global_invariant_analysis/disable_in_body.exp deleted file mode 100644 index 9c89ce115cb803..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/disable_in_body.exp +++ /dev/null @@ -1,54 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun DisableInv::foo($t0|s: &signer) { - var $t1: &signer - var $t2: bool - var $t3: DisableInv::R2 - 0: $t1 := move($t0) - 1: $t2 := false - 2: $t3 := pack DisableInv::R2($t2) - 3: move_to($t3, $t1) - 4: return () -} - -============ after pipeline `global_invariant_analysis` ================ - -[variant verification] -fun DisableInv::foo($t0|s: signer) { - var $t1: bool - var $t2: DisableInv::R2 - var $t3: num - 0: $t1 := false - 1: $t2 := pack DisableInv::R2($t1) - 2: move_to($t2, $t0) on_abort goto 5 with $t3 - 3: label L1 - 4: return () - 5: label L2 - 6: abort($t3) -} - - -********* Result of global invariant instrumentation ********* - -DisableInv::foo: [ - entrypoint { - assume @0 = [ - <> -> [ - <> - ] - ] - } - 2: move_to($t2, $t0) on_abort goto L2 with $t3 {} - exitpoint { - assert @0 = [ - <> -> [ - <> - ] - ] - } -] - -********* Global invariants by ID ********* - -@0 => invariant [suspendable] forall a: address where exists(a): exists(a); diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/disable_in_body.move b/third_party/move/move-model/bytecode/tests/global_invariant_analysis/disable_in_body.move deleted file mode 100644 index 6239bf43b13358..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/disable_in_body.move +++ /dev/null @@ -1,15 +0,0 @@ -module 0x1::DisableInv { - struct R1 has key { } - struct R2 has key { } - - fun foo(s: &signer) { - move_to(s, R2 {}); - } - spec foo { - pragma disable_invariants_in_body; - } - - spec module { - invariant [suspendable] forall a: address where exists(a): exists(a); - } -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/mutual_inst.exp b/third_party/move/move-model/bytecode/tests/global_invariant_analysis/mutual_inst.exp deleted file mode 100644 index 4c558e0ef0c59c..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/mutual_inst.exp +++ /dev/null @@ -1,418 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun S::publish_u64_bool($t0|account: signer, $t1|x: u64, $t2|y: bool) { - var $t3: &signer - var $t4: u64 - var $t5: bool - var $t6: u8 - var $t7: S::Storage - 0: $t3 := borrow_local($t0) - 1: $t4 := move($t1) - 2: $t5 := move($t2) - 3: $t6 := 0 - 4: $t7 := pack S::Storage($t4, $t5, $t6) - 5: move_to>($t7, $t3) - 6: return () -} - - -[variant baseline] -public fun S::publish_u64_y<#0>($t0|account: signer, $t1|x: u64, $t2|y: #0) { - var $t3: &signer - var $t4: u64 - var $t5: #0 - var $t6: u8 - var $t7: S::Storage - 0: $t3 := borrow_local($t0) - 1: $t4 := move($t1) - 2: $t5 := move($t2) - 3: $t6 := 1 - 4: $t7 := pack S::Storage($t4, $t5, $t6) - 5: move_to>($t7, $t3) - 6: return () -} - - -[variant baseline] -public fun S::publish_x_bool<#0>($t0|account: signer, $t1|x: #0, $t2|y: bool) { - var $t3: &signer - var $t4: #0 - var $t5: bool - var $t6: u8 - var $t7: S::Storage<#0, bool> - 0: $t3 := borrow_local($t0) - 1: $t4 := move($t1) - 2: $t5 := move($t2) - 3: $t6 := 2 - 4: $t7 := pack S::Storage<#0, bool>($t4, $t5, $t6) - 5: move_to>($t7, $t3) - 6: return () -} - - -[variant baseline] -public fun S::publish_x_y<#0, #1>($t0|account: signer, $t1|x: #0, $t2|y: #1) { - var $t3: &signer - var $t4: #0 - var $t5: #1 - var $t6: u8 - var $t7: S::Storage<#0, #1> - 0: $t3 := borrow_local($t0) - 1: $t4 := move($t1) - 2: $t5 := move($t2) - 3: $t6 := 3 - 4: $t7 := pack S::Storage<#0, #1>($t4, $t5, $t6) - 5: move_to>($t7, $t3) - 6: return () -} - - -[variant baseline] -public fun A::good($t0|account1: signer, $t1|account2: signer) { - var $t2: signer - var $t3: u64 - var $t4: bool - var $t5: signer - var $t6: u64 - var $t7: bool - 0: $t2 := move($t0) - 1: $t3 := 1 - 2: $t4 := true - 3: S::publish_x_y($t2, $t3, $t4) - 4: $t5 := move($t1) - 5: $t6 := 1 - 6: $t7 := true - 7: S::publish_x_y($t5, $t6, $t7) - 8: return () -} - -============ after pipeline `global_invariant_analysis` ================ - -[variant verification] -public fun S::publish_u64_bool($t0|account: signer, $t1|x: u64, $t2|y: bool) { - var $t3: u8 - var $t4: S::Storage - var $t5: num - 0: $t3 := 0 - 1: $t4 := pack S::Storage($t1, $t2, $t3) - 2: move_to>($t4, $t0) on_abort goto 5 with $t5 - 3: label L1 - 4: return () - 5: label L2 - 6: abort($t5) -} - - -[variant verification] -public fun S::publish_u64_y<#0>($t0|account: signer, $t1|x: u64, $t2|y: #0) { - var $t3: u8 - var $t4: S::Storage - var $t5: num - 0: $t3 := 1 - 1: $t4 := pack S::Storage($t1, $t2, $t3) - 2: move_to>($t4, $t0) on_abort goto 5 with $t5 - 3: label L1 - 4: return () - 5: label L2 - 6: abort($t5) -} - - -[variant verification] -public fun S::publish_x_bool<#0>($t0|account: signer, $t1|x: #0, $t2|y: bool) { - var $t3: u8 - var $t4: S::Storage<#0, bool> - var $t5: num - 0: $t3 := 2 - 1: $t4 := pack S::Storage<#0, bool>($t1, $t2, $t3) - 2: move_to>($t4, $t0) on_abort goto 5 with $t5 - 3: label L1 - 4: return () - 5: label L2 - 6: abort($t5) -} - - -[variant baseline] -public fun S::publish_x_y<#0, #1>($t0|account: signer, $t1|x: #0, $t2|y: #1) { - var $t3: u8 - var $t4: S::Storage<#0, #1> - var $t5: num - 0: $t3 := 3 - 1: $t4 := pack S::Storage<#0, #1>($t1, $t2, $t3) - 2: move_to>($t4, $t0) on_abort goto 5 with $t5 - 3: label L1 - 4: return () - 5: label L2 - 6: abort($t5) -} - - -[variant verification] -public fun S::publish_x_y<#0, #1>($t0|account: signer, $t1|x: #0, $t2|y: #1) { - var $t3: u8 - var $t4: S::Storage<#0, #1> - var $t5: num - 0: $t3 := 3 - 1: $t4 := pack S::Storage<#0, #1>($t1, $t2, $t3) - 2: move_to>($t4, $t0) on_abort goto 5 with $t5 - 3: label L1 - 4: return () - 5: label L2 - 6: abort($t5) -} - - -[variant verification] -public fun A::good($t0|account1: signer, $t1|account2: signer) { - var $t2: u64 - var $t3: bool - var $t4: num - var $t5: u64 - var $t6: bool - 0: $t2 := 1 - 1: $t3 := true - 2: S::publish_x_y($t0, $t2, $t3) on_abort goto 8 with $t4 - 3: $t5 := 1 - 4: $t6 := true - 5: S::publish_x_y($t1, $t5, $t6) on_abort goto 8 with $t4 - 6: label L1 - 7: return () - 8: label L2 - 9: abort($t4) -} - - -********* Result of global invariant instrumentation ********* - -S::publish_u64_bool: [ - entrypoint { - assume @0 = [ - <> -> [ - <> - ] - ] - assume @1 = [ - <> -> [ - - ] - ] - assume @2 = [ - <> -> [ - - ] - ] - assume @3 = [ - <> -> [ - - ] - ] - } - 2: move_to>($t4, $t0) on_abort goto L2 with $t5 { - assert @0 = [ - <> -> [ - <> - ] - ] - assert @1 = [ - <> -> [ - - ] - ] - assert @2 = [ - <> -> [ - - ] - ] - assert @3 = [ - <> -> [ - - ] - ] - } - exitpoint {} -] -S::publish_u64_y: [ - entrypoint { - assume @0 = [ - -> [ - <> - ] - ] - assume @1 = [ - <#0> -> [ - <#0> - ] - ] - assume @2 = [ - -> [ - - ] - ] - assume @3 = [ - <#0> -> [ - - ] - ] - } - 2: move_to>($t4, $t0) on_abort goto L2 with $t5 { - assert @0 = [ - -> [ - <> - ] - ] - assert @1 = [ - <#0> -> [ - <#0> - ] - ] - assert @2 = [ - -> [ - - ] - ] - assert @3 = [ - <#0> -> [ - - ] - ] - } - exitpoint {} -] -S::publish_x_bool: [ - entrypoint { - assume @0 = [ - -> [ - <> - ] - ] - assume @1 = [ - -> [ - - ] - ] - assume @2 = [ - <#0> -> [ - <#0> - ] - ] - assume @3 = [ - <#0> -> [ - <#0, bool> - ] - ] - } - 2: move_to>($t4, $t0) on_abort goto L2 with $t5 { - assert @0 = [ - -> [ - <> - ] - ] - assert @1 = [ - -> [ - - ] - ] - assert @2 = [ - <#0> -> [ - <#0> - ] - ] - assert @3 = [ - <#0> -> [ - <#0, bool> - ] - ] - } - exitpoint {} -] -S::publish_x_y: [ - entrypoint { - assume @0 = [ - -> [ - <> - ] - ] - assume @1 = [ - -> [ - <#1> - ] - ] - assume @2 = [ - <#0, bool> -> [ - <#0> - ] - ] - assume @3 = [ - <#0, #1> -> [ - <#0, #1> - ] - ] - } - 2: move_to>($t4, $t0) on_abort goto L2 with $t5 { - assert @0 = [ - -> [ - <> - ] - ] - assert @1 = [ - -> [ - <#1> - ] - ] - assert @2 = [ - <#0, bool> -> [ - <#0> - ] - ] - assert @3 = [ - <#0, #1> -> [ - <#0, #1> - ] - ] - } - exitpoint {} -] -A::good: [ - entrypoint { - assume @0 = [ - <> -> [ - <> - ] - ] - assume @1 = [ - <> -> [ - - ] - ] - assume @2 = [ - <> -> [ - - ] - ] - assume @3 = [ - <> -> [ - - ] - ] - } - 2: S::publish_x_y($t0, $t2, $t3) on_abort goto L2 with $t4 {} - 5: S::publish_x_y($t1, $t5, $t6) on_abort goto L2 with $t4 {} - exitpoint {} -] - -********* Global invariants by ID ********* - -@0 => invariant - exists>(@0x22) - ==> global>(@0x22).x == 1; -@1 => invariant - exists>(@0x23) - ==> global>(@0x23).x > 0; -@2 => invariant - exists>(@0x24) - ==> global>(@0x24).y; -@3 => invariant - (exists>(@0x25) && exists>(@0x26)) - ==> global>(@0x25) == global>(@0x26); diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/mutual_inst.move b/third_party/move/move-model/bytecode/tests/global_invariant_analysis/mutual_inst.move deleted file mode 100644 index ecf351852ee34a..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/mutual_inst.move +++ /dev/null @@ -1,60 +0,0 @@ -address 0x2 { -module S { - struct Storage has key { - x: X, - y: Y, - v: u8, - } - - // F1: - public fun publish_u64_bool(account: signer, x: u64, y: bool) { - move_to(&account, Storage { x, y, v: 0 }) - } - - // F2: - public fun publish_u64_y(account: signer, x: u64, y: Y) { - move_to(&account, Storage { x, y, v: 1 }) - } - - // F3: - public fun publish_x_bool(account: signer, x: X, y: bool) { - move_to(&account, Storage { x, y, v: 2 }) - } - - // F4: - public fun publish_x_y(account: signer, x: X, y: Y) { - move_to(&account, Storage { x, y, v: 3 }) - } -} - -module A { - use 0x2::S; - - // I1: - invariant - exists>(@0x22) - ==> global>(@0x22).x == 1; - - // I2: - invariant - exists>(@0x23) - ==> global>(@0x23).x > 0; - - // I3: - invariant - exists>(@0x24) - ==> global>(@0x24).y; - - // I4: - invariant - (exists>(@0x25) && exists>(@0x26)) - ==> global>(@0x25) == global>(@0x26); - - public fun good(account1: signer, account2: signer) { - S::publish_x_y(account1, 1, true); - S::publish_x_y(account2, 1, true); - } - - // all invariants (I1-I4) should be disproved in all functions (F1-F4) -} -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/uninst_type_param_in_inv.exp b/third_party/move/move-model/bytecode/tests/global_invariant_analysis/uninst_type_param_in_inv.exp deleted file mode 100644 index ef36c8e42fd0df..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/uninst_type_param_in_inv.exp +++ /dev/null @@ -1,116 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun Demo::f1($t0|addr: address) { - var $t1: address - var $t2: bool - var $t3: u8 - var $t4: address - var $t5: &mut Demo::S1 - var $t6: &mut u8 - var $t7: address - var $t8: bool - var $t9: u8 - var $t10: address - var $t11: &mut Demo::S1 - var $t12: &mut u8 - 0: $t1 := copy($t0) - 1: $t2 := exists>($t1) - 2: if ($t2) goto 3 else goto 10 - 3: label L1 - 4: $t3 := 0 - 5: $t4 := copy($t0) - 6: $t5 := borrow_global>($t4) - 7: $t6 := borrow_field>.v($t5) - 8: write_ref($t6, $t3) - 9: goto 10 - 10: label L0 - 11: $t7 := copy($t0) - 12: $t8 := exists>($t7) - 13: if ($t8) goto 14 else goto 21 - 14: label L3 - 15: $t9 := 0 - 16: $t10 := move($t0) - 17: $t11 := borrow_global>($t10) - 18: $t12 := borrow_field>.v($t11) - 19: write_ref($t12, $t9) - 20: goto 21 - 21: label L2 - 22: return () -} - -============ after pipeline `global_invariant_analysis` ================ - -[variant verification] -fun Demo::f1($t0|addr: address) { - var $t1: bool - var $t2: u8 - var $t3: &mut Demo::S1 - var $t4: num - var $t5: &mut u8 - var $t6: bool - var $t7: u8 - var $t8: &mut Demo::S1 - var $t9: &mut u8 - 0: $t1 := exists>($t0) - 1: if ($t1) goto 2 else goto 9 - 2: label L1 - 3: $t2 := 0 - 4: $t3 := borrow_global>($t0) on_abort goto 22 with $t4 - 5: $t5 := borrow_field>.v($t3) - 6: write_ref($t5, $t2) - 7: write_back[Reference($t3).v (u8)]($t5) - 8: write_back[Demo::S1@]($t3) - 9: label L0 - 10: $t6 := exists>($t0) - 11: if ($t6) goto 12 else goto 19 - 12: label L3 - 13: $t7 := 0 - 14: $t8 := borrow_global>($t0) on_abort goto 22 with $t4 - 15: $t9 := borrow_field>.v($t8) - 16: write_ref($t9, $t7) - 17: write_back[Reference($t8).v (u8)]($t9) - 18: write_back[Demo::S1@]($t8) - 19: label L2 - 20: label L4 - 21: return () - 22: label L5 - 23: abort($t4) -} - - -********* Result of global invariant instrumentation ********* - -Demo::f1: [ - entrypoint { - assume @0 = [ - <> -> [ - - - ] - ] - } - 0: $t1 := exists>($t0) {} - 8: write_back[Demo::S1@]($t3) { - assert @0 = [ - <> -> [ - - ] - ] - } - 10: $t6 := exists>($t0) {} - 18: write_back[Demo::S1@]($t8) { - assert @0 = [ - <> -> [ - - ] - ] - } - exitpoint {} -] - -********* Global invariants by ID ********* - -@0 => invariant - (exists>(@0x2) && exists>(@0x2)) - ==> global>(@0x2).v == 0; diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/uninst_type_param_in_inv.move b/third_party/move/move-model/bytecode/tests/global_invariant_analysis/uninst_type_param_in_inv.move deleted file mode 100644 index b99296f8a43ca6..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_analysis/uninst_type_param_in_inv.move +++ /dev/null @@ -1,27 +0,0 @@ -module 0x42::Demo { - struct S1 has key, store { - t: T, - v: u8, - } - - struct S2 has key, store { - t: T, - v: u8, - } - - fun f1(addr: address) acquires S1 { - if (exists>(addr)) { - *&mut borrow_global_mut>(addr).v = 0; - }; - - if (exists>(addr)) { - *&mut borrow_global_mut>(addr).v = 0; - }; - } - - spec module { - invariant - (exists>(@0x2) && exists>(@0x2)) - ==> global>(@0x2).v == 0; - } -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/borrow.exp b/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/borrow.exp deleted file mode 100644 index a9ca29d494e6d7..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/borrow.exp +++ /dev/null @@ -1,57 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun Test::borrow($t0|a: address) { - var $t1|r: &mut Test::R - var $t2: address - var $t3: &mut Test::R - var $t4: &mut Test::R - var $t5: &u64 - var $t6: u64 - var $t7: u64 - var $t8: u64 - var $t9: &mut Test::R - var $t10: &mut u64 - 0: $t2 := move($t0) - 1: $t3 := borrow_global($t2) - 2: $t1 := $t3 - 3: $t4 := copy($t1) - 4: $t5 := borrow_field.x($t4) - 5: $t6 := read_ref($t5) - 6: $t7 := 1 - 7: $t8 := +($t6, $t7) - 8: $t9 := move($t1) - 9: $t10 := borrow_field.x($t9) - 10: write_ref($t10, $t8) - 11: return () -} - -============ after pipeline `global_invariant_instrumentation` ================ - -[variant verification] -public fun Test::borrow($t0|a: address) { - var $t1|r: &mut Test::R - var $t2: &mut Test::R - var $t3: num - var $t4: u64 - var $t5: u64 - var $t6: u64 - var $t7: &mut u64 - # global invariant at tests/global_invariant_instrumentation/borrow.move:7:9+57 - 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) - 1: $t2 := borrow_global($t0) on_abort goto 12 with $t3 - 2: $t4 := get_field.x($t2) - 3: $t5 := 1 - 4: $t6 := +($t4, $t5) on_abort goto 12 with $t3 - 5: $t7 := borrow_field.x($t2) - 6: write_ref($t7, $t6) - 7: write_back[Reference($t2).x (u64)]($t7) - 8: write_back[Test::R@]($t2) - # global invariant at tests/global_invariant_instrumentation/borrow.move:7:9+57 - # VC: global memory invariant does not hold at tests/global_invariant_instrumentation/borrow.move:7:9+57 - 9: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) - 10: label L1 - 11: return () - 12: label L2 - 13: abort($t3) -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/borrow.move b/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/borrow.move deleted file mode 100644 index eed4446d7ac5ef..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/borrow.move +++ /dev/null @@ -1,14 +0,0 @@ -module 0x42::Test { - struct R has key { - x: u64, - } - - spec module { - invariant [global] forall a: address: global(a).x > 0; - } - - public fun borrow(a: address) acquires R { - let r = borrow_global_mut(a); - r.x = r.x + 1; - } -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/move.exp b/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/move.exp deleted file mode 100644 index aef9288188481d..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/move.exp +++ /dev/null @@ -1,61 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun Test::publish($t0|s: &signer) { - var $t1: &signer - var $t2: u64 - var $t3: Test::R - 0: $t1 := move($t0) - 1: $t2 := 1 - 2: $t3 := pack Test::R($t2) - 3: move_to($t3, $t1) - 4: return () -} - - -[variant baseline] -public fun Test::remove($t0|a: address): Test::R { - var $t1: address - var $t2: Test::R - 0: $t1 := move($t0) - 1: $t2 := move_from($t1) - 2: return $t2 -} - -============ after pipeline `global_invariant_instrumentation` ================ - -[variant verification] -public fun Test::publish($t0|s: signer) { - var $t1: u64 - var $t2: Test::R - var $t3: num - # global invariant at tests/global_invariant_instrumentation/move.move:7:9+57 - 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) - 1: $t1 := 1 - 2: $t2 := pack Test::R($t1) - 3: move_to($t2, $t0) on_abort goto 7 with $t3 - # global invariant at tests/global_invariant_instrumentation/move.move:7:9+57 - # VC: global memory invariant does not hold at tests/global_invariant_instrumentation/move.move:7:9+57 - 4: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) - 5: label L1 - 6: return () - 7: label L2 - 8: abort($t3) -} - - -[variant verification] -public fun Test::remove($t0|a: address): Test::R { - var $t1: Test::R - var $t2: num - # global invariant at tests/global_invariant_instrumentation/move.move:7:9+57 - 0: assume forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) - 1: $t1 := move_from($t0) on_abort goto 5 with $t2 - # global invariant at tests/global_invariant_instrumentation/move.move:7:9+57 - # VC: global memory invariant does not hold at tests/global_invariant_instrumentation/move.move:7:9+57 - 2: assert forall a: address: TypeDomain
(): Gt(select Test::R.x(global(a)), 0) - 3: label L1 - 4: return $t1 - 5: label L2 - 6: abort($t2) -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/move.move b/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/move.move deleted file mode 100644 index ecb47396e9d811..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/move.move +++ /dev/null @@ -1,18 +0,0 @@ -module 0x42::Test { - struct R has key { - x: u64, - } - - spec module { - invariant [global] forall a: address: global(a).x > 0; - } - - public fun publish(s: &signer) { - move_to(s, R{x:1}); - } - - public fun remove(a: address): R acquires R { - move_from(a) - } - -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/update.exp b/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/update.exp deleted file mode 100644 index 9ff41de6397465..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/update.exp +++ /dev/null @@ -1,57 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun Test::incr($t0|a: address) { - var $t1|r: &mut Test::R - var $t2: address - var $t3: &mut Test::R - var $t4: &mut Test::R - var $t5: &u64 - var $t6: u64 - var $t7: u64 - var $t8: u64 - var $t9: &mut Test::R - var $t10: &mut u64 - 0: $t2 := move($t0) - 1: $t3 := borrow_global($t2) - 2: $t1 := $t3 - 3: $t4 := copy($t1) - 4: $t5 := borrow_field.x($t4) - 5: $t6 := read_ref($t5) - 6: $t7 := 1 - 7: $t8 := +($t6, $t7) - 8: $t9 := move($t1) - 9: $t10 := borrow_field.x($t9) - 10: write_ref($t10, $t8) - 11: return () -} - -============ after pipeline `global_invariant_instrumentation` ================ - -[variant verification] -public fun Test::incr($t0|a: address) { - var $t1|r: &mut Test::R - var $t2: &mut Test::R - var $t3: num - var $t4: u64 - var $t5: u64 - var $t6: u64 - var $t7: &mut u64 - 0: $t2 := borrow_global($t0) on_abort goto 12 with $t3 - 1: $t4 := get_field.x($t2) - 2: $t5 := 1 - 3: $t6 := +($t4, $t5) on_abort goto 12 with $t3 - 4: $t7 := borrow_field.x($t2) - 5: write_ref($t7, $t6) - 6: write_back[Reference($t2).x (u64)]($t7) - # state save for global update invariants - 7: @1 := save_mem(Test::R) - 8: write_back[Test::R@]($t2) - # global invariant at tests/global_invariant_instrumentation/update.move:7:9+82 - # VC: global memory invariant does not hold at tests/global_invariant_instrumentation/update.move:7:9+82 - 9: assert forall a: address: TypeDomain
(): Lt(select Test::R.x(global[@1](a)), select Test::R.x(global(a))) - 10: label L1 - 11: return () - 12: label L2 - 13: abort($t3) -} diff --git a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/update.move b/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/update.move deleted file mode 100644 index 7be276cd07878a..00000000000000 --- a/third_party/move/move-model/bytecode/tests/global_invariant_instrumentation/update.move +++ /dev/null @@ -1,14 +0,0 @@ -module 0x42::Test { - struct R has key { - x: u64, - } - - spec module { - invariant update [global] forall a: address: old(global(a).x) < global(a).x; - } - - public fun incr(a: address) acquires R { - let r = borrow_global_mut(a); - r.x = r.x + 1; - } -} diff --git a/third_party/move/move-model/bytecode/tests/livevar/basic_test.exp b/third_party/move/move-model/bytecode/tests/livevar/basic_test.exp index c000ec05cd9ec0..4f0f7eb59f93b5 100644 --- a/third_party/move/move-model/bytecode/tests/livevar/basic_test.exp +++ b/third_party/move/move-model/bytecode/tests/livevar/basic_test.exp @@ -120,12 +120,15 @@ fun TestLiveVars::test3($t0|n: u64, $t1|r_ref: &TestLiveVars::R): u64 { ============ after pipeline `livevar` ================ [variant baseline] -fun TestLiveVars::test1($t0|r_ref: TestLiveVars::R): u64 { - var $t1: u64 +fun TestLiveVars::test1($t0|r_ref: &TestLiveVars::R): u64 { + var $t1: &u64 + var $t2: u64 # live vars: r_ref - 0: $t1 := get_field.x($t0) + 0: $t1 := borrow_field.x($t0) # live vars: $t1 - 1: return $t1 + 1: $t2 := read_ref($t1) + # live vars: $t2 + 2: return $t2 } @@ -133,105 +136,137 @@ fun TestLiveVars::test1($t0|r_ref: TestLiveVars::R): u64 { fun TestLiveVars::test2($t0|b: bool): u64 { var $t1|r1: TestLiveVars::R var $t2|r2: TestLiveVars::R - var $t3|r_ref: TestLiveVars::R + var $t3|r_ref: &TestLiveVars::R var $t4: u64 - var $t5: TestLiveVars::R - var $t6: u64 - var $t7: TestLiveVars::R + var $t5: u64 + var $t6: &TestLiveVars::R + var $t7: &TestLiveVars::R var $t8: u64 # live vars: b 0: $t4 := 3 # live vars: b, $t4 - 1: $t5 := pack TestLiveVars::R($t4) - # live vars: b, $t5 - 2: $t6 := 4 - # live vars: b, $t5, $t6 - 3: $t7 := pack TestLiveVars::R($t6) - # live vars: b, $t5, $t7 - 4: $t3 := $t5 - # live vars: b, r_ref, $t7 - 5: if ($t0) goto 6 else goto 8 - # live vars: $t7 - 6: label L1 + 1: $t1 := pack TestLiveVars::R($t4) + # live vars: b, r1 + 2: $t5 := 4 + # live vars: b, r1, $t5 + 3: $t2 := pack TestLiveVars::R($t5) + # live vars: b, r1, r2 + 4: $t6 := borrow_local($t1) + # live vars: b, r2, $t6 + 5: $t3 := $t6 + # live vars: b, r2, r_ref, $t6 + 6: if ($t0) goto 15 else goto 18 + # live vars: r2, $t6 + 7: label L1 + # live vars: r2, $t6 + 8: destroy($t6) + # live vars: r2 + 9: $t7 := borrow_local($t2) # live vars: $t7 - 7: $t3 := $t7 + 10: $t3 := $t7 + # live vars: r_ref + 11: goto 12 # live vars: r_ref - 8: label L0 + 12: label L0 # live vars: r_ref - 9: $t8 := TestLiveVars::test1($t3) + 13: $t8 := TestLiveVars::test1($t3) # live vars: $t8 - 10: return $t8 + 14: return $t8 + # live vars: r2, r_ref, $t6 + 15: label L2 + # live vars: r2, r_ref, $t6 + 16: destroy($t3) + # live vars: r2, $t6 + 17: goto 7 + # live vars: r_ref, $t6 + 18: label L3 + # live vars: r_ref, $t6 + 19: destroy($t6) + # live vars: r_ref + 20: goto 12 } [variant baseline] -fun TestLiveVars::test3($t0|n: u64, $t1|r_ref: TestLiveVars::R): u64 { +fun TestLiveVars::test3($t0|n: u64, $t1|r_ref: &TestLiveVars::R): u64 { var $t2|r1: TestLiveVars::R var $t3|r2: TestLiveVars::R var $t4: u64 - var $t5: TestLiveVars::R + var $t5: u64 var $t6: u64 - var $t7: TestLiveVars::R + var $t7: bool var $t8: u64 - var $t9: bool + var $t9: u64 var $t10: u64 - var $t11: u64 - var $t12: u64 - var $t13: bool + var $t11: bool + var $t12: &TestLiveVars::R + var $t13: &TestLiveVars::R var $t14: u64 var $t15: u64 # live vars: n, r_ref 0: $t4 := 3 # live vars: n, r_ref, $t4 - 1: $t5 := pack TestLiveVars::R($t4) - # live vars: n, r_ref, $t5 - 2: $t6 := 4 - # live vars: n, r_ref, $t5, $t6 - 3: $t7 := pack TestLiveVars::R($t6) - # live vars: n, r_ref, $t5, $t7 - 4: label L6 - # live vars: n, r_ref, $t5, $t7 - 5: $t8 := 0 - # live vars: n, r_ref, $t5, $t7, $t8 - 6: $t9 := <($t8, $t0) - # live vars: n, r_ref, $t5, $t7, $t9 - 7: if ($t9) goto 8 else goto 24 - # live vars: n, $t5, $t7 - 8: label L1 - # live vars: n, $t5, $t7 - 9: label L2 - # live vars: n, $t5, $t7 - 10: $t10 := 2 - # live vars: n, $t5, $t7, $t10 - 11: $t11 := /($t0, $t10) - # live vars: n, $t5, $t7, $t11 - 12: $t12 := 0 - # live vars: n, $t5, $t7, $t11, $t12 - 13: $t13 := ==($t11, $t12) - # live vars: n, $t5, $t7, $t13 - 14: if ($t13) goto 15 else goto 18 - # live vars: n, $t5, $t7 - 15: label L4 - # live vars: n, $t5, $t7 - 16: $t1 := $t5 - # live vars: n, r_ref, $t5, $t7 - 17: goto 20 - # live vars: n, $t5, $t7 - 18: label L3 - # live vars: n, $t5, $t7 - 19: $t1 := $t7 - # live vars: n, r_ref, $t5, $t7 - 20: label L5 - # live vars: n, r_ref, $t5, $t7 - 21: $t14 := 1 - # live vars: n, r_ref, $t5, $t7, $t14 - 22: $t0 := -($t0, $t14) - # live vars: n, r_ref, $t5, $t7 - 23: goto 4 + 1: $t2 := pack TestLiveVars::R($t4) + # live vars: n, r_ref, r1 + 2: $t5 := 4 + # live vars: n, r_ref, r1, $t5 + 3: $t3 := pack TestLiveVars::R($t5) + # live vars: n, r_ref, r1, r2 + 4: goto 5 + # live vars: n, r_ref, r1, r2 + 5: label L6 + # live vars: n, r_ref, r1, r2 + 6: $t6 := 0 + # live vars: n, r_ref, r1, r2, $t6 + 7: $t7 := <($t6, $t0) + # live vars: n, r_ref, r1, r2, $t7 + 8: if ($t7) goto 9 else goto 30 + # live vars: n, r_ref, r1, r2 + 9: label L1 + # live vars: n, r_ref, r1, r2 + 10: goto 11 + # live vars: n, r_ref, r1, r2 + 11: label L2 + # live vars: n, r_ref, r1, r2 + 12: destroy($t1) + # live vars: n, r1, r2 + 13: $t8 := 2 + # live vars: n, r1, r2, $t8 + 14: $t9 := /($t0, $t8) + # live vars: n, r1, r2, $t9 + 15: $t10 := 0 + # live vars: n, r1, r2, $t9, $t10 + 16: $t11 := ==($t9, $t10) + # live vars: n, r1, r2, $t11 + 17: if ($t11) goto 18 else goto 22 + # live vars: n, r1, r2 + 18: label L4 + # live vars: n, r1, r2 + 19: $t12 := borrow_local($t2) + # live vars: n, r1, r2, $t12 + 20: $t1 := $t12 + # live vars: n, r_ref, r1, r2 + 21: goto 26 + # live vars: n, r1, r2 + 22: label L3 + # live vars: n, r1, r2 + 23: $t13 := borrow_local($t3) + # live vars: n, r1, r2, $t13 + 24: $t1 := $t13 + # live vars: n, r_ref, r1, r2 + 25: goto 26 + # live vars: n, r_ref, r1, r2 + 26: label L5 + # live vars: n, r_ref, r1, r2 + 27: $t14 := 1 + # live vars: n, r_ref, r1, r2, $t14 + 28: $t0 := -($t0, $t14) + # live vars: n, r_ref, r1, r2 + 29: goto 5 # live vars: r_ref - 24: label L0 + 30: label L0 # live vars: r_ref - 25: $t15 := TestLiveVars::test1($t1) + 31: $t15 := TestLiveVars::test1($t1) # live vars: $t15 - 26: return $t15 + 32: return $t15 } diff --git a/third_party/move/move-model/bytecode/tests/memory_instr/basic_test.exp b/third_party/move/move-model/bytecode/tests/memory_instr/basic_test.exp deleted file mode 100644 index 0e395d1c8fa793..00000000000000 --- a/third_party/move/move-model/bytecode/tests/memory_instr/basic_test.exp +++ /dev/null @@ -1,516 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun TestPackref::test1(): TestPackref::R { - var $t0|r: TestPackref::R - var $t1|x_ref: &mut u64 - var $t2: u64 - var $t3: TestPackref::R - var $t4: &mut TestPackref::R - var $t5: &mut u64 - var $t6: u64 - var $t7: &mut u64 - var $t8: TestPackref::R - 0: $t2 := 3 - 1: $t3 := pack TestPackref::R($t2) - 2: $t0 := $t3 - 3: $t4 := borrow_local($t0) - 4: $t5 := borrow_field.x($t4) - 5: $t1 := $t5 - 6: $t6 := 0 - 7: $t7 := move($t1) - 8: write_ref($t7, $t6) - 9: $t8 := move($t0) - 10: return $t8 -} - - -[variant baseline] -fun TestPackref::test2($t0|x_ref: &mut u64, $t1|v: u64) { - var $t2: u64 - var $t3: &mut u64 - 0: $t2 := move($t1) - 1: $t3 := move($t0) - 2: write_ref($t3, $t2) - 3: return () -} - - -[variant baseline] -public fun TestPackref::test3($t0|r_ref: &mut TestPackref::R, $t1|v: u64) { - var $t2: &mut TestPackref::R - var $t3: &mut u64 - var $t4: u64 - 0: $t2 := move($t0) - 1: $t3 := borrow_field.x($t2) - 2: $t4 := move($t1) - 3: TestPackref::test2($t3, $t4) - 4: return () -} - - -[variant baseline] -fun TestPackref::test4(): TestPackref::R { - var $t0|r: TestPackref::R - var $t1: u64 - var $t2: TestPackref::R - var $t3: &mut TestPackref::R - var $t4: u64 - var $t5: TestPackref::R - 0: $t1 := 3 - 1: $t2 := pack TestPackref::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: $t4 := 0 - 5: TestPackref::test3($t3, $t4) - 6: $t5 := move($t0) - 7: return $t5 -} - - -[variant baseline] -public fun TestPackref::test5($t0|r_ref: &mut TestPackref::R): &mut u64 { - var $t1: &mut TestPackref::R - var $t2: &mut u64 - 0: $t1 := move($t0) - 1: $t2 := borrow_field.x($t1) - 2: return $t2 -} - - -[variant baseline] -fun TestPackref::test6(): TestPackref::R { - var $t0|r: TestPackref::R - var $t1: u64 - var $t2: TestPackref::R - var $t3: &mut TestPackref::R - var $t4: &mut u64 - var $t5: u64 - var $t6: TestPackref::R - 0: $t1 := 3 - 1: $t2 := pack TestPackref::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: $t4 := TestPackref::test5($t3) - 5: $t5 := 0 - 6: TestPackref::test2($t4, $t5) - 7: $t6 := move($t0) - 8: return $t6 -} - - -[variant baseline] -fun TestPackref::test7($t0|b: bool) { - var $t1|r1: TestPackref::R - var $t2|r2: TestPackref::R - var $t3|r_ref: &mut TestPackref::R - var $t4: u64 - var $t5: TestPackref::R - var $t6: u64 - var $t7: TestPackref::R - var $t8: &mut TestPackref::R - var $t9: bool - var $t10: &mut TestPackref::R - var $t11: &mut TestPackref::R - var $t12: &mut TestPackref::R - var $t13: u64 - 0: $t4 := 3 - 1: $t5 := pack TestPackref::R($t4) - 2: $t1 := $t5 - 3: $t6 := 4 - 4: $t7 := pack TestPackref::R($t6) - 5: $t2 := $t7 - 6: $t8 := borrow_local($t1) - 7: $t3 := $t8 - 8: $t9 := move($t0) - 9: if ($t9) goto 10 else goto 16 - 10: label L1 - 11: $t10 := move($t3) - 12: destroy($t10) - 13: $t11 := borrow_local($t2) - 14: $t3 := $t11 - 15: goto 16 - 16: label L0 - 17: $t12 := move($t3) - 18: $t13 := 0 - 19: TestPackref::test3($t12, $t13) - 20: return () -} - - -[variant baseline] -fun TestPackref::test8($t0|b: bool, $t1|n: u64, $t2|r_ref: &mut TestPackref::R) { - var $t3|r1: TestPackref::R - var $t4|r2: TestPackref::R - var $t5|t_ref: &mut TestPackref::R - var $t6: u64 - var $t7: TestPackref::R - var $t8: u64 - var $t9: TestPackref::R - var $t10: &mut TestPackref::R - var $t11: u64 - var $t12: u64 - var $t13: bool - var $t14: &mut TestPackref::R - var $t15: u64 - var $t16: u64 - var $t17: u64 - var $t18: u64 - var $t19: bool - var $t20: &mut TestPackref::R - var $t21: &mut TestPackref::R - var $t22: u64 - var $t23: u64 - var $t24: u64 - var $t25: bool - var $t26: &mut TestPackref::R - var $t27: &mut TestPackref::R - var $t28: u64 - var $t29: &mut TestPackref::R - var $t30: &mut TestPackref::R - var $t31: u64 - 0: $t6 := 3 - 1: $t7 := pack TestPackref::R($t6) - 2: $t3 := $t7 - 3: $t8 := 4 - 4: $t9 := pack TestPackref::R($t8) - 5: $t4 := $t9 - 6: $t10 := borrow_local($t4) - 7: $t5 := $t10 - 8: goto 9 - 9: label L6 - 10: $t11 := 0 - 11: $t12 := copy($t1) - 12: $t13 := <($t11, $t12) - 13: if ($t13) goto 14 else goto 39 - 14: label L1 - 15: goto 16 - 16: label L2 - 17: $t14 := move($t5) - 18: destroy($t14) - 19: $t15 := copy($t1) - 20: $t16 := 2 - 21: $t17 := /($t15, $t16) - 22: $t18 := 0 - 23: $t19 := ==($t17, $t18) - 24: if ($t19) goto 25 else goto 29 - 25: label L4 - 26: $t20 := borrow_local($t3) - 27: $t5 := $t20 - 28: goto 33 - 29: label L3 - 30: $t21 := borrow_local($t4) - 31: $t5 := $t21 - 32: goto 33 - 33: label L5 - 34: $t22 := move($t1) - 35: $t23 := 1 - 36: $t24 := -($t22, $t23) - 37: $t1 := $t24 - 38: goto 9 - 39: label L0 - 40: $t25 := move($t0) - 41: if ($t25) goto 42 else goto 49 - 42: label L8 - 43: $t26 := move($t5) - 44: destroy($t26) - 45: $t27 := move($t2) - 46: $t28 := 0 - 47: TestPackref::test3($t27, $t28) - 48: goto 56 - 49: label L7 - 50: $t29 := move($t2) - 51: destroy($t29) - 52: $t30 := move($t5) - 53: $t31 := 0 - 54: TestPackref::test3($t30, $t31) - 55: goto 56 - 56: label L9 - 57: return () -} - -============ after pipeline `memory_instr` ================ - -[variant baseline] -fun TestPackref::test1(): TestPackref::R { - var $t0|r: TestPackref::R - var $t1|x_ref: &mut u64 - var $t2: u64 - var $t3: &mut TestPackref::R - var $t4: &mut u64 - var $t5: u64 - var $t6: TestPackref::R - 0: $t2 := 3 - 1: $t0 := pack TestPackref::R($t2) - 2: $t3 := borrow_local($t0) - 3: $t4 := borrow_field.x($t3) - 4: $t5 := 0 - 5: write_ref($t4, $t5) - 6: write_back[Reference($t3).x (u64)]($t4) - 7: write_back[LocalRoot($t0)@]($t3) - 8: trace_local[r]($t0) - 9: $t6 := move($t0) - 10: return $t6 -} - - -[variant baseline] -fun TestPackref::test2($t0|x_ref: &mut u64, $t1|v: u64) { - 0: write_ref($t0, $t1) - 1: trace_local[x_ref]($t0) - 2: return () -} - - -[variant baseline] -public fun TestPackref::test3($t0|r_ref: &mut TestPackref::R, $t1|v: u64) { - var $t2: &mut u64 - 0: $t2 := borrow_field.x($t0) - 1: TestPackref::test2($t2, $t1) - 2: write_back[Reference($t0).x (u64)]($t2) - 3: trace_local[r_ref]($t0) - 4: trace_local[r_ref]($t0) - 5: return () -} - - -[variant baseline] -fun TestPackref::test4(): TestPackref::R { - var $t0|r: TestPackref::R - var $t1: u64 - var $t2: &mut TestPackref::R - var $t3: u64 - var $t4: TestPackref::R - 0: $t1 := 3 - 1: $t0 := pack TestPackref::R($t1) - 2: $t2 := borrow_local($t0) - 3: $t3 := 0 - 4: TestPackref::test3($t2, $t3) - 5: write_back[LocalRoot($t0)@]($t2) - 6: trace_local[r]($t0) - 7: $t4 := move($t0) - 8: return $t4 -} - - -[variant baseline] -public fun TestPackref::test5($t0|r_ref: &mut TestPackref::R): &mut u64 { - var $t1: &mut u64 - 0: $t1 := borrow_field.x($t0) - 1: trace_local[r_ref]($t0) - 2: write_back[Reference($t0).x (u64)]($t1) - 3: trace_local[r_ref]($t0) - 4: return $t1 -} - - -[variant baseline] -fun TestPackref::test6(): TestPackref::R { - var $t0|r: TestPackref::R - var $t1: u64 - var $t2: &mut TestPackref::R - var $t3: &mut u64 - var $t4: u64 - var $t5: TestPackref::R - 0: $t1 := 3 - 1: $t0 := pack TestPackref::R($t1) - 2: $t2 := borrow_local($t0) - 3: $t3 := TestPackref::test5($t2) - 4: $t4 := 0 - 5: TestPackref::test2($t3, $t4) - 6: write_back[Reference($t2).x (u64)]($t3) - 7: write_back[LocalRoot($t0)@]($t2) - 8: trace_local[r]($t0) - 9: $t5 := move($t0) - 10: return $t5 -} - - -[variant baseline] -fun TestPackref::test7($t0|b: bool) { - var $t1|r1: TestPackref::R - var $t2|r2: TestPackref::R - var $t3|r_ref: &mut TestPackref::R - var $t4: u64 - var $t5: u64 - var $t6: &mut TestPackref::R - var $t7: &mut TestPackref::R - var $t8: u64 - var $t9: bool - var $t10: bool - 0: $t4 := 3 - 1: $t1 := pack TestPackref::R($t4) - 2: $t5 := 4 - 3: $t2 := pack TestPackref::R($t5) - 4: $t6 := borrow_local($t1) - 5: $t3 := $t6 - 6: if ($t0) goto 31 else goto 35 - 7: label L1 - 8: write_back[LocalRoot($t1)@]($t6) - 9: trace_local[r1]($t1) - 10: destroy($t6) - 11: $t7 := borrow_local($t2) - 12: $t3 := $t7 - 13: label L0 - 14: $t8 := 0 - 15: TestPackref::test3($t3, $t8) - 16: $t9 := is_parent[Reference($t6)@]($t3) - 17: if ($t9) goto 18 else goto 22 - 18: label L4 - 19: write_back[Reference($t6)@]($t3) - 20: write_back[LocalRoot($t1)@]($t6) - 21: trace_local[r1]($t1) - 22: label L5 - 23: $t10 := is_parent[Reference($t7)@]($t3) - 24: if ($t10) goto 25 else goto 29 - 25: label L6 - 26: write_back[Reference($t7)@]($t3) - 27: write_back[LocalRoot($t2)@]($t7) - 28: trace_local[r2]($t2) - 29: label L7 - 30: return () - 31: label L2 - 32: write_back[Reference($t6)@]($t3) - 33: destroy($t3) - 34: goto 7 - 35: label L3 - 36: destroy($t6) - 37: goto 13 -} - - -[variant baseline] -fun TestPackref::test8($t0|b: bool, $t1|n: u64, $t2|r_ref: &mut TestPackref::R) { - var $t3|r1: TestPackref::R - var $t4|r2: TestPackref::R - var $t5|t_ref: &mut TestPackref::R - var $t6: u64 - var $t7: u64 - var $t8: &mut TestPackref::R - var $t9: u64 - var $t10: bool - var $t11: u64 - var $t12: u64 - var $t13: u64 - var $t14: bool - var $t15: &mut TestPackref::R - var $t16: &mut TestPackref::R - var $t17: u64 - var $t18: u64 - var $t19: u64 - var $t20: bool - var $t21: bool - var $t22: bool - var $t23: bool - var $t24: bool - var $t25: bool - var $t26: bool - var $t27: bool - var $t28: bool - 0: $t6 := 3 - 1: $t3 := pack TestPackref::R($t6) - 2: $t7 := 4 - 3: $t4 := pack TestPackref::R($t7) - 4: $t8 := borrow_local($t4) - 5: $t5 := $t8 - 6: label L6 - 7: $t9 := 0 - 8: $t10 := <($t9, $t1) - 9: if ($t10) goto 10 else goto 50 - 10: label L1 - 11: label L2 - 12: $t20 := is_parent[Reference($t8)@]($t5) - 13: if ($t20) goto 14 else goto 18 - 14: label L10 - 15: write_back[Reference($t8)@]($t5) - 16: write_back[LocalRoot($t4)@]($t8) - 17: trace_local[r2]($t4) - 18: label L11 - 19: $t21 := is_parent[Reference($t15)@]($t5) - 20: if ($t21) goto 21 else goto 25 - 21: label L12 - 22: write_back[Reference($t15)@]($t5) - 23: write_back[LocalRoot($t3)@]($t15) - 24: trace_local[r1]($t3) - 25: label L13 - 26: $t22 := is_parent[Reference($t16)@]($t5) - 27: if ($t22) goto 28 else goto 32 - 28: label L14 - 29: write_back[Reference($t16)@]($t5) - 30: write_back[LocalRoot($t4)@]($t16) - 31: trace_local[r2]($t4) - 32: label L15 - 33: destroy($t5) - 34: $t11 := 2 - 35: $t12 := /($t1, $t11) - 36: $t13 := 0 - 37: $t14 := ==($t12, $t13) - 38: if ($t14) goto 39 else goto 43 - 39: label L4 - 40: $t15 := borrow_local($t3) - 41: $t5 := $t15 - 42: goto 46 - 43: label L3 - 44: $t16 := borrow_local($t4) - 45: $t5 := $t16 - 46: label L5 - 47: $t17 := 1 - 48: $t1 := -($t1, $t17) - 49: goto 6 - 50: label L0 - 51: if ($t0) goto 52 else goto 78 - 52: label L8 - 53: $t23 := is_parent[Reference($t8)@]($t5) - 54: if ($t23) goto 55 else goto 59 - 55: label L16 - 56: write_back[Reference($t8)@]($t5) - 57: write_back[LocalRoot($t4)@]($t8) - 58: trace_local[r2]($t4) - 59: label L17 - 60: $t24 := is_parent[Reference($t15)@]($t5) - 61: if ($t24) goto 62 else goto 66 - 62: label L18 - 63: write_back[Reference($t15)@]($t5) - 64: write_back[LocalRoot($t3)@]($t15) - 65: trace_local[r1]($t3) - 66: label L19 - 67: $t25 := is_parent[Reference($t16)@]($t5) - 68: if ($t25) goto 69 else goto 73 - 69: label L20 - 70: write_back[Reference($t16)@]($t5) - 71: write_back[LocalRoot($t4)@]($t16) - 72: trace_local[r2]($t4) - 73: label L21 - 74: destroy($t5) - 75: $t18 := 0 - 76: TestPackref::test3($t2, $t18) - 77: goto 103 - 78: label L7 - 79: destroy($t2) - 80: $t19 := 0 - 81: TestPackref::test3($t5, $t19) - 82: $t26 := is_parent[Reference($t8)@]($t5) - 83: if ($t26) goto 84 else goto 88 - 84: label L22 - 85: write_back[Reference($t8)@]($t5) - 86: write_back[LocalRoot($t4)@]($t8) - 87: trace_local[r2]($t4) - 88: label L23 - 89: $t27 := is_parent[Reference($t15)@]($t5) - 90: if ($t27) goto 91 else goto 95 - 91: label L24 - 92: write_back[Reference($t15)@]($t5) - 93: write_back[LocalRoot($t3)@]($t15) - 94: trace_local[r1]($t3) - 95: label L25 - 96: $t28 := is_parent[Reference($t16)@]($t5) - 97: if ($t28) goto 98 else goto 102 - 98: label L26 - 99: write_back[Reference($t16)@]($t5) -100: write_back[LocalRoot($t4)@]($t16) -101: trace_local[r2]($t4) -102: label L27 -103: label L9 -104: trace_local[r_ref]($t2) -105: return () -} diff --git a/third_party/move/move-model/bytecode/tests/memory_instr/basic_test.move b/third_party/move/move-model/bytecode/tests/memory_instr/basic_test.move deleted file mode 100644 index bacf2b4f7fd614..00000000000000 --- a/third_party/move/move-model/bytecode/tests/memory_instr/basic_test.move +++ /dev/null @@ -1,70 +0,0 @@ -module 0x42::TestPackref { - struct R has copy, drop { - x: u64 - } - - fun test1() : R { - let r = R {x: 3}; - let r_ref = &mut r; - let x_ref = &mut r_ref.x; - *x_ref = 0; - r - } - - fun test2(x_ref: &mut u64, v: u64) { - *x_ref = v - } - - public fun test3(r_ref: &mut R, v: u64) { - let x_ref = &mut r_ref.x; - test2(x_ref, v) - } - - fun test4() : R { - let r = R {x: 3}; - let r_ref = &mut r; - test3(r_ref, 0); - r - } - - public fun test5(r_ref: &mut R) : &mut u64 { - &mut r_ref.x - } - - fun test6() : R { - let r = R {x: 3}; - let r_ref = &mut r; - let x_ref = test5(r_ref); - test2(x_ref, 0); - r - } - - fun test7(b: bool) { - let r1 = R {x: 3}; - let r2 = R {x: 4}; - let r_ref = &mut r1; - if (b) { - r_ref = &mut r2; - }; - test3(r_ref, 0) - } - - fun test8(b: bool, n: u64, r_ref: &mut R) { - let r1 = R {x: 3}; - let r2 = R {x: 4}; - let t_ref = &mut r2; - while (0 < n) { - if (n/2 == 0) { - t_ref = &mut r1 - } else { - t_ref = &mut r2; - }; - n = n - 1 - }; - if (b) { - test3(r_ref, 0); - } else { - test3(t_ref, 0); - } - } -} diff --git a/third_party/move/move-model/bytecode/tests/memory_instr/mut_ref.exp b/third_party/move/move-model/bytecode/tests/memory_instr/mut_ref.exp deleted file mode 100644 index 897433e4e32eaf..00000000000000 --- a/third_party/move/move-model/bytecode/tests/memory_instr/mut_ref.exp +++ /dev/null @@ -1,495 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun TestMutRefs::data_invariant($t0|_x: &mut TestMutRefs::T) { - 0: return () -} - - -[variant baseline] -public fun TestMutRefs::decrement_invalid($t0|x: &mut TestMutRefs::T) { - var $t1|r: &mut TestMutRefs::TSum - var $t2: &mut TestMutRefs::T - var $t3: &u64 - var $t4: u64 - var $t5: u64 - var $t6: u64 - var $t7: &mut TestMutRefs::T - var $t8: &mut u64 - var $t9: address - var $t10: &mut TestMutRefs::TSum - var $t11: &mut TestMutRefs::TSum - var $t12: &u64 - var $t13: u64 - var $t14: u64 - var $t15: u64 - var $t16: &mut TestMutRefs::TSum - var $t17: &mut u64 - 0: $t2 := copy($t0) - 1: $t3 := borrow_field.value($t2) - 2: $t4 := read_ref($t3) - 3: $t5 := 1 - 4: $t6 := -($t4, $t5) - 5: $t7 := move($t0) - 6: $t8 := borrow_field.value($t7) - 7: write_ref($t8, $t6) - 8: $t9 := 0x0 - 9: $t10 := borrow_global($t9) - 10: $t1 := $t10 - 11: $t11 := copy($t1) - 12: $t12 := borrow_field.sum($t11) - 13: $t13 := read_ref($t12) - 14: $t14 := 1 - 15: $t15 := -($t13, $t14) - 16: $t16 := move($t1) - 17: $t17 := borrow_field.sum($t16) - 18: write_ref($t17, $t15) - 19: return () -} - - -[variant baseline] -public fun TestMutRefs::delete($t0|x: TestMutRefs::T) { - var $t1|r: &mut TestMutRefs::TSum - var $t2|v: u64 - var $t3: address - var $t4: &mut TestMutRefs::TSum - var $t5: TestMutRefs::T - var $t6: u64 - var $t7: &mut TestMutRefs::TSum - var $t8: &u64 - var $t9: u64 - var $t10: u64 - var $t11: u64 - var $t12: &mut TestMutRefs::TSum - var $t13: &mut u64 - 0: $t3 := 0x0 - 1: $t4 := borrow_global($t3) - 2: $t1 := $t4 - 3: $t5 := move($t0) - 4: $t6 := unpack TestMutRefs::T($t5) - 5: $t2 := $t6 - 6: $t7 := copy($t1) - 7: $t8 := borrow_field.sum($t7) - 8: $t9 := read_ref($t8) - 9: $t10 := move($t2) - 10: $t11 := -($t9, $t10) - 11: $t12 := move($t1) - 12: $t13 := borrow_field.sum($t12) - 13: write_ref($t13, $t11) - 14: return () -} - - -[variant baseline] -public fun TestMutRefs::increment($t0|x: &mut TestMutRefs::T) { - var $t1|r: &mut TestMutRefs::TSum - var $t2: &mut TestMutRefs::T - var $t3: &u64 - var $t4: u64 - var $t5: u64 - var $t6: u64 - var $t7: &mut TestMutRefs::T - var $t8: &mut u64 - var $t9: address - var $t10: &mut TestMutRefs::TSum - var $t11: &mut TestMutRefs::TSum - var $t12: &u64 - var $t13: u64 - var $t14: u64 - var $t15: u64 - var $t16: &mut TestMutRefs::TSum - var $t17: &mut u64 - 0: $t2 := copy($t0) - 1: $t3 := borrow_field.value($t2) - 2: $t4 := read_ref($t3) - 3: $t5 := 1 - 4: $t6 := +($t4, $t5) - 5: $t7 := move($t0) - 6: $t8 := borrow_field.value($t7) - 7: write_ref($t8, $t6) - 8: $t9 := 0x0 - 9: $t10 := borrow_global($t9) - 10: $t1 := $t10 - 11: $t11 := copy($t1) - 12: $t12 := borrow_field.sum($t11) - 13: $t13 := read_ref($t12) - 14: $t14 := 1 - 15: $t15 := +($t13, $t14) - 16: $t16 := move($t1) - 17: $t17 := borrow_field.sum($t16) - 18: write_ref($t17, $t15) - 19: return () -} - - -[variant baseline] -public fun TestMutRefs::increment_invalid($t0|x: &mut TestMutRefs::T) { - var $t1: &mut TestMutRefs::T - var $t2: &u64 - var $t3: u64 - var $t4: u64 - var $t5: u64 - var $t6: &mut TestMutRefs::T - var $t7: &mut u64 - 0: $t1 := copy($t0) - 1: $t2 := borrow_field.value($t1) - 2: $t3 := read_ref($t2) - 3: $t4 := 1 - 4: $t5 := +($t3, $t4) - 5: $t6 := move($t0) - 6: $t7 := borrow_field.value($t6) - 7: write_ref($t7, $t5) - 8: return () -} - - -[variant baseline] -public fun TestMutRefs::new($t0|x: u64): TestMutRefs::T { - var $t1|r: &mut TestMutRefs::TSum - var $t2: address - var $t3: &mut TestMutRefs::TSum - var $t4: &mut TestMutRefs::TSum - var $t5: &u64 - var $t6: u64 - var $t7: u64 - var $t8: u64 - var $t9: &mut TestMutRefs::TSum - var $t10: &mut u64 - var $t11: u64 - var $t12: TestMutRefs::T - 0: $t2 := 0x0 - 1: $t3 := borrow_global($t2) - 2: $t1 := $t3 - 3: $t4 := copy($t1) - 4: $t5 := borrow_field.sum($t4) - 5: $t6 := read_ref($t5) - 6: $t7 := copy($t0) - 7: $t8 := +($t6, $t7) - 8: $t9 := move($t1) - 9: $t10 := borrow_field.sum($t9) - 10: write_ref($t10, $t8) - 11: $t11 := move($t0) - 12: $t12 := pack TestMutRefs::T($t11) - 13: return $t12 -} - - -[variant baseline] -fun TestMutRefs::private_data_invariant_invalid($t0|_x: &mut TestMutRefs::T) { - 0: return () -} - - -[variant baseline] -fun TestMutRefs::private_decrement($t0|x: &mut TestMutRefs::T) { - var $t1|r: &mut TestMutRefs::TSum - var $t2: &mut TestMutRefs::T - var $t3: &u64 - var $t4: u64 - var $t5: u64 - var $t6: u64 - var $t7: &mut TestMutRefs::T - var $t8: &mut u64 - var $t9: address - var $t10: &mut TestMutRefs::TSum - var $t11: &mut TestMutRefs::TSum - var $t12: &u64 - var $t13: u64 - var $t14: u64 - var $t15: u64 - var $t16: &mut TestMutRefs::TSum - var $t17: &mut u64 - 0: $t2 := copy($t0) - 1: $t3 := borrow_field.value($t2) - 2: $t4 := read_ref($t3) - 3: $t5 := 1 - 4: $t6 := -($t4, $t5) - 5: $t7 := move($t0) - 6: $t8 := borrow_field.value($t7) - 7: write_ref($t8, $t6) - 8: $t9 := 0x0 - 9: $t10 := borrow_global($t9) - 10: $t1 := $t10 - 11: $t11 := copy($t1) - 12: $t12 := borrow_field.sum($t11) - 13: $t13 := read_ref($t12) - 14: $t14 := 1 - 15: $t15 := -($t13, $t14) - 16: $t16 := move($t1) - 17: $t17 := borrow_field.sum($t16) - 18: write_ref($t17, $t15) - 19: return () -} - - -[variant baseline] -fun TestMutRefs::private_to_public_caller($t0|r: &mut TestMutRefs::T) { - var $t1: &mut TestMutRefs::T - 0: $t1 := move($t0) - 1: TestMutRefs::increment($t1) - 2: return () -} - - -[variant baseline] -fun TestMutRefs::private_to_public_caller_invalid_data_invariant() { - var $t0|r: &mut TestMutRefs::T - var $t1|x: TestMutRefs::T - var $t2: u64 - var $t3: TestMutRefs::T - var $t4: &mut TestMutRefs::T - var $t5: &mut TestMutRefs::T - var $t6: &mut TestMutRefs::T - 0: $t2 := 1 - 1: $t3 := TestMutRefs::new($t2) - 2: $t1 := $t3 - 3: $t4 := borrow_local($t1) - 4: $t0 := $t4 - 5: $t5 := copy($t0) - 6: TestMutRefs::private_decrement($t5) - 7: $t6 := move($t0) - 8: TestMutRefs::increment($t6) - 9: return () -} - - -[variant baseline] -public fun TestMutRefsUser::valid() { - var $t0|x: TestMutRefs::T - var $t1: u64 - var $t2: TestMutRefs::T - var $t3: &mut TestMutRefs::T - var $t4: TestMutRefs::T - 0: $t1 := 4 - 1: $t2 := TestMutRefs::new($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: TestMutRefs::increment($t3) - 5: $t4 := move($t0) - 6: TestMutRefs::delete($t4) - 7: return () -} - -============ after pipeline `memory_instr` ================ - -[variant baseline] -public fun TestMutRefs::data_invariant($t0|_x: &mut TestMutRefs::T) { - 0: trace_local[_x]($t0) - 1: return () -} - - -[variant baseline] -public fun TestMutRefs::decrement_invalid($t0|x: &mut TestMutRefs::T) { - var $t1|r: &mut TestMutRefs::TSum - var $t2: u64 - var $t3: u64 - var $t4: u64 - var $t5: &mut u64 - var $t6: address - var $t7: &mut TestMutRefs::TSum - var $t8: u64 - var $t9: u64 - var $t10: u64 - var $t11: &mut u64 - 0: $t2 := get_field.value($t0) - 1: $t3 := 1 - 2: $t4 := -($t2, $t3) - 3: $t5 := borrow_field.value($t0) - 4: write_ref($t5, $t4) - 5: write_back[Reference($t0).value (u64)]($t5) - 6: trace_local[x]($t0) - 7: $t6 := 0x0 - 8: $t7 := borrow_global($t6) - 9: $t8 := get_field.sum($t7) - 10: $t9 := 1 - 11: $t10 := -($t8, $t9) - 12: $t11 := borrow_field.sum($t7) - 13: write_ref($t11, $t10) - 14: write_back[Reference($t7).sum (u64)]($t11) - 15: write_back[TestMutRefs::TSum@]($t7) - 16: trace_local[x]($t0) - 17: return () -} - - -[variant baseline] -public fun TestMutRefs::delete($t0|x: TestMutRefs::T) { - var $t1|r: &mut TestMutRefs::TSum - var $t2|v: u64 - var $t3: address - var $t4: &mut TestMutRefs::TSum - var $t5: u64 - var $t6: u64 - var $t7: u64 - var $t8: &mut u64 - 0: $t3 := 0x0 - 1: $t4 := borrow_global($t3) - 2: $t5 := unpack TestMutRefs::T($t0) - 3: $t6 := get_field.sum($t4) - 4: $t7 := -($t6, $t5) - 5: $t8 := borrow_field.sum($t4) - 6: write_ref($t8, $t7) - 7: write_back[Reference($t4).sum (u64)]($t8) - 8: write_back[TestMutRefs::TSum@]($t4) - 9: return () -} - - -[variant baseline] -public fun TestMutRefs::increment($t0|x: &mut TestMutRefs::T) { - var $t1|r: &mut TestMutRefs::TSum - var $t2: u64 - var $t3: u64 - var $t4: u64 - var $t5: &mut u64 - var $t6: address - var $t7: &mut TestMutRefs::TSum - var $t8: u64 - var $t9: u64 - var $t10: u64 - var $t11: &mut u64 - 0: $t2 := get_field.value($t0) - 1: $t3 := 1 - 2: $t4 := +($t2, $t3) - 3: $t5 := borrow_field.value($t0) - 4: write_ref($t5, $t4) - 5: write_back[Reference($t0).value (u64)]($t5) - 6: trace_local[x]($t0) - 7: $t6 := 0x0 - 8: $t7 := borrow_global($t6) - 9: $t8 := get_field.sum($t7) - 10: $t9 := 1 - 11: $t10 := +($t8, $t9) - 12: $t11 := borrow_field.sum($t7) - 13: write_ref($t11, $t10) - 14: write_back[Reference($t7).sum (u64)]($t11) - 15: write_back[TestMutRefs::TSum@]($t7) - 16: trace_local[x]($t0) - 17: return () -} - - -[variant baseline] -public fun TestMutRefs::increment_invalid($t0|x: &mut TestMutRefs::T) { - var $t1: u64 - var $t2: u64 - var $t3: u64 - var $t4: &mut u64 - 0: $t1 := get_field.value($t0) - 1: $t2 := 1 - 2: $t3 := +($t1, $t2) - 3: $t4 := borrow_field.value($t0) - 4: write_ref($t4, $t3) - 5: write_back[Reference($t0).value (u64)]($t4) - 6: trace_local[x]($t0) - 7: trace_local[x]($t0) - 8: return () -} - - -[variant baseline] -public fun TestMutRefs::new($t0|x: u64): TestMutRefs::T { - var $t1|r: &mut TestMutRefs::TSum - var $t2: address - var $t3: &mut TestMutRefs::TSum - var $t4: u64 - var $t5: u64 - var $t6: &mut u64 - var $t7: TestMutRefs::T - 0: $t2 := 0x0 - 1: $t3 := borrow_global($t2) - 2: $t4 := get_field.sum($t3) - 3: $t5 := +($t4, $t0) - 4: $t6 := borrow_field.sum($t3) - 5: write_ref($t6, $t5) - 6: write_back[Reference($t3).sum (u64)]($t6) - 7: write_back[TestMutRefs::TSum@]($t3) - 8: $t7 := pack TestMutRefs::T($t0) - 9: return $t7 -} - - -[variant baseline] -fun TestMutRefs::private_data_invariant_invalid($t0|_x: &mut TestMutRefs::T) { - 0: trace_local[_x]($t0) - 1: return () -} - - -[variant baseline] -fun TestMutRefs::private_decrement($t0|x: &mut TestMutRefs::T) { - var $t1|r: &mut TestMutRefs::TSum - var $t2: u64 - var $t3: u64 - var $t4: u64 - var $t5: &mut u64 - var $t6: address - var $t7: &mut TestMutRefs::TSum - var $t8: u64 - var $t9: u64 - var $t10: u64 - var $t11: &mut u64 - 0: $t2 := get_field.value($t0) - 1: $t3 := 1 - 2: $t4 := -($t2, $t3) - 3: $t5 := borrow_field.value($t0) - 4: write_ref($t5, $t4) - 5: write_back[Reference($t0).value (u64)]($t5) - 6: trace_local[x]($t0) - 7: $t6 := 0x0 - 8: $t7 := borrow_global($t6) - 9: $t8 := get_field.sum($t7) - 10: $t9 := 1 - 11: $t10 := -($t8, $t9) - 12: $t11 := borrow_field.sum($t7) - 13: write_ref($t11, $t10) - 14: write_back[Reference($t7).sum (u64)]($t11) - 15: write_back[TestMutRefs::TSum@]($t7) - 16: trace_local[x]($t0) - 17: return () -} - - -[variant baseline] -fun TestMutRefs::private_to_public_caller($t0|r: &mut TestMutRefs::T) { - 0: TestMutRefs::increment($t0) - 1: trace_local[r]($t0) - 2: return () -} - - -[variant baseline] -fun TestMutRefs::private_to_public_caller_invalid_data_invariant() { - var $t0|r: &mut TestMutRefs::T - var $t1|x: TestMutRefs::T - var $t2: u64 - var $t3: &mut TestMutRefs::T - 0: $t2 := 1 - 1: $t1 := TestMutRefs::new($t2) - 2: $t3 := borrow_local($t1) - 3: TestMutRefs::private_decrement($t3) - 4: TestMutRefs::increment($t3) - 5: write_back[LocalRoot($t1)@]($t3) - 6: trace_local[x]($t1) - 7: return () -} - - -[variant baseline] -public fun TestMutRefsUser::valid() { - var $t0|x: TestMutRefs::T - var $t1: u64 - var $t2: &mut TestMutRefs::T - var $t3: TestMutRefs::T - 0: $t1 := 4 - 1: $t0 := TestMutRefs::new($t1) - 2: $t2 := borrow_local($t0) - 3: TestMutRefs::increment($t2) - 4: write_back[LocalRoot($t0)@]($t2) - 5: trace_local[x]($t0) - 6: $t3 := move($t0) - 7: TestMutRefs::delete($t3) - 8: return () -} diff --git a/third_party/move/move-model/bytecode/tests/memory_instr/mut_ref.move b/third_party/move/move-model/bytecode/tests/memory_instr/mut_ref.move deleted file mode 100644 index df4f747bfce4e8..00000000000000 --- a/third_party/move/move-model/bytecode/tests/memory_instr/mut_ref.move +++ /dev/null @@ -1,71 +0,0 @@ -address 0x1 { -module TestMutRefs { - struct T has copy, drop { value: u64 } - - // Resource to track the sum of values in T - struct TSum has key { - sum: u64 - } - - public fun new(x: u64): T acquires TSum { - let r = borrow_global_mut(@0x0); - r.sum = r.sum + x; - T{value: x} - } - - public fun delete(x: T) acquires TSum { - let r = borrow_global_mut(@0x0); - let T{value: v} = x; - r.sum = r.sum - v; - } - - public fun increment(x: &mut T) acquires TSum { - x.value = x.value + 1; - let r = borrow_global_mut(@0x0); - r.sum = r.sum + 1; - } - - public fun increment_invalid(x: &mut T) { - x.value = x.value + 1; - } - - public fun decrement_invalid(x: &mut T) acquires TSum { - x.value = x.value - 1; - let r = borrow_global_mut(@0x0); - r.sum = r.sum - 1; - } - - fun private_decrement(x: &mut T) acquires TSum { - x.value = x.value - 1; - let r = borrow_global_mut(@0x0); - r.sum = r.sum - 1; - } - - public fun data_invariant(_x: &mut T) { - } - - fun private_data_invariant_invalid(_x: &mut T) { - } - - fun private_to_public_caller(r: &mut T) acquires TSum { - increment(r); - } - - fun private_to_public_caller_invalid_data_invariant() acquires TSum { - let x = new(1); - let r = &mut x; - private_decrement(r); - increment(r); - } -} - -module TestMutRefsUser { - use 0x1::TestMutRefs; - - public fun valid() { - let x = TestMutRefs::new(4); - TestMutRefs::increment(&mut x); - TestMutRefs::delete(x); - } -} -} diff --git a/third_party/move/move-model/bytecode/tests/mono_analysis/test.exp b/third_party/move/move-model/bytecode/tests/mono_analysis/test.exp deleted file mode 100644 index c6e5fe4a874863..00000000000000 --- a/third_party/move/move-model/bytecode/tests/mono_analysis/test.exp +++ /dev/null @@ -1,79 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun Test::f1<#0>($t0|x1: #0): Test::A<#0, u64> { - var $t1: #0 - var $t2: u64 - var $t3: Test::A<#0, u64> - 0: $t1 := move($t0) - 1: $t2 := 10 - 2: $t3 := pack Test::A<#0, u64>($t1, $t2) - 3: return $t3 -} - - -[variant baseline] -public fun Test::f2($t0|x: u8): Test::B { - var $t1: u8 - var $t2: Test::A - var $t3: Test::B - 0: $t1 := move($t0) - 1: $t2 := Test::f1($t1) - 2: $t3 := pack Test::B($t2) - 3: return $t3 -} - - -[variant baseline] -public fun Test::f3<#0>($t0|x1: #0): Test::A<#0, u64> { - var $t1: #0 - var $t2: u64 - var $t3: Test::A<#0, u64> - 0: $t1 := move($t0) - 1: $t2 := 1 - 2: $t3 := pack Test::A<#0, u64>($t1, $t2) - 3: return $t3 -} - - -[variant baseline] -public fun Test::f4<#0>($t0|x1: #0): Test::B<#0> { - var $t1: #0 - var $t2: Test::A<#0, u64> - var $t3: Test::B<#0> - 0: $t1 := move($t0) - 1: $t2 := Test::f3<#0>($t1) - 2: $t3 := pack Test::B<#0>($t2) - 3: return $t3 -} - - -[variant baseline] -public fun Test::f5(): Test::B { - var $t0: u128 - var $t1: Test::B - 0: $t0 := 1 - 1: $t1 := Test::f4($t0) - 2: return $t1 -} - - - -==== mono-analysis result ==== - -struct Test::A = { - - - <#0, u64> -} -struct Test::B = { - - - <#0> -} -fun Test::f1 [baseline] = { - -} -fun Test::f4 [baseline] = { - -} diff --git a/third_party/move/move-model/bytecode/tests/mono_analysis/test.move b/third_party/move/move-model/bytecode/tests/mono_analysis/test.move deleted file mode 100644 index 03424d1931cc20..00000000000000 --- a/third_party/move/move-model/bytecode/tests/mono_analysis/test.move +++ /dev/null @@ -1,37 +0,0 @@ -address 0x123 { -module Test { - - struct A { - x1: T1, - x2: T2, - } - - struct B { - x1: A, - } - - public fun f1(x1: T): A { - A{x1, x2: 10} - } - - public fun f2(x: u8): B { - B{x1: f1(x)} - } - - public fun f3(x1: T): A { - A{x1, x2: 1} - } - spec f3 { - pragma opaque = true; - } - - public fun f4(x1: T): B { - B{x1: f3(x1)} - } - - public fun f5(): B { - f4(1) - } - -} -} diff --git a/third_party/move/move-model/bytecode/tests/mut_ref_instrumentation/basic_test.exp b/third_party/move/move-model/bytecode/tests/mut_ref_instrumentation/basic_test.exp deleted file mode 100644 index 855dd40f3f52de..00000000000000 --- a/third_party/move/move-model/bytecode/tests/mut_ref_instrumentation/basic_test.exp +++ /dev/null @@ -1,460 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun TestEliminateMutRefs::test1(): TestEliminateMutRefs::R { - var $t0|r: TestEliminateMutRefs::R - var $t1|x_ref: &mut u64 - var $t2: u64 - var $t3: TestEliminateMutRefs::R - var $t4: &mut TestEliminateMutRefs::R - var $t5: &mut u64 - var $t6: u64 - var $t7: &mut u64 - var $t8: TestEliminateMutRefs::R - 0: $t2 := 3 - 1: $t3 := pack TestEliminateMutRefs::R($t2) - 2: $t0 := $t3 - 3: $t4 := borrow_local($t0) - 4: $t5 := borrow_field.x($t4) - 5: $t1 := $t5 - 6: $t6 := 0 - 7: $t7 := move($t1) - 8: write_ref($t7, $t6) - 9: $t8 := move($t0) - 10: return $t8 -} - - -[variant baseline] -fun TestEliminateMutRefs::test2($t0|x_ref: &mut u64, $t1|v: u64) { - var $t2: u64 - var $t3: &mut u64 - 0: $t2 := move($t1) - 1: $t3 := move($t0) - 2: write_ref($t3, $t2) - 3: return () -} - - -[variant baseline] -public fun TestEliminateMutRefs::test3($t0|r_ref: &mut TestEliminateMutRefs::R, $t1|v: u64) { - var $t2: &mut TestEliminateMutRefs::R - var $t3: &mut u64 - var $t4: u64 - 0: $t2 := move($t0) - 1: $t3 := borrow_field.x($t2) - 2: $t4 := move($t1) - 3: TestEliminateMutRefs::test2($t3, $t4) - 4: return () -} - - -[variant baseline] -fun TestEliminateMutRefs::test4(): TestEliminateMutRefs::R { - var $t0|r: TestEliminateMutRefs::R - var $t1: u64 - var $t2: TestEliminateMutRefs::R - var $t3: &mut TestEliminateMutRefs::R - var $t4: u64 - var $t5: TestEliminateMutRefs::R - 0: $t1 := 3 - 1: $t2 := pack TestEliminateMutRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: $t4 := 0 - 5: TestEliminateMutRefs::test3($t3, $t4) - 6: $t5 := move($t0) - 7: return $t5 -} - - -[variant baseline] -public fun TestEliminateMutRefs::test5($t0|r_ref: &mut TestEliminateMutRefs::R): &mut u64 { - var $t1: &mut TestEliminateMutRefs::R - var $t2: &mut u64 - 0: $t1 := move($t0) - 1: $t2 := borrow_field.x($t1) - 2: return $t2 -} - - -[variant baseline] -fun TestEliminateMutRefs::test6(): TestEliminateMutRefs::R { - var $t0|r: TestEliminateMutRefs::R - var $t1: u64 - var $t2: TestEliminateMutRefs::R - var $t3: &mut TestEliminateMutRefs::R - var $t4: &mut u64 - var $t5: u64 - var $t6: TestEliminateMutRefs::R - 0: $t1 := 3 - 1: $t2 := pack TestEliminateMutRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: $t4 := TestEliminateMutRefs::test5($t3) - 5: $t5 := 0 - 6: TestEliminateMutRefs::test2($t4, $t5) - 7: $t6 := move($t0) - 8: return $t6 -} - - -[variant baseline] -fun TestEliminateMutRefs::test7($t0|b: bool) { - var $t1|r1: TestEliminateMutRefs::R - var $t2|r2: TestEliminateMutRefs::R - var $t3|r_ref: &mut TestEliminateMutRefs::R - var $t4: u64 - var $t5: TestEliminateMutRefs::R - var $t6: u64 - var $t7: TestEliminateMutRefs::R - var $t8: &mut TestEliminateMutRefs::R - var $t9: bool - var $t10: &mut TestEliminateMutRefs::R - var $t11: &mut TestEliminateMutRefs::R - var $t12: &mut TestEliminateMutRefs::R - var $t13: u64 - 0: $t4 := 3 - 1: $t5 := pack TestEliminateMutRefs::R($t4) - 2: $t1 := $t5 - 3: $t6 := 4 - 4: $t7 := pack TestEliminateMutRefs::R($t6) - 5: $t2 := $t7 - 6: $t8 := borrow_local($t1) - 7: $t3 := $t8 - 8: $t9 := move($t0) - 9: if ($t9) goto 10 else goto 16 - 10: label L1 - 11: $t10 := move($t3) - 12: destroy($t10) - 13: $t11 := borrow_local($t2) - 14: $t3 := $t11 - 15: goto 16 - 16: label L0 - 17: $t12 := move($t3) - 18: $t13 := 0 - 19: TestEliminateMutRefs::test3($t12, $t13) - 20: return () -} - - -[variant baseline] -fun TestEliminateMutRefs::test8($t0|b: bool, $t1|n: u64, $t2|r_ref: &mut TestEliminateMutRefs::R) { - var $t3|r1: TestEliminateMutRefs::R - var $t4|r2: TestEliminateMutRefs::R - var $t5|t_ref: &mut TestEliminateMutRefs::R - var $t6: u64 - var $t7: TestEliminateMutRefs::R - var $t8: u64 - var $t9: TestEliminateMutRefs::R - var $t10: &mut TestEliminateMutRefs::R - var $t11: u64 - var $t12: u64 - var $t13: bool - var $t14: &mut TestEliminateMutRefs::R - var $t15: u64 - var $t16: u64 - var $t17: u64 - var $t18: u64 - var $t19: bool - var $t20: &mut TestEliminateMutRefs::R - var $t21: &mut TestEliminateMutRefs::R - var $t22: u64 - var $t23: u64 - var $t24: u64 - var $t25: bool - var $t26: &mut TestEliminateMutRefs::R - var $t27: &mut TestEliminateMutRefs::R - var $t28: u64 - var $t29: &mut TestEliminateMutRefs::R - var $t30: &mut TestEliminateMutRefs::R - var $t31: u64 - 0: $t6 := 3 - 1: $t7 := pack TestEliminateMutRefs::R($t6) - 2: $t3 := $t7 - 3: $t8 := 4 - 4: $t9 := pack TestEliminateMutRefs::R($t8) - 5: $t4 := $t9 - 6: $t10 := borrow_local($t4) - 7: $t5 := $t10 - 8: goto 9 - 9: label L6 - 10: $t11 := 0 - 11: $t12 := copy($t1) - 12: $t13 := <($t11, $t12) - 13: if ($t13) goto 14 else goto 39 - 14: label L1 - 15: goto 16 - 16: label L2 - 17: $t14 := move($t5) - 18: destroy($t14) - 19: $t15 := copy($t1) - 20: $t16 := 2 - 21: $t17 := /($t15, $t16) - 22: $t18 := 0 - 23: $t19 := ==($t17, $t18) - 24: if ($t19) goto 25 else goto 29 - 25: label L4 - 26: $t20 := borrow_local($t3) - 27: $t5 := $t20 - 28: goto 33 - 29: label L3 - 30: $t21 := borrow_local($t4) - 31: $t5 := $t21 - 32: goto 33 - 33: label L5 - 34: $t22 := move($t1) - 35: $t23 := 1 - 36: $t24 := -($t22, $t23) - 37: $t1 := $t24 - 38: goto 9 - 39: label L0 - 40: $t25 := move($t0) - 41: if ($t25) goto 42 else goto 49 - 42: label L8 - 43: $t26 := move($t5) - 44: destroy($t26) - 45: $t27 := move($t2) - 46: $t28 := 0 - 47: TestEliminateMutRefs::test3($t27, $t28) - 48: goto 56 - 49: label L7 - 50: $t29 := move($t2) - 51: destroy($t29) - 52: $t30 := move($t5) - 53: $t31 := 0 - 54: TestEliminateMutRefs::test3($t30, $t31) - 55: goto 56 - 56: label L9 - 57: return () -} - -============ after pipeline `mut_ref_instrumentation` ================ - -[variant baseline] -fun TestEliminateMutRefs::test1(): TestEliminateMutRefs::R { - var $t0|r: TestEliminateMutRefs::R - var $t1|x_ref: &mut u64 - var $t2: u64 - var $t3: TestEliminateMutRefs::R - var $t4: &mut TestEliminateMutRefs::R - var $t5: &mut u64 - var $t6: u64 - var $t7: &mut u64 - var $t8: TestEliminateMutRefs::R - 0: $t2 := 3 - 1: $t3 := pack TestEliminateMutRefs::R($t2) - 2: $t0 := $t3 - 3: $t4 := borrow_local($t0) - 4: $t5 := borrow_field.x($t4) - 5: $t1 := $t5 - 6: $t6 := 0 - 7: $t7 := move($t1) - 8: write_ref($t7, $t6) - 9: $t8 := move($t0) - 10: return $t8 -} - - -[variant baseline] -fun TestEliminateMutRefs::test2($t0|x_ref: &mut u64, $t1|v: u64) { - var $t2: u64 - var $t3: &mut u64 - 0: $t2 := move($t1) - 1: $t3 := copy($t0) - 2: write_ref($t3, $t2) - 3: trace_local[x_ref]($t0) - 4: return () -} - - -[variant baseline] -public fun TestEliminateMutRefs::test3($t0|r_ref: &mut TestEliminateMutRefs::R, $t1|v: u64) { - var $t2: &mut TestEliminateMutRefs::R - var $t3: &mut u64 - var $t4: u64 - 0: $t2 := copy($t0) - 1: $t3 := borrow_field.x($t2) - 2: $t4 := move($t1) - 3: TestEliminateMutRefs::test2($t3, $t4) - 4: trace_local[r_ref]($t0) - 5: return () -} - - -[variant baseline] -fun TestEliminateMutRefs::test4(): TestEliminateMutRefs::R { - var $t0|r: TestEliminateMutRefs::R - var $t1: u64 - var $t2: TestEliminateMutRefs::R - var $t3: &mut TestEliminateMutRefs::R - var $t4: u64 - var $t5: TestEliminateMutRefs::R - 0: $t1 := 3 - 1: $t2 := pack TestEliminateMutRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: $t4 := 0 - 5: TestEliminateMutRefs::test3($t3, $t4) - 6: $t5 := move($t0) - 7: return $t5 -} - - -[variant baseline] -public fun TestEliminateMutRefs::test5($t0|r_ref: &mut TestEliminateMutRefs::R): &mut u64 { - var $t1: &mut TestEliminateMutRefs::R - var $t2: &mut u64 - 0: $t1 := copy($t0) - 1: $t2 := borrow_field.x($t1) - 2: trace_local[r_ref]($t0) - 3: return $t2 -} - - -[variant baseline] -fun TestEliminateMutRefs::test6(): TestEliminateMutRefs::R { - var $t0|r: TestEliminateMutRefs::R - var $t1: u64 - var $t2: TestEliminateMutRefs::R - var $t3: &mut TestEliminateMutRefs::R - var $t4: &mut u64 - var $t5: u64 - var $t6: TestEliminateMutRefs::R - 0: $t1 := 3 - 1: $t2 := pack TestEliminateMutRefs::R($t1) - 2: $t0 := $t2 - 3: $t3 := borrow_local($t0) - 4: $t4 := TestEliminateMutRefs::test5($t3) - 5: $t5 := 0 - 6: TestEliminateMutRefs::test2($t4, $t5) - 7: $t6 := move($t0) - 8: return $t6 -} - - -[variant baseline] -fun TestEliminateMutRefs::test7($t0|b: bool) { - var $t1|r1: TestEliminateMutRefs::R - var $t2|r2: TestEliminateMutRefs::R - var $t3|r_ref: &mut TestEliminateMutRefs::R - var $t4: u64 - var $t5: TestEliminateMutRefs::R - var $t6: u64 - var $t7: TestEliminateMutRefs::R - var $t8: &mut TestEliminateMutRefs::R - var $t9: bool - var $t10: &mut TestEliminateMutRefs::R - var $t11: &mut TestEliminateMutRefs::R - var $t12: &mut TestEliminateMutRefs::R - var $t13: u64 - 0: $t4 := 3 - 1: $t5 := pack TestEliminateMutRefs::R($t4) - 2: $t1 := $t5 - 3: $t6 := 4 - 4: $t7 := pack TestEliminateMutRefs::R($t6) - 5: $t2 := $t7 - 6: $t8 := borrow_local($t1) - 7: $t3 := $t8 - 8: $t9 := move($t0) - 9: if ($t9) goto 10 else goto 15 - 10: label L1 - 11: $t10 := move($t3) - 12: destroy($t10) - 13: $t11 := borrow_local($t2) - 14: $t3 := $t11 - 15: label L0 - 16: $t12 := move($t3) - 17: $t13 := 0 - 18: TestEliminateMutRefs::test3($t12, $t13) - 19: return () -} - - -[variant baseline] -fun TestEliminateMutRefs::test8($t0|b: bool, $t1|n: u64, $t2|r_ref: &mut TestEliminateMutRefs::R) { - var $t3|r1: TestEliminateMutRefs::R - var $t4|r2: TestEliminateMutRefs::R - var $t5|t_ref: &mut TestEliminateMutRefs::R - var $t6: u64 - var $t7: TestEliminateMutRefs::R - var $t8: u64 - var $t9: TestEliminateMutRefs::R - var $t10: &mut TestEliminateMutRefs::R - var $t11: u64 - var $t12: u64 - var $t13: bool - var $t14: &mut TestEliminateMutRefs::R - var $t15: u64 - var $t16: u64 - var $t17: u64 - var $t18: u64 - var $t19: bool - var $t20: &mut TestEliminateMutRefs::R - var $t21: &mut TestEliminateMutRefs::R - var $t22: u64 - var $t23: u64 - var $t24: u64 - var $t25: bool - var $t26: &mut TestEliminateMutRefs::R - var $t27: &mut TestEliminateMutRefs::R - var $t28: u64 - var $t29: &mut TestEliminateMutRefs::R - var $t30: &mut TestEliminateMutRefs::R - var $t31: u64 - 0: $t6 := 3 - 1: $t7 := pack TestEliminateMutRefs::R($t6) - 2: $t3 := $t7 - 3: $t8 := 4 - 4: $t9 := pack TestEliminateMutRefs::R($t8) - 5: $t4 := $t9 - 6: $t10 := borrow_local($t4) - 7: $t5 := $t10 - 8: label L6 - 9: $t11 := 0 - 10: $t12 := copy($t1) - 11: $t13 := <($t11, $t12) - 12: if ($t13) goto 13 else goto 36 - 13: label L1 - 14: label L2 - 15: $t14 := move($t5) - 16: destroy($t14) - 17: $t15 := copy($t1) - 18: $t16 := 2 - 19: $t17 := /($t15, $t16) - 20: $t18 := 0 - 21: $t19 := ==($t17, $t18) - 22: if ($t19) goto 23 else goto 27 - 23: label L4 - 24: $t20 := borrow_local($t3) - 25: $t5 := $t20 - 26: goto 30 - 27: label L3 - 28: $t21 := borrow_local($t4) - 29: $t5 := $t21 - 30: label L5 - 31: $t22 := move($t1) - 32: $t23 := 1 - 33: $t24 := -($t22, $t23) - 34: $t1 := $t24 - 35: goto 8 - 36: label L0 - 37: $t25 := move($t0) - 38: if ($t25) goto 39 else goto 46 - 39: label L8 - 40: $t26 := move($t5) - 41: destroy($t26) - 42: $t27 := copy($t2) - 43: $t28 := 0 - 44: TestEliminateMutRefs::test3($t27, $t28) - 45: goto 52 - 46: label L7 - 47: $t29 := copy($t2) - 48: destroy($t29) - 49: $t30 := move($t5) - 50: $t31 := 0 - 51: TestEliminateMutRefs::test3($t30, $t31) - 52: label L9 - 53: trace_local[r_ref]($t2) - 54: return () -} diff --git a/third_party/move/move-model/bytecode/tests/mut_ref_instrumentation/basic_test.move b/third_party/move/move-model/bytecode/tests/mut_ref_instrumentation/basic_test.move deleted file mode 100644 index 5133d72e27845b..00000000000000 --- a/third_party/move/move-model/bytecode/tests/mut_ref_instrumentation/basic_test.move +++ /dev/null @@ -1,71 +0,0 @@ -module 0x42::TestEliminateMutRefs { - - struct R has copy, drop { - x: u64 - } - - fun test1() : R { - let r = R {x: 3}; - let r_ref = &mut r; - let x_ref = &mut r_ref.x; - *x_ref = 0; - r - } - - fun test2(x_ref: &mut u64, v: u64) { - *x_ref = v - } - - public fun test3(r_ref: &mut R, v: u64) { - let x_ref = &mut r_ref.x; - test2(x_ref, v) - } - - fun test4() : R { - let r = R {x: 3}; - let r_ref = &mut r; - test3(r_ref, 0); - r - } - - public fun test5(r_ref: &mut R) : &mut u64 { - &mut r_ref.x - } - - fun test6() : R { - let r = R {x: 3}; - let r_ref = &mut r; - let x_ref = test5(r_ref); - test2(x_ref, 0); - r - } - - fun test7(b: bool) { - let r1 = R {x: 3}; - let r2 = R {x: 4}; - let r_ref = &mut r1; - if (b) { - r_ref = &mut r2; - }; - test3(r_ref, 0) - } - - fun test8(b: bool, n: u64, r_ref: &mut R) { - let r1 = R {x: 3}; - let r2 = R {x: 4}; - let t_ref = &mut r2; - while (0 < n) { - if (n/2 == 0) { - t_ref = &mut r1 - } else { - t_ref = &mut r2; - }; - n = n - 1 - }; - if (b) { - test3(r_ref, 0); - } else { - test3(t_ref, 0); - } - } -} diff --git a/third_party/move/move-model/bytecode/tests/reaching_def/basic_test.exp b/third_party/move/move-model/bytecode/tests/reaching_def/basic_test.exp index baab1afae6517c..f6a91b898b5582 100644 --- a/third_party/move/move-model/bytecode/tests/reaching_def/basic_test.exp +++ b/third_party/move/move-model/bytecode/tests/reaching_def/basic_test.exp @@ -57,8 +57,8 @@ fun ReachingDefTest::basic($t0|a: u64, $t1|b: u64): u64 { [variant baseline] -fun ReachingDefTest::create_resource($t0|sender: signer) { - var $t1: signer +fun ReachingDefTest::create_resource($t0|sender: &signer) { + var $t1: &signer var $t2: u64 var $t3: bool var $t4: ReachingDefTest::R diff --git a/third_party/move/move-model/bytecode/tests/reaching_def/test_branching.exp b/third_party/move/move-model/bytecode/tests/reaching_def/test_branching.exp index 27b13bd8293f95..335f083dfeaf06 100644 --- a/third_party/move/move-model/bytecode/tests/reaching_def/test_branching.exp +++ b/third_party/move/move-model/bytecode/tests/reaching_def/test_branching.exp @@ -36,11 +36,12 @@ fun TestBranching::branching($t0|cond: bool): u64 { 2: label L1 3: $t3 := 3 4: $t1 := $t3 - 5: goto 9 + 5: goto 10 6: label L0 7: $t4 := 4 8: $t1 := $t4 - 9: label L2 - 10: $t5 := move($t1) - 11: return $t1 + 9: goto 10 + 10: label L2 + 11: $t5 := move($t1) + 12: return $t1 } diff --git a/third_party/move/move-model/bytecode/tests/spec_instrumentation/fun_spec.exp b/third_party/move/move-model/bytecode/tests/spec_instrumentation/fun_spec.exp deleted file mode 100644 index 672fda40c9adef..00000000000000 --- a/third_party/move/move-model/bytecode/tests/spec_instrumentation/fun_spec.exp +++ /dev/null @@ -1,460 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun Test::branching_result($t0|is_div: bool, $t1|a: u64, $t2|b: u64): u64 { - var $t3|tmp#$3: 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 - 0: $t4 := move($t0) - 1: if ($t4) goto 2 else goto 8 - 2: label L1 - 3: $t5 := move($t1) - 4: $t6 := move($t2) - 5: $t7 := /($t5, $t6) - 6: $t3 := $t7 - 7: goto 14 - 8: label L0 - 9: $t8 := move($t1) - 10: $t9 := move($t2) - 11: $t10 := *($t8, $t9) - 12: $t3 := $t10 - 13: goto 14 - 14: label L2 - 15: $t11 := move($t3) - 16: return $t11 -} - - -[variant baseline] -fun Test::implicit_and_explicit_abort($t0|a: u64, $t1|b: u64): u64 { - var $t2: u64 - var $t3: u64 - var $t4: bool - var $t5: u64 - var $t6: u64 - var $t7: u64 - var $t8: u64 - 0: $t2 := copy($t1) - 1: $t3 := 0 - 2: $t4 := !=($t2, $t3) - 3: if ($t4) goto 4 else goto 7 - 4: label L1 - 5: $t5 := 22 - 6: abort($t5) - 7: label L0 - 8: $t6 := move($t0) - 9: $t7 := move($t1) - 10: $t8 := /($t6, $t7) - 11: return $t8 -} - - -[variant baseline] -fun Test::multiple_results($t0|a: u64, $t1|b: u64): (u64, u64) { - var $t2: u64 - var $t3: u64 - var $t4: u64 - var $t5: u64 - var $t6: u64 - var $t7: u64 - 0: $t2 := copy($t0) - 1: $t3 := copy($t1) - 2: $t4 := /($t2, $t3) - 3: $t5 := move($t0) - 4: $t6 := move($t1) - 5: $t7 := %($t5, $t6) - 6: return ($t4, $t7) -} - - -[variant baseline] -fun Test::mut_ref_param($t0|r: &mut Test::R): u64 { - var $t1|x: u64 - var $t2: &mut Test::R - var $t3: &u64 - var $t4: u64 - var $t5: &mut Test::R - var $t6: &u64 - var $t7: u64 - var $t8: u64 - var $t9: u64 - var $t10: &mut Test::R - var $t11: &mut u64 - var $t12: u64 - 0: $t2 := copy($t0) - 1: $t3 := borrow_field.v($t2) - 2: $t4 := read_ref($t3) - 3: $t1 := $t4 - 4: $t5 := copy($t0) - 5: $t6 := borrow_field.v($t5) - 6: $t7 := read_ref($t6) - 7: $t8 := 1 - 8: $t9 := -($t7, $t8) - 9: $t10 := move($t0) - 10: $t11 := borrow_field.v($t10) - 11: write_ref($t11, $t9) - 12: $t12 := move($t1) - 13: return $t12 -} - - -[variant baseline] -fun Test::ref_param($t0|r: &Test::R): u64 { - var $t1: &Test::R - var $t2: &u64 - var $t3: u64 - 0: $t1 := move($t0) - 1: $t2 := borrow_field.v($t1) - 2: $t3 := read_ref($t2) - 3: return $t3 -} - - -[variant baseline] -fun Test::ref_param_return_ref($t0|r: &Test::R): &u64 { - var $t1: &Test::R - var $t2: &u64 - 0: $t1 := move($t0) - 1: $t2 := borrow_field.v($t1) - 2: return $t2 -} - - -[variant baseline] -fun Test::resource_with_old($t0|val: u64) { - var $t1|r: &mut Test::R - var $t2: address - var $t3: bool - var $t4: bool - var $t5: u64 - var $t6: address - var $t7: &mut Test::R - var $t8: &mut Test::R - var $t9: &u64 - var $t10: u64 - var $t11: u64 - var $t12: u64 - var $t13: &mut Test::R - var $t14: &mut u64 - 0: $t2 := 0x0 - 1: $t3 := exists($t2) - 2: $t4 := !($t3) - 3: if ($t4) goto 4 else goto 7 - 4: label L1 - 5: $t5 := 33 - 6: abort($t5) - 7: label L0 - 8: $t6 := 0x0 - 9: $t7 := borrow_global($t6) - 10: $t1 := $t7 - 11: $t8 := copy($t1) - 12: $t9 := borrow_field.v($t8) - 13: $t10 := read_ref($t9) - 14: $t11 := move($t0) - 15: $t12 := +($t10, $t11) - 16: $t13 := move($t1) - 17: $t14 := borrow_field.v($t13) - 18: write_ref($t14, $t12) - 19: return () -} - -============ after pipeline `spec_instrumentation` ================ - -[variant verification] -fun Test::branching_result($t0|is_div: bool, $t1|a: u64, $t2|b: u64): u64 { - var $t3|tmp#$3: u64 - var $t4: num - 0: if ($t0) goto 1 else goto 4 - 1: label L1 - 2: $t3 := /($t1, $t2) on_abort goto 12 with $t4 - 3: goto 6 - 4: label L0 - 5: $t3 := *($t1, $t2) on_abort goto 12 with $t4 - 6: label L2 - 7: label L3 - # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:27:6+50 - 8: assert Not(And($t0, Eq($t2, 0))) - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:28:6+35 - 9: assert Implies($t0, Eq($t3, Div($t1, $t2))) - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:29:6+36 - 10: assert Implies(Not($t0), Eq($t3, Mul($t1, $t2))) - 11: return $t3 - 12: label L4 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/fun_spec.move:26:2+165 - 13: assert And($t0, Eq($t2, 0)) - # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/fun_spec.move:26:2+165 - 14: assert And(And($t0, Eq($t2, 0)), Eq(-1, $t4)) - 15: abort($t4) -} - - -[variant verification] -fun Test::implicit_and_explicit_abort($t0|a: u64, $t1|b: u64): u64 { - var $t2: u64 - var $t3: bool - var $t4: u64 - var $t5: num - var $t6: u64 - 0: $t2 := 0 - 1: $t3 := !=($t1, $t2) - 2: if ($t3) goto 3 else goto 7 - 3: label L1 - 4: $t4 := 22 - 5: $t5 := move($t4) - 6: goto 14 - 7: label L0 - 8: $t6 := /($t0, $t1) on_abort goto 14 with $t5 - 9: label L2 - # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:9:6+25 - 10: assert Not(Eq($t1, 0)) - # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:10:6+17 - 11: assert Not(Eq($t0, 0)) - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:11:6+24 - 12: assert Eq($t6, Div($t0, $t1)) - 13: return $t6 - 14: label L3 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/fun_spec.move:8:2+121 - 15: assert Or(Eq($t1, 0), Eq($t0, 0)) - # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/fun_spec.move:8:2+121 - 16: assert Or(And(Eq($t1, 0), Eq(22, $t5)), Eq($t0, 0)) - 17: abort($t5) -} - - -[variant verification] -fun Test::multiple_results($t0|a: u64, $t1|b: u64): (u64, u64) { - var $t2: u64 - var $t3: num - var $t4: u64 - 0: $t2 := /($t0, $t1) on_abort goto 7 with $t3 - 1: $t4 := %($t0, $t1) on_abort goto 7 with $t3 - 2: label L1 - # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:18:6+40 - 3: assert Not(Eq($t1, 0)) - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:19:6+26 - 4: assert Eq($t2, Div($t0, $t1)) - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:20:6+26 - 5: assert Eq($t4, Mod($t0, $t1)) - 6: return ($t2, $t4) - 7: label L2 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/fun_spec.move:17:2+136 - 8: assert Eq($t1, 0) - # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/fun_spec.move:17:2+136 - 9: assert And(Eq($t1, 0), Eq(-1, $t3)) - 10: abort($t3) -} - - -[variant verification] -fun Test::mut_ref_param($t0|r: &mut Test::R): u64 { - var $t1|x: u64 - var $t2: Test::R - var $t3: u64 - var $t4: u64 - var $t5: u64 - var $t6: u64 - var $t7: num - var $t8: &mut u64 - 0: $t2 := read_ref($t0) - 1: $t3 := get_field.v($t0) - 2: $t4 := get_field.v($t0) - 3: $t5 := 1 - 4: $t6 := -($t4, $t5) on_abort goto 15 with $t7 - 5: $t8 := borrow_field.v($t0) - 6: write_ref($t8, $t6) - 7: write_back[Reference($t0).v (u64)]($t8) - 8: trace_local[r]($t0) - 9: trace_local[r]($t0) - 10: label L1 - # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:67:6+42 - 11: assert Not(Eq(select Test::R.v($t2), 0)) - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:68:6+27 - 12: assert Eq($t3, select Test::R.v($t2)) - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:69:6+28 - 13: assert Eq(select Test::R.v($t0), Add(select Test::R.v($t2), 1)) - 14: return $t3 - 15: label L2 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/fun_spec.move:66:2+138 - 16: assert Eq(select Test::R.v($t2), 0) - # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/fun_spec.move:66:2+138 - 17: assert And(Eq(select Test::R.v($t2), 0), Eq(-1, $t7)) - 18: abort($t7) -} - - -[variant verification] -fun Test::ref_param($t0|r: Test::R): u64 { - var $t1: u64 - 0: $t1 := get_field.v($t0) - 1: label L1 - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:51:6+22 - 2: assert Eq($t1, select Test::R.v($t0)) - 3: return $t1 -} - - -[variant verification] -fun Test::ref_param_return_ref($t0|r: Test::R): u64 { - var $t1: u64 - 0: $t1 := get_field.v($t0) - 1: label L1 - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:58:6+22 - 2: assert Eq($t1, select Test::R.v($t0)) - 3: return $t1 -} - - -[variant verification] -fun Test::resource_with_old($t0|val: u64) { - var $t1|r: &mut Test::R - var $t2: address - var $t3: bool - var $t4: bool - var $t5: u64 - var $t6: num - var $t7: address - var $t8: &mut Test::R - var $t9: u64 - var $t10: u64 - var $t11: &mut u64 - 0: assume Gt($t0, 0) - 1: assume CanModify(0x0) - 2: @0 := save_mem(Test::R) - 3: $t2 := 0x0 - 4: $t3 := exists($t2) - 5: $t4 := !($t3) - 6: if ($t4) goto 7 else goto 11 - 7: label L1 - 8: $t5 := 33 - 9: $t6 := move($t5) - 10: goto 26 - 11: label L0 - 12: $t7 := 0x0 - # VC: caller does not have permission to modify `Test::R` at given address at tests/spec_instrumentation/fun_spec.move:36:14+17 - 13: assert CanModify($t7) - 14: $t8 := borrow_global($t7) on_abort goto 26 with $t6 - 15: $t9 := get_field.v($t8) - 16: $t10 := +($t9, $t0) on_abort goto 26 with $t6 - 17: $t11 := borrow_field.v($t8) - 18: write_ref($t11, $t10) - 19: write_back[Reference($t8).v (u64)]($t11) - 20: write_back[Test::R@]($t8) - 21: label L2 - # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:41:6+35 - 22: assert Not(Not(exists[@0](0x0))) - # VC: function does not abort under this condition at tests/spec_instrumentation/fun_spec.move:42:6+58 - 23: assert Not(Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) - # VC: post-condition does not hold at tests/spec_instrumentation/fun_spec.move:43:6+58 - 24: assert Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(global[@0](0x0)), $t0)) - 25: return () - 26: label L3 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/fun_spec.move:39:2+250 - 27: assert Or(Not(exists[@0](0x0)), Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) - # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/fun_spec.move:39:2+250 - 28: assert Or(And(Not(exists[@0](0x0)), Eq(33, $t6)), Ge(Add(select Test::R.v(global[@0](0x0)), $t0), 18446744073709551615)) - 29: abort($t6) -} - - - -==== spec-instrumenter input specs ==== - -fun Test::branching_result[baseline] -spec { - aborts_if And($t0, Eq($t2, 0)); - ensures Implies($t0, Eq(result0(), Div($t1, $t2))); - ensures Implies(Not($t0), Eq(result0(), Mul($t1, $t2))); -} - -fun Test::branching_result[verification] -spec { - aborts_if And($t0, Eq($t2, 0)); - ensures Implies($t0, Eq(result0(), Div($t1, $t2))); - ensures Implies(Not($t0), Eq(result0(), Mul($t1, $t2))); -} - -fun Test::implicit_and_explicit_abort[baseline] -spec { - aborts_if Eq($t1, 0); - aborts_if Eq($t0, 0); - ensures Eq(result0(), Div($t0, $t1)); -} - -fun Test::implicit_and_explicit_abort[verification] -spec { - aborts_if Eq($t1, 0); - aborts_if Eq($t0, 0); - ensures Eq(result0(), Div($t0, $t1)); -} - -fun Test::multiple_results[baseline] -spec { - aborts_if Eq($t1, 0); - ensures Eq(result0(), Div($t0, $t1)); - ensures Eq(result1(), Mod($t0, $t1)); -} - -fun Test::multiple_results[verification] -spec { - aborts_if Eq($t1, 0); - ensures Eq(result0(), Div($t0, $t1)); - ensures Eq(result1(), Mod($t0, $t1)); -} - -fun Test::mut_ref_param[baseline] -spec { - aborts_if Eq(select Test::R.v($t0), 0); - ensures Eq(result0(), Old(select Test::R.v($t0))); - ensures Eq(select Test::R.v($t0), Add(Old(select Test::R.v($t0)), 1)); -} - -fun Test::mut_ref_param[verification] -spec { - aborts_if Eq(select Test::R.v($t0), 0); - ensures Eq(result0(), Old(select Test::R.v($t0))); - ensures Eq(select Test::R.v($t0), Add(Old(select Test::R.v($t0)), 1)); -} - -fun Test::ref_param[baseline] -spec { - ensures Eq(result0(), select Test::R.v($t0)); -} - -fun Test::ref_param[verification] -spec { - ensures Eq(result0(), select Test::R.v($t0)); -} - -fun Test::ref_param_return_ref[baseline] -spec { - ensures Eq(result0(), select Test::R.v($t0)); -} - -fun Test::ref_param_return_ref[verification] -spec { - ensures Eq(result0(), select Test::R.v($t0)); -} - -fun Test::resource_with_old[baseline] -spec { - requires Gt($t0, 0); - aborts_if Not(exists(0x0)); - aborts_if Ge(Add(select Test::R.v(global(0x0)), $t0), 18446744073709551615); - ensures Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(Old(global(0x0))), $t0)); - modifies global(0x0); -} - -fun Test::resource_with_old[verification] -spec { - requires Gt($t0, 0); - aborts_if Not(exists(0x0)); - aborts_if Ge(Add(select Test::R.v(global(0x0)), $t0), 18446744073709551615); - ensures Eq(select Test::R.v(global(0x0)), Add(select Test::R.v(Old(global(0x0))), $t0)); - modifies global(0x0); -} diff --git a/third_party/move/move-model/bytecode/tests/spec_instrumentation/fun_spec.move b/third_party/move/move-model/bytecode/tests/spec_instrumentation/fun_spec.move deleted file mode 100644 index 5d4a943f1f2b61..00000000000000 --- a/third_party/move/move-model/bytecode/tests/spec_instrumentation/fun_spec.move +++ /dev/null @@ -1,72 +0,0 @@ -// Contains tests for treatment of function specifications. -module 0x42::Test { - - fun implicit_and_explicit_abort(a: u64, b: u64): u64 { - if (b != 0) abort(22); - a / b - } - spec implicit_and_explicit_abort { - aborts_if b == 0 with 22; - aborts_if a == 0; - ensures result == a / b; - } - - fun multiple_results(a: u64, b: u64): (u64, u64) { - (a / b, a % b) - } - spec multiple_results { - aborts_if b == 0 with EXECUTION_FAILURE; - ensures result_1 == a / b; - ensures result_2 == a % b; - } - - fun branching_result(is_div: bool, a: u64, b: u64): u64 { - if (is_div) a / b else a * b - } - spec branching_result { - aborts_if is_div && b == 0 with EXECUTION_FAILURE; - ensures is_div ==> result == a / b; - ensures !is_div ==> result == a * b; - } - - struct R has key { v: u64 } - - fun resource_with_old(val: u64) acquires R { - if (!exists(@0x0)) abort 33; - let r = borrow_global_mut(@0x0); - r.v = r.v + val; - } - spec resource_with_old { - requires val > 0; - aborts_if !exists(@0x0) with 33; - aborts_if global(@0x0).v + val >= 18446744073709551615; - ensures global(@0x0).v == old(global(@0x0)).v + val; - modifies global(@0x0); - } - - fun ref_param(r: &R): u64 { - r.v - } - spec ref_param { - ensures result == r.v; - } - - fun ref_param_return_ref(r: &R): &u64 { - &r.v - } - spec ref_param_return_ref { - ensures result == r.v; - } - - fun mut_ref_param(r: &mut R): u64 { - let x = r.v; - r.v = r.v - 1; - x - } - spec mut_ref_param { - aborts_if r.v == 0 with EXECUTION_FAILURE; - ensures result == old(r.v); - ensures r.v == old(r.v) + 1; - } - -} diff --git a/third_party/move/move-model/bytecode/tests/spec_instrumentation/generics.exp b/third_party/move/move-model/bytecode/tests/spec_instrumentation/generics.exp deleted file mode 100644 index 82dcdda4e77a4e..00000000000000 --- a/third_party/move/move-model/bytecode/tests/spec_instrumentation/generics.exp +++ /dev/null @@ -1,94 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun Generics::remove<#0>($t0|a: address): Generics::R<#0> { - var $t1: address - var $t2: Generics::R<#0> - 0: $t1 := move($t0) - 1: $t2 := move_from>($t1) - 2: return $t2 -} - - -[variant baseline] -fun Generics::remove_u64($t0|a: address): Generics::R { - var $t1: address - var $t2: Generics::R - 0: $t1 := move($t0) - 1: $t2 := Generics::remove($t1) - 2: return $t2 -} - -============ after pipeline `spec_instrumentation` ================ - -[variant verification] -fun Generics::remove<#0>($t0|a: address): Generics::R<#0> { - var $t1: Generics::R<#0> - var $t2: num - 0: assume CanModify>($t0) - # VC: caller does not have permission to modify `Generics::R<#0>` at given address at tests/spec_instrumentation/generics.move:11:9+9 - 1: assert CanModify>($t0) - 2: $t1 := move_from>($t0) on_abort goto 6 with $t2 - 3: label L1 - # VC: post-condition does not hold at tests/spec_instrumentation/generics.move:20:9+25 - 4: assert Not(exists>($t0)) - 5: return $t1 - 6: label L2 - 7: abort($t2) -} - - -[variant verification] -fun Generics::remove_u64($t0|a: address): Generics::R { - var $t1: Generics::R - var $t2: bool - var $t3: num - 0: assume CanModify>($t0) - # VC: caller does not have permission to modify `Generics::R` at given address at tests/spec_instrumentation/generics.move:24:9+14 - 1: assert CanModify>($t0) - 2: $t1 := opaque begin: Generics::remove($t0) - 3: $t2 := havoc[val]() - 4: if ($t2) goto 5 else goto 8 - 5: label L4 - 6: trace_abort($t3) - 7: goto 16 - 8: label L3 - 9: modifies global>($t0) - 10: assume WellFormed($t1) - 11: assume Not(exists>($t0)) - 12: $t1 := opaque end: Generics::remove($t0) - 13: label L1 - # VC: post-condition does not hold at tests/spec_instrumentation/generics.move:20:9+25 - 14: assert Not(exists>($t0)) - 15: return $t1 - 16: label L2 - 17: abort($t3) -} - - - -==== spec-instrumenter input specs ==== - -fun Generics::remove[baseline] -spec { - modifies global>($t0); - ensures Not(exists>($t0)); -} - -fun Generics::remove[verification] -spec { - modifies global>($t0); - ensures Not(exists>($t0)); -} - -fun Generics::remove_u64[baseline] -spec { - modifies global>($t0); - ensures Not(exists>($t0)); -} - -fun Generics::remove_u64[verification] -spec { - modifies global>($t0); - ensures Not(exists>($t0)); -} diff --git a/third_party/move/move-model/bytecode/tests/spec_instrumentation/generics.move b/third_party/move/move-model/bytecode/tests/spec_instrumentation/generics.move deleted file mode 100644 index 70d7bc795804b9..00000000000000 --- a/third_party/move/move-model/bytecode/tests/spec_instrumentation/generics.move +++ /dev/null @@ -1,29 +0,0 @@ -// flag: --v2 -module 0x42::Generics { - - spec module { - pragma verify = true; - } - - struct R has key { x: T } - - fun remove(a: address): R acquires R { - move_from>(a) - } - spec remove { - pragma opaque; - include Remove; - } - spec schema Remove { - a: address; - modifies global>(a); - ensures !exists>(a); - } - - fun remove_u64(a: address): R acquires R { - remove(a) - } - spec remove_u64 { - include Remove; - } -} diff --git a/third_party/move/move-model/bytecode/tests/spec_instrumentation/modifies.exp b/third_party/move/move-model/bytecode/tests/spec_instrumentation/modifies.exp deleted file mode 100644 index b30e8e98e0df1e..00000000000000 --- a/third_party/move/move-model/bytecode/tests/spec_instrumentation/modifies.exp +++ /dev/null @@ -1,537 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -public fun A::mutate_at($t0|addr: address) { - var $t1|s: &mut A::S - var $t2: address - var $t3: &mut A::S - var $t4: u64 - var $t5: &mut A::S - var $t6: &mut u64 - 0: $t2 := move($t0) - 1: $t3 := borrow_global($t2) - 2: $t1 := $t3 - 3: $t4 := 2 - 4: $t5 := move($t1) - 5: $t6 := borrow_field.x($t5) - 6: write_ref($t6, $t4) - 7: return () -} - - -[variant baseline] -public fun A::read_at($t0|addr: address): u64 { - var $t1: address - var $t2: &A::S - var $t3: &u64 - var $t4: u64 - 0: $t1 := move($t0) - 1: $t2 := borrow_global($t1) - 2: $t3 := borrow_field.x($t2) - 3: $t4 := read_ref($t3) - 4: return $t4 -} - - -[variant baseline] -public fun B::move_from_test_incorrect($t0|addr1: address, $t1|addr2: address): B::T { - var $t2|v: B::T - var $t3|x0: u64 - var $t4|x1: u64 - var $t5: address - var $t6: u64 - var $t7: address - var $t8: B::T - var $t9: address - var $t10: u64 - var $t11: B::T - 0: $t5 := copy($t1) - 1: $t6 := A::read_at($t5) - 2: $t3 := $t6 - 3: $t7 := move($t0) - 4: $t8 := move_from($t7) - 5: $t2 := $t8 - 6: $t9 := move($t1) - 7: $t10 := A::read_at($t9) - 8: $t4 := $t10 - 9: assert Eq($t3, $t4) - 10: $t11 := move($t2) - 11: return $t11 -} - - -[variant baseline] -public fun B::move_to_test_incorrect($t0|account: &signer, $t1|addr2: address) { - var $t2|x0: u64 - var $t3|x1: u64 - var $t4: address - var $t5: u64 - var $t6: &signer - var $t7: u64 - var $t8: B::T - var $t9: address - var $t10: u64 - 0: $t4 := copy($t1) - 1: $t5 := A::read_at($t4) - 2: $t2 := $t5 - 3: $t6 := move($t0) - 4: $t7 := 2 - 5: $t8 := pack B::T($t7) - 6: move_to($t8, $t6) - 7: $t9 := move($t1) - 8: $t10 := A::read_at($t9) - 9: $t3 := $t10 - 10: assert Eq($t2, $t3) - 11: return () -} - - -[variant baseline] -public fun B::mutate_S_test1_incorrect($t0|addr1: address, $t1|addr2: address) { - var $t2|x0: u64 - var $t3|x1: u64 - var $t4: address - var $t5: u64 - var $t6: address - var $t7: address - var $t8: u64 - 0: $t4 := copy($t1) - 1: $t5 := A::read_at($t4) - 2: $t2 := $t5 - 3: $t6 := move($t0) - 4: A::mutate_at($t6) - 5: $t7 := move($t1) - 6: $t8 := A::read_at($t7) - 7: $t3 := $t8 - 8: assert Eq($t2, $t3) - 9: return () -} - - -[variant baseline] -public fun B::mutate_S_test2_incorrect($t0|addr: address) { - var $t1|x0: u64 - var $t2|x1: u64 - var $t3: address - var $t4: u64 - var $t5: address - var $t6: address - var $t7: u64 - 0: $t3 := copy($t0) - 1: $t4 := A::read_at($t3) - 2: $t1 := $t4 - 3: $t5 := copy($t0) - 4: A::mutate_at($t5) - 5: $t6 := move($t0) - 6: $t7 := A::read_at($t6) - 7: $t2 := $t7 - 8: assert Eq($t1, $t2) - 9: return () -} - - -[variant baseline] -public fun B::mutate_at_test_incorrect($t0|addr1: address, $t1|addr2: address) { - var $t2|t: &mut B::T - var $t3|x0: u64 - var $t4|x1: u64 - var $t5: address - var $t6: u64 - var $t7: address - var $t8: &mut B::T - var $t9: u64 - var $t10: &mut B::T - var $t11: &mut u64 - var $t12: address - var $t13: u64 - 0: $t5 := copy($t1) - 1: $t6 := A::read_at($t5) - 2: $t3 := $t6 - 3: $t7 := move($t0) - 4: $t8 := borrow_global($t7) - 5: $t2 := $t8 - 6: $t9 := 2 - 7: $t10 := move($t2) - 8: $t11 := borrow_field.x($t10) - 9: write_ref($t11, $t9) - 10: $t12 := move($t1) - 11: $t13 := A::read_at($t12) - 12: $t4 := $t13 - 13: assert Eq($t3, $t4) - 14: return () -} - -============ after pipeline `spec_instrumentation` ================ - -[variant verification] -public fun A::mutate_at($t0|addr: address) { - var $t1|s: &mut A::S - var $t2: &mut A::S - var $t3: num - var $t4: u64 - var $t5: &mut u64 - 0: assume CanModify($t0) - 1: @1 := save_mem(A::S) - # VC: caller does not have permission to modify `A::S` at given address at tests/spec_instrumentation/modifies.move:18:17+17 - 2: assert CanModify($t0) - 3: $t2 := borrow_global($t0) on_abort goto 13 with $t3 - 4: $t4 := 2 - 5: $t5 := borrow_field.x($t2) - 6: write_ref($t5, $t4) - 7: write_back[Reference($t2).x (u64)]($t5) - 8: write_back[A::S@]($t2) - 9: label L1 - # VC: function does not abort under this condition at tests/spec_instrumentation/modifies.move:24:9+27 - 10: assert Not(Not(exists[@1]($t0))) - # VC: post-condition does not hold at tests/spec_instrumentation/modifies.move:23:9+31 - 11: assert Eq(select A::S.x(global($t0)), 2) - 12: return () - 13: label L2 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/modifies.move:21:5+162 - 14: assert Not(exists[@1]($t0)) - 15: abort($t3) -} - - -[variant verification] -public fun A::read_at($t0|addr: address): u64 { - var $t1: A::S - var $t2: num - var $t3: u64 - 0: @0 := save_mem(A::S) - 1: $t1 := get_global($t0) on_abort goto 7 with $t2 - 2: $t3 := get_field.x($t1) - 3: label L1 - # VC: function does not abort under this condition at tests/spec_instrumentation/modifies.move:13:9+27 - 4: assert Not(Not(exists[@0]($t0))) - # VC: post-condition does not hold at tests/spec_instrumentation/modifies.move:14:9+36 - 5: assert Eq($t3, select A::S.x(global($t0))) - 6: return $t3 - 7: label L2 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/modifies.move:11:5+131 - 8: assert Not(exists[@0]($t0)) - 9: abort($t2) -} - - -[variant verification] -public fun B::move_from_test_incorrect($t0|addr1: address, $t1|addr2: address): B::T { - var $t2|v: B::T - var $t3|x0: u64 - var $t4|x1: u64 - var $t5: u64 - var $t6: bool - var $t7: num - var $t8: B::T - var $t9: u64 - var $t10: bool - 0: assume CanModify($t1) - 1: $t5 := opaque begin: A::read_at($t1) - 2: assume Identical($t6, Not(exists($t1))) - 3: if ($t6) goto 4 else goto 7 - 4: label L4 - 5: trace_abort($t7) - 6: goto 26 - 7: label L3 - 8: assume WellFormed($t5) - 9: assume Eq($t5, select A::S.x(global($t1))) - 10: $t5 := opaque end: A::read_at($t1) - # VC: caller does not have permission to modify `B::T` at given address at tests/spec_instrumentation/modifies.move:65:17+9 - 11: assert CanModify($t0) - 12: $t8 := move_from($t0) on_abort goto 26 with $t7 - 13: $t9 := opaque begin: A::read_at($t1) - 14: assume Identical($t10, Not(exists($t1))) - 15: if ($t10) goto 16 else goto 19 - 16: label L6 - 17: trace_abort($t7) - 18: goto 26 - 19: label L5 - 20: assume WellFormed($t9) - 21: assume Eq($t9, select A::S.x(global($t1))) - 22: $t9 := opaque end: A::read_at($t1) - 23: assert Eq($t5, $t9) - 24: label L1 - 25: return $t8 - 26: label L2 - 27: abort($t7) -} - - -[variant verification] -public fun B::move_to_test_incorrect($t0|account: signer, $t1|addr2: address) { - var $t2|x0: u64 - var $t3|x1: u64 - var $t4: u64 - var $t5: bool - var $t6: num - var $t7: u64 - var $t8: B::T - var $t9: u64 - var $t10: bool - 0: assume CanModify($t1) - 1: $t4 := opaque begin: A::read_at($t1) - 2: assume Identical($t5, Not(exists($t1))) - 3: if ($t5) goto 4 else goto 7 - 4: label L4 - 5: trace_abort($t6) - 6: goto 28 - 7: label L3 - 8: assume WellFormed($t4) - 9: assume Eq($t4, select A::S.x(global($t1))) - 10: $t4 := opaque end: A::read_at($t1) - 11: $t7 := 2 - 12: $t8 := pack B::T($t7) - # VC: caller does not have permission to modify `B::T` at given address at tests/spec_instrumentation/modifies.move:52:9+7 - 13: assert CanModify($t0) - 14: move_to($t8, $t0) on_abort goto 28 with $t6 - 15: $t9 := opaque begin: A::read_at($t1) - 16: assume Identical($t10, Not(exists($t1))) - 17: if ($t10) goto 18 else goto 21 - 18: label L6 - 19: trace_abort($t6) - 20: goto 28 - 21: label L5 - 22: assume WellFormed($t9) - 23: assume Eq($t9, select A::S.x(global($t1))) - 24: $t9 := opaque end: A::read_at($t1) - 25: assert Eq($t4, $t9) - 26: label L1 - 27: return () - 28: label L2 - 29: abort($t6) -} - - -[variant verification] -public fun B::mutate_S_test1_incorrect($t0|addr1: address, $t1|addr2: address) { - var $t2|x0: u64 - var $t3|x1: u64 - var $t4: u64 - var $t5: bool - var $t6: num - var $t7: bool - var $t8: u64 - var $t9: bool - 0: assume Neq
($t0, $t1) - 1: assume CanModify($t1) - 2: $t4 := opaque begin: A::read_at($t1) - 3: assume Identical($t5, Not(exists($t1))) - 4: if ($t5) goto 5 else goto 8 - 5: label L4 - 6: trace_abort($t6) - 7: goto 36 - 8: label L3 - 9: assume WellFormed($t4) - 10: assume Eq($t4, select A::S.x(global($t1))) - 11: $t4 := opaque end: A::read_at($t1) - # VC: caller does not have permission to modify `A::S` at given address at tests/spec_instrumentation/modifies.move:79:9+19 - 12: assert CanModify($t0) - 13: opaque begin: A::mutate_at($t0) - 14: assume Identical($t7, Not(exists($t0))) - 15: if ($t7) goto 16 else goto 19 - 16: label L6 - 17: trace_abort($t6) - 18: goto 36 - 19: label L5 - 20: modifies global($t0) - 21: assume Eq(select A::S.x(global($t0)), 2) - 22: opaque end: A::mutate_at($t0) - 23: $t8 := opaque begin: A::read_at($t1) - 24: assume Identical($t9, Not(exists($t1))) - 25: if ($t9) goto 26 else goto 29 - 26: label L8 - 27: trace_abort($t6) - 28: goto 36 - 29: label L7 - 30: assume WellFormed($t8) - 31: assume Eq($t8, select A::S.x(global($t1))) - 32: $t8 := opaque end: A::read_at($t1) - 33: assert Eq($t4, $t8) - 34: label L1 - 35: return () - 36: label L2 - 37: abort($t6) -} - - -[variant verification] -public fun B::mutate_S_test2_incorrect($t0|addr: address) { - var $t1|x0: u64 - var $t2|x1: u64 - var $t3: u64 - var $t4: bool - var $t5: num - var $t6: bool - var $t7: u64 - var $t8: bool - 0: assume CanModify($t0) - 1: $t3 := opaque begin: A::read_at($t0) - 2: assume Identical($t4, Not(exists($t0))) - 3: if ($t4) goto 4 else goto 7 - 4: label L4 - 5: trace_abort($t5) - 6: goto 35 - 7: label L3 - 8: assume WellFormed($t3) - 9: assume Eq($t3, select A::S.x(global($t0))) - 10: $t3 := opaque end: A::read_at($t0) - # VC: caller does not have permission to modify `A::S` at given address at tests/spec_instrumentation/modifies.move:92:9+18 - 11: assert CanModify($t0) - 12: opaque begin: A::mutate_at($t0) - 13: assume Identical($t6, Not(exists($t0))) - 14: if ($t6) goto 15 else goto 18 - 15: label L6 - 16: trace_abort($t5) - 17: goto 35 - 18: label L5 - 19: modifies global($t0) - 20: assume Eq(select A::S.x(global($t0)), 2) - 21: opaque end: A::mutate_at($t0) - 22: $t7 := opaque begin: A::read_at($t0) - 23: assume Identical($t8, Not(exists($t0))) - 24: if ($t8) goto 25 else goto 28 - 25: label L8 - 26: trace_abort($t5) - 27: goto 35 - 28: label L7 - 29: assume WellFormed($t7) - 30: assume Eq($t7, select A::S.x(global($t0))) - 31: $t7 := opaque end: A::read_at($t0) - 32: assert Eq($t3, $t7) - 33: label L1 - 34: return () - 35: label L2 - 36: abort($t5) -} - - -[variant verification] -public fun B::mutate_at_test_incorrect($t0|addr1: address, $t1|addr2: address) { - var $t2|t: &mut B::T - var $t3|x0: u64 - var $t4|x1: u64 - var $t5: u64 - var $t6: bool - var $t7: num - var $t8: &mut B::T - var $t9: u64 - var $t10: &mut u64 - var $t11: u64 - var $t12: bool - 0: assume CanModify($t1) - 1: $t5 := opaque begin: A::read_at($t1) - 2: assume Identical($t6, Not(exists($t1))) - 3: if ($t6) goto 4 else goto 7 - 4: label L4 - 5: trace_abort($t7) - 6: goto 31 - 7: label L3 - 8: assume WellFormed($t5) - 9: assume Eq($t5, select A::S.x(global($t1))) - 10: $t5 := opaque end: A::read_at($t1) - # VC: caller does not have permission to modify `B::T` at given address at tests/spec_instrumentation/modifies.move:38:17+17 - 11: assert CanModify($t0) - 12: $t8 := borrow_global($t0) on_abort goto 31 with $t7 - 13: $t9 := 2 - 14: $t10 := borrow_field.x($t8) - 15: write_ref($t10, $t9) - 16: write_back[Reference($t8).x (u64)]($t10) - 17: write_back[B::T@]($t8) - 18: $t11 := opaque begin: A::read_at($t1) - 19: assume Identical($t12, Not(exists($t1))) - 20: if ($t12) goto 21 else goto 24 - 21: label L6 - 22: trace_abort($t7) - 23: goto 31 - 24: label L5 - 25: assume WellFormed($t11) - 26: assume Eq($t11, select A::S.x(global($t1))) - 27: $t11 := opaque end: A::read_at($t1) - 28: assert Eq($t5, $t11) - 29: label L1 - 30: return () - 31: label L2 - 32: abort($t7) -} - - - -==== spec-instrumenter input specs ==== - -fun A::mutate_at[baseline] -spec { - ensures Eq(select A::S.x(global($t0)), 2); - aborts_if Not(exists($t0)); - modifies global($t0); -} - -fun A::mutate_at[verification] -spec { - ensures Eq(select A::S.x(global($t0)), 2); - aborts_if Not(exists($t0)); - modifies global($t0); -} - -fun A::read_at[baseline] -spec { - aborts_if Not(exists($t0)); - ensures Eq(result0(), select A::S.x(global($t0))); -} - -fun A::read_at[verification] -spec { - aborts_if Not(exists($t0)); - ensures Eq(result0(), select A::S.x(global($t0))); -} - -fun B::move_from_test_incorrect[baseline] -spec { - modifies global($t1); -} - -fun B::move_from_test_incorrect[verification] -spec { - modifies global($t1); -} - -fun B::move_to_test_incorrect[baseline] -spec { - modifies global($t1); -} - -fun B::move_to_test_incorrect[verification] -spec { - modifies global($t1); -} - -fun B::mutate_S_test1_incorrect[baseline] -spec { - requires Neq
($t0, $t1); - modifies global($t1); -} - -fun B::mutate_S_test1_incorrect[verification] -spec { - requires Neq
($t0, $t1); - modifies global($t1); -} - -fun B::mutate_S_test2_incorrect[baseline] -spec { - modifies global($t0); -} - -fun B::mutate_S_test2_incorrect[verification] -spec { - modifies global($t0); -} - -fun B::mutate_at_test_incorrect[baseline] -spec { - modifies global($t1); -} - -fun B::mutate_at_test_incorrect[verification] -spec { - modifies global($t1); -} diff --git a/third_party/move/move-model/bytecode/tests/spec_instrumentation/modifies.move b/third_party/move/move-model/bytecode/tests/spec_instrumentation/modifies.move deleted file mode 100644 index 243d2a0eab7600..00000000000000 --- a/third_party/move/move-model/bytecode/tests/spec_instrumentation/modifies.move +++ /dev/null @@ -1,102 +0,0 @@ -// flag: --v2 -address 0x0 { -module A { - struct S has key { - x: u64 - } - public fun read_at(addr: address): u64 acquires S { - let s = borrow_global(addr); - s.x - } - spec read_at { - pragma opaque = true; - aborts_if !exists(addr); - ensures result == global(addr).x; - } - - public fun mutate_at(addr: address) acquires S { - let s = borrow_global_mut(addr); - s.x = 2; - } - spec mutate_at { - pragma opaque = true; - ensures global(addr).x == 2; - aborts_if !exists(addr); - modifies global(addr); - } -} - -module B { - use 0x0::A; - - struct T has key { - x: u64 - } - - public fun mutate_at_test_incorrect(addr1: address, addr2: address) acquires T { - let x0 = A::read_at(addr2); - let t = borrow_global_mut(addr1); - t.x = 2; - let x1 = A::read_at(addr2); - spec { - assert x0 == x1; - }; - } - spec mutate_at_test_incorrect { - pragma opaque = true; - modifies global(addr2); - } - - public fun move_to_test_incorrect(account: &signer, addr2: address) { - let x0 = A::read_at(addr2); - move_to(account, T{x: 2}); - let x1 = A::read_at(addr2); - spec { - assert x0 == x1; - }; - } - spec move_to_test_incorrect { - pragma opaque = true; - modifies global(addr2); - } - - public fun move_from_test_incorrect(addr1: address, addr2: address): T acquires T { - let x0 = A::read_at(addr2); - let v = move_from(addr1); - let x1 = A::read_at(addr2); - spec { - assert x0 == x1; - }; - v - } - spec move_from_test_incorrect { - pragma opaque = true; - modifies global(addr2); - } - - public fun mutate_S_test1_incorrect(addr1: address, addr2: address) { - let x0 = A::read_at(addr2); - A::mutate_at(addr1); - let x1 = A::read_at(addr2); - spec { - assert x0 == x1; - }; - } - spec mutate_S_test1_incorrect { - requires addr1 != addr2; - modifies global(addr2); - } - - public fun mutate_S_test2_incorrect(addr: address) { - let x0 = A::read_at(addr); - A::mutate_at(addr); - let x1 = A::read_at(addr); - spec { - assert x0 == x1; - }; - } - spec mutate_S_test2_incorrect { - modifies global(addr); - } -} -} diff --git a/third_party/move/move-model/bytecode/tests/spec_instrumentation/opaque_call.exp b/third_party/move/move-model/bytecode/tests/spec_instrumentation/opaque_call.exp deleted file mode 100644 index 405255224cce71..00000000000000 --- a/third_party/move/move-model/bytecode/tests/spec_instrumentation/opaque_call.exp +++ /dev/null @@ -1,218 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun Test::get_and_incr($t0|addr: address): u64 { - var $t1|r: &mut Test::R - var $t2|v: u64 - var $t3: address - var $t4: bool - var $t5: bool - var $t6: u64 - var $t7: address - var $t8: &mut Test::R - var $t9: &mut Test::R - var $t10: &u64 - var $t11: u64 - var $t12: &mut Test::R - var $t13: &u64 - var $t14: u64 - var $t15: u64 - var $t16: u64 - var $t17: &mut Test::R - var $t18: &mut u64 - var $t19: u64 - 0: $t3 := copy($t0) - 1: $t4 := exists($t3) - 2: $t5 := !($t4) - 3: if ($t5) goto 4 else goto 7 - 4: label L1 - 5: $t6 := 33 - 6: abort($t6) - 7: label L0 - 8: $t7 := move($t0) - 9: $t8 := borrow_global($t7) - 10: $t1 := $t8 - 11: $t9 := copy($t1) - 12: $t10 := borrow_field.v($t9) - 13: $t11 := read_ref($t10) - 14: $t2 := $t11 - 15: $t12 := copy($t1) - 16: $t13 := borrow_field.v($t12) - 17: $t14 := read_ref($t13) - 18: $t15 := 1 - 19: $t16 := +($t14, $t15) - 20: $t17 := move($t1) - 21: $t18 := borrow_field.v($t17) - 22: write_ref($t18, $t16) - 23: $t19 := move($t2) - 24: return $t19 -} - - -[variant baseline] -fun Test::incr_twice() { - var $t0: address - var $t1: u64 - var $t2: address - var $t3: u64 - 0: $t0 := 0x1 - 1: $t1 := Test::get_and_incr($t0) - 2: destroy($t1) - 3: $t2 := 0x1 - 4: $t3 := Test::get_and_incr($t2) - 5: destroy($t3) - 6: return () -} - -============ after pipeline `spec_instrumentation` ================ - -[variant verification] -fun Test::get_and_incr($t0|addr: address): u64 { - var $t1|r: &mut Test::R - var $t2|v: u64 - var $t3: bool - var $t4: bool - var $t5: u64 - var $t6: num - var $t7: &mut Test::R - var $t8: u64 - var $t9: u64 - var $t10: u64 - var $t11: u64 - var $t12: &mut u64 - 0: assume Neq
($t0, 0x0) - 1: assume CanModify($t0) - 2: @0 := save_mem(Test::R) - 3: $t3 := exists($t0) - 4: $t4 := !($t3) - 5: if ($t4) goto 6 else goto 10 - 6: label L1 - 7: $t5 := 33 - 8: $t6 := move($t5) - 9: goto 27 - 10: label L0 - # VC: caller does not have permission to modify `Test::R` at given address at tests/spec_instrumentation/opaque_call.move:8:14+17 - 11: assert CanModify($t0) - 12: $t7 := borrow_global($t0) on_abort goto 27 with $t6 - 13: $t8 := get_field.v($t7) - 14: $t9 := get_field.v($t7) - 15: $t10 := 1 - 16: $t11 := +($t9, $t10) on_abort goto 27 with $t6 - 17: $t12 := borrow_field.v($t7) - 18: write_ref($t12, $t11) - 19: write_back[Reference($t7).v (u64)]($t12) - 20: write_back[Test::R@]($t7) - 21: label L2 - # VC: function does not abort under this condition at tests/spec_instrumentation/opaque_call.move:16:6+35 - 22: assert Not(Not(exists[@0]($t0))) - # VC: function does not abort under this condition at tests/spec_instrumentation/opaque_call.move:17:6+56 - 23: assert Not(Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) - # VC: post-condition does not hold at tests/spec_instrumentation/opaque_call.move:19:6+56 - 24: assert Eq(select Test::R.v(global($t0)), Add(select Test::R.v(global[@0]($t0)), 1)) - # VC: post-condition does not hold at tests/spec_instrumentation/opaque_call.move:20:6+36 - 25: assert Eq($t8, select Test::R.v(global($t0))) - 26: return $t8 - 27: label L3 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/opaque_call.move:13:2+308 - 28: assert Or(Not(exists[@0]($t0)), Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) - # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/opaque_call.move:13:2+308 - 29: assert Or(And(Not(exists[@0]($t0)), Eq(33, $t6)), Ge(Add(select Test::R.v(global[@0]($t0)), 1), 18446744073709551615)) - 30: abort($t6) -} - - -[variant verification] -fun Test::incr_twice() { - var $t0: address - var $t1: u64 - var $t2: bool - var $t3: num - var $t4: address - var $t5: u64 - var $t6: bool - 0: @1 := save_mem(Test::R) - 1: $t0 := 0x1 - # VC: precondition does not hold at this call at tests/spec_instrumentation/opaque_call.move:15:6+22 - 2: assert Neq
($t0, 0x0) - 3: $t1 := opaque begin: Test::get_and_incr($t0) - 4: assume Identical($t2, Or(Not(exists($t0)), Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615))) - 5: if ($t2) goto 6 else goto 10 - 6: label L4 - 7: assume Or(And(Not(exists($t0)), Eq(33, $t3)), Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615)) - 8: trace_abort($t3) - 9: goto 39 - 10: label L3 - 11: @2 := save_mem(Test::R) - 12: modifies global($t0) - 13: assume WellFormed($t1) - 14: assume Eq(select Test::R.v(global($t0)), Add(select Test::R.v(global[@2]($t0)), 1)) - 15: assume Eq($t1, select Test::R.v(global($t0))) - 16: $t1 := opaque end: Test::get_and_incr($t0) - 17: destroy($t1) - 18: $t4 := 0x1 - # VC: precondition does not hold at this call at tests/spec_instrumentation/opaque_call.move:15:6+22 - 19: assert Neq
($t4, 0x0) - 20: $t5 := opaque begin: Test::get_and_incr($t4) - 21: assume Identical($t6, Or(Not(exists($t4)), Ge(Add(select Test::R.v(global($t4)), 1), 18446744073709551615))) - 22: if ($t6) goto 23 else goto 27 - 23: label L6 - 24: assume Or(And(Not(exists($t4)), Eq(33, $t3)), Ge(Add(select Test::R.v(global($t4)), 1), 18446744073709551615)) - 25: trace_abort($t3) - 26: goto 39 - 27: label L5 - 28: @3 := save_mem(Test::R) - 29: modifies global($t4) - 30: assume WellFormed($t5) - 31: assume Eq(select Test::R.v(global($t4)), Add(select Test::R.v(global[@3]($t4)), 1)) - 32: assume Eq($t5, select Test::R.v(global($t4))) - 33: $t5 := opaque end: Test::get_and_incr($t4) - 34: destroy($t5) - 35: label L1 - # VC: function does not abort under this condition at tests/spec_instrumentation/opaque_call.move:28:6+35 - 36: assert Not(Not(exists[@1](0x1))) - # VC: post-condition does not hold at tests/spec_instrumentation/opaque_call.move:29:6+56 - 37: assert Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(global[@1](0x1)), 2)) - 38: return () - 39: label L2 - # VC: abort not covered by any of the `aborts_if` clauses at tests/spec_instrumentation/opaque_call.move:27:2+123 - 40: assert Not(exists[@1](0x1)) - # VC: abort code not covered by any of the `aborts_if` or `aborts_with` clauses at tests/spec_instrumentation/opaque_call.move:27:2+123 - 41: assert And(Not(exists[@1](0x1)), Eq(33, $t3)) - 42: abort($t3) -} - - - -==== spec-instrumenter input specs ==== - -fun Test::get_and_incr[baseline] -spec { - requires Neq
($t0, 0x0); - aborts_if Not(exists($t0)); - aborts_if Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615); - modifies global($t0); - ensures Eq(select Test::R.v(global($t0)), Add(select Test::R.v(Old(global($t0))), 1)); - ensures Eq(result0(), select Test::R.v(global($t0))); -} - -fun Test::get_and_incr[verification] -spec { - requires Neq
($t0, 0x0); - aborts_if Not(exists($t0)); - aborts_if Ge(Add(select Test::R.v(global($t0)), 1), 18446744073709551615); - modifies global($t0); - ensures Eq(select Test::R.v(global($t0)), Add(select Test::R.v(Old(global($t0))), 1)); - ensures Eq(result0(), select Test::R.v(global($t0))); -} - -fun Test::incr_twice[baseline] -spec { - aborts_if Not(exists(0x1)); - ensures Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(Old(global(0x1))), 2)); -} - -fun Test::incr_twice[verification] -spec { - aborts_if Not(exists(0x1)); - ensures Eq(select Test::R.v(global(0x1)), Add(select Test::R.v(Old(global(0x1))), 2)); -} diff --git a/third_party/move/move-model/bytecode/tests/spec_instrumentation/opaque_call.move b/third_party/move/move-model/bytecode/tests/spec_instrumentation/opaque_call.move deleted file mode 100644 index e80c77e0a3bdd6..00000000000000 --- a/third_party/move/move-model/bytecode/tests/spec_instrumentation/opaque_call.move +++ /dev/null @@ -1,31 +0,0 @@ -// Contains tests for treatment of opaque calls -module 0x42::Test { - - struct R has key { v: u64 } - - fun get_and_incr(addr: address): u64 acquires R { - if (!exists(addr)) abort 33; - let r = borrow_global_mut(addr); - let v = r.v; - r.v = r.v + 1; - v - } - spec get_and_incr { - pragma opaque; - requires addr != @0x0; - aborts_if !exists(addr) with 33; - aborts_if global(addr).v + 1 >= 18446744073709551615; - modifies global(addr); - ensures global(addr).v == old(global(addr)).v + 1; - ensures result == global(addr).v; - } - - fun incr_twice() acquires R { - get_and_incr(@0x1); - get_and_incr(@0x1); - } - spec incr_twice { - aborts_if !exists(@0x1) with 33; - ensures global(@0x1).v == old(global(@0x1)).v + 2; - } -} diff --git a/third_party/move/move-model/bytecode/tests/testsuite.rs b/third_party/move/move-model/bytecode/tests/testsuite.rs index 62e6c307e1b0c5..eeb2344aed2f0d 100644 --- a/third_party/move/move-model/bytecode/tests/testsuite.rs +++ b/third_party/move/move-model/bytecode/tests/testsuite.rs @@ -3,32 +3,10 @@ // SPDX-License-Identifier: Apache-2.0 use anyhow::anyhow; -use codespan_reporting::{diagnostic::Severity, term::termcolor::Buffer}; -use move_command_line_common::testing::EXP_EXT; -use move_compiler::shared::{known_attributes::KnownAttribute, PackagePaths}; -use move_model::{model::GlobalEnv, options::ModelBuilderOptions, run_model_builder_with_options}; -use move_prover_test_utils::{baseline_test::verify_or_update_baseline, extract_test_directives}; use move_stackless_bytecode::{ - borrow_analysis::BorrowAnalysisProcessor, - clean_and_optimize::CleanAndOptimizeProcessor, - data_invariant_instrumentation::DataInvariantInstrumentationProcessor, - eliminate_imm_refs::EliminateImmRefsProcessor, - function_target_pipeline::{ - FunctionTargetPipeline, FunctionTargetsHolder, ProcessorResultDisplay, - }, - global_invariant_analysis::GlobalInvariantAnalysisProcessor, - global_invariant_instrumentation::GlobalInvariantInstrumentationProcessor, - livevar_analysis::LiveVarAnalysisProcessor, - memory_instrumentation::MemoryInstrumentationProcessor, - mono_analysis::MonoAnalysisProcessor, - mut_ref_instrumentation::MutRefInstrumenter, - options::ProverOptions, - print_targets_for_test, - reaching_def_analysis::ReachingDefProcessor, - spec_instrumentation::SpecInstrumentationProcessor, + borrow_analysis::BorrowAnalysisProcessor, function_target_pipeline::FunctionTargetPipeline, + livevar_analysis::LiveVarAnalysisProcessor, reaching_def_analysis::ReachingDefProcessor, usage_analysis::UsageProcessor, - verification_analysis::VerificationAnalysisProcessor, - well_formed_instrumentation::WellFormedInstrumentationProcessor, }; use std::path::Path; @@ -37,36 +15,19 @@ fn get_tested_transformation_pipeline( ) -> anyhow::Result> { match dir_name { "from_move" => Ok(None), - "eliminate_imm_refs" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - Ok(Some(pipeline)) - }, - "mut_ref_instrumentation" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); - Ok(Some(pipeline)) - }, "reaching_def" => { let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); pipeline.add_processor(ReachingDefProcessor::new()); Ok(Some(pipeline)) }, "livevar" => { let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); pipeline.add_processor(ReachingDefProcessor::new()); pipeline.add_processor(LiveVarAnalysisProcessor::new()); Ok(Some(pipeline)) }, "borrow" => { let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); pipeline.add_processor(ReachingDefProcessor::new()); pipeline.add_processor(LiveVarAnalysisProcessor::new()); pipeline.add_processor(BorrowAnalysisProcessor::new()); @@ -74,118 +35,9 @@ fn get_tested_transformation_pipeline( }, "borrow_strong" => { let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); - pipeline.add_processor(ReachingDefProcessor::new()); - pipeline.add_processor(LiveVarAnalysisProcessor::new()); - pipeline.add_processor(BorrowAnalysisProcessor::new()); - Ok(Some(pipeline)) - }, - "memory_instr" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); - pipeline.add_processor(ReachingDefProcessor::new()); - pipeline.add_processor(LiveVarAnalysisProcessor::new()); - pipeline.add_processor(BorrowAnalysisProcessor::new()); - pipeline.add_processor(MemoryInstrumentationProcessor::new()); - Ok(Some(pipeline)) - }, - "clean_and_optimize" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); pipeline.add_processor(ReachingDefProcessor::new()); pipeline.add_processor(LiveVarAnalysisProcessor::new()); pipeline.add_processor(BorrowAnalysisProcessor::new()); - pipeline.add_processor(MemoryInstrumentationProcessor::new()); - pipeline.add_processor(CleanAndOptimizeProcessor::new()); - Ok(Some(pipeline)) - }, - "verification_analysis" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); - pipeline.add_processor(ReachingDefProcessor::new()); - pipeline.add_processor(LiveVarAnalysisProcessor::new()); - pipeline.add_processor(BorrowAnalysisProcessor::new()); - pipeline.add_processor(MemoryInstrumentationProcessor::new()); - pipeline.add_processor(CleanAndOptimizeProcessor::new()); - pipeline.add_processor(UsageProcessor::new()); - pipeline.add_processor(VerificationAnalysisProcessor::new()); - Ok(Some(pipeline)) - }, - "spec_instrumentation" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); - pipeline.add_processor(ReachingDefProcessor::new()); - pipeline.add_processor(LiveVarAnalysisProcessor::new()); - pipeline.add_processor(BorrowAnalysisProcessor::new()); - pipeline.add_processor(MemoryInstrumentationProcessor::new()); - pipeline.add_processor(CleanAndOptimizeProcessor::new()); - pipeline.add_processor(UsageProcessor::new()); - pipeline.add_processor(VerificationAnalysisProcessor::new()); - pipeline.add_processor(SpecInstrumentationProcessor::new()); - Ok(Some(pipeline)) - }, - "data_invariant_instrumentation" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); - pipeline.add_processor(ReachingDefProcessor::new()); - pipeline.add_processor(LiveVarAnalysisProcessor::new()); - pipeline.add_processor(BorrowAnalysisProcessor::new()); - pipeline.add_processor(MemoryInstrumentationProcessor::new()); - pipeline.add_processor(CleanAndOptimizeProcessor::new()); - pipeline.add_processor(UsageProcessor::new()); - pipeline.add_processor(VerificationAnalysisProcessor::new()); - pipeline.add_processor(SpecInstrumentationProcessor::new()); - pipeline.add_processor(GlobalInvariantAnalysisProcessor::new()); - pipeline.add_processor(WellFormedInstrumentationProcessor::new()); - pipeline.add_processor(DataInvariantInstrumentationProcessor::new()); - Ok(Some(pipeline)) - }, - "global_invariant_analysis" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); - pipeline.add_processor(ReachingDefProcessor::new()); - pipeline.add_processor(LiveVarAnalysisProcessor::new()); - pipeline.add_processor(BorrowAnalysisProcessor::new()); - pipeline.add_processor(MemoryInstrumentationProcessor::new()); - pipeline.add_processor(CleanAndOptimizeProcessor::new()); - pipeline.add_processor(UsageProcessor::new()); - pipeline.add_processor(VerificationAnalysisProcessor::new()); - pipeline.add_processor(SpecInstrumentationProcessor::new()); - pipeline.add_processor(GlobalInvariantAnalysisProcessor::new()); - Ok(Some(pipeline)) - }, - "global_invariant_instrumentation" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(EliminateImmRefsProcessor::new()); - pipeline.add_processor(MutRefInstrumenter::new()); - pipeline.add_processor(ReachingDefProcessor::new()); - pipeline.add_processor(LiveVarAnalysisProcessor::new()); - pipeline.add_processor(BorrowAnalysisProcessor::new()); - pipeline.add_processor(MemoryInstrumentationProcessor::new()); - pipeline.add_processor(CleanAndOptimizeProcessor::new()); - pipeline.add_processor(UsageProcessor::new()); - pipeline.add_processor(VerificationAnalysisProcessor::new()); - pipeline.add_processor(SpecInstrumentationProcessor::new()); - pipeline.add_processor(GlobalInvariantAnalysisProcessor::new()); - pipeline.add_processor(GlobalInvariantInstrumentationProcessor::new()); - Ok(Some(pipeline)) - }, - "mono_analysis" => { - let mut pipeline = FunctionTargetPipeline::default(); - pipeline.add_processor(UsageProcessor::new()); - pipeline.add_processor(VerificationAnalysisProcessor::new()); - pipeline.add_processor(SpecInstrumentationProcessor::new()); - pipeline.add_processor(GlobalInvariantAnalysisProcessor::new()); - pipeline.add_processor(WellFormedInstrumentationProcessor::new()); - pipeline.add_processor(DataInvariantInstrumentationProcessor::new()); - pipeline.add_processor(MonoAnalysisProcessor::new()); Ok(Some(pipeline)) }, "usage_analysis" => { @@ -201,75 +53,13 @@ fn get_tested_transformation_pipeline( } fn test_runner(path: &Path) -> datatest_stable::Result<()> { - let mut sources = extract_test_directives(path, "// dep:")?; - sources.push(path.to_string_lossy().to_string()); - let env: GlobalEnv = run_model_builder_with_options( - vec![PackagePaths { - name: None, - paths: sources, - named_address_map: move_stdlib::move_stdlib_named_addresses(), - }], - vec![], - ModelBuilderOptions::default(), - false, - KnownAttribute::get_all_attribute_names(), - )?; - let out = if env.has_errors() { - let mut error_writer = Buffer::no_color(); - env.report_diag(&mut error_writer, Severity::Error); - String::from_utf8_lossy(&error_writer.into_inner()).to_string() - } else { - let options = ProverOptions { - stable_test_output: true, - ..Default::default() - }; - env.set_extension(options); - let dir_name = path - .parent() - .and_then(|p| p.file_name()) - .and_then(|p| p.to_str()) - .ok_or_else(|| anyhow!("bad file name"))?; - let pipeline_opt = get_tested_transformation_pipeline(dir_name)?; - - // Initialize and print function targets - let mut text = String::new(); - let mut targets = FunctionTargetsHolder::default(); - for module_env in env.get_modules() { - for func_env in module_env.get_functions() { - targets.add_target(&func_env); - } - } - text += &print_targets_for_test(&env, "initial translation from Move", &targets); - - // Run pipeline if any - if let Some(pipeline) = pipeline_opt { - pipeline.run(&env, &mut targets); - let processor = pipeline.last_processor(); - if !processor.is_single_run() { - text += &print_targets_for_test( - &env, - &format!("after pipeline `{}`", dir_name), - &targets, - ); - } - text += &ProcessorResultDisplay { - env: &env, - targets: &targets, - processor, - } - .to_string(); - } - // add Warning and Error diagnostics to output - let mut error_writer = Buffer::no_color(); - if env.has_errors() || env.has_warnings() { - env.report_diag(&mut error_writer, Severity::Warning); - text += "============ Diagnostics ================\n"; - text += &String::from_utf8_lossy(&error_writer.into_inner()); - } - text - }; - let baseline_path = path.with_extension(EXP_EXT); - verify_or_update_baseline(baseline_path.as_path(), &out)?; + let dir_name = path + .parent() + .and_then(|p| p.file_name()) + .and_then(|p| p.to_str()) + .ok_or_else(|| anyhow!("bad file name"))?; + let pipeline_opt = get_tested_transformation_pipeline(dir_name)?; + move_stackless_bytecode_test_utils::test_runner(path, pipeline_opt)?; Ok(()) } diff --git a/third_party/move/move-model/bytecode/tests/verification_analysis/inv_relevance.exp b/third_party/move/move-model/bytecode/tests/verification_analysis/inv_relevance.exp deleted file mode 100644 index 91d8e13b2fcfb1..00000000000000 --- a/third_party/move/move-model/bytecode/tests/verification_analysis/inv_relevance.exp +++ /dev/null @@ -1,120 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun InvRelevance::inner<#0>($t0|s: &signer, $t1|t: #0) { - var $t2: &signer - var $t3: #0 - var $t4: InvRelevance::R<#0> - 0: $t2 := move($t0) - 1: $t3 := move($t1) - 2: $t4 := pack InvRelevance::R<#0>($t3) - 3: move_to>($t4, $t2) - 4: return () -} - - -[variant baseline] -public fun InvRelevance::outer_T<#0>($t0|s: &signer, $t1|t: #0) { - var $t2: &signer - var $t3: #0 - 0: $t2 := move($t0) - 1: $t3 := move($t1) - 2: InvRelevance::inner<#0>($t2, $t3) - 3: return () -} - - -[variant baseline] -public fun InvRelevance::outer_bool($t0|s: &signer, $t1|t: bool) { - var $t2: &signer - var $t3: bool - 0: $t2 := move($t0) - 1: $t3 := move($t1) - 2: InvRelevance::inner($t2, $t3) - 3: return () -} - - -[variant baseline] -public fun InvRelevance::outer_u64($t0|s: &signer, $t1|t: u64) { - var $t2: &signer - var $t3: u64 - 0: $t2 := move($t0) - 1: $t3 := move($t1) - 2: InvRelevance::inner($t2, $t3) - 3: return () -} - -============ after pipeline `verification_analysis` ================ - -[variant baseline] -fun InvRelevance::inner<#0>($t0|s: signer, $t1|t: #0) { - var $t2: InvRelevance::R<#0> - 0: $t2 := pack InvRelevance::R<#0>($t1) - 1: move_to>($t2, $t0) - 2: return () -} - - -[variant baseline] -public fun InvRelevance::outer_T<#0>($t0|s: signer, $t1|t: #0) { - 0: InvRelevance::inner<#0>($t0, $t1) - 1: return () -} - - -[variant baseline] -public fun InvRelevance::outer_bool($t0|s: signer, $t1|t: bool) { - 0: InvRelevance::inner($t0, $t1) - 1: return () -} - - -[variant baseline] -public fun InvRelevance::outer_u64($t0|s: signer, $t1|t: u64) { - 0: InvRelevance::inner($t0, $t1) - 1: return () -} - - -********* Result of verification analysis ********* - -functions that defer invariant checking at return: [ -] - -functions that delegate invariants to its callers: [ -] - -invariant applicability: [ - InvRelevance::inner: { - accessed: [@0*] - modified: [@0*] - directly accessed: [@0*] - directly modified: [@0*] - } - InvRelevance::outer_T: { - accessed: [@0*] - modified: [@0*] - directly accessed: [] - directly modified: [] - } - InvRelevance::outer_bool: { - accessed: [@0*] - modified: [@0*] - directly accessed: [] - directly modified: [] - } - InvRelevance::outer_u64: { - accessed: [] - modified: [] - directly accessed: [] - directly modified: [] - } -] - -verification analysis: [ - InvRelevance::inner: verified + inlined - InvRelevance::outer_T: verified - InvRelevance::outer_bool: verified - InvRelevance::outer_u64: verified -] diff --git a/third_party/move/move-model/bytecode/tests/verification_analysis/inv_relevance.move b/third_party/move/move-model/bytecode/tests/verification_analysis/inv_relevance.move deleted file mode 100644 index 985f9d52d1c6fb..00000000000000 --- a/third_party/move/move-model/bytecode/tests/verification_analysis/inv_relevance.move +++ /dev/null @@ -1,25 +0,0 @@ -module 0x2::InvRelevance { - struct R has key, store { - t: T, - } - - fun inner(s: &signer, t: T) { - move_to(s, R { t }); - } - - public fun outer_bool(s: &signer, t: bool) { - inner(s, t); - } - - public fun outer_u64(s: &signer, t: u64) { - inner(s, t); - } - - public fun outer_T(s: &signer, t: T) { - inner(s, t); - } - - spec module { - invariant forall a: address where exists>(a): global>(a).t; - } -} diff --git a/third_party/move/move-model/bytecode/tests/verification_analysis/inv_suspension.exp b/third_party/move/move-model/bytecode/tests/verification_analysis/inv_suspension.exp deleted file mode 100644 index 5447894370b345..00000000000000 --- a/third_party/move/move-model/bytecode/tests/verification_analysis/inv_suspension.exp +++ /dev/null @@ -1,121 +0,0 @@ -============ initial translation from Move ================ - -[variant baseline] -fun InvRelevance::inner<#0>($t0|s: &signer, $t1|t: #0) { - var $t2: &signer - var $t3: #0 - var $t4: InvRelevance::R<#0> - 0: $t2 := move($t0) - 1: $t3 := move($t1) - 2: $t4 := pack InvRelevance::R<#0>($t3) - 3: move_to>($t4, $t2) - 4: return () -} - - -[variant baseline] -public fun InvRelevance::outer_T<#0>($t0|s: &signer, $t1|t: #0) { - var $t2: &signer - var $t3: #0 - 0: $t2 := move($t0) - 1: $t3 := move($t1) - 2: InvRelevance::inner<#0>($t2, $t3) - 3: return () -} - - -[variant baseline] -public fun InvRelevance::outer_bool($t0|s: &signer, $t1|t: bool) { - var $t2: &signer - var $t3: bool - 0: $t2 := move($t0) - 1: $t3 := move($t1) - 2: InvRelevance::inner($t2, $t3) - 3: return () -} - - -[variant baseline] -public fun InvRelevance::outer_u64($t0|s: &signer, $t1|t: u64) { - var $t2: &signer - var $t3: u64 - 0: $t2 := move($t0) - 1: $t3 := move($t1) - 2: InvRelevance::inner($t2, $t3) - 3: return () -} - -============ after pipeline `verification_analysis` ================ - -[variant baseline] -fun InvRelevance::inner<#0>($t0|s: signer, $t1|t: #0) { - var $t2: InvRelevance::R<#0> - 0: $t2 := pack InvRelevance::R<#0>($t1) - 1: move_to>($t2, $t0) - 2: return () -} - - -[variant baseline] -public fun InvRelevance::outer_T<#0>($t0|s: signer, $t1|t: #0) { - 0: InvRelevance::inner<#0>($t0, $t1) - 1: return () -} - - -[variant baseline] -public fun InvRelevance::outer_bool($t0|s: signer, $t1|t: bool) { - 0: InvRelevance::inner($t0, $t1) - 1: return () -} - - -[variant baseline] -public fun InvRelevance::outer_u64($t0|s: signer, $t1|t: u64) { - 0: InvRelevance::inner($t0, $t1) - 1: return () -} - - -********* Result of verification analysis ********* - -functions that defer invariant checking at return: [ -] - -functions that delegate invariants to its callers: [ - InvRelevance::inner -] - -invariant applicability: [ - InvRelevance::inner: { - accessed: [@0*] - modified: [@0*] - directly accessed: [@0*] - directly modified: [@0*] - } - InvRelevance::outer_T: { - accessed: [@0*, @1*] - modified: [@0*, @1*] - directly accessed: [@1*] - directly modified: [@1*] - } - InvRelevance::outer_bool: { - accessed: [@0*] - modified: [@0*] - directly accessed: [] - directly modified: [] - } - InvRelevance::outer_u64: { - accessed: [@1*] - modified: [@1*] - directly accessed: [@1*] - directly modified: [@1*] - } -] - -verification analysis: [ - InvRelevance::inner: verified + inlined - InvRelevance::outer_T: verified - InvRelevance::outer_bool: verified - InvRelevance::outer_u64: verified -] diff --git a/third_party/move/move-model/bytecode/tests/verification_analysis/inv_suspension.move b/third_party/move/move-model/bytecode/tests/verification_analysis/inv_suspension.move deleted file mode 100644 index 3bca1e3d288a28..00000000000000 --- a/third_party/move/move-model/bytecode/tests/verification_analysis/inv_suspension.move +++ /dev/null @@ -1,32 +0,0 @@ -module 0x2::InvRelevance { - struct R has key, store { - t: T, - } - - fun inner(s: &signer, t: T) { - move_to(s, R { t }); - } - spec inner { - pragma delegate_invariants_to_caller; - } - - public fun outer_bool(s: &signer, t: bool) { - inner(s, t); - } - - public fun outer_u64(s: &signer, t: u64) { - inner(s, t); - } - - public fun outer_T(s: &signer, t: T) { - inner(s, t); - } - - spec module { - invariant - forall a: address where exists>(a): global>(a).t; - - invariant [suspendable] - forall a: address where exists>(a): global>(a).t == 0; - } -} diff --git a/third_party/move/move-prover/Cargo.toml b/third_party/move/move-prover/Cargo.toml index 2df773322f181a..4f69f90b6ad954 100644 --- a/third_party/move/move-prover/Cargo.toml +++ b/third_party/move/move-prover/Cargo.toml @@ -19,6 +19,7 @@ move-ir-types = { path = "../move-ir/types" } move-model = { path = "../move-model" } # move dependencies move-prover-boogie-backend = { path = "boogie-backend" } +move-prover-bytecode-pipeline = { path = "bytecode-pipeline" } move-stackless-bytecode = { path = "../move-model/bytecode" } # external dependencies diff --git a/third_party/move/move-prover/boogie-backend/Cargo.toml b/third_party/move/move-prover/boogie-backend/Cargo.toml index 06e2e8f92971c0..8e3ecd14c856c3 100644 --- a/third_party/move/move-prover/boogie-backend/Cargo.toml +++ b/third_party/move/move-prover/boogie-backend/Cargo.toml @@ -20,6 +20,7 @@ move-command-line-common = { path = "../../move-command-line-common" } move-compiler = { path = "../../move-compiler" } move-core-types = { path = "../../move-core/types" } move-model = { path = "../../move-model" } +move-prover-bytecode-pipeline = { path = "../bytecode-pipeline" } move-stackless-bytecode = { path = "../../move-model/bytecode" } num = "0.4.0" once_cell = "1.7.2" diff --git a/third_party/move/move-prover/boogie-backend/src/bytecode_translator.rs b/third_party/move/move-prover/boogie-backend/src/bytecode_translator.rs index 4673c8d1d7cee2..3e23e137bc8764 100644 --- a/third_party/move/move-prover/boogie-backend/src/bytecode_translator.rs +++ b/third_party/move/move-prover/boogie-backend/src/bytecode_translator.rs @@ -37,15 +37,17 @@ use move_model::{ ty::{PrimitiveType, Type, TypeDisplayContext, BOOL_TYPE}, well_known::{TYPE_INFO_MOVE, TYPE_NAME_GET_MOVE, TYPE_NAME_MOVE}, }; -use move_stackless_bytecode::{ - function_target::FunctionTarget, - function_target_pipeline::{FunctionTargetsHolder, FunctionVariant, VerificationFlavor}, +use move_prover_bytecode_pipeline::{ mono_analysis, number_operation::{ FuncOperationMap, GlobalNumberOperationState, NumOperation, NumOperation::{Bitwise, Bottom}, }, options::ProverOptions, +}; +use move_stackless_bytecode::{ + function_target::FunctionTarget, + function_target_pipeline::{FunctionTargetsHolder, FunctionVariant, VerificationFlavor}, stackless_bytecode::{ AbortAction, BorrowEdge, BorrowNode, Bytecode, Constant, HavocKind, IndexEdgeKind, Operation, PropKind, diff --git a/third_party/move/move-prover/boogie-backend/src/lib.rs b/third_party/move/move-prover/boogie-backend/src/lib.rs index 1808df428e5397..a8b598a2a8bf21 100644 --- a/third_party/move/move-prover/boogie-backend/src/lib.rs +++ b/third_party/move/move-prover/boogie-backend/src/lib.rs @@ -29,7 +29,7 @@ use move_model::{ }, ty::{PrimitiveType, Type}, }; -use move_stackless_bytecode::mono_analysis; +use move_prover_bytecode_pipeline::mono_analysis; use serde::{Deserialize, Serialize}; use std::collections::BTreeSet; use tera::{Context, Tera}; diff --git a/third_party/move/move-prover/boogie-backend/src/spec_translator.rs b/third_party/move/move-prover/boogie-backend/src/spec_translator.rs index ea27083a129c1a..afd58a88173470 100644 --- a/third_party/move/move-prover/boogie-backend/src/spec_translator.rs +++ b/third_party/move/move-prover/boogie-backend/src/spec_translator.rs @@ -35,7 +35,7 @@ use move_model::{ ty::{PrimitiveType, Type}, well_known::{TYPE_INFO_SPEC, TYPE_NAME_GET_SPEC, TYPE_NAME_SPEC, TYPE_SPEC_IS_STRUCT}, }; -use move_stackless_bytecode::{ +use move_prover_bytecode_pipeline::{ mono_analysis::MonoInfo, number_operation::{GlobalNumberOperationState, NumOperation::Bitwise}, }; diff --git a/third_party/move/move-prover/bytecode-pipeline/Cargo.toml b/third_party/move/move-prover/bytecode-pipeline/Cargo.toml new file mode 100644 index 00000000000000..3845e728e550aa --- /dev/null +++ b/third_party/move/move-prover/bytecode-pipeline/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "move-prover-bytecode-pipeline" +version = "0.1.0" +authors = ["Aptos Labs "] +publish = false +edition = "2021" +license = "Apache-2.0" + +[dependencies] +anyhow = "1.0.52" +move-binary-format = { path = "../../move-binary-format" } +move-core-types = { path = "../../move-core/types" } +move-model = { path = "../../move-model" } + +# move dependencies +move-stackless-bytecode = { path = "../../move-model/bytecode" } + +# external dependencies +async-trait = "0.1.42" +atty = "0.2.14" +clap = { version = "4.3.9", features = ["derive"] } +codespan = "0.11.1" +codespan-reporting = "0.11.1" +futures = "0.3.12" +hex = "0.4.3" +itertools = "0.10.0" +log = { version = "0.4.14", features = ["serde"] } +num = "0.4.0" +once_cell = "1.7.2" +pretty = "0.10.0" +rand = "0.8.3" +serde = { version = "1.0.124", features = ["derive"] } +serde_json = "1.0.64" +simplelog = "0.9.0" +tokio = { version = "1.18.2", features = ["full"] } +toml = "0.5.8" + +[dev-dependencies] +datatest-stable = "0.1.1" +move-stackless-bytecode-test-utils = { path = "../../move-model/bytecode-test-utils" } +shell-words = "1.0.0" +tempfile = "3.2.0" +walkdir = "2.3.1" + +[[test]] +name = "testsuite" +harness = false diff --git a/third_party/move/move-model/bytecode/src/clean_and_optimize.rs b/third_party/move/move-prover/bytecode-pipeline/src/clean_and_optimize.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/clean_and_optimize.rs rename to third_party/move/move-prover/bytecode-pipeline/src/clean_and_optimize.rs index d03c9beeb332d4..b72c9fd6f7c7d8 100644 --- a/third_party/move/move-model/bytecode/src/clean_and_optimize.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/clean_and_optimize.rs @@ -4,21 +4,21 @@ // Final phase of cleanup and optimization. -use crate::{ +use crate::options::ProverOptions; +use move_binary_format::file_format::CodeOffset; +use move_model::{ + model::FunctionEnv, + pragmas::INTRINSIC_FUN_MAP_BORROW_MUT, + well_known::{EVENT_EMIT_EVENT, VECTOR_BORROW_MUT}, +}; +use move_stackless_bytecode::{ dataflow_analysis::{DataflowAnalysis, TransferFunctions}, dataflow_domains::{AbstractDomain, JoinResult}, function_target::{FunctionData, FunctionTarget}, function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, - options::ProverOptions, stackless_bytecode::{BorrowNode, Bytecode, Operation}, stackless_control_flow_graph::StacklessControlFlowGraph, }; -use move_binary_format::file_format::CodeOffset; -use move_model::{ - model::FunctionEnv, - pragmas::INTRINSIC_FUN_MAP_BORROW_MUT, - well_known::{EVENT_EMIT_EVENT, VECTOR_BORROW_MUT}, -}; use std::collections::BTreeSet; pub struct CleanAndOptimizeProcessor(); diff --git a/third_party/move/move-model/bytecode/src/data_invariant_instrumentation.rs b/third_party/move/move-prover/bytecode-pipeline/src/data_invariant_instrumentation.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/data_invariant_instrumentation.rs rename to third_party/move/move-prover/bytecode-pipeline/src/data_invariant_instrumentation.rs index bd3eef6d00b5d5..2af5efe8bb83d3 100644 --- a/third_party/move/move-model/bytecode/src/data_invariant_instrumentation.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/data_invariant_instrumentation.rs @@ -11,13 +11,7 @@ //! (which depends on the compilation scheme). It also handles PackRef/PackRefDeep //! instructions introduced by memory instrumentation, as well as the Pack instructions. -use crate::{ - function_data_builder::FunctionDataBuilder, - function_target::FunctionData, - function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, - options::ProverOptions, - stackless_bytecode::{Bytecode, Operation, PropKind}, -}; +use crate::options::ProverOptions; use move_model::{ ast, ast::{ConditionKind, Exp, ExpData, QuantKind, TempIndex}, @@ -26,6 +20,12 @@ use move_model::{ pragmas::{INTRINSIC_FUN_MAP_SPEC_GET, INTRINSIC_TYPE_MAP}, ty::Type, }; +use move_stackless_bytecode::{ + function_data_builder::FunctionDataBuilder, + function_target::FunctionData, + function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, + stackless_bytecode::{Bytecode, Operation, PropKind}, +}; const INVARIANT_FAILS_MESSAGE: &str = "data invariant does not hold"; diff --git a/third_party/move/move-model/bytecode/src/eliminate_imm_refs.rs b/third_party/move/move-prover/bytecode-pipeline/src/eliminate_imm_refs.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/eliminate_imm_refs.rs rename to third_party/move/move-prover/bytecode-pipeline/src/eliminate_imm_refs.rs index 5eb6a764fc7974..cd1c2d2745f421 100644 --- a/third_party/move/move-model/bytecode/src/eliminate_imm_refs.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/eliminate_imm_refs.rs @@ -2,17 +2,17 @@ // Copyright (c) The Move Contributors // SPDX-License-Identifier: Apache-2.0 -use crate::{ - function_data_builder::FunctionDataBuilder, - function_target::FunctionData, - function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, - stackless_bytecode::{AssignKind, Bytecode, Operation}, -}; use move_model::{ ast::TempIndex, model::FunctionEnv, ty::{ReferenceKind, Type}, }; +use move_stackless_bytecode::{ + function_data_builder::FunctionDataBuilder, + function_target::FunctionData, + function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, + stackless_bytecode::{AssignKind, Bytecode, Operation}, +}; pub struct EliminateImmRefsProcessor {} diff --git a/third_party/move/move-model/bytecode/src/global_invariant_analysis.rs b/third_party/move/move-prover/bytecode-pipeline/src/global_invariant_analysis.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/global_invariant_analysis.rs rename to third_party/move/move-prover/bytecode-pipeline/src/global_invariant_analysis.rs index d40d661d58d461..82af45d86b5f3f 100644 --- a/third_party/move/move-model/bytecode/src/global_invariant_analysis.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/global_invariant_analysis.rs @@ -4,20 +4,20 @@ // Analysis pass which analyzes how to injects global invariants into the bytecode. -use crate::{ +use crate::verification_analysis::{is_invariant_suspendable, InvariantAnalysisData}; +use move_binary_format::file_format::CodeOffset; +use move_model::{ + ast::ConditionKind, + model::{FunId, FunctionEnv, GlobalEnv, GlobalId, QualifiedId, QualifiedInstId, StructId}, + ty::{Type, TypeDisplayContext, TypeInstantiationDerivation, TypeUnificationAdapter, Variance}, +}; +use move_stackless_bytecode::{ function_target::{FunctionData, FunctionTarget}, function_target_pipeline::{ FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, VerificationFlavor, }, stackless_bytecode::{BorrowNode, Bytecode, Operation, PropKind}, usage_analysis, - verification_analysis::{is_invariant_suspendable, InvariantAnalysisData}, -}; -use move_binary_format::file_format::CodeOffset; -use move_model::{ - ast::ConditionKind, - model::{FunId, FunctionEnv, GlobalEnv, GlobalId, QualifiedId, QualifiedInstId, StructId}, - ty::{Type, TypeDisplayContext, TypeInstantiationDerivation, TypeUnificationAdapter, Variance}, }; use std::{ collections::{BTreeMap, BTreeSet}, diff --git a/third_party/move/move-model/bytecode/src/global_invariant_instrumentation.rs b/third_party/move/move-prover/bytecode-pipeline/src/global_invariant_instrumentation.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/global_invariant_instrumentation.rs rename to third_party/move/move-prover/bytecode-pipeline/src/global_invariant_instrumentation.rs index a7b5a70a97e3a3..dd29ad2fb0c0bb 100644 --- a/third_party/move/move-model/bytecode/src/global_invariant_instrumentation.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/global_invariant_instrumentation.rs @@ -5,14 +5,8 @@ // Instrumentation pass which injects global invariants into the bytecode. use crate::{ - function_data_builder::FunctionDataBuilder, - function_target::{FunctionData, FunctionTarget}, - function_target_pipeline::{ - FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, VerificationFlavor, - }, - global_invariant_analysis::{self, PerFunctionRelevance}, + global_invariant_analysis, global_invariant_analysis::PerFunctionRelevance, options::ProverOptions, - stackless_bytecode::{Bytecode, Operation, PropKind}, }; use move_binary_format::file_format::CodeOffset; use move_model::{ @@ -22,6 +16,14 @@ use move_model::{ spec_translator::{SpecTranslator, TranslatedSpec}, ty::Type, }; +use move_stackless_bytecode::{ + function_data_builder::FunctionDataBuilder, + function_target::{FunctionData, FunctionTarget}, + function_target_pipeline::{ + FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, VerificationFlavor, + }, + stackless_bytecode::{Bytecode, Operation, PropKind}, +}; use std::collections::{BTreeMap, BTreeSet}; const GLOBAL_INVARIANT_FAILS_MESSAGE: &str = "global memory invariant does not hold"; diff --git a/third_party/move/move-model/bytecode/src/global_invariant_instrumentation_v2.rs b/third_party/move/move-prover/bytecode-pipeline/src/global_invariant_instrumentation_v2.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/global_invariant_instrumentation_v2.rs rename to third_party/move/move-prover/bytecode-pipeline/src/global_invariant_instrumentation_v2.rs index 09c23fcc641c92..3262c60496389e 100644 --- a/third_party/move/move-model/bytecode/src/global_invariant_instrumentation_v2.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/global_invariant_instrumentation_v2.rs @@ -4,17 +4,7 @@ // Transformation which injects global invariants into the bytecode. -use crate::{ - function_data_builder::FunctionDataBuilder, - function_target::{FunctionData, FunctionTarget}, - function_target_pipeline::{ - FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, VerificationFlavor, - }, - options::ProverOptions, - stackless_bytecode::{BorrowNode, Bytecode, Operation, PropKind}, - usage_analysis, - verification_analysis_v2::InvariantAnalysisData, -}; +use crate::{options::ProverOptions, verification_analysis_v2::InvariantAnalysisData}; use itertools::Itertools; #[allow(unused_imports)] use log::{debug, info, log, warn}; @@ -28,6 +18,15 @@ use move_model::{ spec_translator::{SpecTranslator, TranslatedSpec}, ty::{Type, TypeUnificationAdapter, Variance}, }; +use move_stackless_bytecode::{ + function_data_builder::FunctionDataBuilder, + function_target::{FunctionData, FunctionTarget}, + function_target_pipeline::{ + FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, VerificationFlavor, + }, + stackless_bytecode::{BorrowNode, Bytecode, Operation, PropKind}, + usage_analysis, +}; use std::collections::{BTreeMap, BTreeSet}; const GLOBAL_INVARIANT_FAILS_MESSAGE: &str = "global memory invariant does not hold"; diff --git a/third_party/move/move-model/bytecode/src/inconsistency_check.rs b/third_party/move/move-prover/bytecode-pipeline/src/inconsistency_check.rs similarity index 98% rename from third_party/move/move-model/bytecode/src/inconsistency_check.rs rename to third_party/move/move-prover/bytecode-pipeline/src/inconsistency_check.rs index 033d15e5f058b3..1da58828dbeb1b 100644 --- a/third_party/move/move-model/bytecode/src/inconsistency_check.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/inconsistency_check.rs @@ -20,16 +20,16 @@ //! any post-condition can be proved. Checking of this behavior is turned-off by default, and can //! be enabled with the `unconditional-abort-as-inconsistency` flag. -use crate::{ +use crate::options::ProverOptions; +use move_model::{exp_generator::ExpGenerator, model::FunctionEnv}; +use move_stackless_bytecode::{ function_data_builder::FunctionDataBuilder, function_target::FunctionData, function_target_pipeline::{ FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, VerificationFlavor, }, - options::ProverOptions, stackless_bytecode::{Bytecode, PropKind}, }; -use move_model::{exp_generator::ExpGenerator, model::FunctionEnv}; // This message is for the boogie wrapper, and not shown to the users. const EXPECTED_TO_FAIL: &str = "expected to fail"; diff --git a/third_party/move/move-prover/bytecode-pipeline/src/lib.rs b/third_party/move/move-prover/bytecode-pipeline/src/lib.rs new file mode 100644 index 00000000000000..f8d8d9ad95e083 --- /dev/null +++ b/third_party/move/move-prover/bytecode-pipeline/src/lib.rs @@ -0,0 +1,24 @@ +// Copyright © Aptos Foundation +// Parts of the project are originally copyright © Meta Platforms, Inc. +// SPDX-License-Identifier: Apache-2.0 +pub mod clean_and_optimize; +pub mod data_invariant_instrumentation; +pub mod eliminate_imm_refs; +pub mod global_invariant_analysis; +pub mod global_invariant_instrumentation; +pub mod global_invariant_instrumentation_v2; +pub mod inconsistency_check; +pub mod loop_analysis; +pub mod memory_instrumentation; +pub mod mono_analysis; +pub mod mut_ref_instrumentation; +pub mod mutation_tester; +pub mod number_operation; +pub mod number_operation_analysis; +pub mod options; +pub mod packed_types_analysis; +pub mod pipeline_factory; +pub mod spec_instrumentation; +pub mod verification_analysis; +pub mod verification_analysis_v2; +pub mod well_formed_instrumentation; diff --git a/third_party/move/move-model/bytecode/src/loop_analysis.rs b/third_party/move/move-prover/bytecode-pipeline/src/loop_analysis.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/loop_analysis.rs rename to third_party/move/move-prover/bytecode-pipeline/src/loop_analysis.rs index a35fbe04690277..6203344653073b 100644 --- a/third_party/move/move-model/bytecode/src/loop_analysis.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/loop_analysis.rs @@ -2,15 +2,7 @@ // Copyright (c) The Move Contributors // SPDX-License-Identifier: Apache-2.0 -use crate::{ - function_data_builder::{FunctionDataBuilder, FunctionDataBuilderOptions}, - function_target::{FunctionData, FunctionTarget}, - function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, - graph::{Graph, NaturalLoop}, - options::ProverOptions, - stackless_bytecode::{AttrId, Bytecode, HavocKind, Label, Operation, PropKind}, - stackless_control_flow_graph::{BlockContent, BlockId, StacklessControlFlowGraph}, -}; +use crate::options::ProverOptions; use move_binary_format::file_format::CodeOffset; use move_model::{ ast::{self, TempIndex}, @@ -19,6 +11,14 @@ use move_model::{ pragmas::UNROLL_PRAGMA, ty::{PrimitiveType, Type}, }; +use move_stackless_bytecode::{ + function_data_builder::{FunctionDataBuilder, FunctionDataBuilderOptions}, + function_target::{FunctionData, FunctionTarget}, + function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, + graph::{Graph, NaturalLoop}, + stackless_bytecode::{AttrId, Bytecode, HavocKind, Label, Operation, PropKind}, + stackless_control_flow_graph::{BlockContent, BlockId, StacklessControlFlowGraph}, +}; use std::collections::{BTreeMap, BTreeSet}; const LOOP_INVARIANT_BASE_FAILED: &str = "base case of the loop invariant does not hold"; diff --git a/third_party/move/move-model/bytecode/src/memory_instrumentation.rs b/third_party/move/move-prover/bytecode-pipeline/src/memory_instrumentation.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/memory_instrumentation.rs rename to third_party/move/move-prover/bytecode-pipeline/src/memory_instrumentation.rs index 9250fc6c9d023b..1fb9196c3931e2 100644 --- a/third_party/move/move-model/bytecode/src/memory_instrumentation.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/memory_instrumentation.rs @@ -2,7 +2,14 @@ // Copyright (c) The Move Contributors // SPDX-License-Identifier: Apache-2.0 -use crate::{ +use move_binary_format::file_format::CodeOffset; +use move_model::{ + ast::ConditionKind, + exp_generator::ExpGenerator, + model::{FunctionEnv, StructEnv}, + ty::{Type, BOOL_TYPE}, +}; +use move_stackless_bytecode::{ borrow_analysis::{BorrowAnnotation, WriteBackAction}, function_data_builder::FunctionDataBuilder, function_target::FunctionData, @@ -13,13 +20,6 @@ use crate::{ Operation, }, }; -use move_binary_format::file_format::CodeOffset; -use move_model::{ - ast::ConditionKind, - exp_generator::ExpGenerator, - model::{FunctionEnv, StructEnv}, - ty::{Type, BOOL_TYPE}, -}; use std::collections::BTreeSet; pub struct MemoryInstrumentationProcessor {} diff --git a/third_party/move/move-model/bytecode/src/mono_analysis.rs b/third_party/move/move-prover/bytecode-pipeline/src/mono_analysis.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/mono_analysis.rs rename to third_party/move/move-prover/bytecode-pipeline/src/mono_analysis.rs index 19fce6252ca314..544e732cddca84 100644 --- a/third_party/move/move-model/bytecode/src/mono_analysis.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/mono_analysis.rs @@ -5,12 +5,6 @@ //! Analysis which computes information needed in backends for monomorphization. This //! computes the distinct type instantiations in the model for structs and inlined functions. -use crate::{ - function_target::FunctionTarget, - function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant}, - stackless_bytecode::{BorrowEdge, Bytecode, Operation}, - usage_analysis::UsageProcessor, -}; use itertools::Itertools; use move_model::{ ast, @@ -26,6 +20,12 @@ use move_model::{ TYPE_NAME_SPEC, TYPE_SPEC_IS_STRUCT, }, }; +use move_stackless_bytecode::{ + function_target::FunctionTarget, + function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant}, + stackless_bytecode::{BorrowEdge, Bytecode, Operation}, + usage_analysis::UsageProcessor, +}; use std::{ collections::{BTreeMap, BTreeSet}, fmt, diff --git a/third_party/move/move-model/bytecode/src/mut_ref_instrumentation.rs b/third_party/move/move-prover/bytecode-pipeline/src/mut_ref_instrumentation.rs similarity index 98% rename from third_party/move/move-model/bytecode/src/mut_ref_instrumentation.rs rename to third_party/move/move-prover/bytecode-pipeline/src/mut_ref_instrumentation.rs index 5733f7e31a51c2..0b224c7842bbe7 100644 --- a/third_party/move/move-model/bytecode/src/mut_ref_instrumentation.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/mut_ref_instrumentation.rs @@ -2,14 +2,14 @@ // Copyright (c) The Move Contributors // SPDX-License-Identifier: Apache-2.0 -use crate::{ +use itertools::Itertools; +use move_model::{ast::TempIndex, model::FunctionEnv}; +use move_stackless_bytecode::{ function_data_builder::FunctionDataBuilder, function_target::FunctionData, function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, stackless_bytecode::{AssignKind, Bytecode, Operation}, }; -use itertools::Itertools; -use move_model::{ast::TempIndex, model::FunctionEnv}; pub struct MutRefInstrumenter {} diff --git a/third_party/move/move-model/bytecode/src/mutation_tester.rs b/third_party/move/move-prover/bytecode-pipeline/src/mutation_tester.rs similarity index 98% rename from third_party/move/move-model/bytecode/src/mutation_tester.rs rename to third_party/move/move-prover/bytecode-pipeline/src/mutation_tester.rs index ff867c219552ea..06f34a560f01d7 100644 --- a/third_party/move/move-model/bytecode/src/mutation_tester.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/mutation_tester.rs @@ -9,17 +9,17 @@ //! It emits instructions in bytecode format, but with changes made //! Note that this mutation does nothing if mutation flags are not enabled -use crate::{ +use crate::options::ProverOptions; +use move_model::{ + exp_generator::ExpGenerator, + model::{FunctionEnv, GlobalEnv}, +}; +use move_stackless_bytecode::{ function_data_builder::FunctionDataBuilder, function_target::FunctionData, function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, - options::ProverOptions, stackless_bytecode::{Bytecode, Operation}, }; -use move_model::{ - exp_generator::ExpGenerator, - model::{FunctionEnv, GlobalEnv}, -}; pub struct MutationTester {} diff --git a/third_party/move/move-model/bytecode/src/number_operation.rs b/third_party/move/move-prover/bytecode-pipeline/src/number_operation.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/number_operation.rs rename to third_party/move/move-prover/bytecode-pipeline/src/number_operation.rs index 706c0e774e6b63..7c50796cd65269 100644 --- a/third_party/move/move-model/bytecode/src/number_operation.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/number_operation.rs @@ -6,7 +6,6 @@ //! mark the operation (arithmetic or bitwise) that a variable or a field involves, //! which will be used later when the correct number type (`int` or `bv`) in the boogie program -use crate::COMPILED_MODULE_AVAILABLE; use itertools::Itertools; use move_model::{ ast::{PropertyValue, TempIndex, Value}, @@ -14,6 +13,7 @@ use move_model::{ pragmas::{BV_PARAM_PROP, BV_RET_PROP}, ty::Type, }; +use move_stackless_bytecode::COMPILED_MODULE_AVAILABLE; use std::{collections::BTreeMap, ops::Deref, str}; static PARSING_ERROR: &str = "error happened when parsing the bv pragma"; diff --git a/third_party/move/move-model/bytecode/src/number_operation_analysis.rs b/third_party/move/move-prover/bytecode-pipeline/src/number_operation_analysis.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/number_operation_analysis.rs rename to third_party/move/move-prover/bytecode-pipeline/src/number_operation_analysis.rs index 1a939c746a28db..9699d45cb8e54c 100644 --- a/third_party/move/move-model/bytecode/src/number_operation_analysis.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/number_operation_analysis.rs @@ -7,19 +7,11 @@ // The result of this analysis will be used when generating the boogie code use crate::{ - dataflow_analysis::{DataflowAnalysis, TransferFunctions}, - dataflow_domains::{AbstractDomain, JoinResult}, - function_target::FunctionTarget, - function_target_pipeline::{ - FunctionTargetPipeline, FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, - }, number_operation::{ - GlobalNumberOperationState, - NumOperation::{self, Arithmetic, Bitwise, Bottom}, + GlobalNumberOperationState, NumOperation, + NumOperation::{Arithmetic, Bitwise, Bottom}, }, options::ProverOptions, - stackless_bytecode::{AttrId, Bytecode, Operation}, - stackless_control_flow_graph::StacklessControlFlowGraph, }; use itertools::Either; use move_binary_format::file_format::CodeOffset; @@ -28,6 +20,16 @@ use move_model::{ model::{FunId, GlobalEnv, ModuleId, Parameter}, ty::{PrimitiveType, Type}, }; +use move_stackless_bytecode::{ + dataflow_analysis::{DataflowAnalysis, TransferFunctions}, + dataflow_domains::{AbstractDomain, JoinResult}, + function_target::FunctionTarget, + function_target_pipeline::{ + FunctionTargetPipeline, FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, + }, + stackless_bytecode::{AttrId, Bytecode, Operation}, + stackless_control_flow_graph::StacklessControlFlowGraph, +}; use std::{ collections::{BTreeMap, BTreeSet}, str, diff --git a/third_party/move/move-model/bytecode/src/options.rs b/third_party/move/move-prover/bytecode-pipeline/src/options.rs similarity index 100% rename from third_party/move/move-model/bytecode/src/options.rs rename to third_party/move/move-prover/bytecode-pipeline/src/options.rs diff --git a/third_party/move/move-model/bytecode/src/packed_types_analysis.rs b/third_party/move/move-prover/bytecode-pipeline/src/packed_types_analysis.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/packed_types_analysis.rs rename to third_party/move/move-prover/bytecode-pipeline/src/packed_types_analysis.rs index d4e71c7e576fd5..26a062f2e5e26f 100644 --- a/third_party/move/move-model/bytecode/src/packed_types_analysis.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/packed_types_analysis.rs @@ -2,7 +2,13 @@ // Copyright (c) The Move Contributors // SPDX-License-Identifier: Apache-2.0 -use crate::{ +use move_binary_format::file_format::CodeOffset; +use move_core_types::language_storage::{StructTag, TypeTag}; +use move_model::{ + model::{FunctionEnv, GlobalEnv}, + ty::Type, +}; +use move_stackless_bytecode::{ compositional_analysis::{CompositionalAnalysis, SummaryCache}, dataflow_analysis::{DataflowAnalysis, TransferFunctions}, dataflow_domains::{AbstractDomain, JoinResult, SetDomain}, @@ -11,12 +17,6 @@ use crate::{ stackless_bytecode::{Bytecode, Operation}, COMPILED_MODULE_AVAILABLE, }; -use move_binary_format::file_format::CodeOffset; -use move_core_types::language_storage::{StructTag, TypeTag}; -use move_model::{ - model::{FunctionEnv, GlobalEnv}, - ty::Type, -}; use std::collections::BTreeSet; /// Get all closed types that may be packed by (1) genesis and (2) all transaction scripts. diff --git a/third_party/move/move-model/bytecode/src/pipeline_factory.rs b/third_party/move/move-prover/bytecode-pipeline/src/pipeline_factory.rs similarity index 90% rename from third_party/move/move-model/bytecode/src/pipeline_factory.rs rename to third_party/move/move-prover/bytecode-pipeline/src/pipeline_factory.rs index 95083f159c390d..eeaa53d395a4ac 100644 --- a/third_party/move/move-model/bytecode/src/pipeline_factory.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/pipeline_factory.rs @@ -3,29 +3,27 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{ - borrow_analysis::BorrowAnalysisProcessor, clean_and_optimize::CleanAndOptimizeProcessor, data_invariant_instrumentation::DataInvariantInstrumentationProcessor, - debug_instrumentation::DebugInstrumenter, eliminate_imm_refs::EliminateImmRefsProcessor, - function_target_pipeline::{FunctionTargetPipeline, FunctionTargetProcessor}, global_invariant_analysis::GlobalInvariantAnalysisProcessor, global_invariant_instrumentation::GlobalInvariantInstrumentationProcessor, - inconsistency_check::InconsistencyCheckInstrumenter, - livevar_analysis::LiveVarAnalysisProcessor, - loop_analysis::LoopAnalysisProcessor, - memory_instrumentation::MemoryInstrumentationProcessor, - mono_analysis::MonoAnalysisProcessor, - mut_ref_instrumentation::MutRefInstrumenter, - mutation_tester::MutationTester, - number_operation_analysis::NumberOperationProcessor, - options::ProverOptions, - reaching_def_analysis::ReachingDefProcessor, + inconsistency_check::InconsistencyCheckInstrumenter, loop_analysis::LoopAnalysisProcessor, + memory_instrumentation::MemoryInstrumentationProcessor, mono_analysis::MonoAnalysisProcessor, + mut_ref_instrumentation::MutRefInstrumenter, mutation_tester::MutationTester, + number_operation_analysis::NumberOperationProcessor, options::ProverOptions, spec_instrumentation::SpecInstrumentationProcessor, - usage_analysis::UsageProcessor, verification_analysis::VerificationAnalysisProcessor, well_formed_instrumentation::WellFormedInstrumentationProcessor, }; +use move_stackless_bytecode::{ + borrow_analysis::BorrowAnalysisProcessor, + debug_instrumentation::DebugInstrumenter, + function_target_pipeline::{FunctionTargetPipeline, FunctionTargetProcessor}, + livevar_analysis::LiveVarAnalysisProcessor, + reaching_def_analysis::ReachingDefProcessor, + usage_analysis::UsageProcessor, +}; pub fn default_pipeline_with_options(options: &ProverOptions) -> FunctionTargetPipeline { // NOTE: the order of these processors is import! @@ -79,6 +77,7 @@ pub fn default_pipeline_with_options(options: &ProverOptions) -> FunctionTargetP res } +#[allow(unused)] pub fn default_pipeline() -> FunctionTargetPipeline { default_pipeline_with_options(&ProverOptions::default()) } diff --git a/third_party/move/move-model/bytecode/src/spec_instrumentation.rs b/third_party/move/move-prover/bytecode-pipeline/src/spec_instrumentation.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/spec_instrumentation.rs rename to third_party/move/move-prover/bytecode-pipeline/src/spec_instrumentation.rs index 8178f886f239a6..ff8329f5fe1b36 100644 --- a/third_party/move/move-model/bytecode/src/spec_instrumentation.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/spec_instrumentation.rs @@ -4,30 +4,30 @@ // Transformation which injects specifications (Move function spec blocks) into the bytecode. -use crate::{ +use crate::{options::ProverOptions, verification_analysis}; +use itertools::Itertools; +use move_model::{ + ast, + ast::{Exp, ExpData, TempIndex, Value}, + exp_generator::ExpGenerator, + model::{FunId, FunctionEnv, GlobalEnv, Loc, ModuleId, QualifiedId, QualifiedInstId, StructId}, + pragmas::{ABORTS_IF_IS_PARTIAL_PRAGMA, EMITS_IS_PARTIAL_PRAGMA, EMITS_IS_STRICT_PRAGMA}, + spec_translator::{SpecTranslator, TranslatedSpec}, + ty::{ReferenceKind, Type, TypeDisplayContext, BOOL_TYPE, NUM_TYPE}, +}; +use move_stackless_bytecode::{ function_data_builder::FunctionDataBuilder, function_target::{FunctionData, FunctionTarget}, function_target_pipeline::{ FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant, VerificationFlavor, }, livevar_analysis::LiveVarAnalysisProcessor, - options::ProverOptions, reaching_def_analysis::ReachingDefProcessor, stackless_bytecode::{ AbortAction, AssignKind, AttrId, BorrowEdge, BorrowNode, Bytecode, HavocKind, Label, Operation, PropKind, }, - usage_analysis, verification_analysis, COMPILED_MODULE_AVAILABLE, -}; -use itertools::Itertools; -use move_model::{ - ast, - ast::{Exp, ExpData, TempIndex, Value}, - exp_generator::ExpGenerator, - model::{FunId, FunctionEnv, GlobalEnv, Loc, ModuleId, QualifiedId, QualifiedInstId, StructId}, - pragmas::{ABORTS_IF_IS_PARTIAL_PRAGMA, EMITS_IS_PARTIAL_PRAGMA, EMITS_IS_STRICT_PRAGMA}, - spec_translator::{SpecTranslator, TranslatedSpec}, - ty::{ReferenceKind, Type, TypeDisplayContext, BOOL_TYPE, NUM_TYPE}, + usage_analysis, COMPILED_MODULE_AVAILABLE, }; use std::{ collections::{BTreeMap, BTreeSet}, diff --git a/third_party/move/move-model/bytecode/src/verification_analysis.rs b/third_party/move/move-prover/bytecode-pipeline/src/verification_analysis.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/verification_analysis.rs rename to third_party/move/move-prover/bytecode-pipeline/src/verification_analysis.rs index a728d0cb426718..700cdef56730ed 100644 --- a/third_party/move/move-model/bytecode/src/verification_analysis.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/verification_analysis.rs @@ -7,12 +7,7 @@ //! each function as well as collect information on how these invariants should be handled (i.e., //! checked after bytecode, checked at function exit, or deferred to caller). -use crate::{ - function_target::{FunctionData, FunctionTarget}, - function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant}, - options::ProverOptions, - usage_analysis, COMPILED_MODULE_AVAILABLE, -}; +use crate::options::ProverOptions; use codespan_reporting::diagnostic::Severity; use itertools::Itertools; use move_model::{ @@ -24,6 +19,11 @@ use move_model::{ }, ty::{TypeUnificationAdapter, Variance}, }; +use move_stackless_bytecode::{ + function_target::{FunctionData, FunctionTarget}, + function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant}, + usage_analysis, COMPILED_MODULE_AVAILABLE, +}; use std::{ collections::{BTreeMap, BTreeSet}, fmt::{self, Formatter}, diff --git a/third_party/move/move-model/bytecode/src/verification_analysis_v2.rs b/third_party/move/move-prover/bytecode-pipeline/src/verification_analysis_v2.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/verification_analysis_v2.rs rename to third_party/move/move-prover/bytecode-pipeline/src/verification_analysis_v2.rs index b07cf2f5e2c596..a7384307bb72b5 100644 --- a/third_party/move/move-model/bytecode/src/verification_analysis_v2.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/verification_analysis_v2.rs @@ -4,13 +4,7 @@ //! Analysis which computes an annotation for each function whether -use crate::{ - dataflow_domains::SetDomain, - function_target::{FunctionData, FunctionTarget}, - function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant}, - options::ProverOptions, - usage_analysis, COMPILED_MODULE_AVAILABLE, -}; +use crate::options::ProverOptions; use itertools::Itertools; use log::debug; use move_model::{ @@ -20,6 +14,12 @@ use move_model::{ DISABLE_INVARIANTS_IN_BODY_PRAGMA, VERIFY_PRAGMA, }, }; +use move_stackless_bytecode::{ + dataflow_domains::SetDomain, + function_target::{FunctionData, FunctionTarget}, + function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder, FunctionVariant}, + usage_analysis, COMPILED_MODULE_AVAILABLE, +}; use std::collections::{BTreeMap, BTreeSet, VecDeque}; /// The annotation for information about verification. diff --git a/third_party/move/move-model/bytecode/src/well_formed_instrumentation.rs b/third_party/move/move-prover/bytecode-pipeline/src/well_formed_instrumentation.rs similarity index 99% rename from third_party/move/move-model/bytecode/src/well_formed_instrumentation.rs rename to third_party/move/move-prover/bytecode-pipeline/src/well_formed_instrumentation.rs index e9d08e688937d1..44346537814159 100644 --- a/third_party/move/move-model/bytecode/src/well_formed_instrumentation.rs +++ b/third_party/move/move-prover/bytecode-pipeline/src/well_formed_instrumentation.rs @@ -14,13 +14,6 @@ //! Because data invariants cannot refer to global memory, they are not relevant for memory //! usage, and their injection therefore can happen after this phase. -use crate::{ - function_data_builder::FunctionDataBuilder, - function_target::FunctionData, - function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, - stackless_bytecode::PropKind, - usage_analysis::UsageProcessor, -}; use move_core_types::account_address::AccountAddress; use move_model::{ ast::{Operation, QuantKind}, @@ -28,6 +21,13 @@ use move_model::{ model::FunctionEnv, ty::BOOL_TYPE, }; +use move_stackless_bytecode::{ + function_data_builder::FunctionDataBuilder, + function_target::FunctionData, + function_target_pipeline::{FunctionTargetProcessor, FunctionTargetsHolder}, + stackless_bytecode::PropKind, + usage_analysis::UsageProcessor, +}; pub struct WellFormedInstrumentationProcessor {} diff --git a/third_party/move/move-prover/bytecode-pipeline/tests/testsuite.rs b/third_party/move/move-prover/bytecode-pipeline/tests/testsuite.rs new file mode 100644 index 00000000000000..94cc3282818708 --- /dev/null +++ b/third_party/move/move-prover/bytecode-pipeline/tests/testsuite.rs @@ -0,0 +1,165 @@ +// Copyright (c) The Diem Core Contributors +// Copyright (c) The Move Contributors +// SPDX-License-Identifier: Apache-2.0 + +use anyhow::anyhow; +use move_prover_bytecode_pipeline::{ + clean_and_optimize::CleanAndOptimizeProcessor, + data_invariant_instrumentation::DataInvariantInstrumentationProcessor, + eliminate_imm_refs::EliminateImmRefsProcessor, + global_invariant_analysis::GlobalInvariantAnalysisProcessor, + global_invariant_instrumentation::GlobalInvariantInstrumentationProcessor, + memory_instrumentation::MemoryInstrumentationProcessor, mono_analysis::MonoAnalysisProcessor, + mut_ref_instrumentation::MutRefInstrumenter, + spec_instrumentation::SpecInstrumentationProcessor, + verification_analysis::VerificationAnalysisProcessor, + well_formed_instrumentation::WellFormedInstrumentationProcessor, +}; +use move_stackless_bytecode::{ + borrow_analysis::BorrowAnalysisProcessor, function_target_pipeline::FunctionTargetPipeline, + livevar_analysis::LiveVarAnalysisProcessor, reaching_def_analysis::ReachingDefProcessor, + usage_analysis::UsageProcessor, +}; +use std::path::Path; + +fn get_tested_transformation_pipeline( + dir_name: &str, +) -> anyhow::Result> { + match dir_name { + "eliminate_imm_refs" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + Ok(Some(pipeline)) + }, + "mut_ref_instrumentation" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + pipeline.add_processor(MutRefInstrumenter::new()); + Ok(Some(pipeline)) + }, + "memory_instr" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + pipeline.add_processor(MutRefInstrumenter::new()); + pipeline.add_processor(ReachingDefProcessor::new()); + pipeline.add_processor(LiveVarAnalysisProcessor::new()); + pipeline.add_processor(BorrowAnalysisProcessor::new()); + pipeline.add_processor(MemoryInstrumentationProcessor::new()); + Ok(Some(pipeline)) + }, + "clean_and_optimize" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + pipeline.add_processor(MutRefInstrumenter::new()); + pipeline.add_processor(ReachingDefProcessor::new()); + pipeline.add_processor(LiveVarAnalysisProcessor::new()); + pipeline.add_processor(BorrowAnalysisProcessor::new()); + pipeline.add_processor(MemoryInstrumentationProcessor::new()); + pipeline.add_processor(CleanAndOptimizeProcessor::new()); + Ok(Some(pipeline)) + }, + "verification_analysis" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + pipeline.add_processor(MutRefInstrumenter::new()); + pipeline.add_processor(ReachingDefProcessor::new()); + pipeline.add_processor(LiveVarAnalysisProcessor::new()); + pipeline.add_processor(BorrowAnalysisProcessor::new()); + pipeline.add_processor(MemoryInstrumentationProcessor::new()); + pipeline.add_processor(CleanAndOptimizeProcessor::new()); + pipeline.add_processor(UsageProcessor::new()); + pipeline.add_processor(VerificationAnalysisProcessor::new()); + Ok(Some(pipeline)) + }, + "spec_instrumentation" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + pipeline.add_processor(MutRefInstrumenter::new()); + pipeline.add_processor(ReachingDefProcessor::new()); + pipeline.add_processor(LiveVarAnalysisProcessor::new()); + pipeline.add_processor(BorrowAnalysisProcessor::new()); + pipeline.add_processor(MemoryInstrumentationProcessor::new()); + pipeline.add_processor(CleanAndOptimizeProcessor::new()); + pipeline.add_processor(UsageProcessor::new()); + pipeline.add_processor(VerificationAnalysisProcessor::new()); + pipeline.add_processor(SpecInstrumentationProcessor::new()); + Ok(Some(pipeline)) + }, + "data_invariant_instrumentation" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + pipeline.add_processor(MutRefInstrumenter::new()); + pipeline.add_processor(ReachingDefProcessor::new()); + pipeline.add_processor(LiveVarAnalysisProcessor::new()); + pipeline.add_processor(BorrowAnalysisProcessor::new()); + pipeline.add_processor(MemoryInstrumentationProcessor::new()); + pipeline.add_processor(CleanAndOptimizeProcessor::new()); + pipeline.add_processor(UsageProcessor::new()); + pipeline.add_processor(VerificationAnalysisProcessor::new()); + pipeline.add_processor(SpecInstrumentationProcessor::new()); + pipeline.add_processor(GlobalInvariantAnalysisProcessor::new()); + pipeline.add_processor(WellFormedInstrumentationProcessor::new()); + pipeline.add_processor(DataInvariantInstrumentationProcessor::new()); + Ok(Some(pipeline)) + }, + "global_invariant_analysis" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + pipeline.add_processor(MutRefInstrumenter::new()); + pipeline.add_processor(ReachingDefProcessor::new()); + pipeline.add_processor(LiveVarAnalysisProcessor::new()); + pipeline.add_processor(BorrowAnalysisProcessor::new()); + pipeline.add_processor(MemoryInstrumentationProcessor::new()); + pipeline.add_processor(CleanAndOptimizeProcessor::new()); + pipeline.add_processor(UsageProcessor::new()); + pipeline.add_processor(VerificationAnalysisProcessor::new()); + pipeline.add_processor(SpecInstrumentationProcessor::new()); + pipeline.add_processor(GlobalInvariantAnalysisProcessor::new()); + Ok(Some(pipeline)) + }, + "global_invariant_instrumentation" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(EliminateImmRefsProcessor::new()); + pipeline.add_processor(MutRefInstrumenter::new()); + pipeline.add_processor(ReachingDefProcessor::new()); + pipeline.add_processor(LiveVarAnalysisProcessor::new()); + pipeline.add_processor(BorrowAnalysisProcessor::new()); + pipeline.add_processor(MemoryInstrumentationProcessor::new()); + pipeline.add_processor(CleanAndOptimizeProcessor::new()); + pipeline.add_processor(UsageProcessor::new()); + pipeline.add_processor(VerificationAnalysisProcessor::new()); + pipeline.add_processor(SpecInstrumentationProcessor::new()); + pipeline.add_processor(GlobalInvariantAnalysisProcessor::new()); + pipeline.add_processor(GlobalInvariantInstrumentationProcessor::new()); + Ok(Some(pipeline)) + }, + "mono_analysis" => { + let mut pipeline = FunctionTargetPipeline::default(); + pipeline.add_processor(UsageProcessor::new()); + pipeline.add_processor(VerificationAnalysisProcessor::new()); + pipeline.add_processor(SpecInstrumentationProcessor::new()); + pipeline.add_processor(GlobalInvariantAnalysisProcessor::new()); + pipeline.add_processor(WellFormedInstrumentationProcessor::new()); + pipeline.add_processor(DataInvariantInstrumentationProcessor::new()); + pipeline.add_processor(MonoAnalysisProcessor::new()); + Ok(Some(pipeline)) + }, + _ => Err(anyhow!( + "the sub-directory `{}` has no associated pipeline to test", + dir_name + )), + } +} + +fn test_runner(path: &Path) -> datatest_stable::Result<()> { + let dir_name = path + .parent() + .and_then(|p| p.file_name()) + .and_then(|p| p.to_str()) + .ok_or_else(|| anyhow!("bad file name"))?; + let pipeline_opt = get_tested_transformation_pipeline(dir_name)?; + move_stackless_bytecode_test_utils::test_runner(path, pipeline_opt)?; + Ok(()) +} + +datatest_stable::harness!(test_runner, "tests", r".*\.move"); diff --git a/third_party/move/move-prover/lab/Cargo.toml b/third_party/move/move-prover/lab/Cargo.toml index b0119e714eb85b..f761474b210d80 100644 --- a/third_party/move/move-prover/lab/Cargo.toml +++ b/third_party/move/move-prover/lab/Cargo.toml @@ -12,6 +12,7 @@ move-compiler = { path = "../../move-compiler" } move-model = { path = "../../move-model" } move-prover = { path = ".." } move-prover-boogie-backend = { path = "../boogie-backend" } +move-prover-bytecode-pipeline = { path = "../bytecode-pipeline" } move-stackless-bytecode = { path = "../../move-model/bytecode" } # FB external dependencies diff --git a/third_party/move/move-prover/lab/src/benchmark.rs b/third_party/move/move-prover/lab/src/benchmark.rs index 9060c5c4da3e74..e1143977b042b1 100644 --- a/third_party/move/move-prover/lab/src/benchmark.rs +++ b/third_party/move/move-prover/lab/src/benchmark.rs @@ -23,7 +23,7 @@ use move_prover::{ check_errors, cli::Options, create_and_process_bytecode, create_init_num_operation_state, generate_boogie, verify_boogie, }; -use move_stackless_bytecode::options::ProverOptions; +use move_prover_bytecode_pipeline::options::ProverOptions; use std::{ fmt::Debug, fs::File, diff --git a/third_party/move/move-prover/src/cli.rs b/third_party/move/move-prover/src/cli.rs index 3139723273113d..6f1012860e1947 100644 --- a/third_party/move/move-prover/src/cli.rs +++ b/third_party/move/move-prover/src/cli.rs @@ -16,7 +16,7 @@ use move_docgen::DocgenOptions; use move_errmapgen::ErrmapOptions; use move_model::{model::VerificationScope, options::ModelBuilderOptions}; use move_prover_boogie_backend::options::{BoogieOptions, VectorTheory}; -use move_stackless_bytecode::options::{AutoTraceLevel, ProverOptions}; +use move_prover_bytecode_pipeline::options::{AutoTraceLevel, ProverOptions}; use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use simplelog::{ diff --git a/third_party/move/move-prover/src/lib.rs b/third_party/move/move-prover/src/lib.rs index 3ad78753c84c83..6b01de0e159905 100644 --- a/third_party/move/move-prover/src/lib.rs +++ b/third_party/move/move-prover/src/lib.rs @@ -20,10 +20,10 @@ use move_model::{ use move_prover_boogie_backend::{ add_prelude, boogie_wrapper::BoogieWrapper, bytecode_translator::BoogieTranslator, }; -use move_stackless_bytecode::{ - function_target_pipeline::FunctionTargetsHolder, number_operation::GlobalNumberOperationState, - pipeline_factory, +use move_prover_bytecode_pipeline::{ + number_operation::GlobalNumberOperationState, pipeline_factory, }; +use move_stackless_bytecode::function_target_pipeline::FunctionTargetsHolder; use std::{ fs, path::{Path, PathBuf},