Repository navigation
[PROPOSAL] region-structurer foundation (regionstructure): 7-increment SAILR/Phoenix roadmap - #58
Merged
Merged
Conversation
The staged Phoenix/SAILR structurer plan behind the structuring/goto/switch/loops gains. Feasible via a clean seam: under --option regionstructure (default OFF), replace CollapseStructure::collapse_all() in ActionBlockStructure::apply with a region structurer that walks the kuna_regionid region tree and emits the same sblocks BlockKind tree the renderer already consumes. 7 parity-safe increments (Inc 0 adapter → Inc 1 PoC sequence schema → ITE → loops → switch → short-circuit/H2 → DIV-6 flip). Awaiting human go/no-go before the loop implements it. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01PBrckq3YYAzBLq5k4KpWac
Contributor
Author
|
APPROVE |
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.
Region-based (Phoenix/SAILR) structurer for kuna — staged roadmap
Status: PROPOSAL (draft PR) — awaiting go/no-go before implementation.
This is the foundation behind the "structuring / goto / switch / loops" gains. Multiple
feature attempts (e.g. the head-in-body natural-loop PR #44) returned NEGATIVE with the same
verdict: "needs region/SAILR structurer." kuna's structuring is Ghidra's goto-emitting
CollapseStructure; angr's SAILR/Phoenix structurer produces far fewer gotos and recoversloops/switches. This roadmap gives kuna that structurer, incrementally and parity-safely.
Feasibility & seam
Feasible, with an unusually clean seam, because kuna already has both hard halves:
s7_regions/kuna_regionid.rs, the angrRegionIdentifierport) — analysis-only today, not wired into output.substrate/block.rsBlockKind::{List,Condition,If, WhileDo,DoWhile,Switch,InfLoop,Goto,Copy}) maps almost 1:1 onto angr's structurer nodes.Seam: under a new master
--option regionstructure(default OFF), replace theCollapseStructure::collapse_all()call inActionBlockStructure::apply(
s8_structure/blockaction.rs:~3372) with a region structurer that walks the region tree,matches Phoenix schemas, and emits the same
sblocksBlockKindtree the renderer(
s9_emit/printc.rs) already consumes. The p-code/varnode data flow is never touched.Default-OFF ⇒ all 675 datatests render byte-identical. New module:
s8_structure/region_structurer.rs, porting angranalyses/decompiler/structuring/{phoenix,sailr,recursive_structurer,structurer_base}.py.Increments (each: option-gated, default-OFF, both-directions stage test, 3 gates green)
build_from_block_graph+ends_with_branchind_or_cbranchover realbblocksops, sori.compute()runs on real CFGs. No output change._virtualize_edgegoto fallback + SAILR H1/H3 ordering; wire intoActionBlockStructure::apply+ register the option. Proves the whole seam end-to-end.recursive_structurer,phoenix._match_acyclic_sequence,_virtualize_edge,sailr._order_virtualizable_edgesboolean_flip; no claripy).phoenix._match_acyclic_ite, structuralhave_opposite_edge_conditionsphoenix._analyze_cyclic+ 4 cyclic matchers, break/continue rewritersswitch_case_edges/find_jump_table_indexalready in blockaction.rs. Independent of 2/3 after Inc 1.phoenix._match_acyclic_switch_cases*if(a)if(b)→if(a&&b)) + SAILR H2 post-dom heuristic (with angr's size caps) + recursive re-structure. Closes the quality gap.phoenix._match_acyclic_short_circuit_conditions*,sailrH2Parity & performance
make testPARITY OK).Honest-partial-safe: an un-matched region falls back to a virtualized goto / the existing
CollapseStructurepath — never aborts.postdom_max_edges=10/postdom_max_graph_size=50); reuseKunaIncrementalDominatorsrather than rebuilding perschema; watch
failed_region_attemptsgrowth. Zero perf cost on the default pipeline untilInc 6 (option OFF). Benchmark the largest datatest functions (cf. the prior
ActionPoolO(N²) regression).
Effort & sequencing
~6–7 PRs. Sequential spine Inc 0 → 1 → 2 → 3; Inc 4 and Inc 5 parallelizable after
Inc 1; Inc 6 last. First dispatch: Inc 0 (small), then Inc 1 PoC — target a function
shaped
if(c){A}else{B} → join → tailwhere Ghidra gotos the join→tail edge; the sequenceschema folds it, yielding one fewer
gotoverifiable viakuna decompile ./elf fn --option regionstructure on|off.Critical files
s7_regions/kuna_regionid.rs,s8_structure/blockaction.rs,substrate/block.rs,s9_emit/printc.rs,p0_knowledge/options.rs(+stages.toml,infra/universalaction.rs),and the new
s8_structure/region_structurer.rs.