| 29 | transformations, ignore_inapplicable_transformations) {} |
| 30 | |
| 31 | void FuzzerPassAddLoopPreheaders::Apply() { |
| 32 | for (auto& function : *GetIRContext()->module()) { |
| 33 | // Keep track of all the loop headers we want to add a preheader to. |
| 34 | std::vector<uint32_t> loop_header_ids_to_consider; |
| 35 | for (auto& block : function) { |
| 36 | // We only care about loop headers. |
| 37 | if (!block.IsLoopHeader()) { |
| 38 | continue; |
| 39 | } |
| 40 | |
| 41 | // Randomly decide whether to consider this header. |
| 42 | if (!GetFuzzerContext()->ChoosePercentage( |
| 43 | GetFuzzerContext()->GetChanceOfAddingLoopPreheader())) { |
| 44 | continue; |
| 45 | } |
| 46 | |
| 47 | // We exclude loop headers with just one predecessor (the back-edge block) |
| 48 | // because they are unreachable. |
| 49 | if (GetIRContext()->cfg()->preds(block.id()).size() < 2) { |
| 50 | continue; |
| 51 | } |
| 52 | |
| 53 | loop_header_ids_to_consider.push_back(block.id()); |
| 54 | } |
| 55 | |
| 56 | for (uint32_t header_id : loop_header_ids_to_consider) { |
| 57 | // If not already present, add a preheader which is not also a loop |
| 58 | // header. |
| 59 | GetOrCreateSimpleLoopPreheader(header_id); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | } // namespace fuzz |
| 65 | } // namespace spvtools |
nothing calls this directly
no test coverage detected