[PATCH] D134456: [PGO] Consider parent context when weighing branches with likelyhood.

Duncan P. N. Exon Smith via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 30 08:19:21 PDT 2022


dexonsmith added a comment.

In D134456#3827332 <https://reviews.llvm.org/D134456#3827332>, @dexonsmith wrote:

> In D134456#3827263 <https://reviews.llvm.org/D134456#3827263>, @aaron.ballman wrote:
>
>> My worry is that parallel attributes will be used as:
>>
>>   #if __has_cpp_attribute(clang::likely_but_honor_this_one)
>>   #define LIKELY [[clang::likely_but_honor_this_one]]
>>   #elif __has_cpp_attribute(likely)
>>   #define LIKELY [[likely]]
>>   #else
>>   #define LIKELY
>>   #endif
>
> To be clear, I was imagining:
>
>   if (always_false()) [[likely]] [[clang::nopgo]] {
>     // ...
>   }
>
> where ``nopgo`` might be independently useful for telling clang to ignore any collected PGO data when estimating branch weights in a particular control flow block.
>
> Some users might combine the two into a macro ("always ignore the profile when I say something is likely!"), but I don't think there'd be a cascade.

(In practice a use of `nopgo` probably needs to drop the profile for the whole function, but maybe that's fine...)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134456/new/

https://reviews.llvm.org/D134456



More information about the cfe-commits mailing list