[PATCH] D86841: [clang] Add mustprogress and llvm.loop.mustprogress attribute deduction

Florian Hahn via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 8 07:17:47 PST 2021


fhahn added a comment.

In D86841#2484705 <https://reviews.llvm.org/D86841#2484705>, @atmnpatel wrote:

> I'm happy to add a patch amending this, the reason it wasn't done that way was because at the time and even now, out of icc/clang/msvc/gcc, gcc seems to be the only one that happily removed such loops in C++ (https://godbolt.org/z/W9vj99), and I didn't have a particularly strong opinion on which way we should lean at the time.

I think ideally we would make this decision on what the standard allows. AFAICT the C++ spec for iteration statements (http://eel.is/c++draft/stmt.iter) does not have the same escape hatch as C. So IMO the current behavior is surprising and potentially leads to confusion for users (e.g. wondering why are some loops removed, but others not, even if the C++ spec allows for both to be removed).

There may be practical reasons for opting to be more conservative (e.g. if it would break a large number of user codes), but so far there seems to be no such indication in the discussion. It would probably be good to also implement `-ffinite-loops` as suggested by @xbolva00 so users can better control this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86841/new/

https://reviews.llvm.org/D86841



More information about the cfe-commits mailing list