Skip to content

Commit 6d78d24

Browse files
committed
Remove support for sending pointers to GenMC.
1 parent 3f0226c commit 6d78d24

File tree

12 files changed

+11
-641
lines changed

12 files changed

+11
-641
lines changed

genmc-sys/src/lib.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ pub struct GenmcThreadId(pub i32);
1414
pub const GENMC_MAIN_THREAD_ID: GenmcThreadId = GenmcThreadId(0);
1515

1616
impl GenmcScalar {
17-
pub const UNINIT: Self = Self { value: 0, extra: 0, is_init: false };
17+
pub const UNINIT: Self = Self { value: 0, is_init: false };
1818
pub const DUMMY: Self = Self::from_u64(0xDEADBEEF);
1919

2020
pub const fn from_u64(value: u64) -> Self {
21-
Self { value, extra: 0, is_init: true }
21+
Self { value, is_init: true }
2222
}
2323
}
2424

@@ -87,7 +87,6 @@ mod ffi {
8787
#[derive(Debug, Clone, Copy)]
8888
struct GenmcScalar {
8989
value: u64,
90-
extra: u64,
9190
is_init: bool,
9291
}
9392

src/concurrency/genmc/helper.rs

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use rustc_middle::ty::ScalarInt;
44
use tracing::info;
55

66
use super::GenmcScalar;
7-
use crate::alloc_addresses::EvalContextExt as _;
8-
use crate::{BorTag, MiriInterpCx, Pointer, Provenance, Scalar, throw_unsup_format};
7+
use crate::{MiriInterpCx, Scalar, throw_unsup_format};
98

109
pub fn split_access(address: Size, size: Size) -> impl Iterator<Item = (u64, u64)> {
1110
/// Maximum size memory access in bytes that GenMC supports.
@@ -70,66 +69,28 @@ pub fn option_scalar_to_genmc_scalar<'tcx>(
7069
}
7170

7271
pub fn scalar_to_genmc_scalar<'tcx>(
73-
ecx: &MiriInterpCx<'tcx>,
72+
_ecx: &MiriInterpCx<'tcx>,
7473
scalar: Scalar,
7574
) -> InterpResult<'tcx, GenmcScalar> {
7675
interp_ok(match scalar {
7776
rustc_const_eval::interpret::Scalar::Int(scalar_int) => {
7877
// TODO GENMC: u128 support
7978
let value: u64 = scalar_int.to_uint(scalar_int.size()).try_into().unwrap(); // TODO GENMC: doesn't work for size != 8
80-
GenmcScalar { value, extra: 0, is_init: true }
81-
}
82-
rustc_const_eval::interpret::Scalar::Ptr(pointer, size) => {
83-
let addr = Pointer::from(pointer).addr();
84-
if let Provenance::Wildcard = pointer.provenance {
85-
throw_unsup_format!("Pointers with wildcard provenance not allowed in GenMC mode");
86-
}
87-
let (alloc_id, _size, _prov_extra) =
88-
rustc_const_eval::interpret::Machine::ptr_get_alloc(ecx, pointer, size.into())
89-
.unwrap();
90-
let base_addr = ecx.addr_from_alloc_id(alloc_id, None)?;
91-
GenmcScalar { value: addr.bytes(), extra: base_addr, is_init: true }
79+
GenmcScalar { value, is_init: true }
9280
}
81+
rustc_const_eval::interpret::Scalar::Ptr(_pointer, _size) =>
82+
throw_unsup_format!(
83+
"FIXME(genmc): Implement sending pointers (with provenance) to GenMC."
84+
),
9385
})
9486
}
9587

9688
pub fn genmc_scalar_to_scalar<'tcx>(
97-
ecx: &MiriInterpCx<'tcx>,
89+
_ecx: &MiriInterpCx<'tcx>,
9890
scalar: GenmcScalar,
9991
size: Size,
10092
) -> InterpResult<'tcx, Scalar> {
101-
// TODO GENMC: proper handling of large integers
102-
// TODO GENMC: proper handling of pointers (currently assumes all integers)
103-
104-
if scalar.extra != 0 {
105-
// We have a pointer!
106-
107-
let addr = Size::from_bytes(scalar.value);
108-
let base_addr = scalar.extra;
109-
110-
let alloc_size = 0; // TODO GENMC: what is the correct size here? Is 0 ok?
111-
let only_exposed_allocations = false;
112-
let Some(alloc_id) =
113-
ecx.alloc_id_from_addr(base_addr, alloc_size, only_exposed_allocations)
114-
else {
115-
// TODO GENMC: what is the correct error in this case?
116-
throw_unsup_format!(
117-
"Cannot get allocation id of pointer received from GenMC (base address: 0x{base_addr:x}, pointer address: 0x{:x})",
118-
addr.bytes()
119-
);
120-
};
121-
122-
// TODO GENMC: is using `size: Size` ok here? Can we ever have `size != sizeof pointer`?
123-
124-
// FIXME: Currently GenMC mode incompatible with aliasing model checking
125-
let tag = BorTag::default();
126-
let provenance = crate::machine::Provenance::Concrete { alloc_id, tag };
127-
let offset = addr;
128-
let ptr = rustc_middle::mir::interpret::Pointer::new(provenance, offset);
129-
130-
let size = size.bytes().try_into().unwrap();
131-
return interp_ok(Scalar::Ptr(ptr, size));
132-
}
93+
// FIXME(genmc): Add GencmScalar to Miri Pointer conversion.
13394

13495
// NOTE: GenMC always returns 64 bit values, and the upper bits are not yet truncated.
13596
// FIXME(genmc): Rework if 128bit support is added to GenMC.

tests/genmc/pass/data-structures/ms_queue_dynamic.rs

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

tests/genmc/pass/data-structures/ms_queue_dynamic.stderr

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

0 commit comments

Comments
 (0)