Always run incremental_verify_ich
when re-computing query results
Issue #82920 showed that the kind of bugs caught by this flag have soundness implications. This causes performance regressions of up to 15.2% during incremental compilation, but this is necessary to catch miscompilations caused by bugs in query implementations.
This commit is contained in:
parent
066f01d81b
commit
7d7c81a114
1 changed files with 18 additions and 11 deletions
|
@ -533,7 +533,13 @@ where
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let result = if let Some(result) = result {
|
if let Some(result) = result {
|
||||||
|
// If `-Zincremental-verify-ich` is specified, re-hash results from
|
||||||
|
// the cache and make sure that they have the expected fingerprint.
|
||||||
|
if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) {
|
||||||
|
incremental_verify_ich(*tcx.dep_context(), &result, dep_node, dep_node_index, query);
|
||||||
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
// We could not load a result from the on-disk cache, so
|
// We could not load a result from the on-disk cache, so
|
||||||
|
@ -545,20 +551,21 @@ where
|
||||||
|
|
||||||
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
|
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
|
||||||
|
|
||||||
result
|
// Verify that re-running the query produced a result with the expected hash
|
||||||
};
|
// This catches bugs in query implementations, turning them into ICEs.
|
||||||
|
// For example, a query might sort its result by `DefId` - since `DefId`s are
|
||||||
// If `-Zincremental-verify-ich` is specified, re-hash results from
|
// not stable across compilation sessions, the result could get up getting sorted
|
||||||
// the cache and make sure that they have the expected fingerprint.
|
// in a different order when the query is re-run, even though all of the inputs
|
||||||
if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) {
|
// (e.g. `DefPathHash` values) were green.
|
||||||
|
//
|
||||||
|
// See issue #82920 for an example of a miscompilation that would get turned into
|
||||||
|
// an ICE by this check
|
||||||
incremental_verify_ich(*tcx.dep_context(), &result, dep_node, dep_node_index, query);
|
incremental_verify_ich(*tcx.dep_context(), &result, dep_node, dep_node_index, query);
|
||||||
}
|
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[inline(never)]
|
|
||||||
#[cold]
|
|
||||||
fn incremental_verify_ich<CTX, K, V: Debug>(
|
fn incremental_verify_ich<CTX, K, V: Debug>(
|
||||||
tcx: CTX::DepContext,
|
tcx: CTX::DepContext,
|
||||||
result: &V,
|
result: &V,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue