Create stable metric to measure long computation in Const Eval
This patch adds a `MirPass` that tracks the number of back-edges and function calls in the CFG, adds a new MIR instruction to increment a counter every time they are encountered during Const Eval, and emit a warning if a configured limit is breached.
This commit is contained in:
@@ -286,7 +286,10 @@ pub enum StatementKind<'tcx> {
|
||||
/// This is permitted for both generators and ADTs. This does not necessarily write to the
|
||||
/// entire place; instead, it writes to the minimum set of bytes as required by the layout for
|
||||
/// the type.
|
||||
SetDiscriminant { place: Box<Place<'tcx>>, variant_index: VariantIdx },
|
||||
SetDiscriminant {
|
||||
place: Box<Place<'tcx>>,
|
||||
variant_index: VariantIdx,
|
||||
},
|
||||
|
||||
/// Deinitializes the place.
|
||||
///
|
||||
@@ -355,6 +358,8 @@ pub enum StatementKind<'tcx> {
|
||||
/// This avoids adding a new block and a terminator for simple intrinsics.
|
||||
Intrinsic(Box<NonDivergingIntrinsic<'tcx>>),
|
||||
|
||||
ConstEvalCounter,
|
||||
|
||||
/// No-op. Useful for deleting instructions without affecting statement indices.
|
||||
Nop,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user