Auto merge of #96965 - oli-obk:flaky_inliner_ice, r=cjgillot

Gracefully handle normalization failures in the prospective inliner cycle detector

Preliminary work for adding the regression test in #96950 to our test suite (it was flaky on glacier).

If this PR solves the flakiness on glacier, we can then merge #96950
This commit is contained in:
bors 2022-05-13 06:20:56 +00:00
commit 97d48bec2d

View file

@ -1,5 +1,4 @@
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sso::SsoHashSet;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_middle::mir::TerminatorKind;
@ -45,7 +44,10 @@ crate fn mir_callgraph_reachable<'tcx>(
) -> bool {
trace!(%caller);
for &(callee, substs) in tcx.mir_inliner_callees(caller.def) {
let substs = caller.subst_mir_and_normalize_erasing_regions(tcx, param_env, substs);
let Ok(substs) = caller.try_subst_mir_and_normalize_erasing_regions(tcx, param_env, substs) else {
trace!(?caller, ?param_env, ?substs, "cannot normalize, skipping");
continue;
};
let Some(callee) = ty::Instance::resolve(tcx, param_env, callee, substs).unwrap() else {
trace!(?callee, "cannot resolve, skipping");
continue;
@ -150,7 +152,7 @@ crate fn mir_inliner_callees<'tcx>(
// Functions from other crates and MIR shims
_ => tcx.instance_mir(instance),
};
let mut calls = SsoHashSet::new();
let mut calls = FxIndexSet::default();
for bb_data in body.basic_blocks() {
let terminator = bb_data.terminator();
if let TerminatorKind::Call { func, .. } = &terminator.kind {