<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:634259021;
        mso-list-type:hybrid;
        mso-list-template-ids:-1648577256 67698711 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-number-format:alpha-lower;
        mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level3
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level4
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
@list l0:level7
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-number-format:roman-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:right;
        text-indent:-9.0pt;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">We recently got some profiling going with llvm 3.1. (Alastair has got some code in for metadata generation after reading the profiled data(post 3.1) which you
 can follow in some of the earlier mail chains). I will describe the (earlier) 3.1 method which has worked for us. Note this is just a way of doing it. Not *<b>the</b>* way.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Assume you are using clang/clang++ and have a set of C/C++ files:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><span style="mso-list:Ignore">a)<span style="font:7.0pt "Times New Roman"">     
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Run individual C/C++ files with :
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">clang/clang++
</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">-mllvm  -emit-llvm -S<b>
</b></span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">–o x.o x.c/x.cpp</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"><span style="mso-list:Ignore">b)<span style="font:7.0pt "Times New Roman"">     
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Link all the .o s using llvm-link</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">: llvm-link *.o –o X.o // new
 single X.o created<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"><span style="mso-list:Ignore">c)<span style="font:7.0pt "Times New Roman"">      
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%">Insert edge profiling</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">:
 opt -O3  -insert-edge-profiling X.o -o X_prof.o<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"><span style="mso-list:Ignore">d)<span style="font:7.0pt "Times New Roman"">     
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">llc X_prof.o // creates X_prof.o.s<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"><span style="mso-list:Ignore">e)<span style="font:7.0pt "Times New Roman"">     
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">as X_prof.o.s // creates a.out<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"><span style="mso-list:Ignore">f)<span style="font:7.0pt "Times New Roman"">      
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black">clang/clang++ -o X_prof.exe a.out –lprofile_rt –L<path of your installed lib where libprofile_rt resides> //creates the instrumented binary X_prof.exe<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%">Now run the instrumented executable “X_prof.exe” using whatever input test data you
 have. This will create the <b>llvmprof.out</b> file.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%">Create the new optimized executable after reading llvmprof.out:</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><span style="mso-list:Ignore">g)<span style="font:7.0pt "Times New Roman"">     
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%"> </span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">opt
 –O3 –profile-loader X.o –o X_opt.o   // you can replace this with Alastair’s profile loading step –profile-metadata-loader<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><span style="mso-list:Ignore">h)<span style="font:7.0pt "Times New Roman"">     
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">llc X_opt.o // creates X_opt.o.s<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><span style="mso-list:Ignore">i)<span style="font:7.0pt "Times New Roman"">       
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">as X_opt.o.s // creates a.out<o:p></o:p></span></p>
<p class="MsoListParagraph" style="text-indent:-.25in;mso-list:l0 level1 lfo1"><![if !supportLists]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><span style="mso-list:Ignore">j)<span style="font:7.0pt "Times New Roman"">       
</span></span></span><![endif]><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">clang/clang++ -o X_opt.exe a.out –lprofile_rt –L<path of your installed lib where libprofile_rt resides> //creates the final optimized binary X_opt.exe<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%">Hope this helps.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#376092;mso-style-textfill-fill-color:#376092;mso-style-textfill-fill-alpha:100.0%">-Dibyendu<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.25in"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-bounces@cs.uiuc.edu]
<b>On Behalf Of </b>Joseph Reddington<br>
<b>Sent:</b> Monday, September 10, 2012 1:32 PM<br>
<b>To:</b> llvmdev@cs.uiuc.edu<br>
<b>Subject:</b> [LLVMdev] Profiling - execution count of basic blocks...<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi gang,  time for my weekly confusion... (I'm trying not to bombard the board with questions) 
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The thing that's on my mind at the moment (there's some backend-stuff that I'm just working my way though) is that I'm not getting very far when trying to get LLVM to profile code - I'm looking for nothing more special than list of how
 many times each basic block has been called - but when wading though the docs I get lots of command line fragments that don't work and the distint impression that the method for profiling has changed three times in the last three release - I don't suppose
 that you have any insight into what's going on with profiling for llvm...?  I'm starting to get the feeling that I've missed something obvious...   My setup is: <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">LLVM (<a href="http://llvm.org/">http://llvm.org/</a>):<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  LLVM version 3.2svn<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  DEBUG build with assertions.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  Built Jul 27 2012 (18:29:09).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  Default target: x86_64-apple-darwin11.4.0<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">  Host CPU: corei7-avx<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div>
<p class="MsoNormal">Any ideas?<o:p></o:p></p>
</div>
</div>
</body>
</html>