Do not run optimizations on trivial MIR.
This commit is contained in:
parent
ab039f79b8
commit
005ec2e51c
2 changed files with 10 additions and 1 deletions
|
@ -613,6 +613,15 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If `mir_drops_elaborated_and_const_checked` found that the current body has unsatisfiable
|
||||||
|
// predicates, it will shrink the MIR to a single `unreachable` terminator.
|
||||||
|
// More generally, if MIR is a lone `unreachable`, there is nothing to optimize.
|
||||||
|
if let TerminatorKind::Unreachable = body.basic_blocks[START_BLOCK].terminator().kind
|
||||||
|
&& body.basic_blocks[START_BLOCK].statements.is_empty()
|
||||||
|
{
|
||||||
|
return body;
|
||||||
|
}
|
||||||
|
|
||||||
run_optimization_passes(tcx, &mut body);
|
run_optimization_passes(tcx, &mut body);
|
||||||
|
|
||||||
body
|
body
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// check-pass
|
// check-pass
|
||||||
// compile-flags: --emit=mir,link
|
// compile-flags: --emit=mir,link -Zmir-opt-level=4
|
||||||
// Checks that we don't ICE due to attempting to run const prop
|
// Checks that we don't ICE due to attempting to run const prop
|
||||||
// on a function with unsatisifable 'where' clauses
|
// on a function with unsatisifable 'where' clauses
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue