Skip to main content

Module optimizer

Module optimizer 

Source

Enums§

CfgDumpStage

Functions§

assign_offsets
Recomputes byte offsets for all labels and instructions in the AST from scratch, in node order. Called after any pass that alters the node list so there is a single authoritative place that assigns offsets.
eliminate_unreachable_functions
Removes functions not reachable from the entry via call imm.
fix_alu32_extension
Makes eBPF’s ALU32 zero-extension hold under SBPF, where add32, sub32 and mul32 sign-extend. Each such instruction is kept, promoted to its 64-bit form, or zero-extended. Assumes the AST follows eBPF semantics (LLVM output).
optimize
Runs every CFG optimization on a single CFG built from the AST, then writes the result back once: dead-function elimination, then the ALU32 extension fix-up.
optimize_with_observer
Like optimize, and exposes the CFG before and after dead-function elimination. The observer owns any optional diagnostics or I/O, keeping the passes themselves pure.