DFS through inputs of `end` to find `start`. `start` must be positioned before `end`.
| 605 | // DFS through inputs of `end` to find `start`. |
| 606 | // `start` must be positioned before `end`. |
| 607 | bool reaches(instruction_ref start, instruction_ref end) |
| 608 | { |
| 609 | if(start == end) |
| 610 | return true; |
| 611 | std::unordered_set<instruction_ref> visited; |
| 612 | return fix<bool>([&](auto self, auto ins) -> bool { |
| 613 | if(ins == start) |
| 614 | return true; |
| 615 | // hit a previously visited instruction |
| 616 | if(not visited.insert(ins).second) |
| 617 | return false; |
| 618 | return std::any_of(ins->inputs().begin(), ins->inputs().end(), self); |
| 619 | })(end); |
| 620 | } |
| 621 | |
| 622 | // `reaches` version that checks if instructions are in the module `m` |
| 623 | // Additional condition that stops if DFS instruction's distance to `end` |
no test coverage detected