<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>I agree, this a fundamental problem with how the AutoFDO maps addresses to statements.</div>
<div><br>
</div>
<div>I have an experimental build where, rather than turning off certain optimizations, I change the DebugLoc information when we hoist instructions into a new execution context. That avoids the problem of wrong branch weights but means some branch weights
 are inferred rather than measured.  </div>
<div><br>
</div>
<div>Perhaps rather than limit optimizations we have a variant of ‘-g’ which tolerates this kind of change</div>
<div><br>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Sanjay Patel <<a href="mailto:spatel@rotateright.com">spatel@rotateright.com</a>><br>
<span style="font-weight:bold">Date: </span>Wednesday, August 17, 2016 at 8:19 AM<br>
<span style="font-weight:bold">To: </span>Xinliang David Li <<a href="mailto:xinliangli@gmail.com">xinliangli@gmail.com</a>><br>
<span style="font-weight:bold">Cc: </span>David Callahan <<a href="mailto:dcallahan@fb.com">dcallahan@fb.com</a>>, LLVM Dev Mailing list <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [llvm-dev] AutoFDO sample profiles v. SelectInst,<br>
</div>
<div><br>
</div>
<div>
<div>
<div dir="ltr"><br>
<div class="gmail_extra">
<div class="gmail_quote">On Fri, Aug 12, 2016 at 12:15 PM, Xinliang David Li via llvm-dev
<span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">+dehao.
<div><br>
</div>
<div>There are two potential problems:</div>
<div><br>
</div>
<div>1) the branch gets eliminated in the binary that is being profiled, so there is no profile data</div>
</div>
</blockquote>
<div><br>
</div>
<div>This seems like a fundamental problem for PGO. Maybe it is also responsible for this bug:
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D27359&d=DQMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=lFyiPUrFdOHdaobP7i4hoA&m=ySKs86N9LiBaTDmiRjbJJIGlO-z7BHXRaRnz-hS1Gno&s=ZkL9ORQxX1oNnyUFSaW9NT6PcpKuF8Ow5gqA-aEp7YA&e=">
https://llvm.org/bugs/show_bug.cgi?id=27359</a> ?<br>
</div>
<div> <br>
</div>
<div>Should we limit select optimizations in IR for a PGO-training build? Or should there be a 'select smasher' pass later in the pipeline that turns selects into branches for a PGO-training build? (I don't have a good understanding of PGO, so I'm just throwing
 out ideas...maybe a better question is: how do other compilers handle this?)<br>
</div>
</div>
<br>
</div>
</div>
</div>
</div>
</span>
</body>
</html>