This is repository for <Merlin: multi-tier optimization of eBPF code for performance and compactness>
git clone https://github.com/4ar0nma0/Merlin.git && cd MerlinBefore 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 .
makeYou 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.llMacro-op Fusion:
opt --load-pass-plugin ./lib/libAtomicBPF.so -passes=atomicbpf input.ll -o output.llTogether, 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.llLibrarys
pip install lief numpyUsage
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