Allocate less while constructing cranelift-fuzzgen tests (#4863)

* Improve panic message if typevar_operand is None

* cranelift-fuzzgen: Don't allocate for each choice

I don't think the performance of test-case generation is at all
important here. I'm actually doing this in preparation for a bigger
refactor where I want to be able to borrow the list of valid choices for
a given opcode without worrying about lifetimes.

* cranelift-fuzzgen: Remove next_func_index

It's only used locally within `generate_funcrefs`, so it doesn't need to
be in the FunctionBuilder struct.

Also there's already a local counter that I think is good enough for
this. As far as I know, the function indexes only need to be distinct,
not contiguous.

* cranelift-fuzzgen: Separate resources from config

The function-global variables, blocks, etc that are generated before
generating instructions are all owned collections without any lifetime
parameters. By contrast, the Unstructured and Config are both borrowed.
Separating them will make it easier to borrow from the owned resources.
This commit is contained in:
Jamey Sharp
2022-09-07 12:19:55 -07:00
committed by GitHub
parent f57b4412ec
commit e694a6f5d4
2 changed files with 77 additions and 88 deletions

View File

@@ -864,7 +864,12 @@ impl DataFlowGraph {
self.value_type(
self[inst]
.typevar_operand(&self.value_lists)
.expect("Instruction format doesn't have a designated operand, bad opcode."),
.unwrap_or_else(|| {
panic!(
"Instruction format for {:?} doesn't have a designated operand",
self[inst]
)
}),
)
} else {
self.value_type(self.first_result(inst))