IMPL10.md (1199B)
1 # IMPL10: Implement Indexed CFG and Cached Metadata 2 3 ## Summary 4 5 Refactor CFG to use indexed storage and precompute successor indices and 6 function block ranges, reducing traversal overhead and repeated scans. 7 8 ## Steps 9 10 1) Update CFG data structures 11 - Change `cfgBlocks` to `Data.Primitive.Array.Array BasicBlock`. 12 - Add fields for cached successors and last-instr metadata. 13 14 2) Build caches during CFG construction 15 - Compute `bbSuccIdxs` and `bbHasFallthrough` once in `buildCFG`. 16 - Build `cfgFuncBlocks :: Map Text [Int]` in a single pass. 17 18 3) Update APIs 19 - `blockSuccessors` should return cached indices. 20 - `functionBlocks` should lookup in `cfgFuncBlocks`. 21 - `buildCallGraph` should use cached function blocks. 22 23 4) Update analysis callers 24 - Replace list indexing `blocks !! idx` with vector indexing. 25 - Ensure call sites in `Taint`, `Check`, and tests are updated. 26 27 5) Tests and benchmarks 28 - Add/adjust tests for CFG correctness (succ edges, function ranges). 29 - Use new benchmarks to quantify improvements. 30 31 ## Files to Touch 32 33 - `lib/Audit/AArch64/CFG.hs` 34 - `lib/Audit/AArch64/Taint.hs` 35 - `lib/Audit/AArch64/Check.hs` 36 - `test/` 37 38 ## Validation 39 40 - `cabal test` 41 - `cabal bench` (criterion + weigh)