Auto merge of #33030 - nagisa:mir-unrequire-end-block, r=nikomatsakis

MIR: Do not require END_BLOCK to always exist

Basically, all this does, is removing restriction for END_BLOCK to exist past the first invocation of RemoveDeadBlocks pass. This way for functions whose CFG does not reach the `END_BLOCK` end up not containing the block.

As far as the implementation goes, I’m not entirely satisfied with the `BasicBlock::end_block`. I had hoped to make `new` a `const fn` and then just have a `const END_BLOCK` private to mir::build, but it turns out that constant functions don’t yet support conditionals nor a way to assert.
This commit is contained in:
bors 2016-04-20 21:25:26 -07:00
commit 6e03608209
5 changed files with 35 additions and 29 deletions

View file

@ -63,9 +63,6 @@ pub struct Mir<'tcx> {
/// where execution begins
pub const START_BLOCK: BasicBlock = BasicBlock(0);
/// where execution ends, on normal return
pub const END_BLOCK: BasicBlock = BasicBlock(1);
impl<'tcx> Mir<'tcx> {
pub fn all_basic_blocks(&self) -> Vec<BasicBlock> {
(0..self.basic_blocks.len())
@ -322,8 +319,7 @@ pub enum TerminatorKind<'tcx> {
Resume,
/// Indicates a normal return. The ReturnPointer lvalue should
/// have been filled in by now. This should only occur in the
/// `END_BLOCK`.
/// have been filled in by now. This should occur at most once.
Return,
/// Drop the Lvalue