Skip to content

Commit

Permalink
Auto merge of #77006 - oli-obk:🐌_const_queries, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Cache `eval_to_allocation_raw` on disk

#74949 (comment) regressed the performance on these queries, this PR gets the perf back.
  • Loading branch information
bors committed Sep 24, 2020
2 parents 893fadd + 40629ef commit 87d262a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::ty::{ParamEnv, Ty, TyCtxt};
use super::{sign_extend, truncate, AllocId, Allocation, InterpResult, Pointer, PointerArithmetic};

/// Represents the result of const evaluation via the `eval_to_allocation` query.
#[derive(Clone, HashStable)]
#[derive(Clone, HashStable, TyEncodable, TyDecodable)]
pub struct ConstAlloc<'tcx> {
// the value lives here, at offset 0, and that allocation definitely is a `AllocKind::Memory`
// (so you can use `AllocMap::unwrap_memory`).
Expand Down
6 changes: 2 additions & 4 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ rustc_queries! {
"const-evaluating + checking `{}`",
key.value.display(tcx)
}
cache_on_disk_if { true }
}

/// Evaluates const items or anonymous constants
Expand All @@ -730,10 +731,7 @@ rustc_queries! {
"simplifying constant for the type system `{}`",
key.value.display(tcx)
}
cache_on_disk_if(_, opt_result) {
// Only store results without errors
opt_result.map_or(true, |r| r.is_ok())
}
cache_on_disk_if { true }
}

/// Destructure a constant ADT or array into its variant index and its
Expand Down

0 comments on commit 87d262a

Please sign in to comment.