Fix loops not printing breaks in SPIR-V disassembly

* If the end of the loop exits it's a redundant goto but similar to switches we
  still want the break
This commit is contained in:
baldurk committed 2026-07-15 11:01:31 +01:00
1 parent 274042a1a7
commit 1f3334d358
1 file changed
+5 -2
@@ -1077,9 +1077,9 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint,
if(decodedlabelId == decoded.targetLabel)
{
// however if we're in a switch we might want to print a clarifying fallthrough comment
// or end-of-case break
// or end-of-case break, and in a loop we could need a break
if(!cfgStack.empty() && cfgStack.back().type == StructuredCFG::Switch)
if(!cfgStack.empty() && cfgStack.back().type != StructuredCFG::If)
{
// add a break even for the final branch to the merge block
if(cfgStack.back().mergeTarget == decoded.targetLabel)
@@ -1088,7 +1088,10 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint,
lineNum++;
continue;
}
}
if(!cfgStack.empty() && cfgStack.back().type == StructuredCFG::Switch)
{
// if we're falling through to the next case, print a comment
for(const SwitchPairU64LiteralId &caseTarget : cfgStack.back().caseTargets)
{