This is repository for <Merlin: multi-tier optimization of eBPF code for performance and compactness>
git clone https://github.com/4ar0nma0/Merlin.git && cd Merlin
Before you do a cmake, change the llvm install dir and version in the cmakelist file in each directory. After that, run cmake and make
cmake .<
75CD
/span>
make
You can find compiled .so library in ./lib directory. To integrate the pass into compilation process, you need to use opt. Alignment optimization:
opt --load-pass-plugin ./lib/libAlignBPF.so -passes=alignbpf input.ll -o output.ll
Macro-op Fusion:
opt --load-pass-plugin ./lib/libAtomicBPF.so -passes=atomicbpf input.ll -o output.ll
Together, but note put alignbpf before atomicbpf:
opt --load-pass-plugin ./lib/libAtomicBPF.so --load-pass-plugin ./lib/libAtomicBPF.so -passes=alignbpf,atomicbpf input.ll -o output.ll
Librarys
pip install lief numpy
Usage
prog = BPFProg('test.o')
prog.save('test_optimized.o')
You will need an object file generated by clang or llc. By default the script applies all optimizations. PRs are welcome.
Please re-compile the llvm passes with line 227-229 in alignment optimziation uncommented. If you have any issues, please submit an issue. Note that detailed results may differ if using different flags or llvm versions.
MIT License