Working with LLVM Passes is really exciting - injecting our own logic into the compilation process and handcrafting LLVM IR that we can force into arbitrary locations in our binary is nothing sort of magic.

The goal in this project was to gain some familiarity with writing LLVM Passes and demonstrate how powerful they can be - all in the context of a simple pass.

Some thoughts:


We often find ourselves held back by CPU/OS limitations - not every environment supports the full tracing, instrumentation, or binary modification features we might want.

The pass I implemented has many shortcomings - for example, lack of float/double support and a lack of multithreaded support - but it does go to show that LLVM Passes can bridge these limitations and allow us to implement complex features (in this case, memory access tracing) by using simple primitives (in this case, standard file-writing logic).

The code in this blog post is available here under the MIT License:

MemoryTrace.cpp


I had a lot of fun writing this blog post and even more fun implementing this project - if you have any comments or questions please reach out 🙂.