rust/compiler/rustc_mir_build/src
bors 591ecb88df Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlin
miri: make vtable addresses not globally unique

Miri currently gives vtables a unique global address. That's not actually matching reality though. So this PR enables Miri to generate different addresses for the same type-trait pair.

To avoid generating an unbounded number of `AllocId` (and consuming unbounded amounts of memory), we use the "salt" technique that we also already use for giving constants non-unique addresses: the cache is keyed on a "salt" value n top of the actually relevant key, and Miri picks a random salt (currently in the range `0..16`) each time it needs to choose an `AllocId` for one of these globals -- that means we'll get up to 16 different addresses for each vtable. The salt scheme is integrated into the global allocation deduplication logic in `tcx`, and also used for functions and string literals. (So this also fixes the problem that casting the same function to a fn ptr over and over will consume unbounded memory.)

r? `@saethlin`
Fixes https://github.com/rust-lang/miri/issues/3737
2024-08-13 04:32:34 +00:00
..
build Auto merge of #128742 - RalfJung:miri-vtable-uniqueness, r=saethlin 2024-08-13 04:32:34 +00:00
thir Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors 2024-08-11 07:51:51 +02:00
check_unsafety.rs Disallow enabling features without their implied features 2024-08-07 00:45:00 -04:00
errors.rs Rollup merge of #128304 - Zalathar:thir-pat-display, r=Nadrieril 2024-07-29 11:42:34 +02:00
lib.rs Use tidy to sort crate attributes for all compiler crates. 2024-06-12 15:49:10 +10:00
lints.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00