Repository navigation
s9 emit: port Ghidra markLabelBumpUp — hoist loop-head labels out of loop conditions (fix invalid C) - #150
Merged
Conversation
…tions kuna emitted a goto-target label INSIDE a for/while condition (invalid C), e.g. grep sub_9ddf: `for (; (\nlabel_9e38:*v3 == ':' ...); ...)`. The label mechanism (`f_label_bumpup`, `is_label_bump_up`) existed but nothing set it, and the printer emitted the label directly instead of routing through the label-hoist path. This ports Ghidra's markLabelBumpUp / emitAnyLabelStatement so a loop-head label is hoisted to its own line ABOVE the loop. Port (line-faithful): - substrate/block.rs: `mark_label_bump_up`/`block_graph_mark_label_bump_up` (C++ FlowBlock::markLabelBumpUp block.cc:259, BlockGraph::markLabelBumpUp block.cc:1259, and the BlockWhileDo/BlockDoWhile/BlockInfLoop overrides that steal the lower block's label, block.cc:3364/3477/3505). - s8_structure/blockaction.rs: call `graph.mark_label_bump_up(false)` at the ActionFinalStructure seam, after markUnstructured (port of blockaction.cc:2196). - s9_emit/printc.rs: add `emit_any_label_statement` (C++ PrintC::emitAnyLabelStatement printc.cc:3354 — `if isLabelBumpUp return; bl=getFrontLeaf(); emitLabelStatement`); route emit_block_copy through it (printc.cc:2894) and add it to the 4 loop emitters at the same sites C++ has them (printc.cc:3097/3146/3208/3236). Gates: datatests 675/675 PARITY OK (byte-identical, no baseline change — the corpus asserts 0 labels so the hoist never fires); test-stages 256/256 PARITY OK; rust-test exit 0 (275 suites ok, 0 failures, no golden-fixture changes). Whole-binary safety (decompile-all, before vs after): grep 6 fns changed, all label-position hoists (sub_9ddf + sub_19334 were the genuine label-in-condition bug; 4 more moved a loop-head label from first-statement-inside to its own line above the loop, Ghidra-canonical); factor 4 fns changed, same hoist. In both: label-in-condition 2->0 (grep) / 0->0 (factor); total gotos UNCHANGED (grep 207, factor 88 — a label-position fix, not a goto fix); 0 functions brace-unbalanced; no new errors. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J
mahaloz
added a commit
that referenced
this pull request
Jul 8, 2026
fix(s3): cover INT_EQUAL/INT_NOTEQUAL in opflags_for seam shim (#150 regression)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports Ghidra's unported
markLabelBumpUp/emitAnyLabelStatementlabel-hoist — fixing an invalid-C emission bug (a loop-head label rendered inside afor(...)condition). Found while disentangling proposal #39 (condfold): this is the separable, low-risk half; the largecondfoldregion-structurer work is a follow-up.The bug (grep/parse_grep_colors @ 0x9ddf, O0)
Before — label inside the
forcondition (uncompilable):After — hoisted to its own line above the loop; the
goto label_9e38;still targets it:Root cause
kuna had the
f_label_bumpupflag (block.rs:175) but never ported the mechanism that sets it: Ghidra'smarkLabelBumpUpwas commented out at theActionFinalStructureseam (blockaction.rs:3617), andemitAnyLabelStatementdidn't exist, so loop emitters never hoisted the head label —emit_block_copyemitted it inline (inside thefor).The port (line-faithful, cites C++ origins)
substrate/block.rs:mark_label_bump_up+ graph walk — port ofFlowBlock::markLabelBumpUp(block.cc:259),BlockGraph::markLabelBumpUp(block.cc:1259) + the WhileDo/DoWhile/InfLoop overrides that steal the front-leaf's label (block.cc:3364/3477/3505).s8_structure/blockaction.rs: callmark_label_bump_up(sroot, false)at the seam (blockaction.cc:2196).s9_emit/printc.rs: addedemit_any_label_statement(printc.cc:3354); routedemit_block_copy(printc.cc:2894) + the 4 loop emitters (printc.cc:3097/3146/3208/3236) through it. Double-emit avoidance preserved.Verification
make test675/675 PARITY OK (byte-identical, no baseline edit),make test-stages256/256,make rust-test0 failures (no golden-fixture updates needed).🤖 Generated with Claude Code
https://claude.ai/code/session_018DV2MXxQAAWK7xLPBmsq9J