about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-07-23 15:59:20 +0000
committerbors <bors@rust-lang.org>2015-07-23 15:59:20 +0000
commit7911d9979f672982b45d288d3cd6e5f588a2b699 (patch)
tree7b899f1be1e6db144b67f3535e6243ebf541b781
parent2e5b165e1801c2ddb5d3cc49ff96b9f264a4545c (diff)
parenta66af8788d904a2c197803d5289de01274010891 (diff)
downloadrust-7911d9979f672982b45d288d3cd6e5f588a2b699.tar.gz
rust-7911d9979f672982b45d288d3cd6e5f588a2b699.zip
Auto merge of #27221 - dotdash:no_empty_clean, r=luqmana
When compiling libsyntax this removes about 30k basic blocks that only
contain a single unconditional jump and reduces the peak memory usage by
about 10MB (from 681MB down to 671MB).
-rw-r--r--src/librustc_trans/trans/cleanup.rs28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/librustc_trans/trans/cleanup.rs b/src/librustc_trans/trans/cleanup.rs
index 37722d5a549..0d497120319 100644
--- a/src/librustc_trans/trans/cleanup.rs
+++ b/src/librustc_trans/trans/cleanup.rs
@@ -774,20 +774,22 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
         // At this point, `popped_scopes` is empty, and so the final block
         // that we return to the user is `Cleanup(AST 24)`.
         while let Some(mut scope) = popped_scopes.pop() {
-            let name = scope.block_name("clean");
-            debug!("generating cleanups for {}", name);
-            let bcx_in = self.new_block(label.is_unwind(),
-                                        &name[..],
-                                        None);
-            let mut bcx_out = bcx_in;
-            for cleanup in scope.cleanups.iter().rev() {
-                bcx_out = cleanup.trans(bcx_out,
-                                        scope.debug_loc);
-            }
-            build::Br(bcx_out, prev_llbb, DebugLoc::None);
-            prev_llbb = bcx_in.llbb;
+            if !scope.cleanups.is_empty() {
+                let name = scope.block_name("clean");
+                debug!("generating cleanups for {}", name);
+                let bcx_in = self.new_block(label.is_unwind(),
+                                            &name[..],
+                                            None);
+                let mut bcx_out = bcx_in;
+                for cleanup in scope.cleanups.iter().rev() {
+                    bcx_out = cleanup.trans(bcx_out,
+                                            scope.debug_loc);
+                }
+                build::Br(bcx_out, prev_llbb, DebugLoc::None);
+                prev_llbb = bcx_in.llbb;
 
-            scope.add_cached_early_exit(label, prev_llbb);
+                scope.add_cached_early_exit(label, prev_llbb);
+            }
             self.push_scope(scope);
         }