Skip to content

Commit e985e6a

Browse files
committed
Auto merge of #115764 - RalfJung:const-by-ref-alloc-id, r=oli-obk
some ConstValue refactoring In particular, use AllocId instead of Allocation in ConstValue::ByRef. This helps avoid redundant AllocIds when a `ByRef` constant gets put back into the interpreter. r? `@oli-obk` Fixes rust-lang/rust#105536
2 parents 14f302f + 62a2739 commit e985e6a

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

Diff for: src/eval.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
382382
.unwrap()
383383
.unwrap();
384384

385-
let main_ptr = ecx.create_fn_alloc_ptr(FnVal::Instance(entry_instance));
385+
let main_ptr = ecx.fn_ptr(FnVal::Instance(entry_instance));
386386

387387
// Inlining of `DEFAULT` from
388388
// https://github.com/rust-lang/rust/blob/master/compiler/rustc_session/src/config/sigpipe.rs.

Diff for: src/machine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ impl<'mir, 'tcx> MiriMachine<'mir, 'tcx> {
711711
let layout = this.machine.layouts.const_raw_ptr;
712712
let dlsym = Dlsym::from_str("signal".as_bytes(), &this.tcx.sess.target.os)?
713713
.expect("`signal` must be an actual dlsym on android");
714-
let ptr = this.create_fn_alloc_ptr(FnVal::Other(dlsym));
714+
let ptr = this.fn_ptr(FnVal::Other(dlsym));
715715
let val = ImmTy::from_scalar(Scalar::from_pointer(ptr, this), layout);
716716
Self::alloc_extern_static(this, "signal", val)?;
717717
// A couple zero-initialized pointer-sized extern statics.

Diff for: src/shims/backtrace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
6363
// to reconstruct the needed frame information in `handle_miri_resolve_frame`.
6464
// Note that we never actually read or write anything from/to this pointer -
6565
// all of the data is represented by the pointer value itself.
66-
let fn_ptr = this.create_fn_alloc_ptr(FnVal::Instance(instance));
66+
let fn_ptr = this.fn_ptr(FnVal::Instance(instance));
6767
fn_ptr.wrapping_offset(Size::from_bytes(pos.0), this)
6868
})
6969
.collect();
@@ -159,7 +159,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
159159

160160
// Reconstruct the original function pointer,
161161
// which we pass to user code.
162-
let fn_ptr = this.create_fn_alloc_ptr(FnVal::Instance(fn_instance));
162+
let fn_ptr = this.fn_ptr(FnVal::Instance(fn_instance));
163163

164164
let num_fields = dest.layout.fields.count();
165165

Diff for: src/shims/unix/foreign_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
232232
let symbol = this.read_pointer(symbol)?;
233233
let symbol_name = this.read_c_str(symbol)?;
234234
if let Some(dlsym) = Dlsym::from_str(symbol_name, &this.tcx.sess.target.os)? {
235-
let ptr = this.create_fn_alloc_ptr(FnVal::Other(dlsym));
235+
let ptr = this.fn_ptr(FnVal::Other(dlsym));
236236
this.write_pointer(ptr, dest)?;
237237
} else {
238238
this.write_null(dest)?;

Diff for: src/shims/windows/foreign_items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
335335
this.read_target_isize(hModule)?;
336336
let name = this.read_c_str(this.read_pointer(lpProcName)?)?;
337337
if let Some(dlsym) = Dlsym::from_str(name, &this.tcx.sess.target.os)? {
338-
let ptr = this.create_fn_alloc_ptr(FnVal::Other(dlsym));
338+
let ptr = this.fn_ptr(FnVal::Other(dlsym));
339339
this.write_pointer(ptr, dest)?;
340340
} else {
341341
this.write_null(dest)?;

0 commit comments

Comments
 (0)