cotrol stacked borrows consistency check with its own feature flag

This commit is contained in:
Ralf Jung 2024-03-30 23:10:43 +01:00
parent f04352a7dd
commit 10217fdec6
3 changed files with 18 additions and 10 deletions

View file

@ -59,6 +59,7 @@ harness = false
[features]
default = ["stack-cache"]
stack-cache = []
stack-cache-consistency-check = ["stack-cache"]
# Be aware that this file is inside a workspace when used via the
# submodule in the rustc repo. That means there are many cargo features

View file

@ -22,17 +22,24 @@ if [ "$HOST_TARGET" = i686-pc-windows-msvc ]; then
BASH="C:/Program Files/Git/usr/bin/bash"
fi
# Determine configuration for installed build
echo "Installing release version of Miri"
# Global configuration
export RUSTFLAGS="-D warnings"
export CARGO_INCREMENTAL=0
export CARGO_EXTRA_FLAGS="--locked"
# Determine configuration for installed build
echo "Installing release version of Miri"
./miri install
# Prepare debug build for direct `./miri` invocations
echo "Building debug version of Miri"
echo "Checking various feature flag configurations"
./miri check --no-default-features # make sure this can be built
./miri check --all-features # and this, too
./miri check # and this, too
# `--all-features` is used for the build below, so no extra check needed.
# Prepare debug build for direct `./miri` invocations.
# We enable all features to make sure the Stacked Borrows consistency check runs.
echo "Building debug version of Miri"
export CARGO_EXTRA_FLAGS="$CARGO_EXTRA_FLAGS --all-features"
./miri build --all-targets # the build that all the `./miri test` below will use
endgroup

View file

@ -146,7 +146,7 @@ impl<'tcx> Stack {
/// Panics if any of the caching mechanisms have broken,
/// - The StackCache indices don't refer to the parallel items,
/// - There are no Unique items outside of first_unique..last_unique
#[cfg(all(feature = "stack-cache", debug_assertions))]
#[cfg(feature = "stack-cache-consistency-check")]
fn verify_cache_consistency(&self) {
// Only a full cache needs to be valid. Also see the comments in find_granting_cache
// and set_unknown_bottom.
@ -190,7 +190,7 @@ impl<'tcx> Stack {
tag: ProvenanceExtra,
exposed_tags: &FxHashSet<BorTag>,
) -> Result<Option<usize>, ()> {
#[cfg(all(feature = "stack-cache", debug_assertions))]
#[cfg(feature = "stack-cache-consistency-check")]
self.verify_cache_consistency();
let ProvenanceExtra::Concrete(tag) = tag else {
@ -327,7 +327,7 @@ impl<'tcx> Stack {
// This primes the cache for the next access, which is almost always the just-added tag.
self.cache.add(new_idx, new);
#[cfg(debug_assertions)]
#[cfg(feature = "stack-cache-consistency-check")]
self.verify_cache_consistency();
}
@ -410,7 +410,7 @@ impl<'tcx> Stack {
self.unique_range.end = self.unique_range.end.min(disable_start);
}
#[cfg(all(feature = "stack-cache", debug_assertions))]
#[cfg(feature = "stack-cache-consistency-check")]
self.verify_cache_consistency();
Ok(())
@ -465,7 +465,7 @@ impl<'tcx> Stack {
self.unique_range = 0..0;
}
#[cfg(all(feature = "stack-cache", debug_assertions))]
#[cfg(feature = "stack-cache-consistency-check")]
self.verify_cache_consistency();
Ok(())
}