diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-08-10 04:17:46 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-08-10 04:17:46 -0400 |
| commit | ff7f6d57de1112805272bae57ff5918d4f25e0ab (patch) | |
| tree | e20fa967fb4a9c6cec7af2fa2d56bceef18376b6 /src | |
| parent | 1bae4f5aecbd6c7a4daa09540e7e71f73b9a5c7a (diff) | |
| download | rust-ff7f6d57de1112805272bae57ff5918d4f25e0ab.tar.gz rust-ff7f6d57de1112805272bae57ff5918d4f25e0ab.zip | |
don't walk MIR if no local variables need liveness
This is true for tuple-stress and html5ever
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/liveness/liveness_map.rs | 5 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/type_check/liveness/mod.rs | 2 |
2 files changed, 6 insertions, 1 deletions
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, |
