LLVM Tutorials

Hi,

Could anyone point me to some simple examples/tutorials for writing instrumentation transform passes. Essentially adding instructions to basic blocks, such as print statements, load, add, store. I have tried going through profiling transforms, and was wondering if there is any better documented tutorial etc ?

Thanks
Nipun

Hi,

Could anyone point me to some simple examples/tutorials for writing instrumentation transform passes. Essentially adding instructions to basic blocks, such as print statements, load, add, store. I have tried going through profiling transforms, and was wondering if there is any better documented tutorial etc ?'

Section 5 of the Programmer's Manual may be helpful: http://llvm.org/docs/ProgrammersManual.html#common

Doxygen is a good reference when you need to look up a class. Basically, every LLVM instruction and value have their own class:

http://llvm.org/doxygen/

For an example of an extremely simple instrumentation pass, check out lib/InsertPoolChecks/LoadStoreChecks.cpp in the SAFECode project (http://sva.cs.illinois.edu). This code adds a run-time check on every load and store instruction. It's almost as simple as a transform gets.

-- John T.