diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-10 11:32:21 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-10 12:08:27 -0300 |
| commit | b426a8a99bcad81ecbb41d1f2a2e83738c29d8e1 (patch) | |
| tree | 06e303f1f33ce53cfc2d8a2043e24f032877f9ad /targets/instr_fib.c | |
| parent | 7f363779cb99b0820cce69c433bcfab87bb3d709 (diff) | |
| download | computeranim-b426a8a99bcad81ecbb41d1f2a2e83738c29d8e1.tar.gz computeranim-b426a8a99bcad81ecbb41d1f2a2e83738c29d8e1.zip | |
llvm: a pass that instruments for animation, its runtime, ztrace cc
llvm/pass.cpp is an LLVM pass plugin: lines, stores, loads, calls and
variables, each call into the runtime carrying names and type descriptions,
selected by globs (-ztrace-only, -ztrace-mem), before the optimizer by
default. src/instr/rt.zig is the runtime (libztrace-rt.a), which also
answers clang's own coverage and -finstrument-functions hooks;
src/instr/types.zig the grammar of the type descriptions and its parser.
ztrace cc adds all of it to a compiler command.
test-llvm compiles fib, two sorts, a linked list and a BFS through ztrace
cc and asserts on their recordings; bench-llvm measures what each selection
costs.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Diffstat (limited to 'targets/instr_fib.c')
| -rw-r--r-- | targets/instr_fib.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/targets/instr_fib.c b/targets/instr_fib.c new file mode 100644 index 0000000..9da9306 --- /dev/null +++ b/targets/instr_fib.c @@ -0,0 +1,12 @@ +// fib(n) the slow way: a call tree to draw. Exits with fib(argv[1]), by +// default fib(6). +#include <stdlib.h> + +static unsigned fib(unsigned n) { + if (n < 2) return n; + return fib(n - 1) + fib(n - 2); +} + +int main(int argc, char **argv) { + return (int)fib(argc > 1 ? (unsigned)atoi(argv[1]) : 6); +} |
