diff --git a/cranelift/codegen/src/timing.rs b/cranelift/codegen/src/timing.rs index a06c6001ef41..8eb4630ba0ec 100644 --- a/cranelift/codegen/src/timing.rs +++ b/cranelift/codegen/src/timing.rs @@ -171,7 +171,10 @@ mod enabled { /// Returns the total amount of time taken by all the passes measured. pub fn total(&self) -> Duration { - self.pass.iter().map(|p| p.total - p.child).sum() + self.pass + .iter() + .map(|p| p.total.saturating_sub(p.child)) + .sum() } }