Verify that EBBs are non-empty (#1330)
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
This commit is contained in:
@@ -1971,6 +1971,9 @@ impl<'a> Verifier<'a> {
|
|||||||
self.typecheck_function_signature(errors)?;
|
self.typecheck_function_signature(errors)?;
|
||||||
|
|
||||||
for ebb in self.func.layout.ebbs() {
|
for ebb in self.func.layout.ebbs() {
|
||||||
|
if self.func.layout.first_inst(ebb).is_none() {
|
||||||
|
return errors.fatal((ebb, format!("{} cannot be empty", ebb)));
|
||||||
|
}
|
||||||
for inst in self.func.layout.ebb_insts(ebb) {
|
for inst in self.func.layout.ebb_insts(ebb) {
|
||||||
self.ebb_integrity(ebb, inst, errors)?;
|
self.ebb_integrity(ebb, inst, errors)?;
|
||||||
self.instruction_integrity(inst, errors)?;
|
self.instruction_integrity(inst, errors)?;
|
||||||
@@ -2117,4 +2120,18 @@ mod tests {
|
|||||||
"inst0 (v0, v1 = iconst.i32 42): has more result values than expected"
|
"inst0 (v0, v1 = iconst.i32 42): has more result values than expected"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_empty_ebb() {
|
||||||
|
let mut func = Function::new();
|
||||||
|
let ebb0 = func.dfg.make_ebb();
|
||||||
|
func.layout.append_ebb(ebb0);
|
||||||
|
|
||||||
|
let flags = &settings::Flags::new(settings::builder());
|
||||||
|
let verifier = Verifier::new(&func, flags.into());
|
||||||
|
let mut errors = VerifierErrors::default();
|
||||||
|
let _ = verifier.run(&mut errors);
|
||||||
|
|
||||||
|
assert_err_with_msg!(errors, "ebb0 cannot be empty");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user