This revision was automatically updated to reflect the committed changes.
Mordante marked an inline comment as done.
Closed by commit rGb46fddf75fc2: [CodeGen] Implement [[likely]] and
[[unlikely]] for while and for loop. (authored by Mordante).
Changed prior to commit:
Mordante marked an inline comment as done.
Mordante added a comment.
Thanks for the review.
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3161
+ InGroup;
+def note_attribute_has_no_effect_here : Note<
+ "annotating the %select{infinite loop}0 here">;
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM aside from a request about the note. Thank you for this!
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3161
+ InGroup;
+def
Mordante updated this revision to Diff 301332.
Mordante marked an inline comment as done.
Mordante added a comment.
Addressed the review comments:
- The likelhood attribute no longer affects the `do` statement.
- Added a diagnotic when a likelihood attribute is used on an infinite while
loop.
aaron.ballman added inline comments.
Comment at: clang/include/clang/Basic/AttrDocs.td:1866
+ while(true) [[unlikely]] {
+... // The attribute has no effect
+ } // Clang elides comparison and generates an infinite loop
Mordante marked 10 inline comments as done.
Mordante added a comment.
Thanks for the feedback. I'll update the patch after making the requested
changes.
Comment at: clang/include/clang/Basic/AttrDocs.td:1866
+ while(true) [[unlikely]] {
+... // The
aaron.ballman added inline comments.
Comment at: clang/include/clang/Basic/AttrDocs.td:1861
+
+ do [[unlikely]] { // The loop will always iterate once
+... // The likelihood attribute affects the likelihood of the
Mordante wrote:
>
Mordante planned changes to this revision.
Mordante marked 2 inline comments as done.
Mordante added inline comments.
Comment at: clang/include/clang/Basic/AttrDocs.td:1854
+ for(int i = 0; i != size; ++i) [[likely]] {
+... // The loop the likely path of
aaron.ballman added a comment.
Thank you for this!
Comment at: clang/include/clang/Basic/AttrDocs.td:1773
-At the moment the attributes only have effect when used in an ``if``, ``else``,
-or ``switch`` statement.
+Below some usage examples likelihood attributes and their
Mordante created this revision.
Mordante added reviewers: aaron.ballman, rjmccall, rsmith.
Mordante added a project: clang.
Herald added a subscriber: dexonsmith.
Mordante requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D89899
Files:
10 matches
Mail list logo