A "white-box" profiler built on top of the LLVM infrastructure. Unlike sampling profilres (e.g., perf), Ohm modifies the program's Intermediate Representation (IR) during compilation to inject precise measurement probes. It turns opaque binaries into transparent systems that report their own execution metrics.
The project follows a dual-component architecture design to separate instrumentation logic from measurement logic.
- Role: The "Surgeon".
- Time: Compile-time.
- Function: Analysis the LLVM IR, identifies function entry and exit points (Basic Blocks), and injects calls to the runtime library. It does not measure anything itself; it merely prepares the code.
- Role: The "Lab".
- Time: Runtime.
- Function: A lightweight static library linked to the target binary. It implements the probes, captures CPU cycle counts, and aggregates statistics.
- LLVM & Clang
- CMake (3.13+)
- C++ Compiler supporting C++17/20
git clone https://github.com/monvit/ohm.git monvit-ohm && cd monvit-ohmmkdir build && cd buildcmake ..cmake --build .To instrument a target program (e.g., examples/main.cc):
clang -emit-llvm -c main.cpp -o main.bcopt -load-pass-plugin=./injector/libOhmPass.so -passes="ohm" main.bc -o main_inst.bcclang main_inst.bc -L./runtime -lmonvit_rt -o my_program./my_program