<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
On 4/5/11 11:36 AM, Nabila ABDESSAIED wrote:
<blockquote
cite="mid:BANLkTikwEjd6R6LO9OeG3oZduiYKGD__Gw@mail.gmail.com"
type="cite">
<div dir="ltr"><br>
<br>
<div class="gmail_quote">2011/4/5 John Criswell <span dir="ltr"><<a
moz-do-not-send="true" href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
<div class="im"> On 4/5/11 11:22 AM, Nabila ABDESSAIED
wrote:
<blockquote type="cite">
<div dir="ltr"> <font face="arial, sans-serif"><span
style="border-collapse: collapse;">hi,</span></font>
<div> <font face="arial, sans-serif"><span
style="border-collapse: collapse;">I'm newer
in llvm</span></font></div>
<div><font face="arial, sans-serif"><span
style="border-collapse: collapse;">i would
like to instrument a byte code with a pass and
as a result i would like to get an
instrumented byte code.</span></font></div>
</div>
</blockquote>
<br>
</div>
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?<br>
<br>
By number of instructions, do you mean LLVM instructions
or native code instructions?
<div class="im"><br>
</div>
</div>
</blockquote>
<div>native code instruction a .bc code <br>
</div>
</div>
</div>
</blockquote>
<br>
Okay. That's going to make things more difficult but I would think
is doable.<br>
<br>
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.<br>
<br>
The tricky part is to get the count of native code instructions.
For that, I think you'll need to write a MachineFunctionPass
(<a class="moz-txt-link-freetext" href="http://llvm.org/doxygen/classllvm_1_1MachineFunctionPass.html">http://llvm.org/doxygen/classllvm_1_1MachineFunctionPass.html</a>).
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.<br>
<br>
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.<br>
<br>
Good luck.<br>
<br>
-- John T.<br>
<br>
<blockquote
cite="mid:BANLkTikwEjd6R6LO9OeG3oZduiYKGD__Gw@mail.gmail.com"
type="cite">
<div dir="ltr">
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">
<div class="im"> <br>
<blockquote type="cite">
<div dir="ltr">
<div><font face="arial, sans-serif"><span
style="border-collapse: collapse;">i would
like that a pass add a method (which</span></font><span
style="border-collapse: collapse; font-family:
arial,sans-serif;"> calculate the number of
instructions)</span><span
style="border-collapse: collapse; font-family:
arial,sans-serif;"> in the end of each block.</span></div>
<div><span style="border-collapse: collapse;
font-family: arial,sans-serif;">the instrumented
code should contain in each block a method that
calculate the number of instructions</span></div>
</div>
</blockquote>
<br>
</div>
Have you read the documentation from the web site:<br>
<br>
How to Write an LLVM Pass<br>
</div>
</blockquote>
<div>yes, i have seen them</div>
<div>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</div>
<div>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) </div>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000"> LLVM Programmer's
Manual<br>
LLVM Language Reference Manual (you just need to skim it
to get a basic understanding of what the IR looks like)<br>
<br>
-- John T.
<div class="im"><br>
<br>
<blockquote type="cite">
<div dir="ltr">
<div> <span style="border-collapse: collapse;
font-family: arial,sans-serif;">Please Help me</span></div>
<div><span style="border-collapse: collapse;
font-family: arial,sans-serif;">thank you</span></div>
<div><span style="border-collapse: collapse;
font-family: arial,sans-serif;"><br>
</span></div>
<div><br>
-- <br>
<div dir="ltr">
<div> <font color="#666666">
<div>Nabila ABDESSAIED<br>
<span style="border-collapse: collapse;
font-size: 13px;"><font face="'Wingdings
2'">Tel</font><font face="arial,
sans-serif"> : (+216) 22 473 385
/ </font></span><span
style="border-collapse: collapse;
font-family: arial,sans-serif;
font-size: 13px;">(+216) 55 744 625</span><br>
<span style="border-collapse: collapse;
color: rgb(136, 136, 136);"><span
style="font-size: 13px;"><span
style="font-size: 10pt;"
lang="EN-US"><font color="#666666"><font
face="Wingdings">Email</font><font
face="arial, sans-serif"> : </font></font></span></span><span
style="border-collapse: separate;
font-family: arial,sans-serif;
font-size: 13px; white-space: nowrap;"><font
color="#666666"><a
moz-do-not-send="true"
href="mailto:nabila.abdessaied@gmail.com"
target="_blank">nabila.abdessaied@gmail.com</a></font></span></span></div>
</font></div>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</div>
</div>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div dir="ltr">
<div><font color="#666666">
<div>Nabila ABDESSAIED<br>
<span style="border-collapse: collapse; font-size:
13px;"><font face="'Wingdings 2'">Tel</font><font
face="arial, sans-serif"> : (+216) 22 473 385 / </font></span><span
style="border-collapse: collapse; font-family:
arial,sans-serif; font-size: 13px;">(+216) 55 744 625</span><br>
<span style="border-collapse: collapse; color: rgb(136,
136, 136);"><span style="font-size: 13px;"><span
style="font-size: 10pt;" lang="EN-US"><font
color="#666666"><font face="Wingdings">Email</font><font
face="arial, sans-serif"> : </font></font></span></span><span
style="border-collapse: separate; font-family:
arial,sans-serif; font-size: 13px; white-space:
nowrap;"><font color="#666666"><a
moz-do-not-send="true"
href="mailto:nabila.abdessaied@gmail.com"
target="_blank">nabila.abdessaied@gmail.com</a></font></span></span></div>
</font></div>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>