spirv-fuzz: Do not add synonym-creating loops in dead blocks (#3975)

Fixes #3954.
This commit is contained in:
Alastair Donaldson 2020-10-22 12:07:49 +01:00 committed by GitHub
parent 64eaa9832f
commit 88f7bcb6af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -72,10 +72,15 @@ void FuzzerPassAddLoopsToCreateIntConstantSynonyms::Apply() {
// synonym. We cannot apply the transformation while iterating over the
// module, because we are going to add new blocks.
for (auto& function : *GetIRContext()->module()) {
// Consider all blocks reachable from the first block of the function.
// Consider all non-dead blocks reachable from the first block of the
// function.
GetIRContext()->cfg()->ForEachBlockInPostOrder(
&*function.begin(),
[&blocks](opt::BasicBlock* block) { blocks.push_back(block->id()); });
&*function.begin(), [this, &blocks](opt::BasicBlock* block) {
if (!GetTransformationContext()->GetFactManager()->BlockIsDead(
block->id())) {
blocks.push_back(block->id());
}
});
}
// Make sure that the module has an OpTypeBool instruction, and 32-bit signed