mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 11:10:05 +00:00
spirv-fuzz: iterate over blocks in replace linear algebra pass (#3654)
This PR changes the way FuzzerPassReplaceLinearAlgebraInstructions iterates over the module instructions. It avoids iterating over non-relevant instructions (globals, types, etc.).
This commit is contained in:
parent
efc85ff661
commit
d29eac95aa
@ -36,23 +36,27 @@ FuzzerPassReplaceLinearAlgebraInstructions::
|
||||
void FuzzerPassReplaceLinearAlgebraInstructions::Apply() {
|
||||
// For each instruction, checks whether it is a linear algebra instruction. In
|
||||
// this case, the transformation is randomly applied.
|
||||
GetIRContext()->module()->ForEachInst([this](opt::Instruction* instruction) {
|
||||
if (!spvOpcodeIsLinearAlgebra(instruction->opcode())) {
|
||||
return;
|
||||
}
|
||||
for (auto& function : *GetIRContext()->module()) {
|
||||
for (auto& block : function) {
|
||||
for (auto& instruction : block) {
|
||||
if (!spvOpcodeIsLinearAlgebra(instruction.opcode())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!GetFuzzerContext()->ChoosePercentage(
|
||||
GetFuzzerContext()
|
||||
->GetChanceOfReplacingLinearAlgebraInstructions())) {
|
||||
return;
|
||||
}
|
||||
if (!GetFuzzerContext()->ChoosePercentage(
|
||||
GetFuzzerContext()
|
||||
->GetChanceOfReplacingLinearAlgebraInstructions())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ApplyTransformation(TransformationReplaceLinearAlgebraInstruction(
|
||||
GetFuzzerContext()->GetFreshIds(
|
||||
TransformationReplaceLinearAlgebraInstruction::
|
||||
GetRequiredFreshIdCount(GetIRContext(), instruction)),
|
||||
MakeInstructionDescriptor(GetIRContext(), instruction)));
|
||||
});
|
||||
ApplyTransformation(TransformationReplaceLinearAlgebraInstruction(
|
||||
GetFuzzerContext()->GetFreshIds(
|
||||
TransformationReplaceLinearAlgebraInstruction::
|
||||
GetRequiredFreshIdCount(GetIRContext(), &instruction)),
|
||||
MakeInstructionDescriptor(GetIRContext(), &instruction)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace fuzz
|
||||
|
Loading…
Reference in New Issue
Block a user