Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 71dd9f7

Browse files
committedFeb 25, 2024
strict provenance: rename addr → addr_without_provenance
1 parent e9f9594 commit 71dd9f7

File tree

59 files changed

+258
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+258
-206
lines changed
 

‎compiler/rustc_arena/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ impl<T> TypedArena<T> {
172172
fn can_allocate(&self, additional: usize) -> bool {
173173
// FIXME: this should *likely* use `offset_from`, but more
174174
// investigation is needed (including running tests in miri).
175-
let available_bytes = self.end.get().addr() - self.ptr.get().addr();
175+
let available_bytes =
176+
self.end.get().addr_without_provenance() - self.ptr.get().addr_without_provenance();
176177
let additional_bytes = additional.checked_mul(mem::size_of::<T>()).unwrap();
177178
available_bytes >= additional_bytes
178179
}
@@ -245,7 +246,8 @@ impl<T> TypedArena<T> {
245246
if mem::needs_drop::<T>() {
246247
// FIXME: this should *likely* use `offset_from`, but more
247248
// investigation is needed (including running tests in miri).
248-
let used_bytes = self.ptr.get().addr() - last_chunk.start().addr();
249+
let used_bytes = self.ptr.get().addr_without_provenance()
250+
- last_chunk.start().addr_without_provenance();
249251
last_chunk.entries = used_bytes / mem::size_of::<T>();
250252
}
251253

@@ -271,9 +273,9 @@ impl<T> TypedArena<T> {
271273
// chunks.
272274
fn clear_last_chunk(&self, last_chunk: &mut ArenaChunk<T>) {
273275
// Determine how much was filled.
274-
let start = last_chunk.start().addr();
276+
let start = last_chunk.start().addr_without_provenance();
275277
// We obtain the value of the pointer to the first uninitialized element.
276-
let end = self.ptr.get().addr();
278+
let end = self.ptr.get().addr_without_provenance();
277279
// We then calculate the number of elements to be dropped in the last chunk,
278280
// which is the filled area's length.
279281
let diff = if mem::size_of::<T>() == 0 {
@@ -396,11 +398,11 @@ impl DroplessArena {
396398
self.start.set(chunk.start());
397399

398400
// Align the end to DROPLESS_ALIGNMENT.
399-
let end = align_down(chunk.end().addr(), DROPLESS_ALIGNMENT);
401+
let end = align_down(chunk.end().addr_without_provenance(), DROPLESS_ALIGNMENT);
400402

401403
// Make sure we don't go past `start`. This should not happen since the allocation
402404
// should be at least DROPLESS_ALIGNMENT - 1 bytes.
403-
debug_assert!(chunk.start().addr() <= end);
405+
debug_assert!(chunk.start().addr_without_provenance() <= end);
404406

405407
self.end.set(chunk.end().with_addr(end));
406408

@@ -415,9 +417,9 @@ impl DroplessArena {
415417
// This loop executes once or twice: if allocation fails the first
416418
// time, the `grow` ensures it will succeed the second time.
417419
loop {
418-
let start = self.start.get().addr();
420+
let start = self.start.get().addr_without_provenance();
419421
let old_end = self.end.get();
420-
let end = old_end.addr();
422+
let end = old_end.addr_without_provenance();
421423

422424
// Align allocated bytes so that `self.end` stays aligned to
423425
// DROPLESS_ALIGNMENT.

‎compiler/rustc_codegen_ssa/src/mono_item.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ impl<'a, 'tcx: 'a> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
138138
fn to_raw_string(&self) -> String {
139139
match *self {
140140
MonoItem::Fn(instance) => {
141-
format!("Fn({:?}, {})", instance.def, instance.args.as_ptr().addr())
141+
format!(
142+
"Fn({:?}, {})",
143+
instance.def,
144+
instance.args.as_ptr().addr_without_provenance()
145+
)
142146
}
143147
MonoItem::Static(id) => format!("Static({id:?})"),
144148
MonoItem::GlobalAsm(id) => format!("GlobalAsm({id:?})"),

0 commit comments

Comments
 (0)
Please sign in to comment.