MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / RewriteFunctionIntoSSA

Method RewriteFunctionIntoSSA

source/opt/ssa_rewrite_pass.cpp:653–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

651}
652
653Pass::Status SSARewriter::RewriteFunctionIntoSSA(Function* fp) {
654#if SSA_REWRITE_DEBUGGING_LEVEL > 0
655 std::cerr << "Function before SSA rewrite:\n"
656 << fp->PrettyPrint(0) << "\n\n\n";
657#endif
658
659 // Collect variables that can be converted into SSA IDs.
660 pass_->CollectTargetVars(fp);
661
662 // Generate all the SSA replacements and Phi candidates. This will
663 // generate incomplete and trivial Phis.
664 bool succeeded = pass_->cfg()->WhileEachBlockInReversePostOrder(
665 fp->entry().get(), [this](BasicBlock* bb) {
666 if (!GenerateSSAReplacements(bb)) {
667 return false;
668 }
669 return true;
670 });
671
672 if (!succeeded) {
673 return Pass::Status::Failure;
674 }
675
676 // Remove trivial Phis and add arguments to incomplete Phis.
677 FinalizePhiCandidates();
678
679 // Finally, apply all the replacements in the IR.
680 bool modified = ApplyReplacements();
681
682#if SSA_REWRITE_DEBUGGING_LEVEL > 0
683 std::cerr << "\n\n\nFunction after SSA rewrite:\n"
684 << fp->PrettyPrint(0) << "\n";
685#endif
686
687 return modified ? Pass::Status::SuccessWithChange
688 : Pass::Status::SuccessWithoutChange;
689}
690
691Pass::Status SSARewritePass::Process() {
692 Status status = Status::SuccessWithoutChange;

Callers 1

ProcessMethod · 0.80

Calls 5

CollectTargetVarsMethod · 0.80
getMethod · 0.80
PrettyPrintMethod · 0.45
cfgMethod · 0.45

Tested by

no test coverage detected