diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-07-29 20:19:53 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-29 20:19:53 +1000 |
| commit | f034a4fa14967ac36ceadbfd1ec80d098e1b8c7a (patch) | |
| tree | 579162504f30b9d2af259296360ddb6351f1a9a2 /src/tools/miri/genmc-sys/src_cpp/MiriInterface.cpp | |
| parent | 15ddf9c7b3d2bd8b00de08cfebcf47c00081db03 (diff) | |
| parent | dc33eb6c424a1325e53644517f78c3461591211d (diff) | |
| download | rust-f034a4fa14967ac36ceadbfd1ec80d098e1b8c7a.tar.gz rust-f034a4fa14967ac36ceadbfd1ec80d098e1b8c7a.zip | |
Rollup merge of #144623 - RalfJung:miri, r=RalfJung
miri subtree update Subtree update of `miri` to https://github.com/rust-lang/miri/commit/fc4d9a2720d38f815d3e20627b805b4a379e5c8b. Created using https://github.com/rust-lang/josh-sync. r? `@ghost`
Diffstat (limited to 'src/tools/miri/genmc-sys/src_cpp/MiriInterface.cpp')
| -rw-r--r-- | src/tools/miri/genmc-sys/src_cpp/MiriInterface.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/tools/miri/genmc-sys/src_cpp/MiriInterface.cpp b/src/tools/miri/genmc-sys/src_cpp/MiriInterface.cpp new file mode 100644 index 00000000000..0827bb3d407 --- /dev/null +++ b/src/tools/miri/genmc-sys/src_cpp/MiriInterface.cpp @@ -0,0 +1,50 @@ +#include "MiriInterface.hpp" + +#include "genmc-sys/src/lib.rs.h" + +auto MiriGenMCShim::createHandle(const GenmcParams &config) + -> std::unique_ptr<MiriGenMCShim> +{ + auto conf = std::make_shared<Config>(); + + // Miri needs all threads to be replayed, even fully completed ones. + conf->replayCompletedThreads = true; + + // We only support the RC11 memory model for Rust. + conf->model = ModelType::RC11; + + conf->printRandomScheduleSeed = config.print_random_schedule_seed; + + // FIXME(genmc): disable any options we don't support currently: + conf->ipr = false; + conf->disableBAM = true; + conf->instructionCaching = false; + + ERROR_ON(config.do_symmetry_reduction, "Symmetry reduction is currently unsupported in GenMC mode."); + conf->symmetryReduction = config.do_symmetry_reduction; + + // FIXME(genmc): Should there be a way to change this option from Miri? + conf->schedulePolicy = SchedulePolicy::WF; + + // FIXME(genmc): implement estimation mode: + conf->estimate = false; + conf->estimationMax = 1000; + const auto mode = conf->estimate ? GenMCDriver::Mode(GenMCDriver::EstimationMode{}) + : GenMCDriver::Mode(GenMCDriver::VerificationMode{}); + + // Running Miri-GenMC without race detection is not supported. + // Disabling this option also changes the behavior of the replay scheduler to only schedule at atomic operations, which is required with Miri. + // This happens because Miri can generate multiple GenMC events for a single MIR terminator. Without this option, + // the scheduler might incorrectly schedule an atomic MIR terminator because the first event it creates is a non-atomic (e.g., `StorageLive`). + conf->disableRaceDetection = false; + + // Miri can already check for unfreed memory. Also, GenMC cannot distinguish between memory + // that is allowed to leak and memory that is not. + conf->warnUnfreedMemory = false; + + // FIXME(genmc): check config: + // checkConfigOptions(*conf); + + auto driver = std::make_unique<MiriGenMCShim>(std::move(conf), mode); + return driver; +} |
