Skip to content

Commit 7049ae6

Browse files
Merge remote-tracking branch 'upstream/master' into HEAD
2 parents 3294745 + 1d30a3c commit 7049ae6

29 files changed

+149
-128
lines changed

src/bin/miri.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ fn main() {
342342
// (`install_ice_hook` might change `RUST_BACKTRACE`.)
343343
let env_snapshot = env::vars_os().collect::<Vec<_>>();
344344

345+
let args = rustc_driver::args::raw_args(&early_dcx).unwrap_or_else(|_| std::process::exit(rustc_driver::EXIT_FAILURE));
346+
345347
// If the environment asks us to actually be rustc, then do that.
346348
if let Some(crate_kind) = env::var_os("MIRI_BE_RUSTC") {
347349
// Earliest rustc setup.
@@ -359,7 +361,7 @@ fn main() {
359361

360362
// We cannot use `rustc_driver::main` as we need to adjust the CLI arguments.
361363
run_compiler(
362-
env::args().collect(),
364+
args,
363365
target_crate,
364366
&mut MiriBeRustCompilerCalls { target_crate },
365367
using_internal_features,
@@ -382,7 +384,7 @@ fn main() {
382384

383385
// If user has explicitly enabled/disabled isolation
384386
let mut isolation_enabled: Option<bool> = None;
385-
for arg in env::args() {
387+
for arg in args {
386388
if rustc_args.is_empty() {
387389
// Very first arg: binary name.
388390
rustc_args.push(arg);

src/diagnostics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fmt::{self, Write};
22
use std::num::NonZero;
33

4-
use rustc_errors::{Diag, DiagnosticMessage, Level};
4+
use rustc_errors::{Diag, DiagMessage, Level};
55
use rustc_span::{SpanData, Symbol, DUMMY_SP};
66
use rustc_target::abi::{Align, Size};
77

@@ -95,7 +95,7 @@ impl fmt::Debug for TerminationInfo {
9595
}
9696

9797
impl MachineStopType for TerminationInfo {
98-
fn diagnostic_message(&self) -> DiagnosticMessage {
98+
fn diagnostic_message(&self) -> DiagMessage {
9999
self.to_string().into()
100100
}
101101
fn add_args(

src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
381381
f: ty::Instance<'tcx>,
382382
caller_abi: Abi,
383383
args: &[Immediate<Provenance>],
384-
dest: Option<&PlaceTy<'tcx, Provenance>>,
384+
dest: Option<&MPlaceTy<'tcx, Provenance>>,
385385
stack_pop: StackPopCleanup,
386386
) -> InterpResult<'tcx> {
387387
let this = self.eval_context_mut();

src/machine.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use std::fmt;
88
use std::path::Path;
99
use std::process;
1010

11-
use either::Either;
1211
use rand::rngs::StdRng;
1312
use rand::Rng;
1413
use rand::SeedableRng;
@@ -950,7 +949,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
950949
instance: ty::Instance<'tcx>,
951950
abi: Abi,
952951
args: &[FnArg<'tcx, Provenance>],
953-
dest: &PlaceTy<'tcx, Provenance>,
952+
dest: &MPlaceTy<'tcx, Provenance>,
954953
ret: Option<mir::BasicBlock>,
955954
unwind: mir::UnwindAction,
956955
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
@@ -962,7 +961,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
962961
// to run extra MIR), and Ok(Some(body)) if we found MIR to run for the
963962
// foreign function
964963
// Any needed call to `goto_block` will be performed by `emulate_foreign_item`.
965-
let args = ecx.copy_fn_args(args)?; // FIXME: Should `InPlace` arguments be reset to uninit?
964+
let args = ecx.copy_fn_args(args); // FIXME: Should `InPlace` arguments be reset to uninit?
966965
let link_name = ecx.item_link_name(instance.def_id());
967966
return ecx.emulate_foreign_item(link_name, abi, &args, dest, ret, unwind);
968967
}
@@ -977,11 +976,11 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
977976
fn_val: DynSym,
978977
abi: Abi,
979978
args: &[FnArg<'tcx, Provenance>],
980-
dest: &PlaceTy<'tcx, Provenance>,
979+
dest: &MPlaceTy<'tcx, Provenance>,
981980
ret: Option<mir::BasicBlock>,
982981
unwind: mir::UnwindAction,
983982
) -> InterpResult<'tcx> {
984-
let args = ecx.copy_fn_args(args)?; // FIXME: Should `InPlace` arguments be reset to uninit?
983+
let args = ecx.copy_fn_args(args); // FIXME: Should `InPlace` arguments be reset to uninit?
985984
ecx.emulate_dyn_sym(fn_val, abi, &args, dest, ret, unwind)
986985
}
987986

@@ -990,7 +989,7 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
990989
ecx: &mut MiriInterpCx<'mir, 'tcx>,
991990
instance: ty::Instance<'tcx>,
992991
args: &[OpTy<'tcx, Provenance>],
993-
dest: &PlaceTy<'tcx, Provenance>,
992+
dest: &MPlaceTy<'tcx, Provenance>,
994993
ret: Option<mir::BasicBlock>,
995994
unwind: mir::UnwindAction,
996995
) -> InterpResult<'tcx> {
@@ -1334,18 +1333,12 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
13341333

13351334
fn protect_in_place_function_argument(
13361335
ecx: &mut InterpCx<'mir, 'tcx, Self>,
1337-
place: &PlaceTy<'tcx, Provenance>,
1336+
place: &MPlaceTy<'tcx, Provenance>,
13381337
) -> InterpResult<'tcx> {
13391338
// If we have a borrow tracker, we also have it set up protection so that all reads *and
13401339
// writes* during this call are insta-UB.
13411340
let protected_place = if ecx.machine.borrow_tracker.is_some() {
1342-
// Have to do `to_op` first because a `Place::Local` doesn't imply the local doesn't have an address.
1343-
if let Either::Left(place) = ecx.place_to_op(place)?.as_mplace_or_imm() {
1344-
ecx.protect_place(&place)?.into()
1345-
} else {
1346-
// Locals that don't have their address taken are as protected as they can ever be.
1347-
place.clone()
1348-
}
1341+
ecx.protect_place(&place)?.into()
13491342
} else {
13501343
// No borrow tracker.
13511344
place.clone()

src/shims/backtrace.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
1212
abi: Abi,
1313
link_name: Symbol,
1414
args: &[OpTy<'tcx, Provenance>],
15-
dest: &PlaceTy<'tcx, Provenance>,
15+
dest: &MPlaceTy<'tcx, Provenance>,
1616
) -> InterpResult<'tcx> {
1717
let this = self.eval_context_mut();
1818
let [flags] = this.check_shim(abi, Abi::Rust, link_name, args)?;
@@ -32,7 +32,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
3232
abi: Abi,
3333
link_name: Symbol,
3434
args: &[OpTy<'tcx, Provenance>],
35-
dest: &PlaceTy<'tcx, Provenance>,
35+
dest: &MPlaceTy<'tcx, Provenance>,
3636
) -> InterpResult<'tcx> {
3737
let this = self.eval_context_mut();
3838
let tcx = this.tcx;
@@ -145,7 +145,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
145145
abi: Abi,
146146
link_name: Symbol,
147147
args: &[OpTy<'tcx, Provenance>],
148-
dest: &PlaceTy<'tcx, Provenance>,
148+
dest: &MPlaceTy<'tcx, Provenance>,
149149
) -> InterpResult<'tcx> {
150150
let this = self.eval_context_mut();
151151
let [ptr, flags] = this.check_shim(abi, Abi::Rust, link_name, args)?;
@@ -174,7 +174,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
174174
// `lo.col` is 0-based - add 1 to make it 1-based for the caller.
175175
let colno: u32 = u32::try_from(lo.col.0.saturating_add(1)).unwrap_or(0);
176176

177-
let dest = this.force_allocation(dest)?;
178177
if let ty::Adt(adt, _) = dest.layout.ty.kind() {
179178
if !adt.repr().c() {
180179
throw_ub_format!(
@@ -191,29 +190,29 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
191190
let filename_alloc =
192191
this.allocate_str(&filename, MiriMemoryKind::Rust.into(), Mutability::Mut)?;
193192

194-
this.write_immediate(name_alloc.to_ref(this), &this.project_field(&dest, 0)?)?;
195-
this.write_immediate(filename_alloc.to_ref(this), &this.project_field(&dest, 1)?)?;
193+
this.write_immediate(name_alloc.to_ref(this), &this.project_field(dest, 0)?)?;
194+
this.write_immediate(filename_alloc.to_ref(this), &this.project_field(dest, 1)?)?;
196195
}
197196
1 => {
198197
this.write_scalar(
199198
Scalar::from_target_usize(name.len().try_into().unwrap(), this),
200-
&this.project_field(&dest, 0)?,
199+
&this.project_field(dest, 0)?,
201200
)?;
202201
this.write_scalar(
203202
Scalar::from_target_usize(filename.len().try_into().unwrap(), this),
204-
&this.project_field(&dest, 1)?,
203+
&this.project_field(dest, 1)?,
205204
)?;
206205
}
207206
_ => throw_unsup_format!("unknown `miri_resolve_frame` flags {}", flags),
208207
}
209208

210-
this.write_scalar(Scalar::from_u32(lineno), &this.project_field(&dest, 2)?)?;
211-
this.write_scalar(Scalar::from_u32(colno), &this.project_field(&dest, 3)?)?;
209+
this.write_scalar(Scalar::from_u32(lineno), &this.project_field(dest, 2)?)?;
210+
this.write_scalar(Scalar::from_u32(colno), &this.project_field(dest, 3)?)?;
212211

213212
// Support a 4-field struct for now - this is deprecated
214213
// and slated for removal.
215214
if num_fields == 5 {
216-
this.write_pointer(fn_ptr, &this.project_field(&dest, 4)?)?;
215+
this.write_pointer(fn_ptr, &this.project_field(dest, 4)?)?;
217216
}
218217

219218
Ok(())

src/shims/ffi_support.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
7070
fn call_external_c_and_store_return<'a>(
7171
&mut self,
7272
link_name: Symbol,
73-
dest: &PlaceTy<'tcx, Provenance>,
73+
dest: &MPlaceTy<'tcx, Provenance>,
7474
ptr: CodePtr,
7575
libffi_args: Vec<libffi::high::Arg<'a>>,
7676
) -> InterpResult<'tcx, ()> {
@@ -205,7 +205,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
205205
fn call_external_c_fct(
206206
&mut self,
207207
link_name: Symbol,
208-
dest: &PlaceTy<'tcx, Provenance>,
208+
dest: &MPlaceTy<'tcx, Provenance>,
209209
args: &[OpTy<'tcx, Provenance>],
210210
) -> InterpResult<'tcx, bool> {
211211
// Get the pointer to the function in the shared object file if it exists.

src/shims/foreign_items.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
5757
link_name: Symbol,
5858
abi: Abi,
5959
args: &[OpTy<'tcx, Provenance>],
60-
dest: &PlaceTy<'tcx, Provenance>,
60+
dest: &MPlaceTy<'tcx, Provenance>,
6161
ret: Option<mir::BasicBlock>,
6262
unwind: mir::UnwindAction,
6363
) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
@@ -123,7 +123,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
123123
// Second: functions that return immediately.
124124
match this.emulate_foreign_item_inner(link_name, abi, args, dest)? {
125125
EmulateForeignItemResult::NeedsJumping => {
126-
trace!("{:?}", this.dump_place(dest));
126+
trace!("{:?}", this.dump_place(&dest.clone().into()));
127127
this.go_to_block(ret);
128128
}
129129
EmulateForeignItemResult::AlreadyJumped => (),
@@ -149,7 +149,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
149149
sym: DynSym,
150150
abi: Abi,
151151
args: &[OpTy<'tcx, Provenance>],
152-
dest: &PlaceTy<'tcx, Provenance>,
152+
dest: &MPlaceTy<'tcx, Provenance>,
153153
ret: Option<mir::BasicBlock>,
154154
unwind: mir::UnwindAction,
155155
) -> InterpResult<'tcx> {
@@ -401,7 +401,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
401401
link_name: Symbol,
402402
abi: Abi,
403403
args: &[OpTy<'tcx, Provenance>],
404-
dest: &PlaceTy<'tcx, Provenance>,
404+
dest: &MPlaceTy<'tcx, Provenance>,
405405
) -> InterpResult<'tcx, EmulateForeignItemResult> {
406406
let this = self.eval_context_mut();
407407

@@ -1085,7 +1085,7 @@ trait EvalContextExtPriv<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
10851085
let [op] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
10861086

10871087
let (op, op_len) = this.operand_to_simd(op)?;
1088-
let (dest, dest_len) = this.place_to_simd(dest)?;
1088+
let (dest, dest_len) = this.mplace_to_simd(dest)?;
10891089

10901090
assert_eq!(dest_len, op_len);
10911091

src/shims/intrinsics/atomic.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
1818
&mut self,
1919
intrinsic_name: &str,
2020
args: &[OpTy<'tcx, Provenance>],
21-
dest: &PlaceTy<'tcx, Provenance>,
21+
dest: &MPlaceTy<'tcx, Provenance>,
2222
) -> InterpResult<'tcx> {
2323
let this = self.eval_context_mut();
2424

@@ -124,7 +124,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
124124
fn atomic_load(
125125
&mut self,
126126
args: &[OpTy<'tcx, Provenance>],
127-
dest: &PlaceTy<'tcx, Provenance>,
127+
dest: &MPlaceTy<'tcx, Provenance>,
128128
atomic: AtomicReadOrd,
129129
) -> InterpResult<'tcx> {
130130
let this = self.eval_context_mut();
@@ -181,7 +181,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
181181
fn atomic_rmw_op(
182182
&mut self,
183183
args: &[OpTy<'tcx, Provenance>],
184-
dest: &PlaceTy<'tcx, Provenance>,
184+
dest: &MPlaceTy<'tcx, Provenance>,
185185
atomic_op: AtomicOp,
186186
atomic: AtomicRwOrd,
187187
) -> InterpResult<'tcx> {
@@ -223,7 +223,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
223223
fn atomic_exchange(
224224
&mut self,
225225
args: &[OpTy<'tcx, Provenance>],
226-
dest: &PlaceTy<'tcx, Provenance>,
226+
dest: &MPlaceTy<'tcx, Provenance>,
227227
atomic: AtomicRwOrd,
228228
) -> InterpResult<'tcx> {
229229
let this = self.eval_context_mut();
@@ -240,7 +240,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
240240
fn atomic_compare_exchange_impl(
241241
&mut self,
242242
args: &[OpTy<'tcx, Provenance>],
243-
dest: &PlaceTy<'tcx, Provenance>,
243+
dest: &MPlaceTy<'tcx, Provenance>,
244244
success: AtomicRwOrd,
245245
fail: AtomicReadOrd,
246246
can_fail_spuriously: bool,
@@ -269,7 +269,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
269269
fn atomic_compare_exchange(
270270
&mut self,
271271
args: &[OpTy<'tcx, Provenance>],
272-
dest: &PlaceTy<'tcx, Provenance>,
272+
dest: &MPlaceTy<'tcx, Provenance>,
273273
success: AtomicRwOrd,
274274
fail: AtomicReadOrd,
275275
) -> InterpResult<'tcx> {
@@ -279,7 +279,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
279279
fn atomic_compare_exchange_weak(
280280
&mut self,
281281
args: &[OpTy<'tcx, Provenance>],
282-
dest: &PlaceTy<'tcx, Provenance>,
282+
dest: &MPlaceTy<'tcx, Provenance>,
283283
success: AtomicRwOrd,
284284
fail: AtomicReadOrd,
285285
) -> InterpResult<'tcx> {

src/shims/intrinsics/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
2323
&mut self,
2424
instance: ty::Instance<'tcx>,
2525
args: &[OpTy<'tcx, Provenance>],
26-
dest: &PlaceTy<'tcx, Provenance>,
26+
dest: &MPlaceTy<'tcx, Provenance>,
2727
ret: Option<mir::BasicBlock>,
2828
_unwind: mir::UnwindAction,
2929
) -> InterpResult<'tcx> {
@@ -61,7 +61,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6161
// The rest jumps to `ret` immediately.
6262
this.emulate_intrinsic_by_name(intrinsic_name, instance.args, args, dest)?;
6363

64-
trace!("{:?}", this.dump_place(dest));
64+
trace!("{:?}", this.dump_place(&dest.clone().into()));
6565
this.go_to_block(ret);
6666
Ok(())
6767
}
@@ -72,7 +72,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
7272
intrinsic_name: &str,
7373
generic_args: ty::GenericArgsRef<'tcx>,
7474
args: &[OpTy<'tcx, Provenance>],
75-
dest: &PlaceTy<'tcx, Provenance>,
75+
dest: &MPlaceTy<'tcx, Provenance>,
7676
) -> InterpResult<'tcx> {
7777
let this = self.eval_context_mut();
7878

0 commit comments

Comments
 (0)