auditor

An aarch64 constant-time memory access auditing tool.
git clone git://git.ppad.tech/auditor.git
Log | Files | Refs | README | LICENSE

commit 08fed64dea0812afa3566a21dfdca511d3dac660
parent 889aed3a98b5d862ccc80e8b4d66ccf1c3bba710
Author: Jared Tobin <jared@jtobin.io>
Date:   Wed, 11 Feb 2026 19:48:10 +0400

perf: use strict foldl' in taint analysis

Replace foldl with foldl' in analyzeBlock, analyzeBlockWithSummaries,
and joinTaintState folds to prevent thunk accumulation in long blocks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Diffstat:
Mlib/Audit/AArch64/Taint.hs | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/Audit/AArch64/Taint.hs b/lib/Audit/AArch64/Taint.hs @@ -58,6 +58,7 @@ import qualified Data.IntSet as IS import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import qualified Data.Set as Set +import Data.List (foldl') import Data.Text (Text) -- | Taint state: maps registers to their publicness, plus stack slots. @@ -152,7 +153,7 @@ analyzeLine l st = case lineInstr l of -- | Analyze a basic block, threading taint state through. analyzeBlock :: [Line] -> TaintState -> TaintState -analyzeBlock lns st = foldl (flip analyzeLine) st lns +analyzeBlock lns st = foldl' (flip analyzeLine) st lns -- | Transfer function for taint analysis. -- @@ -672,7 +673,7 @@ runFunctionDataflow cfg blockIndices summaries = ] in case returnOuts of [] -> initTaintState -- No return found, use init - (o:os) -> foldl joinTaintState o os + (o:os) -> foldl' joinTaintState o os -- | Check if block ends with a return instruction. endsWithRet :: BasicBlock -> Bool @@ -721,7 +722,7 @@ runFunctionBlocks cfg (entryIdx:rest) summaries = go initWorklist initIn IM.empt -- | Analyze a block, applying call summaries at bl instructions. analyzeBlockWithSummaries :: BasicBlock -> TaintState -> Map Text FuncSummary -> TaintState -analyzeBlockWithSummaries bb st0 summaries = foldl go st0 (bbLines bb) +analyzeBlockWithSummaries bb st0 summaries = foldl' go st0 (bbLines bb) where go st l = case lineInstr l of Nothing -> st @@ -879,7 +880,7 @@ runFunctionDataflowWithConfig tcfg cfg funcName blockIndices summaries = ] in case returnOuts of [] -> initTaintState - (o:os) -> foldl joinTaintState o os + (o:os) -> foldl' joinTaintState o os -- | Run function blocks with a custom entry state. runFunctionBlocksWithEntry :: CFG -> [Int] -> Map Text FuncSummary