Ensure nested allocations in statics do not get deduplicated

This commit is contained in:
Oli Scherer
2024-02-26 18:03:06 +00:00
parent 92414ab25d
commit d3514a036d
21 changed files with 259 additions and 54 deletions

View File

@@ -59,7 +59,7 @@ fn eval_body_using_ecx<'mir, 'tcx>(
};
let ret = if let InternKind::Static(_) = intern_kind {
create_static_alloc(ecx, cid.instance.def_id(), layout)?
create_static_alloc(ecx, cid.instance.def_id().expect_local(), layout)?
} else {
ecx.allocate(layout, MemoryKind::Stack)?
};
@@ -380,7 +380,11 @@ pub fn eval_in_interpreter<'mir, 'tcx>(
}
Ok(mplace) => {
// Since evaluation had no errors, validate the resulting constant.
// Temporarily allow access to the static_root_ids for the purpose of validation.
let static_root_ids = ecx.machine.static_root_ids.take();
let res = const_validate_mplace(&ecx, &mplace, cid);
ecx.machine.static_root_ids = static_root_ids;
let alloc_id = mplace.ptr().provenance.unwrap().alloc_id();