[LLVMdev] How to instrument a this function using insertBefore instruction???

Alexander Potapenko glider at google.com
Mon Apr 9 02:19:35 PDT 2012


You'll need to declare the function in a separate module, not in the
function pass.
That module needs to be compiled independently and linked to the
program instrumented by your pass.
In order to add a function declaration to the program, use getOrInsertFunction()
You may want to have a look at how AddressSanitizer works
(http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp),
it does essentially the same.

HTH,
Alex



More information about the llvm-dev mailing list