fuzzbug fixes

This commit is contained in:
Chris Fallin 2021-12-23 20:34:50 -08:00
parent 57693e592c
commit 635befa210
3 changed files with 22 additions and 8 deletions

View file

@ -91,6 +91,9 @@ impl Schedule {
log::trace!("v{} waiting on {:?}", value.index(), operands); log::trace!("v{} waiting on {:?}", value.index(), operands);
ctx.remaining_inputs.insert(value, operands.len()); ctx.remaining_inputs.insert(value, operands.len());
for &input in operands { for &input in operands {
if input == Value::undef() {
continue;
}
let input = f.resolve_alias(input); let input = f.resolve_alias(input);
ctx.waiting_on_value ctx.waiting_on_value
.entry(input) .entry(input)

View file

@ -2,7 +2,7 @@
use std::collections::VecDeque; use std::collections::VecDeque;
use crate::{Value, FunctionBody, ValueDef}; use crate::{FunctionBody, Value, ValueDef};
use fxhash::FxHashSet; use fxhash::FxHashSet;
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
@ -23,16 +23,20 @@ impl UseCountAnalysis {
let mut workqueue_set = FxHashSet::default(); let mut workqueue_set = FxHashSet::default();
for block in 0..f.blocks.len() { for block in 0..f.blocks.len() {
for &value in &f.blocks[block].insts { for &value in &f.blocks[block].insts {
let value = f.resolve_alias(value); if value != Value::undef() {
if workqueue_set.insert(value) { let value = f.resolve_alias(value);
workqueue.push_back(value); if workqueue_set.insert(value) {
workqueue.push_back(value);
}
counts.toplevel.insert(value);
} }
counts.toplevel.insert(value);
} }
f.blocks[block].terminator.visit_uses(|value| { f.blocks[block].terminator.visit_uses(|value| {
let value = f.resolve_alias(value); if value != Value::undef() {
if workqueue_set.insert(value) { let value = f.resolve_alias(value);
workqueue.push_back(value); if workqueue_set.insert(value) {
workqueue.push_back(value);
}
} }
}); });
@ -43,6 +47,9 @@ impl UseCountAnalysis {
&ValueDef::Alias(..) | &ValueDef::Arg(..) | &ValueDef::BlockParam(..) => {} &ValueDef::Alias(..) | &ValueDef::Arg(..) | &ValueDef::BlockParam(..) => {}
&ValueDef::Operator(_op, ref args) => { &ValueDef::Operator(_op, ref args) => {
for &arg in args { for &arg in args {
if arg == Value::undef() {
continue;
}
let arg = f.resolve_alias(arg); let arg = f.resolve_alias(arg);
if counts.use_count[arg.index()] == 0 { if counts.use_count[arg.index()] == 0 {
if workqueue_set.insert(arg) { if workqueue_set.insert(arg) {
@ -52,6 +59,9 @@ impl UseCountAnalysis {
} }
} }
&ValueDef::PickOutput(value, _) => { &ValueDef::PickOutput(value, _) => {
if value == Value::undef() {
continue;
}
let value = f.resolve_alias(value); let value = f.resolve_alias(value);
if counts.use_count[value.index()] == 0 { if counts.use_count[value.index()] == 0 {
if workqueue_set.insert(value) { if workqueue_set.insert(value) {

View file

@ -106,6 +106,7 @@ impl FunctionBody {
} }
pub fn resolve_alias(&self, value: Value) -> Value { pub fn resolve_alias(&self, value: Value) -> Value {
assert_ne!(value, Value::undef());
let mut result = value; let mut result = value;
loop { loop {
if let &ValueDef::Alias(to) = &self.values[result.index()] { if let &ValueDef::Alias(to) = &self.values[result.index()] {