diff options
| author | Markus Westerlind <markus.westerlind@distilnetworks.com> | 2020-02-16 23:23:44 +0100 |
|---|---|---|
| committer | Markus Westerlind <markus.westerlind@distilnetworks.com> | 2020-02-16 23:23:44 +0100 |
| commit | 84c024d92f34206d0f02ab814c6e5bd3abb876c3 (patch) | |
| tree | a578ac5b5bd2ffdccd03a6255f658064136bc5b3 /src/librustc_mir/transform | |
| parent | 2440998666cb9fe5f35c1de9ef44849b71870fc3 (diff) | |
| download | rust-84c024d92f34206d0f02ab814c6e5bd3abb876c3.tar.gz rust-84c024d92f34206d0f02ab814c6e5bd3abb876c3.zip | |
Clarify mir block merging
Diffstat (limited to 'src/librustc_mir/transform')
| -rw-r--r-- | src/librustc_mir/transform/simplify.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index d8de9f2180d..1534b9bdcea 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -95,6 +95,10 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { let mut start = START_BLOCK; + // Vec of the blocks that should be merged. We store the indices here, instead of the + // statements itself to avoid moving the (relatively) large statements twice. + // We do not push the statements directly into the target block (`bb`) as that is slower + // due to additional reallocations let mut merged_blocks = Vec::new(); loop { let mut changed = false; @@ -116,6 +120,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { } let mut inner_changed = true; + merged_blocks.clear(); while inner_changed { inner_changed = false; inner_changed |= self.simplify_branch(&mut terminator); @@ -134,7 +139,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { } self.basic_blocks[bb].statements = statements; } - merged_blocks.clear(); self.basic_blocks[bb].terminator = Some(terminator); |
