Skip to content

Commit 7e729c0

Browse files
committed
---
yaml --- r: 273870 b: refs/heads/beta c: 02cb1d4 h: refs/heads/master
1 parent 38ee065 commit 7e729c0

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: c70bc3a5daa2ce46aad7c230004ade7a404c12f1
26+
refs/heads/beta: 02cb1d4ef1e187494f7f089e114515dc74fabd10
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/librustc_trans/basic_block.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@ impl BasicBlock {
4949
_ => None
5050
}
5151
}
52+
53+
pub fn delete(self) {
54+
unsafe {
55+
llvm::LLVMDeleteBasicBlock(self.0);
56+
}
57+
}
5258
}

branches/beta/src/librustc_trans/mir/mod.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use common::{self, Block, BlockAndBuilder, FunctionContext};
1919
use std::ops::Deref;
2020
use std::rc::Rc;
2121

22+
use trans::basic_block::BasicBlock;
23+
2224
use rustc_data_structures::bitvec::BitVector;
2325

2426
use self::lvalue::{LvalueRef, get_dataptr, get_meta};
@@ -170,19 +172,20 @@ pub fn trans_mir<'blk, 'tcx: 'blk>(fcx: &'blk FunctionContext<'blk, 'tcx>) {
170172
mircx.trans_block(bb);
171173
}
172174

173-
// Add unreachable instructions at the end of unreachable blocks
174-
// so they're actually terminated.
175-
// TODO: Remove the blocks from the function
175+
// Remove blocks that haven't been visited, or have no
176+
// predecessors.
176177
for &bb in &mir_blocks {
178+
let block = mircx.blocks[bb.index()];
179+
let block = BasicBlock(block.llbb);
180+
// Unreachable block
177181
if !visited.contains(bb.index()) {
178-
mircx.blocks[bb.index()].build().unreachable();
182+
block.delete();
183+
} else if block.pred_iter().count() == 0 {
184+
block.delete();
179185
}
180186
}
181187

182-
183188
fcx.cleanup();
184-
185-
debug!("trans_mir: {:?}", ::trans::value::Value(fcx.llfn));
186189
}
187190

188191
/// Produce, for each argument, a `ValueRef` pointing at the

0 commit comments

Comments
 (0)