Static analysis tools

May 20, 2026 ยท View on GitHub

RISC-V instructions / registers (rv_histogram)

This is a static analysis tool for assessing the usage of RV32 instructions/registers in a given target program. Build this tool by running the following command:

$ make tool

After building, you can launch the tool using the following command:

$ build/rv_histogram [-ar] [target_program_path]

The tool includes two optional options:

  • -a: output the analysis in ascending order (default is descending order)
  • -r: output usage of registers (default is usage of instructions)

Example instructions histogram Instructions Histogram Example

Example registers histogram Registers Histogram Example

Basic block profiler (rv_profiler)

To install lolviz, use the following command:

$ pip install lolviz

For macOS users, it might be necessary to install additional dependencies:

$ brew install graphviz

Build the profiling data by executing rv32emu. This can be done as follows:

$ build/rv32emu -p build/[test_program].elf

To analyze the profiling data, run rv_profiler from the project root (the script reads build/<test_program>.prof):

$ tools/rv_profiler [--start-address ADDR] [--stop-address ADDR] [--graph-ir ADDR] <test_program>

<test_program> is the basename of the ELF passed to rv32emu -p (for build/rv32emu -p build/hello.elf, pass hello.elf). Each --*-address flag takes a hexadecimal address.