This is an archive of the discontinued LLVM Phabricator instance.

[Sema] Accept and ignore the leaf attribute
Needs ReviewPublic

Authored by phosek on Nov 10 2016, 8:10 PM.

Details

Reviewers
aaron.ballman
Summary

This is a GCC extension, Clang should accept the attribute without a warning for compatibility with GCC.

https://llvm.org/bugs/show_bug.cgi?id=30980

Diff Detail

Repository
rL LLVM

Event Timeline

phosek updated this revision to Diff 77593.Nov 10 2016, 8:10 PM
phosek retitled this revision from to [Sema] Accept and ignore the leaf attribute.
phosek updated this object.
phosek set the repository for this revision to rL LLVM.
phosek added a subscriber: cfe-commits.
aaron.ballman added a subscriber: aaron.ballman.

There are a *lot* of attributes GCC supports that Clang does not, and we generally do not silence diagnostics with them as that usually does the user a disservice because they are unaware that the attribute has no effect under any circumstances. Given that: why is this change needed; is this attribute commonly used in some system header files?

thakis added a subscriber: thakis.Nov 11 2016, 7:45 AM

(Maybe implementing real support isn't so difficult? From a quick glance, it sounds like this is a sema-only attribute?)

That makes sense for diagnostics, but this attribute is only an optimization hint, so compiler should be allowed to ignore it. I can take a look how difficult it'd be to actually implement this attribute, but I don't think it's Sema-only attribute. I don't know if there's a matching IR function attribute; it seems like readonly attribute has similar effect but I'd need to take a look at the exact semantics.

aaron.ballman edited edge metadata.Nov 15 2016, 9:58 AM

That makes sense for diagnostics, but this attribute is only an optimization hint, so compiler should be allowed to ignore it. I can take a look how difficult it'd be to actually implement this attribute, but I don't think it's Sema-only attribute. I don't know if there's a matching IR function attribute; it seems like readonly attribute has similar effect but I'd need to take a look at the exact semantics.

The compiler does ignore it; it even tells you it's ignoring it. ;-) There are other optimization-only attributes we don't support, similarly (such as __attribute__((optimize))).

Hopefully the attribute is something we can fully implement, but if it's not and this attribute isn't used by common system headers, I'd be opposed to silently ignoring it rather than vocally ignoring it.