This blog post details how to implement an LLVM Pass that allows for tracing memory access - by modifying binaries to augment each memory access opcode with tracing logic.
Introducing Memory Access Traces at Compile Time with LLVM Passes
Writing the Pass - Planning and Boilerplate
Writing the Pass - Setting Up a Global File Descriptor
Writing the Pass - Implementing the Memory Trace Function