[PATCH] D12781: PGO IR-level instrumentation infrastructure

Diego Novillo via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 1 15:24:31 PST 2015


On Tue, Dec 1, 2015 at 6:17 PM, Rong Xu via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> +  // Set the hot/cold inline hints based on the count values.
>> > +  void applyFunctionAttributes(uint64_t EntryCount, uint64_t MaxCount)
>> {
>> > +    if (ProgramMaxCount == 0)
>> > +      return;
>> > +    // Threshold of the hot functions.
>> > +    const BranchProbability HotFunctionThreshold(1, 100);
>> > +    // Threshold of the cold functions.
>> > +    const BranchProbability ColdFunctionThreshold(2, 10000);
>> > +    if (EntryCount >= HotFunctionThreshold.scale(ProgramMaxCount))
>> > +      F.addFnAttr(llvm::Attribute::InlineHint);
>> > +    else if (MaxCount <= ColdFunctionThreshold.scale(ProgramMaxCount))
>> > +      F.addFnAttr(llvm::Attribute::Cold);
>>
>> This is more or less a workaround for limitations of the inliner and
>> should eventually be removed in favour of making the inliner smarter,
>> correct?
>>
>
> This is to mimic what the Clang PGO is doing. Once inliner uses the
> profile information. all these should be gone.
>

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.


Diego.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151201/e8dd854d/attachment.html>


More information about the llvm-commits mailing list