https://github.com/lancern/llvm-covmap
Profiling for code coverage via bitmap
https://github.com/lancern/llvm-covmap
code-coverage llvm llvm-ir llvm-pass profiling
Last synced: 11 months ago
JSON representation
Profiling for code coverage via bitmap
- Host: GitHub
- URL: https://github.com/lancern/llvm-covmap
- Owner: Lancern
- License: mit
- Created: 2021-01-03T10:38:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-01-14T06:30:22.000Z (about 5 years ago)
- Last Synced: 2025-04-06T22:54:25.251Z (12 months ago)
- Topics: code-coverage, llvm, llvm-ir, llvm-pass, profiling
- Language: C++
- Homepage:
- Size: 61.5 KB
- Stars: 5
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# llvm-covmap


LLVM passes and utilities that instruments code to profile for **function-level**
code coverage via bitmap during program runtime.
## Build
### Build Prerequisites
- CMake version >= 3.12
- LLVM
To install LLVM on your platform, execute the following command:
```shell
sudo apt install llvm-dev
```
It's recommended to use LLVM version 10.0.0. Other versions of LLVM might work
as well, but they are not tested. To check the LLVM version on your system, execute
the following command:
```shell
llvm-config --version
```
### Build Steps
Clone the repository:
```shell
git clone https://github.com/Lancern/llvm-covmap.git
cd llvm-covmap
```
Create a build directory:
```shell
mkdir build
cd build
```
Build the project using the familiar two-step build:
```shell
cmake ..
cmake --build .
```
The output files are generated in the `lib/` directory in the build tree.
## Usage
> For advanced usage of `llvm-covmap`, please refer to [docs](./docs).
To simplify examples, we assume that the `LLVM_COVMAP_BUILD_DIR` environment is set
to the root of the build tree.
Instrument LLVM modules by hand:
```shell
opt -load $LLVM_COVMAP_BUILD_DIR/lib/libLLVMCoverageMapPass.so -covmap \
-o=instrumented-module.bc \
input-module.bc
```
End-to-end build using the drop-in replacement of `clang` and `clang++`:
```shell
# Compile only, do not link
$LLVM_COVMAP_BUILD_DIR/bin/llvm-covmap-clang -c -o example.o example.c
# End-to-end compile is supported
# All necessary runtime libraries required by llvm-covmap will be linked automatically
$LLVM_COVMAP_BUILD_DIR/bin/llvm-covmap-clang -o example example.c
$LLVM_COVMAP_BUILD_DIR/bin/llvm-covmap-clang++ -o example example.cpp
```
One-shot run an **instrumented** program and dump the coverage information:
```shell
$LLVM_COVMAP_BUILD_DIR/bin/llvm-covmap-shell ls
```
## Contribute
This project is built for private use so we don't accept any feature requests or
pull requests. But you're free to fork your own copy of this project and add
modifications to fit your need.
## License
This repository is open-sourced under the [MIT license](./LICENSE).