hi, I'm newer in llvm i would like to instrument a byte code with a pass and as a result i would like to get an instrumented byte code. i would like that a pass add a method (which calculate the number of instructions) in the end of each block. the instrumented code should contain in each block a method that calculate the number of instructions Please Help me thank you -- Nabila ABDESSAIED Tel : (+216) 22 473 385 / (+216) 55 744 625 Email : nabila.abdessaied at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110405/91cae85f/attachment.html>
On 4/5/11 11:22 AM, Nabila ABDESSAIED wrote:> hi, > I'm newer in llvm > i would like to instrument a byte code with a pass and as a result i > would like to get an instrumented byte code.To rephrase, you want to instrument a program so that, when you run it, it computes the number of instructions executed at run-time. Is this correct? By number of instructions, do you mean LLVM instructions or native code instructions?> i would like that a pass add a method (which calculate the number of > instructions) in the end of each block. > the instrumented code should contain in each block a method that > calculate the number of instructionsHave you read the documentation from the web site: How to Write an LLVM Pass LLVM Programmer's Manual LLVM Language Reference Manual (you just need to skim it to get a basic understanding of what the IR looks like) -- John T.> Please Help me > thank you > > > -- > Nabila ABDESSAIED > Tel : (+216) 22 473 385 / (+216) 55 744 625 > Email : nabila.abdessaied at gmail.com <mailto:nabila.abdessaied at gmail.com> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110405/659c2405/attachment.html>
On 4/5/11 11:36 AM, Nabila ABDESSAIED wrote:> > > 2011/4/5 John Criswell <criswell at illinois.edu > <mailto:criswell at illinois.edu>> > > On 4/5/11 11:22 AM, Nabila ABDESSAIED wrote: >> hi, >> I'm newer in llvm >> i would like to instrument a byte code with a pass and as a >> result i would like to get an instrumented byte code. > > To rephrase, you want to instrument a program so that, when you > run it, it computes the number of instructions executed at > run-time. Is this correct? > > By number of instructions, do you mean LLVM instructions or native > code instructions? > > native code instruction a .bc codeOkay. That's going to make things more difficult but I would think is doable. So, the instrumentation at the LLVM IR is easy: you simply add a CallInst (i.e., a call instruction) at the end of each basic block (technically, before the BasicBlock's terminator instruction) that calls an external function. This external function will be implemented in a run-time library that you link with the program after it is compiled with LLVM. The tricky part is to get the count of native code instructions. For that, I think you'll need to write a MachineFunctionPass (http://llvm.org/doxygen/classllvm_1_1MachineFunctionPass.html). This sort of pass is part of the code generator and works on the IR representing the generated code. You will need to have it count the instructions and then modify the call instruction so that it passes the count of machine instructions to the run-time library. I haven't written a MachineFunctionPass before, so others who have will need to answer questions on it. However, the doxygen docs and the existing MachienFunctionPass passes in LLVM may be a good way to learn how they work. Good luck. -- John T.> >> i would like that a pass add a method (which calculate the number >> of instructions) in the end of each block. >> the instrumented code should contain in each block a method that >> calculate the number of instructions > > Have you read the documentation from the web site: > > How to Write an LLVM Pass > > yes, i have seen them > actually i had written a pass that anlyse a .bc code and gives as a > result the number of instructions and others parameters like the > instcount pass > but what i would like to do it's not to analyse but to instrument (add > methods into th bc code that calculate the nuber of instructions) > > LLVM Programmer's Manual > LLVM Language Reference Manual (you just need to skim it to get a > basic understanding of what the IR looks like) > > -- John T. > > >> Please Help me >> thank you >> >> >> -- >> Nabila ABDESSAIED >> Tel : (+216) 22 473 385 / (+216) 55 744 625 >> Email : nabila.abdessaied at gmail.com >> <mailto:nabila.abdessaied at gmail.com> >> > > > > > -- > Nabila ABDESSAIED > Tel : (+216) 22 473 385 / (+216) 55 744 625 > Email : nabila.abdessaied at gmail.com <mailto:nabila.abdessaied at gmail.com> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110405/8d95181a/attachment.html>
John Criswell <criswell at illinois.edu> writes:> On 4/5/11 11:36 AM, Nabila ABDESSAIED wrote: > > 2011/4/5 John Criswell <criswell at illinois.edu> > > On 4/5/11 11:22 AM, Nabila ABDESSAIED wrote: > > hi, > I'm newer in llvm > i would like to instrument a byte code with a pass and as a result i would like to get an instrumented byte > code. > > To rephrase, you want to instrument a program so that, when you run it, it computes the number of instructions > executed at run-time. Is this correct? > > By number of instructions, do you mean LLVM instructions or native code instructions? > > native code instruction a .bc codeHi Nabila ;-) That reminds me a lot the work of Patrice Gerin: http://tima.imag.fr/tima/fr/mediatheque/PhDthesisresult_id316.html and @conference{bouchhima2009automatic, title={{Automatic instrumentation of embedded software for high level hardware/software co-simulation}}, author={Bouchhima, A. and Gerin, P. and P{\'e}trot, F.}, booktitle={Proceedings of the 2009 Asia and South Pacific Design Automation Conference}, pages={546--551}, year={2009}, organization={IEEE Press} } -- Matthieu Moy http://www-verimag.imag.fr/~moy/
hi, My work consist in : 1)translating the c code program into a bc code with llvm-gcc (done) 2)write a pass to be used to instrument the bc code resulted from 2 ( i will use insert block profiling pass so done ) 3)Use LLVM's llc program to generate C or assembly code of your instrumented program (not yet). 4) Compile the C/asm code to native code with gcc and link it with any native code libraries that it needs. 5) Run the program and gather the information from your instrumentation instructions. wihich i find the same with this article http://old.nabble.com/Determine-branch-coverage-information-td26141617.html#a26440560 but the last command in that article doesn't works fr me: llvm-prof -print-all-code <executable>.1.bc llvm-prof: Error opening 'llvmprof.out': No such file or directory i found that profile.pl which takes a single bytecode file and parameters could do all the work of instrumenting, running and executing llvm-prof in one go. but i try this : sudo /usr/local/llvm-2.8/utils/profile.pl -edge hello.bc Error opening '/usr/lib/llvm-2.8/lib/profile_rt.so': /usr/lib/llvm-2.8/lib/profile_rt.so: cannot open shared object file: No such file or directory -load request ignored. LLVM ERROR: Program used external function 'llvm_start_edge_profiling' which could not be resolved! and when i tried to make each command in the profile.pl manually step by step i found this problems opt -q -f -insert-block-profiling hello.bc -o result.bc.inst opt: Unknown command line argument '-insert-block-profiling'. Try: 'opt -help' thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110407/ff3e9d61/attachment.html>