<div dir="ltr">For PGO, there is a solution to it. <div><br></div><div>See small example:</div><div><div><br></div><div>#include <stdlib.h></div><div>int g;</div><div>__attribute__((noinline)) void foo()</div><div>{</div><div>  g++;</div><div>  if (g==1000)</div><div>    exit(0);</div><div>}</div><div><br></div><div>int main()</div><div>{</div><div>  while (1) {</div><div>    foo();</div><div>  }</div><div><br></div><div>}</div></div><div><br></div><div>The profile count for the loop is generated, but Clang simply can not find a conditional branch instruction to attach the MD_prof data.  Very simply speaking, this can be fixed by allowing MD_prof to be attached to unconditional branch in the infinite loop (such that taken_weight/exit_weight represents trip count). In block frequency propagation, the trip count for infinite loop can be read from the meta data.</div><div><br></div><div>We probably need a different bug tracking the issue.</div><div><br></div><div>David</div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 27, 2015 at 1:46 PM, Chandler Carruth <span dir="ltr"><<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><span class=""><br><div class="gmail_quote">On Fri, Mar 27, 2015 at 1:36 PM, Xinliang David Li <span dir="ltr"><<a href="mailto:xinliangli@gmail.com" target="_blank">xinliangli@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">To be on the safe side, my patch is mapping them down to a 32bit<br>
space, but I am squishing them too much on  the lower end. So regions<br>
of the CFG that before had distinct temperatures are now showing up<br>
with frequency == 1.<br>
<br>
I need a better smoother for the mapping from the Scale64 floats down<br>
to 64bit (or 32bit) integers.<br></blockquote><div><br></div><div><br></div></span><div>This seems to show another weakness of the block frequency propagation --  it can not handle infinite loops.  We need to think about how to handle it ..</div></blockquote></div><br></span>I think we should just have a synthetic "max" and not balloon the range due to it. Then we can pin the max at some fixed multiple of the actual max when scaling it down.</div></div>
</blockquote></div><br></div>