<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 1, 2015 at 6:17 PM, Rong Xu via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="cremed">llvm-commits@lists.llvm.org</a>></span> wrote:</div><div class="gmail_quote"><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"><div class="gmail_quote"><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> +  // Set the hot/cold inline hints based on the count values.<br>
> +  void applyFunctionAttributes(uint64_t EntryCount, uint64_t MaxCount) {<br>
> +    if (ProgramMaxCount == 0)<br>
> +      return;<br>
> +    // Threshold of the hot functions.<br>
> +    const BranchProbability HotFunctionThreshold(1, 100);<br>
> +    // Threshold of the cold functions.<br>
> +    const BranchProbability ColdFunctionThreshold(2, 10000);<br>
> +    if (EntryCount >= HotFunctionThreshold.scale(ProgramMaxCount))<br>
> +      F.addFnAttr(llvm::Attribute::InlineHint);<br>
> +    else if (MaxCount <= ColdFunctionThreshold.scale(ProgramMaxCount))<br>
> +      F.addFnAttr(llvm::Attribute::Cold);<br>
<br>
This is more or less a workaround for limitations of the inliner and<br>
should eventually be removed in favour of making the inliner smarter,<br>
correct?<br></blockquote><div><br></div></div></div><div>This is to mimic what the Clang PGO is doing. Once inliner uses the profile information. all these should be gone. </div></div></div></div></blockquote><div><br></div><div>Note that SamplePGO is doing something similar with inline hints.  We need to abstract this (probably in the inliner).  The profilers need to be able to describe per-callsite weights.  Once the inliner gains this interface, all three variants of this need to start using it.</div><div><br></div><div><br></div><div>Diego.</div></div></div></div>