Bug 114851 - Alternative to -Wmisexpect from LLVM in GCC
Summary: Alternative to -Wmisexpect from LLVM in GCC
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: gcov-profile (show other bugs)
Version: 14.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: new-warning, new_warning
  Show dependency treegraph
 
Reported: 2024-04-25 09:59 UTC by Alexander Zaitsev
Modified: 2024-04-25 17:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Zaitsev 2024-04-25 09:59:39 UTC
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.
Comment 1 Andrew Pinski 2024-04-25 17:01:14 UTC
I don't think GCC has a warning (yet).
Comment 2 Andrew Pinski 2024-04-25 17:02:34 UTC
(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.
Comment 3 Alexander Zaitsev 2024-04-25 17:06:19 UTC
> 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 .