Description
There are (at least) two situations where Miri uses a different AllocId
for allocations than would be used in already created "global" allocations:
extern static
are supported by mapping them to another, existing allocation.- TLS statics need a different
AllocId
for each thread.
Currently both of these use different systems, and the extern static
system has some disadvantages like not erroring on this program:
extern {
static mut TEST: i32;
}
fn main() {
let _x = unsafe { &TEST };
}
We should use the same system for both, and that system should be to do whatever adjustments we need to do when converting Pointer<()>
(an untagged pointer, in global tcx
memory) to Pointer<M::PointerTag>
.
With #70685 resolved we might not need this for TLS statics any more, depending on the solution. But it would still be good to do this for extern static
. Either way, as part of this we should also cleanup the TLS static handling in Miri, which currently special-cases ConstValue::Scalar
being converted into Miri machine values -- we should do the right thing for all pointers in constants/globals.
Cc @oli-obk