spirv-fuzz: Apply fuzzer pass before checking exit conditions (#4199)

Fixes #4198.
This commit is contained in:
Alastair Donaldson 2021-03-19 05:32:54 +00:00 committed by GitHub
parent a611be7782
commit a732e4c03c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -282,6 +282,12 @@ Fuzzer::Result Fuzzer::Run(uint32_t num_of_transformations_to_apply) {
auto status = Status::kComplete;
do {
if (!ApplyPassAndCheckValidity(
repeated_pass_manager_->ChoosePass(transformation_sequence_out_))) {
status = Status::kFuzzerPassLedToInvalidModule;
break;
}
// Check that the module is small enough.
if (ir_context_->module()->id_bound() >=
fuzzer_context_->GetIdBoundLimit()) {
@ -301,7 +307,9 @@ Fuzzer::Result Fuzzer::Run(uint32_t num_of_transformations_to_apply) {
break;
}
// If the number of transformations is still small
// Check that we've not got stuck (this can happen if the only available
// fuzzer passes are not able to apply any transformations, or can only
// apply very few transformations).
if (num_repeated_passes_applied_ >=
fuzzer_context_->GetTransformationLimit()) {
status = Status::kFuzzerStuck;
@ -317,11 +325,6 @@ Fuzzer::Result Fuzzer::Run(uint32_t num_of_transformations_to_apply) {
break;
}
if (!ApplyPassAndCheckValidity(
repeated_pass_manager_->ChoosePass(transformation_sequence_out_))) {
status = Status::kFuzzerPassLedToInvalidModule;
break;
}
} while (ShouldContinueRepeatedPasses(num_of_transformations_to_apply == 0));
if (status != Status::kFuzzerPassLedToInvalidModule) {