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.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user