This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] noclobber & noescape annotations for function arguments


On Fri, 16 Apr 2010, Paolo Bonzini wrote:

> On 04/16/2010 01:11 AM, Chris Lattner wrote:
> > void foo(int __attribute__((const)) *x)
> > 
> > could designate that the function only reads from X or something?
> 
> Indeed, for example:
> 
> - const = only read
> - output = only (always?) written, *T is dead on entry
> - nonnull = alternative form of the nonnull function attribute
> - alloc_size (n) = only x[0]..x[n-1] is read/written, useful for n=1 and for
> warnings maybe
> - malloc = for T ** arguments, *T does not alias anything upon exit
> - noderef = pointer is not dereferenced, but still it might escape

- onlydirectlyderef = pointer is only directly dereferenced, *p, but not 
**p

> - noescape = pointer does not escape

- returns (n) = returns argument n

I see attribute inflation ;)

The choice for the single attribute with string argument was to
make lookup cheap (instead of looking for 6 different attributes
or putting the ERF_* / EAF_* flag array(!) somewhere into our
tree structure).

Now, we could translate them to an internal fnspec attribute
on-the-fly (maybe) if that would be a better thing for our
users?

The attribute btw. wasn't invented to annotate our builtins
(we can easily handle them explicitly - and we do) but to allow
annotation of our language runtimes (libstdc++ and libgfortran).

Thanks for the feedback.
Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]