Thread (39 messages) 39 messages, 8 authors, 2022-01-14

Re: [PATCH 2/6] Add returns_zero_on_success/failure attributes

From: David Malcolm <hidden>
Date: 2021-11-18 23:45:47

On Thu, 2021-11-18 at 14:08 -0600, Segher Boessenkool wrote:
On Wed, Nov 17, 2021 at 10:43:58PM +0000, Joseph Myers wrote:
quoted
On Wed, 17 Nov 2021, Prathamesh Kulkarni via Gcc-patches wrote:
quoted
More generally, would it be a good idea to provide attributes for
mod/ref anaylsis ?
So sth like:
void foo(void) __attribute__((modifies(errno)));
which would state that foo modifies errno, but neither reads nor
modifies any other global var.
and
void bar(void) __attribute__((reads(errno)))
which would state that bar only reads errno, and doesn't modify
or
read any other global var.
Many math.h functions are const except for possibly setting errno, 
possibly raising floating-point exceptions (which might have other
effects 
when using alternate exception handling) and possibly reading the
rounding 
mode.  To represent that, it might be useful for such attributes to
be 
able to describe state (such as the floating-point environment)
that 
doesn't correspond to a C identifier.  (errno tends to be a macro,
so 
referring to it as such in an attribute may be awkward as well.)
We need some way to describe these things in Gimple and RTL as well,
and not just on function calls: also on other expressions.  Adding
attributes that allow to describe this (partially, only per function)
in
C source code does not bring us closer to where we need to be.
Right, but those IR concerns are orthogonal to the needs of the patch
kit, which is a way to express certain *other* things per-function in
the C frontend.  

As noted in my other replies, this thread seems to be turning into
something of a scope-creep pile-on, when I have some specific things I
need for the rest of the patch kit, and they're unrelated to the
problems of errno or floating-point handling.

Dave
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help