[LLVMdev] Instrument examples
John Criswell
criswell at illinois.edu
Thu Nov 3 07:52:53 PDT 2011
On 10/31/2011 2:53 AM, zhouxu(NUDT) wrote:
> Hi,
> I am new to LLVM. I want to use LLVM to instrument codes, such as
> function calls and basic blocks. But I don't know where to start. I
> wonder if there are any example codes to show how to instrument codes
> in the IR level?
First, have you read the Language Reference Manual, the Programmer's
Manual, and the How to Write an LLVM Pass manual at
http://llvm.org/docs? Those are pretty much required reading for
staring to learn how to write LLVM transform passes.
As you start coding, you'll find the doxygen docs (also on that web
page) extremely valuable.
As for examples, you might want to take a look at some of the passes in
the SAFECode project (http://sva.cs.illinois.edu). The load/store
instrumentation pass (safecode/lib/InsertPoolChecks/LoadStoreChecks.cpp)
is a very simple example of a pass that instruments every load and
store. Modifying that code to instrument function calls and basic
blocks should be straightforward.
There are, of course, numerous examples in LLVM itself (in
lib/Transforms), too, although I'm not sure which passes are going to be
small and trivial (maybe the profiling instrumentation passes).
-- John T.
> Thanks.
>
>
>
> --
> zhouxu
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111103/30e0aacf/attachment.html>
More information about the llvm-dev
mailing list