staffantj added a comment.
In D86559#2236931 <https://reviews.llvm.org/D86559#2236931>, @Quuxplusone wrote:
> This feels like the wrong approach to me... but I admit that I don't know
> what the "right" approach might be. (I doubt any right approach exists.)
>
> if (ch == ' ') [[likely]] {
> goto whitespace; // A
> } else if (ch == '\n' || ch == '\t') [[unlikely]] {
> goto whitespace; // B
> } else {
> foo();
> }
> [[likely]] whitespace: bar(); // C
>
> It seems like this patch would basically "copy" the `[[likely]]` attribute
> from line C up to lines A and B, where it would reinforce the likelihood of
> path A and (maybe?) "cancel out" the unlikelihood of path B, without actually
> saying anything specifically about the likelihood of label C (which is surely
> what the programmer intended by applying the attribute, right?). OTOH, I
> can't think of any particular optimization that would care about the
> likelihood of label C. I could imagine trying to align label C to a 4-byte
> boundary or something, but that wouldn't be an //optimization// on any
> platform as far as I know.
The only reason I could see for writing the above (and it's far more likely to
be written with [[unlikely]] in my experience) is to control the probability
that the call to bar() gets inlined or not.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D86559/new/
https://reviews.llvm.org/D86559
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits