How llvm-ir works: Pure Rust representation
mainUnlike FFI-heavy bindings like inkwell, llvm-ir is designed for consumption and analysis of LLVM IR.
It uses the LLVM API (via llvm-sys) only during the initial parsing step to construct a rich, native Rust representation. Once the Module is created, all FFI objects are dropped, allowing you to work with the IR in pure, safe Rust.
Key Abstractions:
Instruction: Anenumwith variants likeAdd,Call, andStore(rather than an opaque type).BasicBlock,Function,Module: Rust structs containing complete IR information.HasDebugLoc: A trait used to accessDebugLoconInstructions,Terminators,GlobalVariables, andFunctions (requires-gduring IR generation).