Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
887c130
solarish platform add supports for available-parallelism.
devnexen May 24, 2024
d3974fa
reorder code
RalfJung May 26, 2024
b531ca7
Auto merge of #3629 - devnexen:illumos_num_cpus, r=RalfJung
bors May 26, 2024
38870cf
avoid using macro_use
RalfJung May 26, 2024
da6c08e
Auto merge of #3634 - RalfJung:macro_use, r=RalfJung
bors May 26, 2024
d562cec
Preparing for merge from rustc
RalfJung May 27, 2024
8058933
Merge from rustc
RalfJung May 27, 2024
84f70ab
fmt
RalfJung May 27, 2024
79c30b6
Auto merge of #3635 - RalfJung:rustup, r=RalfJung
bors May 27, 2024
fcb4cf5
avoid repeating the Provenance parameter everywhere
RalfJung May 27, 2024
98a3ac9
also add type aliases for the pointer types
RalfJung May 27, 2024
2c1a5a7
Auto merge of #3636 - RalfJung:provenance-type-aliases, r=RalfJung
bors May 27, 2024
4277ddf
Preparing for merge from rustc
May 28, 2024
54db9aa
Merge from rustc
May 28, 2024
ef86cbd
Auto merge of #3639 - rust-lang:rustup-2024-05-28, r=RalfJung
bors May 28, 2024
4991fd9
move ./miri environment variables to CONTRIBUTING
RalfJung May 28, 2024
9d162eb
Auto merge of #3641 - RalfJung:env-vars, r=RalfJung
bors May 28, 2024
d5235f9
Fix "local crate" detection
narpfel May 28, 2024
483485e
Add a benchmark for creating large uninit allocations
saethlin May 27, 2024
ec5327d
Auto merge of #3638 - saethlin:big-alloc-bench, r=RalfJung
bors May 29, 2024
a963103
add tests for local crate detection
narpfel May 28, 2024
5bf7832
Preparing for merge from rustc
May 30, 2024
8faa34e
Merge from rustc
May 30, 2024
a200d38
fmt
May 30, 2024
daeb68a
make env/var test deterministic
RalfJung May 30, 2024
8a7338a
Auto merge of #3645 - rust-lang:rustup-2024-05-30, r=RalfJung
bors May 30, 2024
00644c1
add a comment
RalfJung May 30, 2024
58f3894
Auto merge of #3644 - narpfel:local-crates-metadata-format-update, r=…
bors May 30, 2024
0453f37
Preparing for merge from rustc
Jun 5, 2024
7950562
Merge from rustc
Jun 5, 2024
9a77692
fmt
Jun 5, 2024
56438c3
Auto merge of #3648 - rust-lang:rustup-2024-06-05, r=RalfJung
bors Jun 5, 2024
14f65cb
Preparing for merge from rustc
Jun 7, 2024
f0ea91c
Merge from rustc
Jun 7, 2024
60f7aab
Auto merge of #3652 - rust-lang:rustup-2024-06-07, r=RalfJung
bors Jun 7, 2024
27d9a46
Fix stage in contributing
Noratrieb Jun 7, 2024
dce1bbf
Remove --stage entirely from contributing
Noratrieb Jun 7, 2024
4c18f2a
Auto merge of #3654 - Nilstrieb:patch-1, r=RalfJung
bors Jun 7, 2024
a269cf5
Add eventfd shim
tiif Jun 8, 2024
20b3527
Auto merge of #3650 - tiif:feat/eventfd, r=oli-obk
bors Jun 8, 2024
3fa1d47
add support for `pclmulqdq`
folkertdev May 28, 2024
ea73f00
comment nits
RalfJung Jun 8, 2024
4d5fd11
Auto merge of #3640 - folkertdev:add-pclmulqdq, r=RalfJung
bors Jun 8, 2024
ca3d93a
portable-simd: add test for non-power-of-2 bitmask
RalfJung Jun 8, 2024
1f1dd65
Auto merge of #3655 - RalfJung:simd-bitmask, r=RalfJung
bors Jun 8, 2024
1ae0053
Preparing for merge from rustc
RalfJung Jun 8, 2024
5367235
Merge from rustc
RalfJung Jun 8, 2024
989dfb1
Auto merge of #3656 - RalfJung:rustup, r=RalfJung
bors Jun 8, 2024
a13a9ab
simd_bitmask: nicer error when the mask is too big
RalfJung Jun 9, 2024
d5fa08c
Auto merge of #3659 - RalfJung:bitmask-too-large, r=RalfJung
bors Jun 9, 2024
91e53aa
simd_select_bitmask: fix intrinsic name in error
RalfJung Jun 9, 2024
773415d
Auto merge of #3660 - RalfJung:wrong-error, r=RalfJung
bors Jun 9, 2024
110b092
simd_bitmask: work correctly for sizes like 24
RalfJung Jun 9, 2024
ba45198
use strict ops in some places
RalfJung Jun 9, 2024
de822dc
Auto merge of #3662 - RalfJung:simd-bitmask, r=RalfJung
bors Jun 9, 2024
844450a
First attempt
tiif Jun 7, 2024
0bca4e1
Convert u128 to nanosecond
tiif Jun 7, 2024
9f60709
Remove test
tiif Jun 7, 2024
9cf04b5
Use modulo operation to convert nanosecond to Duration
tiif Jun 7, 2024
aa83235
Move duration division out
tiif Jun 7, 2024
d0fb350
Add comment for u128 to u64 conversion.
tiif Jun 9, 2024
e85c521
Checked add for duration update
tiif Jun 9, 2024
21d66af
Saturate to u64::MAX
tiif Jun 9, 2024
40182be
Run cargo fmt
tiif Jun 9, 2024
509eec1
Auto merge of #3653 - tiif:bug/futex_ice, r=RalfJung
bors Jun 9, 2024
87c4d29
don't panic if time computaton overflows
RalfJung Jun 9, 2024
b5ae8bd
Auto merge of #3663 - RalfJung:timeouts, r=RalfJung
bors Jun 9, 2024
69512c7
Follow up fix for eventfd shim
tiif Jun 9, 2024
ad85a20
Auto merge of #3661 - tiif:fix/eventfd, r=RalfJung
bors Jun 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
also add type aliases for the pointer types
  • Loading branch information
