| 606 | } |
| 607 | |
| 608 | Pass::Status LoopUnswitchPass::ProcessFunction(Function* f) { |
| 609 | bool modified = false; |
| 610 | std::unordered_set<Loop*> processed_loop; |
| 611 | |
| 612 | LoopDescriptor& loop_descriptor = *context()->GetLoopDescriptor(f); |
| 613 | |
| 614 | bool loop_changed = true; |
| 615 | while (loop_changed) { |
| 616 | loop_changed = false; |
| 617 | for (Loop& loop : make_range( |
| 618 | ++TreeDFIterator<Loop>(loop_descriptor.GetPlaceholderRootLoop()), |
| 619 | TreeDFIterator<Loop>())) { |
| 620 | if (processed_loop.count(&loop)) continue; |
| 621 | processed_loop.insert(&loop); |
| 622 | |
| 623 | LoopUnswitch unswitcher(context(), f, &loop, &loop_descriptor); |
| 624 | while (unswitcher.CanUnswitchLoop()) { |
| 625 | if (!loop.IsLCSSA()) { |
| 626 | if (!LoopUtils(context(), &loop).MakeLoopClosedSSA()) { |
| 627 | return Status::Failure; |
| 628 | } |
| 629 | } |
| 630 | if (!unswitcher.PerformUnswitch()) { |
| 631 | return Status::Failure; |
| 632 | } |
| 633 | modified = true; |
| 634 | loop_changed = true; |
| 635 | } |
| 636 | if (loop_changed) break; |
| 637 | } |
| 638 | } |
| 639 | |
| 640 | return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange; |
| 641 | } |
| 642 | |
| 643 | } // namespace opt |
| 644 | } // namespace spvtools |
nothing calls this directly
no test coverage detected