<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=utf-8">
<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;}
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;}
--></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">Hi Chandler and Alastair,<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">I have been using the Profile.pl and the related passes and optimizations for about 4 years now. With every new release lately, the support for the profile
scripts and their framework seemed to be downgrading. Hence, I used my own tiny one line fixes to keep them working. I offered to send these small patches to keep these scripts working, to the LLVM dev so that others can use it if they want. I think my email
got lost that time, in the sea of emails we see on the dev mail list.<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">I must confess that I was not aware of the BPI and BFI infrastructures. The breaking of the profiling infrastructure always baffled me. Now it makes sense,
since it has been superseded by these new frameworks.<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">Anyway, if you guys decide to keep the old profiling framework, it would be good. As Alastair has mentioned, the llvm-prof helps in a way for instrumenting
the code with the profile data. Maybe this is also part of the BPI/BFI in which case it's great.<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">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Alok
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">PhD Candidate, NTU Singapore.<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>Chandler Carruth<br>
<b>Sent:</b> Monday, July 16, 2012 6:34 AM<br>
<b>To:</b> Alastair Murray<br>
<b>Cc:</b> csdavec@swan.ac.uk; llvmdev@cs.uiuc.edu<br>
<b>Subject:</b> Re: [LLVMdev] FYI: Planning to remove ProfileInfo and related passes from LLVM<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">On Sun, Jul 15, 2012 at 8:32 AM, Alastair Murray <<a href="mailto:alastairmurray42@gmail.com" target="_blank">alastairmurray42@gmail.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Hi Chandler,<br>
<br>
I'm a GSoC student working on profiling support (mentor CC'ed). I'm no<br>
stranger to the issues with the current system: my original proposal was<br>
written without knowledge of the limitations. This is why this list<br>
hasn't heard much from me yet.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">It would be better to actually email the list with the problems you are hitting sooner. We would have directed you to the BranchProbabilityInfo and BlockFrequencyInfo infrastructure that is now actively in use by several optimization passes
in LLVM.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Can you start a thread with what your specific goals are? The only email I have from you is from May 1st, which was your project outline for the GSoC application, to which Evan responded, but to which nothing else ever materialized.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I think if any of us knew that you were actively working on the existing ProfileInfo and profile loading infrastructure we would have jumped in quickly to redirect things. I'll provide a bit of feedback below, but we should really hold
the main part of this discussion on a separate thread, as ultimately *how* you can use the BPI and BFI analyses and the metadata they are predicated on is independent from whether we remove the existing code... The important thing is that you can use them,
and that the existing code won't help much (if at all).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">I would like to continue working on profiling support but I'm not<br>
attached to ProfileInfo and wouldn't be distraught if it gets removed.<br>
I'd rather work on a useful solution than a dead one and nothing I've<br>
done so far couldn't be ported to a different interface. I know some<br>
people are definitely interested in profiling support.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I am one of them. ;] I've been working on the BPI- and BFI-based optimizations in LLVM.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">My reason for doing this GSoC project was to gain experience with LLVM<br>
and that aim doesn't disappear after one summer's worth of work. My<br>
personal plan was to keep on working on profiling support beyond the end<br>
date, long-term (though not full time). I do compiler research, but not<br>
currently with LLVM -- so this is a genuine desire and plan.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The last thing I want is for GSoC work to come to nothing. I've been a GSoC student, and so it's important to me that we give you useful things to work on that the overarching LLVM community benefits from.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Perhaps the best way to proceed is to remove ProfileInfo etc and then I<br>
can work on re-adding/re-writing it with support for BranchProbability<br>
and BlockFrequency. Then I can maintain what I add. (As an unknown<br>
figure offering to maintain the existing code seems a bit hollow.)<br>
<br>
Naturally, any changes to my GSoC plans need discussion with my mentor.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Yes, I think you and your mentor need to discuss this and to start engaging with the LLVM community through the mailing list about the design of the summer-of-code work, how it should be structured, etc. I think that the community at large
is extremely interested in improved PGO support in LLVM, and so we'd be really interested in giving feedback and direction advice... <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I'd like to hear an explicit OK from you and your mentor before I remove anything, as I don't want to get in the way of any immediate progress or work you're doing as part of GSoC.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">A few specifics below.<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
On 15/07/12 20:07, Chandler Carruth wrote:<br>
> Hello folks,<br>
><br>
> I'd like to remove all of the old and defunct profile info passes from<br>
> LLVM. These have been almost entirely supplanted by the<br>
> BranchProbability and BlockFrequency systems, which are actually on by<br>
> default, and in use in optimization passes.<br>
><br>
> The old system is not on, and hasn't been touched in years except to do<br>
> minor build fixes and updates.<br>
><br>
> As far as I'm aware, the only thing the old system supported which the<br>
> new one does not is loading profile data. However, it didn't support<br>
> doing anything useful with that data once loaded,<o:p></o:p></p>
</div>
<p class="MsoNormal">There is also the llvm-prof tool, but yes: there is only one<br>
optimization pass that uses profiling data and it is not on by default.<br>
The hindrance to using ProfileInfo in other passes is that almost no<br>
passes preserve it and it can not be recalculated (just estimated by<br>
ProfileEstimate).<br>
<br>
As far as I can tell BranchProbability and BlockFrequency would also be<br>
invalidated by any CFG altering passes. Preserving ProfileInfo was my<br>
primary long-term (post-GSoC) task, preserving BranchProbability and<br>
BlockFrequency instead should be no harder.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Details for another thread, but essentially, BranchProbabilityInfo is going to "recompute" the probabilities, but only insofar as they stem from heuristics that can be computed. If you look at the pass, there is also support for loading
branch weight metadata and using that to form probability estimates. This metadata is attached to the IR and is the primary mechanism for preserving information.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The overarching expected strategy is that a profile-loading pass would load a profile and convert it to metadata annotations on the IR itself. Then passes would be taught to preserve this metadata wherever possible, and BranchProbabilityInfo
will compute probabilities based on the metadata, falling back to static heuristics only when the metadata is absent.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The missing pieces are:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">1) Ensuring that passes such as SimplifyCFG preserve as much branch weight metadata as possible. This is already an issue for metadata that comes from __builtin_expect() source code annotations, so it is something you can write tests for
today and observe problems.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">2) A pass to load profile data and attach metadata to branch instructions based on it.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">3) Ensuring that #2 works with the profiles produced by an instrumented binary.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">It's important to note that #2 is easy. It's #1 and #3 that are really hard. When I have talked to others about #3, there has been the feeling that we would probably want to write a custom instrumentation pass that would add instrumentation
to the right LLVM IR formations, in order to make sure that when it is read back in, the profile data matches up with the IR correctly, and is available early enough in the optimization passes to be used.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>