A borrow checker for raw LLVM IR. High-level syntax is for
humans; if the LLM is writing the code anyway, drop straight to SSA bitcode, enforce affine
ownership and Non-Lexical Lifetimes before codegen, link against a zero-libc syscall stdlib
(libir), and emit a 1 KB static ELF binary.
Nothing runs on a server — the checker below is
borrir-core compiled to WebAssembly.
Try:
playground.ll)
Without C or Rust there is no glibc. libir is a minimal standard
library written directly in borrow-checked LLVM IR using raw Linux x86_64
syscall inline assembly. Packages compile to verified .bc bitcode
artifacts pinned by SHA-256 in borrir.lock and linked with
llvm-link.
| Code | Rule | What it catches |
|---|---|---|
E0001 |
Use after move |
Reading, writing, or freeing a pointer after ownership transferred via
"borrir.own" or !borrir.move.
|
E0002 |
Use after free / double free |
Accessing or re-freeing a pointer after @libir_free,
@free, or @sys_munmap.
|
E0003 |
Mutable aliasing | Passing two pointers sharing a root to a call when either is mutable, or overlapping active loans on the same root. |
E0004 |
Immutable write |
Writing through a readonly parameter, !borrir.ref borrow,
or constant global.
|
E0005 |
Dangling stack escape |
Returning a local alloca pointer or storing it into an out-parameter,
heap block, or global.
|
E0006 |
Mutate while borrowed | Mutating, moving, or freeing an owner while a derived borrow is still live under CFG liveness (NLL). |
E0007 |
Owned allocation leak |
Returning from a function while a heap allocation from @libir_alloc /
noalias allocator is unconsumed.
|
E0008 |
CFG merge conflict | Using a pointer after a merge block when it was moved or freed on only one incoming branch. |
W0001 |
Provenance lost |
Synthesizing a pointer from an integer via inttoptr without
!borrir.unsafe.
|
| Attribute / Metadata | Meaning in borrIR |
|---|---|
noalias ptr (return) |
Produces an owned heap root that must be freed or returned on every path. |
ptr readonly |
Shared immutable borrow (&T); multiple aliases permitted, writes
rejected (E0004).
|
ptr noalias (param) |
Exclusive mutable borrow (&mut T); overlapping roots rejected
(E0003).
|
ptr "borrir.own" |
Moves ownership into the callee; caller cannot access afterward
(E0001).
|
!borrir.unsafe |
Escape hatch for low-level primitives (such as @sys_mmap's
inttoptr).
|