Codegen Purity: Hand-Written Assembly Quality at -O0
10 sections
Overview
Achieve hand-written-quality C-level assembly from Ori programs at -O0 by eliminating every known codegen purity deficiency across code journeys 1–12. Functional correctness is already 12/12; this plan targets structural IR quality, attribute precision, and backend parity so debug-mode output does not depend on -O1+ cleanup passes.
Completed
10 sections
Block Merging & CFG Simplification
Zero avoidable bridge blocks in emitted IR while preserving required entry/exit/unwind structure
Function Attributes
Every function and runtime declaration has complete, correct LLVM attributes — noreturn, nounwind, noundef
Arithmetic Correctness
Unary negation of INT_MIN panics instead of silently wrapping
ARC Closure Lifecycle
Closure environments are freed when their last reference goes out of scope — zero leaks
Sum Type Payload Extraction
Match arm payload extraction uses extractvalue (2 instructions) instead of alloca+store+GEP+load (5 instructions)
Dead Code Pruning
No dead loads (unused struct/list fields) and no code generation after noreturn calls
Constant Deduplication
Identical string constants share a single global — zero duplicates in emitted IR
Loop IR Quality
Loops emit minimal IR — no duplicate computations, no loop-invariant block params, optimized range checks for common patterns
Tail Call Optimization
Tail-recursive functions are compiled to loops — no stack growth on tail calls
Verification
All 12 code journeys produce zero findings — hand-written assembly quality at -O0