Skip to content

Commit b22ee40

Browse files
committed
remove -Zmiri-retag-fields
1 parent 4894162 commit b22ee40

File tree

9 files changed

+17
-125
lines changed

9 files changed

+17
-125
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,6 @@ to Miri failing to detect cases of undefined behavior in a program.
464464
errors and warnings.
465465
* `-Zmiri-recursive-validation` is a *highly experimental* flag that makes validity checking
466466
recurse below references.
467-
* `-Zmiri-retag-fields[=<all|none|scalar>]` controls when Stacked Borrows retagging recurses into
468-
fields. `all` means it always recurses (the default, and equivalent to `-Zmiri-retag-fields`
469-
without an explicit value), `none` means it never recurses, `scalar` means it only recurses for
470-
types where we would also emit `noalias` annotations in the generated LLVM IR (types passed as
471-
individual scalars or pairs of scalars). Setting this to `none` is **unsound**.
472467
* `-Zmiri-preemption-rate` configures the probability that at the end of a basic block, the active
473468
thread will be preempted. The default is `0.01` (i.e., 1%). Setting this to `0` disables
474469
preemption. Note that even without preemption, the schedule is still non-deterministic:

src/bin/miri.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use std::sync::atomic::{AtomicI32, AtomicU32, Ordering};
3636

