[LLVMdev] Instrument examples
陳韋任
chenwj at iis.sinica.edu.tw
Thu Nov 3 05:44:00 PDT 2011
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?
No idea what exactly you want to achieve, but let me try.
First, you might need a function doing the instrument. Say,
void HowManyTimeThisFunctionGetCalled();
Then you can insert a call to the function above while creating
a LLVM function [1]. In that way, every time that LLVM function
get called the function doing the instrument will be called.
You might need to take a look on ${LLVM_SOURCE}/example/HowToUseJIT
to get a feel on how to create a LLVM module, function and basic block.
Regards,
chenwj
[1] http://llvm.org/docs/ProgrammersManual.html#Function
--
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
More information about the llvm-dev
mailing list