[PATCH] Support the assume_aligned function attribute
Chandler Carruth
chandlerc at google.com
Sat Sep 6 21:13:11 PDT 2014
On Sat, Sep 6, 2014 at 9:01 PM, Richard Smith <richard at metafoo.co.uk> wrote:
> Here's what I can piece together:
>
> * GCC does not intend to support `nonnull` on reference parameters. It
> rejects `nonnull(N)` where parameter `N` is a reference, *but* if you apply
> `nonnull` with no `N`, it applies to both pointer and reference parameters,
> and happens to have the semantics of checking for "null references".
> * Clang made up its own thing in response to some non-publicly-visible
> radar issue, where it treats the `nonnull` attribute on
> references-to-pointers as applying to the pointer within the reference.
> This makes little sense to me, but there it is. We naturally can't optimize
> on the basis of `nonnull` on a reference-to-pointer like we can on a real
> pointer parameter/return value (we have no IR representation for that).
>
> It seems our options are to either not support `assume_aligned` on
> references (which would be a shame, because it's natural and useful there
> just as it is for pointers), or make `nonnull` and `assume_aligned`
> inconsistent on pointers-to-references,
>
references-to-pointers
> or remove our (dubious, IMO) extension of the GNU `nonnull` semantics. I'm
> not happy with the third option since I don't know what the motivation for
> the extension is nor how many people might be relying on it, but either of
> the first two seem fine to me.
>
How can you rely on it? It can't functionally break existing code, it would
just introduce build errors. We could emit a warning that we are ignoring
nonnull as references are always null that people could suppress.
I would like to remove this dubious extension unless someone at Apple can
help us understand the justification. Even then, I would suggest moving it
to a new, unambiguous name such as 'references_nonnull'. CC'ing Doug to
comment about why this was added. If we're keeping it, considering the
motivation listed was just a "rdar", we should get it documented in the
user manual.
> I don't think the connection between `nonnull` and `assume_aligned` is
> strong enough that the difference would be jarring for people.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140906/51275098/attachment.html>
More information about the cfe-commits
mailing list