Produce more helpful basic block errors in cranelift-frontend.

Previously, the error just notified that there was a failure.
The new-style error says specifically in which ebb, on which instruction.
This commit is contained in:
Sean Stangl
2019-07-22 15:02:40 -06:00
parent 926e4c8bf8
commit 70c91f913d

View File

@@ -479,15 +479,18 @@ impl<'a> FunctionBuilder<'a> {
"all blocks should be filled before dropping a FunctionBuilder" "all blocks should be filled before dropping a FunctionBuilder"
); );
// Check that all blocks are valid basic blocks. // In debug mode, check that all blocks are valid basic blocks.
#[cfg(feature = "basic-blocks")] #[cfg(feature = "basic-blocks")]
debug_assert!( #[cfg(debug_assertions)]
self.func_ctx {
.ebbs // Iterate manually to provide more helpful error messages.
.keys() for ebb in self.func_ctx.ebbs.keys() {
.all(|ebb| self.func.is_ebb_basic(ebb).is_ok()), if let Err((inst, _msg)) = self.func.is_ebb_basic(ebb) {
"all blocks should be encodable as basic blocks" let inst_str = self.func.dfg.display_inst(inst, None);
); panic!("{} failed basic block invariants on {}", ebb, inst_str);
}
}
}
// Clear the state (but preserve the allocated buffers) in preparation // Clear the state (but preserve the allocated buffers) in preparation
// for translation another function. // for translation another function.