diff options
| author | Tshepang Mbambo <hopsi@tuta.io> | 2025-08-02 00:40:01 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-02 00:40:01 +0200 |
| commit | 171c2478c06da00fb010cc77c333d328410ee796 (patch) | |
| tree | e32965651228b69cc5cf14ad47e7e762c8ed7483 /src/tools/miri/genmc-sys/src_cpp/MiriInterface.cpp | |
| parent | 219e4c141dd62e8f026312746fe3d7be0569151f (diff) | |
| parent | 7cab27d73ab228be6a1eface8f0cb2f3c3b76c7c (diff) | |
| download | rust-171c2478c06da00fb010cc77c333d328410ee796.tar.gz rust-171c2478c06da00fb010cc77c333d328410ee796.zip | |
Merge pull request #2526 from rust-lang/rustc-pull
Rustc pull update
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; +} |
