https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122483
--- Comment #37 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #36)
> (In reply to Richard Sandiford from comment #20)
> > But the point is that a choice is always being made. The choice is silent
> > for normal functions and noisy for streaming and streaming-compatible
> > functions. But there's a choice nonetheless. There is no concept of an
> > "uncertain", "non-commital" or "deferential" type.
>
> How is that different from any other ABI attributes?
> We also have normal calling convention, or say regparm(1), or regparm(2), or
> regparm(3) and similarly with many other ABI attributes. No special
> attribute for the normal case, and yet we do accept
> void f(void) [[that_ABI_attribute]];
> void f(void);
> as being the same as
> void f(void) [[that_ABI_attribute]];
> void f(void) [[that_ABI_attribute]];
> because there is no risk of it breaking anything, that is a user friendly
> choice (and sometimes really needed, when you don't have control over what
> attributes some header imposes on standard APIs). The function already has
> some specific calling convention, so there is no reason to harass the user
> that they haven't provided it again.
But like we said in the patch discussion, this isn't just an ABI attribute. It
affects semantics too. It changes what the body of the function can do and how
it interacts with its caller.
For example, take:
#include <arm_sve.h>
svint8_t f(svbool_t pg) {
svint8_t result;
asm ("ldff1b z0.b, p0/z, [x0]" : "=w" (result) : "Upl" (pg) : "memory");
return result;
}
As it stands, this is a valid function. It takes a non-streaming predicate as
input, does a first-faulting load, and returns the result as a non-streaming
vector. It can be called by:
static void g(svint8_t *ptr, svbool_t pg) {
*ptr = f(pg);
}
regardless of the streaming vector length (or regardless of whether SME is
present at all).
If a header file then adds:
svint8_t f(svbool_t pg) __arm_streaming;
"for API reasons", then:
- calling f outside of streaming mode is now UB unless the streaming and
non-streaming vector lengths are the same. That is, g becomes UB in this
situation.
- the function body will now fault at runtime, because LDFF1B is not valid in
streaming mode.
Things like regparm(...) don't have that kind of effect.