RalfJung committed May 27, 2024
commit 98a3ac9e6d762a49d1dc8de106f2b98655e2da51
13 changes: 8 additions & 5 deletions src/tools/miri/src/alloc_addresses/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
Ok(())
}

fn ptr_from_addr_cast(&self, addr: u64) -> InterpResult<'tcx, Pointer<Option<Provenance>>> {
fn ptr_from_addr_cast(&self, addr: u64) -> InterpResult<'tcx, Pointer> {
trace!("Casting {:#x} to a pointer", addr);

let ecx = self.eval_context_ref();
Expand Down Expand Up @@ -297,10 +297,10 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
/// Convert a relative (tcx) pointer to a Miri pointer.
fn adjust_alloc_root_pointer(
&self,
ptr: Pointer<CtfeProvenance>,
ptr: interpret::Pointer<CtfeProvenance>,
tag: BorTag,
kind: MemoryKind,
) -> InterpResult<'tcx, Pointer<Provenance>> {
) -> InterpResult<'tcx, interpret::Pointer<Provenance>> {
let ecx = self.eval_context_ref();

let (prov, offset) = ptr.into_parts(); // offset is relative (AllocId provenance)
Expand All @@ -310,12 +310,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
// Add offset with the right kind of pointer-overflowing arithmetic.
let dl = ecx.data_layout();
let absolute_addr = dl.overflowing_offset(base_addr, offset.bytes()).0;
Ok(Pointer::new(Provenance::Concrete { alloc_id, tag }, Size::from_bytes(absolute_addr)))
Ok(interpret::Pointer::new(
Provenance::Concrete { alloc_id, tag },
Size::from_bytes(absolute_addr),
))
}

