HomePhabricator

[CodeGen] Implement [[likely]] and [[unlikely]] for while and for loop.

Authored by Mordante on Oct 31 2020, 5:07 AM.

Description

[CodeGen] Implement [[likely]] and [[unlikely]] for while and for loop.

The attribute has no effect on a do statement since the path of execution
will always include its substatement.

It adds a diagnostic when the attribute is used on an infinite while loop
since the codegen omits the branch here. Since the likelihood attributes
have no effect on a do statement no diagnostic will be issued for
do [[unlikely]] {...} while(0);

Differential Revision: https://reviews.llvm.org/D89899