LLVM infrastructure supports a diagnostic for checking mismatches between user-provided __builtin_expect/[[likely]] hints and PGO profiles: https://clang.llvm.org/docs/DiagnosticsReference.html#wmisexpect + https://llvm.org/docs/MisExpect.html (and an example of its usage in Chromium: https://issues.chromium.org/issues/40694104). I was trying to find a similar diagnostic in GCC but found nothing. Is there anything similar in GCC? If not, can we make the issue a Feature Request for such a feature? Having such a diagnostic can be helpful in practice since it allows for finding wrongfully placed user hints in sources.
I don't think GCC has a warning (yet).
(In reply to Andrew Pinski from comment #1) > I don't think GCC has a warning (yet). Though I do wonder if the "hints" are used instead of the PGO here.
> Though I do wonder if the "hints" are used instead of the PGO here. We already discussed this question a bit in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112806 . If I understand correctly, no clear answer yet: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112806#c4 .