/// When a pointer is used for a memory access, this computes where in which allocation the
/// access is going.
fn ptr_get_alloc(&self, ptr: Pointer<Provenance>) -> Option<(AllocId, Size)> {
fn ptr_get_alloc(&self, ptr: interpret::Pointer<Provenance>) -> Option<(AllocId, Size)> {
let ecx = self.eval_context_ref();

let (tag, addr) = ptr.into_parts(); // addr is absolute (Tag provenance)
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/src/borrow_tracker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

fn give_pointer_debug_name(
&mut self,
ptr: Pointer<Option<Provenance>>,
ptr: Pointer,
nth_parent: u8,
name: &str,
) -> InterpResult<'tcx> {
Expand Down
6 changes: 3 additions & 3 deletions src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ impl Stacks {
trace!(
"read access with tag {:?}: {:?}, size {}",
tag,
Pointer::new(alloc_id, range.start),
interpret::Pointer::new(alloc_id, range.start),
range.size.bytes()
);
let dcx = DiagnosticCxBuilder::read(machine, tag, range);
Expand All @@ -552,7 +552,7 @@ impl Stacks {
trace!(
"write access with tag {:?}: {:?}, size {}",
tag,
Pointer::new(alloc_id, range.start),
interpret::Pointer::new(alloc_id, range.start),
range.size.bytes()
);
let dcx = DiagnosticCxBuilder::write(machine, tag, range);
Expand Down Expand Up @@ -692,7 +692,7 @@ trait EvalContextPrivExt<'tcx, 'ecx>: crate::MiriInterpCxExt<'tcx> {
new_tag,
orig_tag,
place.layout.ty,
Pointer::new(alloc_id, base_offset),
interpret::Pointer::new(alloc_id, base_offset),
size.bytes()
);

Expand Down
6 changes: 3 additions & 3 deletions src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl<'tcx> Tree {
"{} with tag {:?}: {:?}, size {}",
access_kind,
prov,
Pointer::new(alloc_id, range.start),
interpret::Pointer::new(alloc_id, range.start),
range.size.bytes(),
);
// TODO: for now we bail out on wildcard pointers. Eventually we should
Expand Down Expand Up @@ -258,7 +258,7 @@ trait EvalContextPrivExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
new_tag,
orig_tag,
place.layout.ty,
Pointer::new(alloc_id, base_offset),
interpret::Pointer::new(alloc_id, base_offset),
ptr_size.bytes()
);

Expand Down Expand Up @@ -574,7 +574,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
/// of `ptr` (with 0 representing `ptr` itself)
fn tb_give_pointer_debug_name(
&mut self,
ptr: Pointer<Option<Provenance>>,
ptr: Pointer,
nth_parent: u8,
name: &str,
) -> InterpResult<'tcx> {
Expand Down
8 changes: 4 additions & 4 deletions src/tools/miri/src/concurrency/data_race.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ impl VClockAlloc {
mem_clocks: &MemoryCellClocks,
access: AccessType,
access_size: Size,
ptr_dbg: Pointer<AllocId>,
ptr_dbg: interpret::Pointer<AllocId>,
ty: Option<Ty<'_>>,
) -> InterpResult<'tcx> {
let (active_index, active_clocks) = global.active_thread_state(thread_mgr);
Expand Down Expand Up @@ -1063,7 +1063,7 @@ impl VClockAlloc {
mem_clocks,
AccessType::NaRead(read_type),
access_range.size,
Pointer::new(alloc_id, Size::from_bytes(mem_clocks_range.start)),
interpret::Pointer::new(alloc_id, Size::from_bytes(mem_clocks_range.start)),
ty,
);
}
Expand Down Expand Up @@ -1108,7 +1108,7 @@ impl VClockAlloc {
mem_clocks,
AccessType::NaWrite(write_type),
access_range.size,
Pointer::new(alloc_id, Size::from_bytes(mem_clocks_range.start)),
interpret::Pointer::new(alloc_id, Size::from_bytes(mem_clocks_range.start)),
ty,
);
}
Expand Down Expand Up @@ -1337,7 +1337,7 @@ trait EvalContextPrivExt<'tcx>: MiriInterpCxExt<'tcx> {
mem_clocks,
access,
place.layout.size,
Pointer::new(
interpret::Pointer::new(
alloc_id,
Size::from_bytes(mem_clocks_range.start),
),
Expand Down
45 changes: 21 additions & 24 deletions src/tools/miri/src/concurrency/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,8 @@ pub struct ThreadManager<'tcx> {
///
/// Note that this vector also contains terminated threads.
threads: IndexVec<ThreadId, Thread<'tcx>>,
/// A mapping from a thread-local static to an allocation id of a thread
/// specific allocation.
thread_local_alloc_ids: FxHashMap<(DefId, ThreadId), Pointer<Provenance>>,
/// A mapping from a thread-local static to the thread specific allocation.
thread_local_allocs: FxHashMap<(DefId, ThreadId), StrictPointer>,
/// A flag that indicates that we should change the active thread.
yield_active_thread: bool,
}
Expand All @@ -443,15 +442,15 @@ impl VisitProvenance for ThreadManager<'_> {
fn visit_provenance(&self, visit: &mut VisitWith<'_>) {
let ThreadManager {
threads,
thread_local_alloc_ids,
thread_local_allocs,
active_thread: _,
yield_active_thread: _,
} = self;

for thread in threads {
thread.visit_provenance(visit);
}
for ptr in thread_local_alloc_ids.values() {
for ptr in thread_local_allocs.values() {
ptr.visit_provenance(visit);
}
}
Expand All @@ -465,7 +464,7 @@ impl<'tcx> Default for ThreadManager<'tcx> {
Self {
active_thread: ThreadId::MAIN_THREAD,
threads,
thread_local_alloc_ids: Default::default(),
thread_local_allocs: Default::default(),
yield_active_thread: false,
}
}
Expand All @@ -487,16 +486,16 @@ impl<'tcx> ThreadManager<'tcx> {

/// Check if we have an allocation for the given thread local static for the
/// active thread.
fn get_thread_local_alloc_id(&self, def_id: DefId) -> Option<Pointer<Provenance>> {
self.thread_local_alloc_ids.get(&(def_id, self.active_thread)).cloned()
fn get_thread_local_alloc_id(&self, def_id: DefId) -> Option<StrictPointer> {
self.thread_local_allocs.get(&(def_id, self.active_thread)).cloned()
}

/// Set the pointer for the allocation of the given thread local
/// static for the active thread.
///
/// Panics if a thread local is initialized twice for the same thread.
fn set_thread_local_alloc(&mut self, def_id: DefId, ptr: Pointer<Provenance>) {
self.thread_local_alloc_ids.try_insert((def_id, self.active_thread), ptr).unwrap();
fn set_thread_local_alloc(&mut self, def_id: DefId, ptr: StrictPointer) {
self.thread_local_allocs.try_insert((def_id, self.active_thread), ptr).unwrap();
}

/// Borrow the stack of the active thread.
Expand Down Expand Up @@ -848,7 +847,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn get_or_create_thread_local_alloc(
&mut self,
def_id: DefId,
) -> InterpResult<'tcx, Pointer<Provenance>> {
) -> InterpResult<'tcx, StrictPointer> {
let this = self.eval_context_mut();
let tcx = this.tcx;
if let Some(old_alloc) = this.machine.threads.get_thread_local_alloc_id(def_id) {
Expand Down Expand Up @@ -878,7 +877,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn start_regular_thread(
&mut self,
thread: Option<MPlaceTy<'tcx>>,
start_routine: Pointer<Option<Provenance>>,
start_routine: Pointer,
start_abi: Abi,
func_arg: ImmTy<'tcx>,
ret_layout: TyAndLayout<'tcx>,
Expand Down Expand Up @@ -947,18 +946,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let gone_thread = this.active_thread();
{
let mut free_tls_statics = Vec::new();
this.machine.threads.thread_local_alloc_ids.retain(
|&(_def_id, thread), &mut alloc_id| {
if thread != gone_thread {
// A different thread, keep this static around.
return true;
}
// Delete this static from the map and from memory.
// We cannot free directly here as we cannot use `?` in this context.
free_tls_statics.push(alloc_id);
false
},
);
this.machine.threads.thread_local_allocs.retain(|&(_def_id, thread), &mut alloc_id| {
if thread != gone_thread {
// A different thread, keep this static around.
return true;
}
// Delete this static from the map and from memory.
// We cannot free directly here as we cannot use `?` in this context.
free_tls_statics.push(alloc_id);
false
});
// Now free the TLS statics.
for ptr in free_tls_statics {
match tls_alloc_action {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/miri/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum TerminationInfo {
},
DataRace {
involves_non_atomic: bool,
ptr: Pointer<AllocId>,
ptr: interpret::Pointer<AllocId>,
op1: RacingOp,
op2: RacingOp,
extra: Option<&'static str>,
Expand Down Expand Up @@ -128,7 +128,7 @@ pub enum NonHaltingDiagnostic {
details: bool,
},
WeakMemoryOutdatedLoad {
ptr: Pointer<Option<Provenance>>,
ptr: Pointer,
},
}

Expand Down
19 changes: 9 additions & 10 deletions src/tools/miri/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}

/// Test if this pointer equals 0.
fn ptr_is_null(&self, ptr: Pointer<Option<Provenance>>) -> InterpResult<'tcx, bool> {
fn ptr_is_null(&self, ptr: Pointer) -> InterpResult<'tcx, bool> {
Ok(ptr.addr().bytes() == 0)
}

/// Generate some random bytes, and write them to `dest`.
fn gen_random(&mut self, ptr: Pointer<Option<Provenance>>, len: u64) -> InterpResult<'tcx> {
fn gen_random(&mut self, ptr: Pointer, len: u64) -> InterpResult<'tcx> {
// Some programs pass in a null pointer and a length of 0
// to their platform's random-generation function (e.g. getrandom())
// on Linux. For compatibility with these programs, we don't perform
Expand Down Expand Up @@ -520,8 +520,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
let mut cur_addr = start_addr;
// Called when we detected an `UnsafeCell` at the given offset and size.
// Calls `action` and advances `cur_ptr`.
let mut unsafe_cell_action = |unsafe_cell_ptr: &Pointer<Option<Provenance>>,
unsafe_cell_size: Size| {
let mut unsafe_cell_action = |unsafe_cell_ptr: &Pointer, unsafe_cell_size: Size| {
// We assume that we are given the fields in increasing offset order,
// and nothing else changes.
let unsafe_cell_addr = unsafe_cell_ptr.addr();
Expand Down Expand Up @@ -924,7 +923,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}

/// Read a sequence of bytes until the first null terminator.
fn read_c_str<'a>(&'a self, ptr: Pointer<Option<Provenance>>) -> InterpResult<'tcx, &'a [u8]>
fn read_c_str<'a>(&'a self, ptr: Pointer) -> InterpResult<'tcx, &'a [u8]>
where
'tcx: 'a,
{
Expand Down Expand Up @@ -957,7 +956,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn write_c_str(
&mut self,
c_str: &[u8],
ptr: Pointer<Option<Provenance>>,
ptr: Pointer,
size: u64,
) -> InterpResult<'tcx, (bool, u64)> {
// If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required null
Expand All @@ -976,7 +975,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
/// until the first null terminator.
fn read_c_str_with_char_size<T>(
&self,
mut ptr: Pointer<Option<Provenance>>,
mut ptr: Pointer,
size: Size,
align: Align,
) -> InterpResult<'tcx, Vec<T>>
Expand Down Expand Up @@ -1008,7 +1007,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
}

/// Read a sequence of u16 until the first null terminator.
fn read_wide_str(&self, ptr: Pointer<Option<Provenance>>) -> InterpResult<'tcx, Vec<u16>> {
fn read_wide_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u16>> {
self.read_c_str_with_char_size(ptr, Size::from_bytes(2), Align::from_bytes(2).unwrap())
}

Expand All @@ -1021,7 +1020,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
fn write_wide_str(
&mut self,
wide_str: &[u16],
ptr: Pointer<Option<Provenance>>,
ptr: Pointer,
size: u64,
) -> InterpResult<'tcx, (bool, u64)> {
// If `size` is smaller or equal than `bytes.len()`, writing `bytes` plus the required
Expand All @@ -1046,7 +1045,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {

/// Read a sequence of wchar_t until the first null terminator.
/// Always returns a `Vec<u32>` no matter the size of `wchar_t`.
fn read_wchar_t_str(&self, ptr: Pointer<Option<Provenance>>) -> InterpResult<'tcx, Vec<u32>> {
fn read_wchar_t_str(&self, ptr: Pointer) -> InterpResult<'tcx, Vec<u32>> {
let this = self.eval_context_ref();
let wchar_t = this.libc_ty_layout("wchar_t");
self.read_c_str_with_char_size(ptr, wchar_t.size, wchar_t.align.abi)
Expand Down
2 changes: 2 additions & 0 deletions src/tools/miri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ pub use rustc_const_eval::interpret::*;
pub use rustc_const_eval::interpret::{self, AllocMap, Provenance as _};

// Type aliases that set the provenance parameter.
pub type Pointer = interpret::Pointer<Option<machine::Provenance>>;
pub type StrictPointer = interpret::Pointer<machine::Provenance>;
pub type Scalar = interpret::Scalar<machine::Provenance>;
pub type ImmTy<'tcx> = interpret::ImmTy<'tcx, machine::Provenance>;
pub type OpTy<'tcx> = interpret::OpTy<'tcx, machine::Provenance>;
Expand Down
Loading