3737
use miri::{
3838
BacktraceStyle, BorrowTrackerMethod, GenmcConfig, GenmcCtx, MiriConfig, MiriEntryFnType,
39-
ProvenanceMode, RetagFields, TreeBorrowsParams, ValidationMode, run_genmc_mode,
39+
ProvenanceMode, TreeBorrowsParams, ValidationMode, run_genmc_mode,
4040
};
4141
use rustc_abi::ExternAbi;
4242
use rustc_data_structures::sync;
@@ -535,21 +535,17 @@ fn main() {
535535
} else if arg == "-Zmiri-mute-stdout-stderr" {
536536
miri_config.mute_stdout_stderr = true;
537537
} else if arg == "-Zmiri-retag-fields" {
538-
miri_config.retag_fields = RetagFields::Yes;
538+
eprintln!(
539+
"warning: `-Zmiri-retag-fields` is a NOP and will be removed in a future version of Miri.\n\
540+
Field retagging has been on-by-default for a long time."
541+
);
539542
} else if arg == "-Zmiri-fixed-schedule" {
540543
miri_config.fixed_scheduling = true;
541544
} else if arg == "-Zmiri-deterministic-concurrency" {
542545
miri_config.fixed_scheduling = true;
543546
miri_config.address_reuse_cross_thread_rate = 0.0;
544547
miri_config.cmpxchg_weak_failure_rate = 0.0;
545548
miri_config.weak_memory_emulation = false;
546-
} else if let Some(retag_fields) = arg.strip_prefix("-Zmiri-retag-fields=") {
547-
miri_config.retag_fields = match retag_fields {
548-
"all" => RetagFields::Yes,
549-
"none" => RetagFields::No,
550-
"scalar" => RetagFields::OnlyScalar,
551-
_ => fatal_error!("`-Zmiri-retag-fields` can only be `all`, `none`, or `scalar`"),
552-
};
553549
} else if let Some(param) = arg.strip_prefix("-Zmiri-seed=") {
554550
let seed = param.parse::<u64>().unwrap_or_else(|_| {
555551
fatal_error!("-Zmiri-seed must be an integer that fits into u64")

src/borrow_tracker/mod.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ pub struct GlobalStateInner {
116116
protected_tags: FxHashMap<BorTag, ProtectorKind>,
117117
/// The pointer ids to trace
118118
tracked_pointer_tags: FxHashSet<BorTag>,
119-
/// Whether to recurse into datatypes when searching for pointers to retag.
120-
retag_fields: RetagFields,
121119
}
122120

123121
impl VisitProvenance for GlobalStateInner {
@@ -131,18 +129,6 @@ impl VisitProvenance for GlobalStateInner {
131129
/// We need interior mutable access to the global state.
132130
pub type GlobalState = RefCell<GlobalStateInner>;
133131

134-
/// Policy on whether to recurse into fields to retag
135-
#[derive(Copy, Clone, Debug)]
136-
pub enum RetagFields {
137-
/// Don't retag any fields.
138-
No,
139-
/// Retag all fields.
140-
Yes,
141-
/// Only retag fields of types with Scalar and ScalarPair layout,
142-
/// to match the LLVM `noalias` we generate.
143-
OnlyScalar,
144-
}
145-
146132
/// The flavor of the protector.
147133
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
148134
pub enum ProtectorKind {
@@ -168,15 +154,13 @@ impl GlobalStateInner {
168154
pub fn new(
169155
borrow_tracker_method: BorrowTrackerMethod,
170156
tracked_pointer_tags: FxHashSet<BorTag>,
171-
retag_fields: RetagFields,
172157
) -> Self {
173158
GlobalStateInner {
174159
borrow_tracker_method,
175160
next_ptr_tag: BorTag::one(),
176161
root_ptr_tags: FxHashMap::default(),
177162
protected_tags: FxHashMap::default(),
178163
tracked_pointer_tags,
179-
retag_fields,
180164
}
181165
}
182166

@@ -244,11 +228,7 @@ pub struct TreeBorrowsParams {
244228

245229
impl BorrowTrackerMethod {
246230
pub fn instantiate_global_state(self, config: &MiriConfig) -> GlobalState {
247-
RefCell::new(GlobalStateInner::new(
248-
self,
249-
config.tracked_pointer_tags.clone(),
250-
config.retag_fields,
251-
))
231+
RefCell::new(GlobalStateInner::new(self, config.tracked_pointer_tags.clone()))
252232
}
253233

254234
pub fn get_tree_borrows_params(self) -> TreeBorrowsParams {

src/borrow_tracker/stacked_borrows/mod.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::fmt::Write;
99
use std::sync::atomic::AtomicBool;
1010
use std::{cmp, mem};
1111

12-
use rustc_abi::{BackendRepr, Size};
12+
use rustc_abi::Size;
1313
use rustc_data_structures::fx::FxHashSet;
1414
use rustc_middle::mir::{Mutability, RetagKind};
1515
use rustc_middle::ty::layout::HasTypingEnv;
@@ -887,22 +887,19 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
887887
place: &PlaceTy<'tcx>,
888888
) -> InterpResult<'tcx> {
889889
let this = self.eval_context_mut();
890-
let retag_fields = this.machine.borrow_tracker.as_mut().unwrap().get_mut().retag_fields;
891890
let retag_cause = match kind {
892891
RetagKind::TwoPhase => unreachable!(), // can only happen in `retag_ptr_value`
893892
RetagKind::FnEntry => RetagCause::FnEntry,
894893
RetagKind::Default | RetagKind::Raw => RetagCause::Normal,
895894
};
896-
let mut visitor =
897-
RetagVisitor { ecx: this, kind, retag_cause, retag_fields, in_field: false };
895+
let mut visitor = RetagVisitor { ecx: this, kind, retag_cause, in_field: false };
898896
return visitor.visit_value(place);
899897

900898
// The actual visitor.
901899
struct RetagVisitor<'ecx, 'tcx> {
902900
ecx: &'ecx mut MiriInterpCx<'tcx>,
903901
kind: RetagKind,
904902
retag_cause: RetagCause,
905-
retag_fields: RetagFields,
906903
in_field: bool,
907904
}
908905
impl<'ecx, 'tcx> RetagVisitor<'ecx, 'tcx> {
@@ -967,24 +964,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
967964
self.walk_value(place)?;
968965
}
969966
_ => {
970-
// Not a reference/pointer/box. Only recurse if configured appropriately.
971-
let recurse = match self.retag_fields {
972-
RetagFields::No => false,
973-
RetagFields::Yes => true,
974-
RetagFields::OnlyScalar => {
975-
// Matching `ArgAbi::new` at the time of writing, only fields of
976-
// `Scalar` and `ScalarPair` ABI are considered.
977-
matches!(
978-
place.layout.backend_repr,
979-
BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)
980-
)
981-
}
982-
};
983-
if recurse {
984-
let in_field = mem::replace(&mut self.in_field, true); // remember and restore old value
985-
self.walk_value(place)?;
986-
self.in_field = in_field;
987-
}
967+
// Not a reference/pointer/box. Recurse.
968+
let in_field = mem::replace(&mut self.in_field, true); // remember and restore old value
969+
self.walk_value(place)?;
970+
self.in_field = in_field;
988971
}
989972
}
990973

src/borrow_tracker/tree_borrows/mod.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc_abi::{BackendRepr, Size};
1+
use rustc_abi::Size;
22
use rustc_middle::mir::{Mutability, RetagKind};
33
use rustc_middle::ty::layout::HasTypingEnv;
44
use rustc_middle::ty::{self, Ty};
@@ -468,16 +468,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
468468
place: &PlaceTy<'tcx>,
469469
) -> InterpResult<'tcx> {
470470
let this = self.eval_context_mut();
471-
let options = this.machine.borrow_tracker.as_mut().unwrap().get_mut();
472-
let retag_fields = options.retag_fields;
473-
let mut visitor = RetagVisitor { ecx: this, kind, retag_fields };
471+
let mut visitor = RetagVisitor { ecx: this, kind };
474472
return visitor.visit_value(place);
475473

476474
// The actual visitor.
477475
struct RetagVisitor<'ecx, 'tcx> {
478476
ecx: &'ecx mut MiriInterpCx<'tcx>,
479477
kind: RetagKind,
480-
retag_fields: RetagFields,
481478
}
482479
impl<'ecx, 'tcx> RetagVisitor<'ecx, 'tcx> {
483480
#[inline(always)] // yes this helps in our benchmarks
@@ -545,22 +542,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
545542
self.walk_value(place)?;
546543
}
547544
_ => {
548-
// Not a reference/pointer/box. Only recurse if configured appropriately.
549-
let recurse = match self.retag_fields {
550-
RetagFields::No => false,
551-
RetagFields::Yes => true,
552-
RetagFields::OnlyScalar => {
553-
// Matching `ArgAbi::new` at the time of writing, only fields of
554-
// `Scalar` and `ScalarPair` ABI are considered.
555-
matches!(
556-
place.layout.backend_repr,
557-
BackendRepr::Scalar(..) | BackendRepr::ScalarPair(..)
558-
)
559-
}
560-
};
561-
if recurse {
562-
self.walk_value(place)?;
563-
}
545+
// Not a reference/pointer/box. Recurse.
546+
self.walk_value(place)?;
564547
}
565548
}
566549
interp_ok(())

src/eval.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ pub struct MiriConfig {
8888
pub preemption_rate: f64,
8989
/// Report the current instruction being executed every N basic blocks.
9090
pub report_progress: Option<u32>,
91-
/// Whether Stacked Borrows and Tree Borrows retagging should recurse into fields of datatypes.
92-
pub retag_fields: RetagFields,
9391
/// The location of the shared object files to load when calling external functions
9492
pub native_lib: Vec<PathBuf>,
9593
/// Whether to enable the new native lib tracing system.
@@ -147,7 +145,6 @@ impl Default for MiriConfig {
147145
mute_stdout_stderr: false,
148146
preemption_rate: 0.01, // 1%
149147
report_progress: None,
150-
retag_fields: RetagFields::Yes,
151148
native_lib: vec![],
152149
native_lib_enable_tracing: false,
153150
gc_interval: 10_000,

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ pub use crate::borrow_tracker::stacked_borrows::{
119119
};
120120
pub use crate::borrow_tracker::tree_borrows::{EvalContextExt as _, Tree};
121121
pub use crate::borrow_tracker::{
122-
BorTag, BorrowTrackerMethod, EvalContextExt as _, RetagFields, TreeBorrowsParams,
122+
BorTag, BorrowTrackerMethod, EvalContextExt as _, TreeBorrowsParams,
123123
};
124124
pub use crate::clock::{Instant, MonotonicClock};
125125
pub use crate::concurrency::cpu_affinity::MAX_CPUS;

tests/pass/stacked_borrows/no_field_retagging.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/pass/stacked_borrows/non_scalar_field_retagging.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)