问题
Recently, I am doing some research with LLVM.
At first, I want to write a pass to instrument .bc file.
Thus, it will record the execution path of the basic block of my .bc file.
Then, I want to term this .bc file into .exe file. Please give me your suggestions and if you have some examples for instrumentation of LLVM, please show me.
回答1:
LLVM already comes with a number of instrumentation tools built-in. Take a look in the lib/Transforms/Instrumentation directory in the source tree.
One of the best known passes is Address Sanitizer, an instrumentation-based memory error detector (kinda like Valgrind, but significantly faster). Address Sanitizer has a runtime component + a LLVM pass that inserts instrumentation; the pass lives in lib/Transforms/Instrumentation/AddressSanitizer.cpp. There's some description of how it works on this page.
来源:https://stackoverflow.com/questions/21060434/llvm-instrumentation