From ff7f6d57de1112805272bae57ff5918d4f25e0ab Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 10 Aug 2018 04:17:46 -0400 Subject: don't walk MIR if no local variables need liveness This is true for tuple-stress and html5ever --- .../borrow_check/nll/type_check/liveness/liveness_map.rs | 5 +++++ src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs index 20bf53f4d95..89e8c76b22f 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs @@ -86,6 +86,11 @@ impl NllLivenessMap { to_local, } } + + /// True if there are no local variables that need liveness computation. + crate fn is_empty(&self) -> bool { + self.to_local.is_empty() + } } /// Index given to each local variable whose type contains a region. diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs index d3ef2a36909..a9b69cfe761 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs @@ -55,7 +55,7 @@ pub(super) fn generate<'gcx, 'tcx>( let liveness = LivenessResults::compute(mir, &liveness_map); // For everything else, it is only live where it is actually used. - { + if !liveness_map.is_empty() { let mut generator = TypeLivenessGenerator { cx, mir, -- cgit 1.4.1-3-g733a5