Skip to content

Commit

Permalink
Merge pull request bytecodealliance#2400 from MattX/improve-finalize-msg
Browse files Browse the repository at this point in the history
Specify unsealed / unfilled blocks
  • Loading branch information
fitzgen authored Nov 23, 2020
2 parents 86ae0b7 + 27f3307 commit 1dd20b4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions cranelift/frontend/src/frontend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,19 +459,21 @@ impl<'a> FunctionBuilder<'a> {
/// for another function.
pub fn finalize(&mut self) {
// Check that all the `Block`s are filled and sealed.
debug_assert!(
self.func_ctx.blocks.iter().all(
|(block, block_data)| block_data.pristine || self.func_ctx.ssa.is_sealed(block)
),
"all blocks should be sealed before dropping a FunctionBuilder"
);
debug_assert!(
self.func_ctx
.blocks
.values()
.all(|block_data| block_data.pristine || block_data.filled),
"all blocks should be filled before dropping a FunctionBuilder"
);
#[cfg(debug_assertions)]
{
for (block, block_data) in self.func_ctx.blocks.iter() {
assert!(
block_data.pristine || self.func_ctx.ssa.is_sealed(block),
"FunctionBuilder finalized, but block {} is not sealed",
block,
);
assert!(
block_data.pristine || block_data.filled,
"FunctionBuilder finalized, but block {} is not filled",
block,
);
}
}

// In debug mode, check that all blocks are valid basic blocks.
#[cfg(debug_assertions)]
Expand Down

0 comments on commit 1dd20b4

Please sign in to comment.