diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2022-05-08 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2022-05-08 23:14:56 +0200 |
| commit | fbc3cc18bee7fb6dfd39e11521783f00506ca06b (patch) | |
| tree | 56119a80bd6442a7cf3c5a463f1c009d2ae85dc3 /compiler/rustc_middle/src/mir | |
| parent | 83322c557fcaa9b6750955ceb6b9591df6c53a65 (diff) | |
| download | rust-fbc3cc18bee7fb6dfd39e11521783f00506ca06b.tar.gz rust-fbc3cc18bee7fb6dfd39e11521783f00506ca06b.zip | |
Avoid constructing switch sources unless necessary
Switch sources are used by backward analysis with a custom switch int edge effects, but are otherwise unnecessarily computed. Delay the computation until we know that switch sources are indeed required and avoid the computation otherwise.
Diffstat (limited to 'compiler/rustc_middle/src/mir')
| -rw-r--r-- | compiler/rustc_middle/src/mir/mod.rs | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index 682f3734d30..4d26840fd62 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -580,6 +580,8 @@ impl<'tcx> Body<'tcx> { self.predecessor_cache.compute(&self.basic_blocks) } + /// `body.switch_sources()[target][switch]` returns a list of switch values + /// that lead to a `target` block from a `switch` block. #[inline] pub fn switch_sources(&self) -> &SwitchSources { self.switch_source_cache.compute(&self.basic_blocks) |
