summary refs log tree commit diff
path: root/compiler/rustc_pattern_analysis/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-01-24 10:17:12 +0000
committerbors <bors@rust-lang.org>2024-01-24 10:17:12 +0000
commitcd6d8f2a04528f827ad3d399581c0f3502b15a72 (patch)
tree49a032830b1dc622495887e30f496881ee383b53 /compiler/rustc_pattern_analysis/src
parentf6ee4bf3847277d6d6e2007ff664f8ea0895b11b (diff)
parentc8a675d752364a527967a6ce2be836e385df1bb2 (diff)
downloadrust-cd6d8f2a04528f827ad3d399581c0f3502b15a72.tar.gz
rust-cd6d8f2a04528f827ad3d399581c0f3502b15a72.zip
Auto merge of #118336 - saethlin:const-to-op-cache, r=RalfJung
Return a finite number of AllocIds per ConstAllocation in Miri

Before this, every evaluation of a const slice would produce a new AllocId. So in Miri, this program used to have unbounded memory use:
```rust
fn main() {
    loop {
        helper();
    }
}

fn helper() {
    "ouch";
}
```
Every trip around the loop creates a new AllocId which we need to keep track of a base address for. And the provenance GC can never clean up that AllocId -> u64 mapping, because the AllocId is for a const allocation which will never be deallocated.

So this PR moves the logic of producing an AllocId for a ConstAllocation to the Machine trait, and the implementation that Miri provides will only produce 16 AllocIds for each allocation. The cache is also keyed on the Instance that the const is evaluated in, so that equal consts evaluated in two functions will have disjoint base addresses.

r? RalfJung
Diffstat (limited to 'compiler/rustc_pattern_analysis/src')
0 files changed, 0 insertions, 0 deletions