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

Method HasNoReturnInLoop

source/opt/inline_pass.cpp:757–775  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

755}
756
757bool InlinePass::HasNoReturnInLoop(Function* func) {
758 // If control not structured, do not do loop/return analysis
759 // TODO: Analyze returns in non-structured control flow
760 if (!context()->get_feature_mgr()->HasCapability(spv::Capability::Shader))
761 return false;
762 const auto structured_analysis = context()->GetStructuredCFGAnalysis();
763 // Search for returns in structured construct.
764 bool return_in_loop = false;
765 for (auto& blk : *func) {
766 auto terminal_ii = blk.cend();
767 --terminal_ii;
768 if (spvOpcodeIsReturn(terminal_ii->opcode()) &&
769 structured_analysis->ContainingLoop(blk.id()) != 0) {
770 return_in_loop = true;
771 break;
772 }
773 }
774 return !return_in_loop;
775}
776
777void InlinePass::AnalyzeReturns(Function* func) {
778 // Analyze functions without a return in loop.

Callers

nothing calls this directly

Calls 8

spvOpcodeIsReturnFunction · 0.85
ContainingLoopMethod · 0.80
HasCapabilityMethod · 0.45
get_feature_mgrMethod · 0.45
cendMethod · 0.45
opcodeMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected