Skip to content

Commit 70b2185

Browse files
authored
Rollup merge of rust-lang#122952 - RalfJung:miri, r=RalfJung
Miri subtree update r? `@ghost`
2 parents bad56c4 + 59b2945 commit 70b2185

31 files changed

+376
-120
lines changed

src/tools/miri/.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ jobs:
206206
run: |
207207
PR=$(gh pr create -B master --title 'Automatic Rustup' --body '')
208208
~/.local/bin/zulip-send --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com \
209-
--stream miri --subject "Cron Job Failure (miri, $(date -u +%Y-%m))" \
209+
--stream miri --subject "Miri Build Failure ($(date -u +%Y-%m))" \
210210
--message "A PR doing a rustc-pull [has been automatically created]($PR) for your convenience."
211211
env:
212212
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

src/tools/miri/bench-cargo-miri/invalidate/Cargo.lock renamed to src/tools/miri/bench-cargo-miri/range-iteration/Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
version = 3
44

55
[[package]]
6-
name = "invalidate"
6+
name = "range-iteration"
77
version = "0.1.0"

src/tools/miri/bench-cargo-miri/invalidate/Cargo.toml renamed to src/tools/miri/bench-cargo-miri/range-iteration/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "invalidate"
2+
name = "range-iteration"
33
version = "0.1.0"
44
edition = "2021"
55

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
//! This generates a lot of work for the AllocId part of the GC.
12
fn main() {
23
// The end of the range is just chosen to make the benchmark run for a few seconds.
3-
for _ in 0..200_000 {}
4+
for _ in 0..50_000 {}
45
}

src/tools/miri/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ee03c286cfdca26fa5b2a4ee40957625d2c826ff
1+
c3b05c6e5b5b59613350b8c2875b0add67ed74df

src/tools/miri/src/bin/miri.rs

+20
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,26 @@ impl rustc_driver::Callbacks for MiriBeRustCompilerCalls {
179179
});
180180
}
181181
}
182+
183+
fn after_analysis<'tcx>(
184+
&mut self,
185+
_: &rustc_interface::interface::Compiler,
186+
queries: &'tcx rustc_interface::Queries<'tcx>,
187+
) -> Compilation {
188+
queries.global_ctxt().unwrap().enter(|tcx| {
189+
if self.target_crate {
190+
// cargo-miri has patched the compiler flags to make these into check-only builds,
191+
// but we are still emulating regular rustc builds, which would perform post-mono
192+
// const-eval during collection. So let's also do that here, even if we might be
193+
// running with `--emit=metadata`. In particular this is needed to make
194+
// `compile_fail` doc tests trigger post-mono errors.
195+
// In general `collect_and_partition_mono_items` is not safe to call in check-only
196+
// builds, but we are setting `-Zalways-encode-mir` which avoids those issues.
197+
let _ = tcx.collect_and_partition_mono_items(());
198+
}
199+
});
200+
Compilation::Continue
201+
}
182202
}
183203

184204
fn show_error(msg: &impl std::fmt::Display) -> ! {

src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs

+15-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::borrow_tracker::{
1818
stacked_borrows::diagnostics::{AllocHistory, DiagnosticCx, DiagnosticCxBuilder},
1919
GlobalStateInner, ProtectorKind,
2020
};
21+
use crate::concurrency::data_race::{NaReadType, NaWriteType};
2122
use crate::*;
2223

2324
use diagnostics::{RetagCause, RetagInfo};
@@ -751,7 +752,13 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
751752
assert_eq!(access, AccessKind::Write);
752753
// Make sure the data race model also knows about this.
753754
if let Some(data_race) = alloc_extra.data_race.as_mut() {
754-
data_race.write(alloc_id, range, machine)?;
755+
data_race.write(
756+
alloc_id,
757+
range,
758+
NaWriteType::Retag,
759+
Some(place.layout.ty),
760+
machine,
761+
)?;
755762
}
756763
}
757764
}
@@ -794,7 +801,13 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
794801
assert_eq!(access, AccessKind::Read);
795802
// Make sure the data race model also knows about this.
796803
if let Some(data_race) = alloc_extra.data_race.as_ref() {
797-
data_race.read(alloc_id, range, &this.machine)?;
804+
data_race.read(
805+
alloc_id,
806+
range,
807+
NaReadType::Retag,
808+
Some(place.layout.ty),
809+
&this.machine,
810+
)?;
798811
}
799812
}
800813
Ok(())

src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ use rustc_middle::{
99
use rustc_span::def_id::DefId;
1010
use rustc_target::abi::{Abi, Size};
1111

12-
use crate::borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind};
1312
use crate::*;
13+
use crate::{
14+
borrow_tracker::{GlobalState, GlobalStateInner, ProtectorKind},
15+
concurrency::data_race::NaReadType,
16+
};
1417

1518
pub mod diagnostics;
1619
mod perms;
@@ -312,7 +315,13 @@ trait EvalContextPrivExt<'mir: 'ecx, 'tcx: 'mir, 'ecx>: crate::MiriInterpCxExt<'
312315
// Also inform the data race model (but only if any bytes are actually affected).
313316
if range.size.bytes() > 0 {
314317
if let Some(data_race) = alloc_extra.data_race.as_ref() {
315-
data_race.read(alloc_id, range, &this.machine)?;
318+
data_race.read(
319+
alloc_id,
320+
range,
321+
NaReadType::Retag,
322+
Some(place.layout.ty),
323+
&this.machine,
324+
)?;
316325
}
317326
}
318327

0 commit comments

Comments
 (0)