Verify that FunctionBuilder blocks are basic blocks in debug mode (#857)

To use, enable the "basic-blocks" feature on cranelift-frontend.
This commit is contained in:
Sean Stangl
2019-07-19 09:52:05 -06:00
committed by GitHub
parent 9b97ddf29a
commit 8efaeec502
4 changed files with 45 additions and 36 deletions

View File

@@ -470,6 +470,16 @@ impl<'a> FunctionBuilder<'a> {
"all blocks should be filled before dropping a FunctionBuilder"
);
// Check that all blocks are valid basic blocks.
#[cfg(feature = "basic-blocks")]
debug_assert!(
self.func_ctx
.ebbs
.keys()
.all(|ebb| self.func.is_ebb_basic(ebb).is_ok()),
"all blocks should be encodable as basic blocks"
);
// Clear the state (but preserve the allocated buffers) in preparation
// for translation another function.
self.func_ctx.clear();
@@ -840,6 +850,7 @@ impl<'a> FunctionBuilder<'a> {
);
}
/// An Ebb is 'filled' when a terminator instruction is present.
fn fill_current_block(&mut self) {
self.func_ctx.ebbs[self.position.ebb.unwrap()].filled = true;
}